mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Fix some issues of custom themes.
This commit is contained in:
parent
01b2a04057
commit
188d58b5da
@ -9,6 +9,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
@ -268,7 +269,8 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
|||||||
new InsertCustomThemeAsyncTask.InsertCustomThemeAsyncTaskListener() {
|
new InsertCustomThemeAsyncTask.InsertCustomThemeAsyncTaskListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
Snackbar.make(coordinatorLayout, R.string.import_theme_success, Snackbar.LENGTH_SHORT).show();
|
Toast.makeText(CustomThemeListingActivity.this, R.string.import_theme_success, Toast.LENGTH_SHORT).show();
|
||||||
|
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,24 +39,31 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
if (customTheme.isLightTheme) {
|
|
||||||
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
|
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
|
|
||||||
}
|
|
||||||
if (customTheme.isDarkTheme) {
|
|
||||||
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
|
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
|
|
||||||
}
|
|
||||||
if (customTheme.isAmoledTheme) {
|
|
||||||
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
|
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
|
|
||||||
}
|
|
||||||
if (checkDuplicate) {
|
if (checkDuplicate) {
|
||||||
if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
|
if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
|
||||||
isDuplicate = true;
|
isDuplicate = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CustomTheme previousTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name);
|
||||||
|
if (customTheme.isLightTheme) {
|
||||||
|
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
|
||||||
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
|
||||||
|
} else if (previousTheme.isLightTheme) {
|
||||||
|
lightThemeSharedPreferences.edit().clear().apply();
|
||||||
|
}
|
||||||
|
if (customTheme.isDarkTheme) {
|
||||||
|
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
|
||||||
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
|
||||||
|
} else if (previousTheme.isDarkTheme) {
|
||||||
|
darkThemeSharedPreferences.edit().clear().apply();
|
||||||
|
}
|
||||||
|
if (customTheme.isAmoledTheme) {
|
||||||
|
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
|
||||||
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
|
||||||
|
} else if (previousTheme.isAmoledTheme) {
|
||||||
|
amoledThemeSharedPreferences.edit().clear().apply();
|
||||||
|
}
|
||||||
redditDataRoomDatabase.customThemeDao().insert(customTheme);
|
redditDataRoomDatabase.customThemeDao().insert(customTheme);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user