Loading app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +16 −32 Original line number Diff line number Diff line Loading @@ -205,44 +205,28 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean colorizeVisibility = sharedpreferences.getBoolean(context.getString(R.string.SET_COLORIZE_FOR_VISIBILITY), true); if(colorizeVisibility) { int color_public = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PUBLIC), -1); int color_unlisted = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_UNLISTED), -1); int color_private = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PRIVATE), -1); int color_direct = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_DIRECT), -1); int color_public = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PUBLIC), 0xff388E3C); int color_unlisted = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_UNLISTED), 0xff0288D1); int color_private = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PRIVATE), 0xffFBC02D); int color_direct = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_DIRECT), 0xffE64A19); Drawable mdrawable = holder.binding.content.getBackground(); if(visibility.equalsIgnoreCase("public") ) { if(color_public != -1) { mdrawable.setColorFilter(color_public, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_public)); } else { } } else if(visibility.equalsIgnoreCase("unlisted") ) { if(color_unlisted != -1) { mdrawable.setColorFilter(color_unlisted, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_unlisted)); } else { } } else if(visibility.equalsIgnoreCase("private") ) { if(color_private != -1) { mdrawable.setColorFilter(color_private, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_private)); } else { } } else if(visibility.equalsIgnoreCase("direct") ) { if(color_direct != -1) { mdrawable.setColorFilter(color_direct, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_direct)); } else { } } } } Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentCustomVisibilityColorsSettings.java +25 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ package app.fedilab.android.mastodon.ui.fragment.settings; import android.content.SharedPreferences; import android.os.Bundle; import androidx.appcompat.app.AlertDialog; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import app.fedilab.android.R; public class FragmentCustomVisibilityColorsSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { Loading @@ -31,6 +35,27 @@ public class FragmentCustomVisibilityColorsSettings extends PreferenceFragmentCo } private void createPref() { Preference SET_RESET_CUSTOM_COLOR_VISIBILITY = findPreference(getString(R.string.SET_RESET_CUSTOM_COLOR_VISIBILITY)); if (SET_RESET_CUSTOM_COLOR_VISIBILITY != null) { SET_RESET_CUSTOM_COLOR_VISIBILITY.setOnPreferenceClickListener(preference -> { AlertDialog.Builder resetConfirm = new MaterialAlertDialogBuilder(requireActivity()); resetConfirm.setMessage(getString(R.string.reset_color)); resetConfirm.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()); resetConfirm.setPositiveButton(R.string.reset, (dialog, which) -> { SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); if (sharedPreferences != null) { sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PUBLIC)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_UNLISTED)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PRIVATE)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_DIRECT)).apply(); } dialog.dismiss(); }); resetConfirm.show(); return true; }); } } @Override Loading app/src/main/res/values/strings.xml +5 −4 Original line number Diff line number Diff line Loading @@ -1220,10 +1220,11 @@ <string name="SET_LIGHT_LINK" translatable="false">SET_LIGHT_LINK</string> <string name="SET_LIGHT_ICON" translatable="false">SET_LIGHT_ICON</string> <string name="SET_COLOR_VISIBILITY_PUBLIC">SET_COLOR_VISIBILITY_PUBLIC</string> <string name="SET_COLOR_VISIBILITY_UNLISTED">SET_COLOR_VISIBILITY_UNLISTED</string> <string name="SET_COLOR_VISIBILITY_PRIVATE">SET_COLOR_VISIBILITY_PRIVATE</string> <string name="SET_COLOR_VISIBILITY_DIRECT">SET_COLOR_VISIBILITY_DIRECT</string> <string name="SET_COLOR_VISIBILITY_PUBLIC" translatable="false">SET_COLOR_VISIBILITY_PUBLIC</string> <string name="SET_COLOR_VISIBILITY_UNLISTED" translatable="false">SET_COLOR_VISIBILITY_UNLISTED</string> <string name="SET_COLOR_VISIBILITY_PRIVATE" translatable="false">SET_COLOR_VISIBILITY_PRIVATE</string> <string name="SET_COLOR_VISIBILITY_DIRECT" translatable="false">SET_COLOR_VISIBILITY_DIRECT</string> <string name="SET_RESET_CUSTOM_COLOR_VISIBILITY" translatable="false">SET_RESET_CUSTOM_COLOR_VISIBILITY</string> <string name="SET_DEFAULT_THEME" translatable="false">SYSTEM</string> <string name="SET_AUTO_PLAY_GIG_MEDIA" translatable="false">SET_AUTO_PLAY_GIG_MEDIA</string> Loading app/src/main/res/xml/pref_custom_visibility_colors.xml +11 −0 Original line number Diff line number Diff line Loading @@ -5,27 +5,38 @@ android:layout_height="match_parent"> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xff388E3C" android:key="@string/SET_COLOR_VISIBILITY_PUBLIC" app:iconSpaceReserved="false" app:summary="@string/visibility_color_public" app:title="@string/v_public" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xff0288D1" android:key="@string/SET_COLOR_VISIBILITY_UNLISTED" app:iconSpaceReserved="false" app:summary="@string/visibility_color_unlisted" app:title="@string/v_unlisted" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xffFBC02D" android:key="@string/SET_COLOR_VISIBILITY_PRIVATE" app:iconSpaceReserved="false" app:summary="@string/visibility_color_private" app:title="@string/v_private" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xffE64A19" android:key="@string/SET_COLOR_VISIBILITY_DIRECT" app:iconSpaceReserved="false" app:summary="@string/visibility_color_direct" app:title="@string/v_direct" /> <Preference android:layout_width="match_parent" android:layout_height="wrap_content" android:title="@string/reset_color" app:iconSpaceReserved="false" app:key="@string/SET_RESET_CUSTOM_COLOR_VISIBILITY" /> </androidx.preference.PreferenceScreen> No newline at end of file Loading
app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +16 −32 Original line number Diff line number Diff line Loading @@ -205,44 +205,28 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean colorizeVisibility = sharedpreferences.getBoolean(context.getString(R.string.SET_COLORIZE_FOR_VISIBILITY), true); if(colorizeVisibility) { int color_public = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PUBLIC), -1); int color_unlisted = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_UNLISTED), -1); int color_private = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PRIVATE), -1); int color_direct = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_DIRECT), -1); int color_public = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PUBLIC), 0xff388E3C); int color_unlisted = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_UNLISTED), 0xff0288D1); int color_private = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_PRIVATE), 0xffFBC02D); int color_direct = sharedpreferences.getInt(context.getString(R.string.SET_COLOR_VISIBILITY_DIRECT), 0xffE64A19); Drawable mdrawable = holder.binding.content.getBackground(); if(visibility.equalsIgnoreCase("public") ) { if(color_public != -1) { mdrawable.setColorFilter(color_public, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_public)); } else { } } else if(visibility.equalsIgnoreCase("unlisted") ) { if(color_unlisted != -1) { mdrawable.setColorFilter(color_unlisted, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_unlisted)); } else { } } else if(visibility.equalsIgnoreCase("private") ) { if(color_private != -1) { mdrawable.setColorFilter(color_private, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_private)); } else { } } else if(visibility.equalsIgnoreCase("direct") ) { if(color_direct != -1) { mdrawable.setColorFilter(color_direct, PorterDuff.Mode.SRC_ATOP); holder.binding.content.setBackgroundDrawable(mdrawable); holder.binding.buttonVisibility.setBackgroundTintList(ColorStateList.valueOf(color_direct)); } else { } } } } Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentCustomVisibilityColorsSettings.java +25 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ package app.fedilab.android.mastodon.ui.fragment.settings; import android.content.SharedPreferences; import android.os.Bundle; import androidx.appcompat.app.AlertDialog; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import app.fedilab.android.R; public class FragmentCustomVisibilityColorsSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { Loading @@ -31,6 +35,27 @@ public class FragmentCustomVisibilityColorsSettings extends PreferenceFragmentCo } private void createPref() { Preference SET_RESET_CUSTOM_COLOR_VISIBILITY = findPreference(getString(R.string.SET_RESET_CUSTOM_COLOR_VISIBILITY)); if (SET_RESET_CUSTOM_COLOR_VISIBILITY != null) { SET_RESET_CUSTOM_COLOR_VISIBILITY.setOnPreferenceClickListener(preference -> { AlertDialog.Builder resetConfirm = new MaterialAlertDialogBuilder(requireActivity()); resetConfirm.setMessage(getString(R.string.reset_color)); resetConfirm.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()); resetConfirm.setPositiveButton(R.string.reset, (dialog, which) -> { SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); if (sharedPreferences != null) { sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PUBLIC)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_UNLISTED)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PRIVATE)).apply(); sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_DIRECT)).apply(); } dialog.dismiss(); }); resetConfirm.show(); return true; }); } } @Override Loading
app/src/main/res/values/strings.xml +5 −4 Original line number Diff line number Diff line Loading @@ -1220,10 +1220,11 @@ <string name="SET_LIGHT_LINK" translatable="false">SET_LIGHT_LINK</string> <string name="SET_LIGHT_ICON" translatable="false">SET_LIGHT_ICON</string> <string name="SET_COLOR_VISIBILITY_PUBLIC">SET_COLOR_VISIBILITY_PUBLIC</string> <string name="SET_COLOR_VISIBILITY_UNLISTED">SET_COLOR_VISIBILITY_UNLISTED</string> <string name="SET_COLOR_VISIBILITY_PRIVATE">SET_COLOR_VISIBILITY_PRIVATE</string> <string name="SET_COLOR_VISIBILITY_DIRECT">SET_COLOR_VISIBILITY_DIRECT</string> <string name="SET_COLOR_VISIBILITY_PUBLIC" translatable="false">SET_COLOR_VISIBILITY_PUBLIC</string> <string name="SET_COLOR_VISIBILITY_UNLISTED" translatable="false">SET_COLOR_VISIBILITY_UNLISTED</string> <string name="SET_COLOR_VISIBILITY_PRIVATE" translatable="false">SET_COLOR_VISIBILITY_PRIVATE</string> <string name="SET_COLOR_VISIBILITY_DIRECT" translatable="false">SET_COLOR_VISIBILITY_DIRECT</string> <string name="SET_RESET_CUSTOM_COLOR_VISIBILITY" translatable="false">SET_RESET_CUSTOM_COLOR_VISIBILITY</string> <string name="SET_DEFAULT_THEME" translatable="false">SYSTEM</string> <string name="SET_AUTO_PLAY_GIG_MEDIA" translatable="false">SET_AUTO_PLAY_GIG_MEDIA</string> Loading
app/src/main/res/xml/pref_custom_visibility_colors.xml +11 −0 Original line number Diff line number Diff line Loading @@ -5,27 +5,38 @@ android:layout_height="match_parent"> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xff388E3C" android:key="@string/SET_COLOR_VISIBILITY_PUBLIC" app:iconSpaceReserved="false" app:summary="@string/visibility_color_public" app:title="@string/v_public" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xff0288D1" android:key="@string/SET_COLOR_VISIBILITY_UNLISTED" app:iconSpaceReserved="false" app:summary="@string/visibility_color_unlisted" app:title="@string/v_unlisted" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xffFBC02D" android:key="@string/SET_COLOR_VISIBILITY_PRIVATE" app:iconSpaceReserved="false" app:summary="@string/visibility_color_private" app:title="@string/v_private" /> <com.jaredrummler.android.colorpicker.ColorPreferenceCompat android:defaultValue="0xffE64A19" android:key="@string/SET_COLOR_VISIBILITY_DIRECT" app:iconSpaceReserved="false" app:summary="@string/visibility_color_direct" app:title="@string/v_direct" /> <Preference android:layout_width="match_parent" android:layout_height="wrap_content" android:title="@string/reset_color" app:iconSpaceReserved="false" app:key="@string/SET_RESET_CUSTOM_COLOR_VISIBILITY" /> </androidx.preference.PreferenceScreen> No newline at end of file