Commit 40d742e4 authored by Thomas's avatar Thomas
Browse files

Fix issue #430

parent 9335c22e
......@@ -119,9 +119,9 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
SharedPreferences sharedpreferences = getActivity().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
int i = 0;
if (theme.compareTo("2") == 0) {
if (theme.compareTo("1") == 0) {
editor.putInt(Helper.SET_THEME, Helper.THEME_LIGHT);
} else if (theme.compareTo("1") == 0) {
} else if (theme.compareTo("2") == 0) {
editor.putInt(Helper.SET_THEME, Helper.THEME_DARK);
i = 1;
} else if (theme.compareTo("3") == 0) {
......@@ -130,6 +130,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
}
editor.commit();
list.get(i).apply(Cyanea.getInstance()).recreate(getActivity());
restart();
}
}
}
......@@ -269,49 +270,55 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
CharSequence[] entryValues = new CharSequence[3];
final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpref.getInt(Helper.SET_THEME, Helper.THEME_DARK);
entryValues[0] = String.valueOf(Helper.THEME_LIGHT);
entryValues[1] = String.valueOf(Helper.THEME_DARK);
entryValues[0] = String.valueOf(Helper.THEME_DARK);
entryValues[1] = String.valueOf(Helper.THEME_LIGHT);
entryValues[2] = String.valueOf(Helper.THEME_BLACK);
pref_theme_picker.setEntries(entries);
pref_theme_picker.setEntryValues(entryValues);
pref_theme_picker.setDefaultValue(String.valueOf(theme));
int default_theme_value;
switch (theme){
case Helper.THEME_LIGHT:
default_theme_value = 1;
break;
case Helper.THEME_BLACK:
default_theme_value = 2;
break;
default:
default_theme_value = 0;
}
pref_export.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
exportColors();
return true;
}
pref_theme_picker.setEntryValues(entryValues);
pref_theme_picker.setValueIndex(default_theme_value);
pref_export.setOnPreferenceClickListener(preference -> {
exportColors();
return true;
});
pref_import.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (ContextCompat.checkSelfPermission(Objects.requireNonNull(getActivity()), Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
TootActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return true;
}
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
intent.setType("*/*");
String[] mimetypes = {"*/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(intent, PICK_IMPORT_THEME);
} else {
intent.setType("*/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_import));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
startActivityForResult(chooserIntent, PICK_IMPORT_THEME);
}
pref_import.setOnPreferenceClickListener(preference -> {
if (ContextCompat.checkSelfPermission(Objects.requireNonNull(getActivity()), Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
TootActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return true;
}
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
intent.setType("*/*");
String[] mimetypes = {"*/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(intent, PICK_IMPORT_THEME);
} else {
intent.setType("*/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_import));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
startActivityForResult(chooserIntent, PICK_IMPORT_THEME);
}
return true;
});
reset_pref.setOnPreferenceClickListener(preference -> {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment