introduce 'large font' setting
This commit is contained in:
parent
f75c061627
commit
960b20db3e
|
@ -42,6 +42,7 @@ public class AppSettings {
|
||||||
public static final String CHANNEL_DISCOVERY_METHOD = "channel_discovery_method";
|
public static final String CHANNEL_DISCOVERY_METHOD = "channel_discovery_method";
|
||||||
public static final String SEND_CRASH_REPORTS = "send_crash_reports";
|
public static final String SEND_CRASH_REPORTS = "send_crash_reports";
|
||||||
public static final String COLORFUL_CHAT_BUBBLES = "use_green_background";
|
public static final String COLORFUL_CHAT_BUBBLES = "use_green_background";
|
||||||
|
public static final String LARGE_FONT = "large_font";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
|
@ -98,6 +99,10 @@ public class AppSettings {
|
||||||
return getBooleanPreference(COLORFUL_CHAT_BUBBLES, R.bool.use_green_background);
|
return getBooleanPreference(COLORFUL_CHAT_BUBBLES, R.bool.use_green_background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLargeFont() {
|
||||||
|
return getBooleanPreference(LARGE_FONT, R.bool.large_font);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUseTor() {
|
public boolean isUseTor() {
|
||||||
return getBooleanPreference(USE_TOR, R.bool.use_tor);
|
return getBooleanPreference(USE_TOR, R.bool.use_tor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
private final DisplayMetrics metrics;
|
private final DisplayMetrics metrics;
|
||||||
private OnContactPictureClicked mOnContactPictureClickedListener;
|
private OnContactPictureClicked mOnContactPictureClickedListener;
|
||||||
private OnContactPictureLongClicked mOnContactPictureLongClickedListener;
|
private OnContactPictureLongClicked mOnContactPictureLongClickedListener;
|
||||||
private boolean colorfulChatBubbles = false;
|
private BubbleDesign bubbleDesign = new BubbleDesign(false, false);
|
||||||
private final boolean mForceNames;
|
private final boolean mForceNames;
|
||||||
|
|
||||||
public MessageAdapter(
|
public MessageAdapter(
|
||||||
|
@ -459,15 +459,13 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayTextMessage(
|
private void displayTextMessage(
|
||||||
final ViewHolder viewHolder,
|
final ViewHolder viewHolder, final Message message, final BubbleColor bubbleColor) {
|
||||||
final Message message,
|
|
||||||
final BubbleColor bubbleColor,
|
|
||||||
int type) {
|
|
||||||
viewHolder.download_button.setVisibility(View.GONE);
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
viewHolder.audioPlayer.setVisibility(View.GONE);
|
viewHolder.audioPlayer.setVisibility(View.GONE);
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
setTextColor(viewHolder.messageBody, bubbleColor);
|
setTextColor(viewHolder.messageBody, bubbleColor);
|
||||||
|
setTextSize(viewHolder.messageBody, this.bubbleDesign.largeFont);
|
||||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||||
|
|
||||||
if (message.getBody() != null) {
|
if (message.getBody() != null) {
|
||||||
|
@ -804,7 +802,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean colorfulBackground = this.colorfulChatBubbles;
|
final boolean colorfulBackground = this.bubbleDesign.colorfulChatBubbles;
|
||||||
final BubbleColor bubbleColor;
|
final BubbleColor bubbleColor;
|
||||||
if (type == RECEIVED) {
|
if (type == RECEIVED) {
|
||||||
if (isInValidSession) {
|
if (isInValidSession) {
|
||||||
|
@ -1039,7 +1037,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
bubbleColor);
|
bubbleColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayTextMessage(viewHolder, message, bubbleColor, type);
|
displayTextMessage(viewHolder, message, bubbleColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1117,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
|
|
||||||
public void updatePreferences() {
|
public void updatePreferences() {
|
||||||
final AppSettings appSettings = new AppSettings(activity);
|
final AppSettings appSettings = new AppSettings(activity);
|
||||||
this.colorfulChatBubbles = appSettings.isColorfulChatBubbles();
|
this.bubbleDesign =
|
||||||
|
new BubbleDesign(appSettings.isColorfulChatBubbles(), appSettings.isLargeFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHighlightedTerm(List<String> terms) {
|
public void setHighlightedTerm(List<String> terms) {
|
||||||
|
@ -1173,6 +1172,16 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
textView.setTextColor(bubbleToOnSurfaceColor(textView, bubbleColor));
|
textView.setTextColor(bubbleToOnSurfaceColor(textView, bubbleColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setTextSize(final TextView textView, final boolean largeFont) {
|
||||||
|
if (largeFont) {
|
||||||
|
textView.setTextAppearance(
|
||||||
|
com.google.android.material.R.style.TextAppearance_Material3_BodyLarge);
|
||||||
|
} else {
|
||||||
|
textView.setTextAppearance(
|
||||||
|
com.google.android.material.R.style.TextAppearance_Material3_BodyMedium);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static @ColorInt int bubbleToOnSurfaceVariant(
|
private static @ColorInt int bubbleToOnSurfaceVariant(
|
||||||
final View view, final BubbleColor bubbleColor) {
|
final View view, final BubbleColor bubbleColor) {
|
||||||
final @AttrRes int colorAttributeResId;
|
final @AttrRes int colorAttributeResId;
|
||||||
|
@ -1213,6 +1222,16 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
WARNING
|
WARNING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class BubbleDesign {
|
||||||
|
public final boolean colorfulChatBubbles;
|
||||||
|
public final boolean largeFont;
|
||||||
|
|
||||||
|
private BubbleDesign(final boolean colorfulChatBubbles, final boolean largeFont) {
|
||||||
|
this.colorfulChatBubbles = colorfulChatBubbles;
|
||||||
|
this.largeFont = largeFont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
|
|
||||||
public MaterialButton load_more_messages;
|
public MaterialButton load_more_messages;
|
||||||
|
|
10
src/main/res/drawable/ic_format_size_24dp.xml
Normal file
10
src/main/res/drawable/ic_format_size_24dp.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M560,800L560,280L360,280L360,160L880,160L880,280L680,280L680,800L560,800ZM200,800L200,480L80,480L80,360L440,360L440,480L320,480L320,800L200,800Z" />
|
||||||
|
</vector>
|
|
@ -18,6 +18,7 @@
|
||||||
<integer name="auto_accept_filesize">524288</integer>
|
<integer name="auto_accept_filesize">524288</integer>
|
||||||
<string name="picture_compression">auto</string>
|
<string name="picture_compression">auto</string>
|
||||||
<bool name="use_green_background">true</bool>
|
<bool name="use_green_background">true</bool>
|
||||||
|
<bool name="large_font">false</bool>
|
||||||
<string name="quick_action">recent</string>
|
<string name="quick_action">recent</string>
|
||||||
<bool name="show_dynamic_tags">false</bool>
|
<bool name="show_dynamic_tags">false</bool>
|
||||||
<bool name="btbv">true</bool>
|
<bool name="btbv">true</bool>
|
||||||
|
|
|
@ -1055,5 +1055,7 @@
|
||||||
<string name="pref_category_interaction">Interaction</string>
|
<string name="pref_category_interaction">Interaction</string>
|
||||||
<string name="pref_category_on_this_device">On device</string>
|
<string name="pref_category_on_this_device">On device</string>
|
||||||
<string name="pref_up_long_summary">When acting as a UnifiedPush Distributor the persistent, reliable and battery-friendly XMPP connection will be utilized to wake up other UnifiedPush compatible app such as Tusky, Ltt.rs, FluffyChat and more.</string>
|
<string name="pref_up_long_summary">When acting as a UnifiedPush Distributor the persistent, reliable and battery-friendly XMPP connection will be utilized to wake up other UnifiedPush compatible app such as Tusky, Ltt.rs, FluffyChat and more.</string>
|
||||||
|
<string name="pref_large_font">Large font</string>
|
||||||
|
<string name="pref_large_font_summary">Increase font size in message bubbles</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
android:key="use_green_background"
|
android:key="use_green_background"
|
||||||
android:summary="@string/pref_use_colorful_bubbles_summary"
|
android:summary="@string/pref_use_colorful_bubbles_summary"
|
||||||
android:title="@string/pref_use_colorful_bubbles" />
|
android:title="@string/pref_use_colorful_bubbles" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="@bool/large_font"
|
||||||
|
android:icon="@drawable/ic_format_size_24dp"
|
||||||
|
android:key="large_font"
|
||||||
|
android:summary="@string/pref_large_font_summary"
|
||||||
|
android:title="@string/pref_large_font" />
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="@bool/show_dynamic_tags"
|
android:defaultValue="@bool/show_dynamic_tags"
|
||||||
android:icon="@drawable/ic_label_24dp"
|
android:icon="@drawable/ic_label_24dp"
|
||||||
|
|
Loading…
Reference in a new issue