Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +2 −3 Original line number Diff line number Diff line Loading @@ -1067,13 +1067,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } catch (DBException e) { e.printStackTrace(); } //Apply the custom theme if (currentAccount != null && currentInstance == null) { currentInstance = currentAccount.instance; currentUserID = currentAccount.user_id; Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { recreate(); }; Runnable myRunnable = this::recreate; mainHandler.post(myRunnable); } Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java +14 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static app.fedilab.android.BaseMainActivity.currentUserID; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.util.Log; import androidx.appcompat.app.AlertDialog; import androidx.navigation.NavOptions; Loading Loading @@ -101,8 +100,6 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements editor.putInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_CUSTOM_ACCENT_VALUE.getColor()); } } Log.v(Helper.TAG, "currentUserID: " + currentUserID); Log.v(Helper.TAG, "currentInstance: " + currentInstance); editor.apply(); } Loading @@ -115,7 +112,7 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements if (getPreferenceScreen() == null) { Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); SwitchPreferenceCompat SET_DYNAMIC_COLOR = findPreference(getString(R.string.SET_DYNAMICCOLOR)); SwitchPreferenceCompat SET_CUSTOM_ACCENT = findPreference(getString(R.string.SET_CUSTOM_ACCENT)); ColorPreferenceCompat SET_CUSTOM_ACCENT_DARK_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE)); Loading @@ -133,6 +130,19 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) { getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_LIGHT_VALUE); } } else { if (SET_CUSTOM_ACCENT != null) { boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false); SET_CUSTOM_ACCENT.setChecked(customAccentEnabled); } if (SET_CUSTOM_ACCENT_DARK_VALUE != null) { int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + currentUserID + currentInstance, -1); SET_CUSTOM_ACCENT_DARK_VALUE.setColor(darkValue); } if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) { int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_LIGHT_VALUE) + currentUserID + currentInstance, -1); SET_CUSTOM_ACCENT_LIGHT_VALUE.setColor(darkValue); } } Preference SET_CUSTOMIZE_LIGHT_COLORS_ACTION = findPreference(getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS_ACTION)); Loading app/src/main/res/layouts/mastodon/values/strings.xml +0 −7 Original line number Diff line number Diff line Loading @@ -2,11 +2,4 @@ <resources> <string name="auto">Auto</string> <string name="set_custom_accent">Custom accent color</string> <string name="set_custom_accent_indication">Define a theme color per account</string> <string name="set_custom_accent_light_value">Light accent color</string> <string name="set_custom_accent_dark_value">Dark accent color</string> <string name="set_custom_accent_value_light_description">Color that will be applied to the light theme</string> <string name="set_custom_accent_value_dark_description">Color that will be applied to the dark theme</string> </resources> No newline at end of file app/src/main/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -1970,4 +1970,12 @@ <string name="track_selection_title">Select tracks</string> <string name="auto">Auto</string> <string name="set_custom_accent">Custom accent color</string> <string name="set_custom_accent_indication">Define a theme color per account</string> <string name="set_custom_accent_light_value">Light accent color</string> <string name="set_custom_accent_dark_value">Dark accent color</string> <string name="set_custom_accent_value_light_description">Color that will be applied to the light theme</string> <string name="set_custom_accent_value_dark_description">Color that will be applied to the dark theme</string> </resources> No newline at end of file colorPicker/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ dependencies { //noinspection GradleCompatible implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.preference:preference:1.2.0' implementation 'com.google.android.material:material:1.8.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:runner:1.5.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +2 −3 Original line number Diff line number Diff line Loading @@ -1067,13 +1067,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } catch (DBException e) { e.printStackTrace(); } //Apply the custom theme if (currentAccount != null && currentInstance == null) { currentInstance = currentAccount.instance; currentUserID = currentAccount.user_id; Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { recreate(); }; Runnable myRunnable = this::recreate; mainHandler.post(myRunnable); } Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentThemingSettings.java +14 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static app.fedilab.android.BaseMainActivity.currentUserID; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.util.Log; import androidx.appcompat.app.AlertDialog; import androidx.navigation.NavOptions; Loading Loading @@ -101,8 +100,6 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements editor.putInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_CUSTOM_ACCENT_VALUE.getColor()); } } Log.v(Helper.TAG, "currentUserID: " + currentUserID); Log.v(Helper.TAG, "currentInstance: " + currentInstance); editor.apply(); } Loading @@ -115,7 +112,7 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements if (getPreferenceScreen() == null) { Toasty.error(requireActivity(), getString(R.string.toast_error), Toasty.LENGTH_SHORT).show(); } SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); SwitchPreferenceCompat SET_DYNAMIC_COLOR = findPreference(getString(R.string.SET_DYNAMICCOLOR)); SwitchPreferenceCompat SET_CUSTOM_ACCENT = findPreference(getString(R.string.SET_CUSTOM_ACCENT)); ColorPreferenceCompat SET_CUSTOM_ACCENT_DARK_VALUE = findPreference(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE)); Loading @@ -133,6 +130,19 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) { getPreferenceScreen().removePreference(SET_CUSTOM_ACCENT_LIGHT_VALUE); } } else { if (SET_CUSTOM_ACCENT != null) { boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false); SET_CUSTOM_ACCENT.setChecked(customAccentEnabled); } if (SET_CUSTOM_ACCENT_DARK_VALUE != null) { int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_DARK_VALUE) + currentUserID + currentInstance, -1); SET_CUSTOM_ACCENT_DARK_VALUE.setColor(darkValue); } if (SET_CUSTOM_ACCENT_LIGHT_VALUE != null) { int darkValue = sharedpreferences.getInt(getString(R.string.SET_CUSTOM_ACCENT_LIGHT_VALUE) + currentUserID + currentInstance, -1); SET_CUSTOM_ACCENT_LIGHT_VALUE.setColor(darkValue); } } Preference SET_CUSTOMIZE_LIGHT_COLORS_ACTION = findPreference(getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS_ACTION)); Loading
app/src/main/res/layouts/mastodon/values/strings.xml +0 −7 Original line number Diff line number Diff line Loading @@ -2,11 +2,4 @@ <resources> <string name="auto">Auto</string> <string name="set_custom_accent">Custom accent color</string> <string name="set_custom_accent_indication">Define a theme color per account</string> <string name="set_custom_accent_light_value">Light accent color</string> <string name="set_custom_accent_dark_value">Dark accent color</string> <string name="set_custom_accent_value_light_description">Color that will be applied to the light theme</string> <string name="set_custom_accent_value_dark_description">Color that will be applied to the dark theme</string> </resources> No newline at end of file
app/src/main/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -1970,4 +1970,12 @@ <string name="track_selection_title">Select tracks</string> <string name="auto">Auto</string> <string name="set_custom_accent">Custom accent color</string> <string name="set_custom_accent_indication">Define a theme color per account</string> <string name="set_custom_accent_light_value">Light accent color</string> <string name="set_custom_accent_dark_value">Dark accent color</string> <string name="set_custom_accent_value_light_description">Color that will be applied to the light theme</string> <string name="set_custom_accent_value_dark_description">Color that will be applied to the dark theme</string> </resources> No newline at end of file
colorPicker/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ dependencies { //noinspection GradleCompatible implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.preference:preference:1.2.0' implementation 'com.google.android.material:material:1.8.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:runner:1.5.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' Loading