commit
7c3664be9e
@ -23,6 +23,8 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
|||||||
|
|
||||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
|
private static String previousThemeColorValue = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
@ -33,6 +35,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getSelectedColor(Context context, String colorId){
|
||||||
|
|
||||||
|
String res = "Color not found";
|
||||||
|
String [ ] themeArray = context.getResources().getStringArray(R.array.themeValues);
|
||||||
|
String [ ] colorArray = context.getResources().getStringArray(R.array.themeArray);
|
||||||
|
|
||||||
|
for (int i = 0 ; i < themeArray.length ; i++){
|
||||||
|
if (themeArray[i].equals(colorId)){
|
||||||
|
res = colorArray[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A preference value change listener that updates the preference's summary
|
* A preference value change listener that updates the preference's summary
|
||||||
* to reflect its new value.
|
* to reflect its new value.
|
||||||
@ -45,6 +62,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
Toast.makeText(preference.getContext(), R.string.invalid_url, Toast.LENGTH_LONG).show();
|
Toast.makeText(preference.getContext(), R.string.invalid_url, Toast.LENGTH_LONG).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Check if Theme color has change & Provide selected color
|
||||||
|
else if (preference.getKey().equals("pref_theme")) {
|
||||||
|
|
||||||
|
stringValue = getSelectedColor(preference.getContext(), stringValue);
|
||||||
|
|
||||||
|
if (!previousThemeColorValue.equals("") && !previousThemeColorValue.equals(stringValue)) {
|
||||||
|
Toast.makeText(preference.getContext(), R.string.pref_description_app_theme, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousThemeColorValue = stringValue;
|
||||||
|
preference.setSummary(stringValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
preference.setSummary(stringValue);
|
preference.setSummary(stringValue);
|
||||||
|
|
||||||
@ -96,7 +126,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
|
|
||||||
setupActionBar();
|
setupActionBar();
|
||||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();
|
getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,6 +182,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
// updated to reflect the new value, per the Android Design
|
// updated to reflect the new value, per the Android Design
|
||||||
// guidelines.
|
// guidelines.
|
||||||
bindPreferenceSummaryToValue(findPreference("pref_api_base"));
|
bindPreferenceSummaryToValue(findPreference("pref_api_base"));
|
||||||
|
bindPreferenceSummaryToValue(findPreference("pref_theme"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
android:title="@string/pref_title_app_theme"
|
android:title="@string/pref_title_app_theme"
|
||||||
android:summary="@string/pref_description_app_theme"
|
android:summary="@string/pref_description_app_theme"
|
||||||
android:key="pref_theme"
|
android:key="pref_theme"
|
||||||
android:defaultValue="1"
|
android:defaultValue="AppTheme.ORANGE"
|
||||||
android:entries="@array/themeArray"
|
android:entries="@array/themeArray"
|
||||||
android:entryValues="@array/themeValues" />
|
android:entryValues="@array/themeValues" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user