Allow to customize text header colors

This commit is contained in:
tom79 2019-11-15 19:06:43 +01:00
parent 7d7095ffa7
commit d4d907733c
10 changed files with 58 additions and 12 deletions

View File

@ -336,7 +336,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.notification_status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14 * textSizePercent / 100);
holder.notification_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14 * textSizePercent / 100);
holder.status_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12 * textSizePercent / 100);
int theme_text_header_1_line = prefs.getInt("theme_text_header_1_line", -1);
if (theme_text_header_1_line == -1) {
theme_text_header_1_line = ThemeHelper.getAttColor(context, R.attr.textColor);
}
holder.notification_type.setTextColor(theme_text_header_1_line);
holder.spark_button_fav.pressOnTouch(false);
holder.spark_button_reblog.pressOnTouch(false);

View File

@ -1113,9 +1113,22 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_reblog_count.setTextColor(iconColor);
holder.status_account_displayname.setTextColor(ThemeHelper.getAttColor(context, R.attr.textHeader));
holder.status_toot_date.setTextColor(ThemeHelper.getAttColor(context, R.attr.textHeader));
Helper.changeDrawableColor(context, R.drawable.ic_repeat_head_toot, R.attr.textHeader);
int theme_text_header_2_line = prefs.getInt("theme_text_header_2_line", -1);
if (theme_text_header_2_line == -1) {
theme_text_header_2_line = ThemeHelper.getAttColor(context, R.attr.textHeader);
}
holder.status_account_displayname.setTextColor(theme_text_header_2_line);
holder.status_toot_date.setTextColor(theme_text_header_2_line);
Helper.changeDrawableColor(context, R.drawable.ic_repeat_head_toot, theme_text_header_2_line);
int theme_text_header_1_line = prefs.getInt("theme_text_header_1_line", -1);
if (theme_text_header_1_line == -1) {
theme_text_header_1_line = ThemeHelper.getAttColor(context, R.attr.textColor);
}
holder.status_account_displayname_owner.setTextColor(theme_text_header_1_line);
Helper.changeDrawableColor(context, holder.cached_status, theme_text_header_1_line);
if (holder.cached_status != null && holder.getItemViewType() == DISPLAYED_STATUS) {
@ -1608,7 +1621,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
int matchStart = matcherAcct.start(1);
int matchEnd = matcherAcct.end();
if (wordtoSpan.length() >= matchEnd && matchStart < matchEnd) {
wordtoSpan.setSpan(new ForegroundColorSpan(ThemeHelper.getAttColor(context, R.attr.textHeader)), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
wordtoSpan.setSpan(new ForegroundColorSpan(theme_text_header_2_line), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
}

View File

@ -250,6 +250,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
ListPreference pref_theme_picker = (ListPreference) findPreference("pref_theme_picker");
Preference theme_link_color = findPreference("theme_link_color");
Preference theme_boost_header_color = findPreference("theme_boost_header_color");
Preference theme_text_header_1_line = findPreference("theme_text_header_1_line");
Preference theme_text_header_2_line = findPreference("theme_text_header_2_line");
Preference theme_statuses_color = findPreference("theme_statuses_color");
Preference theme_icons_color = findPreference("theme_icons_color");
Preference theme_text_color = findPreference("theme_text_color");
@ -264,6 +266,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
if (!sharedpreferences.getBoolean("use_custom_theme", false)) {
preferenceScreen.removePreference(theme_link_color);
preferenceScreen.removePreference(theme_boost_header_color);
preferenceScreen.removePreference(theme_text_header_1_line);
preferenceScreen.removePreference(theme_text_header_2_line);
preferenceScreen.removePreference(theme_statuses_color);
preferenceScreen.removePreference(theme_icons_color);
preferenceScreen.removePreference(theme_text_color);
@ -361,6 +365,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = prefs.edit();
editor.remove("theme_boost_header_color");
editor.remove("theme_text_header_1_line");
editor.remove("theme_text_header_2_line");
editor.remove("theme_statuses_color");
editor.remove("theme_link_color");
editor.remove("theme_icons_color");
@ -387,6 +393,8 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
builder.append("value").append(',');
builder.append('\n');
int theme_boost_header_color = prefs.getInt("theme_boost_header_color", -1);
int theme_text_header_1_line = prefs.getInt("theme_text_header_1_line", -1);
int theme_text_header_2_line = prefs.getInt("theme_text_header_2_line", -1);
int theme_statuses_color = prefs.getInt("theme_statuses_color", -1);
int theme_link_color = prefs.getInt("theme_link_color", -1);
int theme_icons_color = prefs.getInt("theme_icons_color", -1);
@ -408,6 +416,14 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
builder.append(theme_boost_header_color).append(',');
builder.append('\n');
builder.append("theme_text_header_1_line").append(',');
builder.append(theme_text_header_1_line).append(',');
builder.append('\n');
builder.append("theme_text_header_2_line").append(',');
builder.append(theme_text_header_2_line).append(',');
builder.append('\n');
builder.append("theme_statuses_color").append(',');
builder.append(theme_statuses_color).append(',');
builder.append('\n');

View File

@ -77,7 +77,6 @@
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginStart="2dp"
android:layout_marginLeft="2dp"
android:gravity="end"
android:textSize="12sp" />
</LinearLayout>
@ -128,7 +127,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_remove_red_eye"
android:drawableLeft="@drawable/ic_remove_red_eye"
android:drawablePadding="5dp"
android:gravity="center"
android:maxLines="1"
@ -189,7 +187,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="2dp"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:orientation="vertical">

View File

@ -280,7 +280,7 @@
android:layout_marginEnd="5dp"
android:contentDescription="@string/cached_status"
android:src="@drawable/ic_cached_black"
android:tint="?attr/iconColorMenu"
android:tint="?attr/textColor"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/status_account_displayname_owner"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -246,7 +246,7 @@
android:layout_marginEnd="5dp"
android:contentDescription="@string/cached_status"
android:src="@drawable/ic_cached_black"
android:tint="?attr/iconColorMenu"
android:tint="?attr/textColor"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/status_account_displayname_owner"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -193,7 +193,7 @@
android:layout_height="20dp"
android:contentDescription="@string/cached_status"
android:src="@drawable/ic_cached_black"
android:tint="?attr/iconColorMenu"
android:tint="?attr/textColor"
android:visibility="gone" />
<LinearLayout

View File

@ -189,7 +189,7 @@
android:layout_height="20dp"
android:contentDescription="@string/cached_status"
android:src="@drawable/ic_cached_black"
android:tint="?attr/iconColorMenu"
android:tint="?attr/textColor"
android:visibility="gone" />
<TextView

View File

@ -1111,6 +1111,8 @@
<string name="link_color_title">Links</string>
<string name="link_color">Change the color of links (URLs, mentions, tags, etc.) in messages</string>
<string name="boost_header_color_title">Reblogs header</string>
<string name="displayname_title">Change the color of display name at the top of messages</string>
<string name="username_title">Change the color of the user name at the top of messages</string>
<string name="boost_header_color">Change the color of the header for reblogs</string>
<string name="background_status_title">Posts</string>
<string name="background_status">Background color of posts in timelines</string>

View File

@ -32,6 +32,20 @@
android:title="@string/boost_header_color_title"
app:iconSpaceReserved="false" />
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:defaultValue="-1"
android:key="theme_text_header_1_line"
android:summary="@string/displayname_title"
android:title="@string/display_name"
app:iconSpaceReserved="false" />
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:defaultValue="-1"
android:key="theme_text_header_2_line"
android:summary="@string/username_title"
android:title="@string/username"
app:iconSpaceReserved="false" />
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:defaultValue="-1"
android:key="theme_statuses_color"