mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
remove internal font size setting
This commit is contained in:
@@ -71,7 +71,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Linkifier;
|
||||
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.Stub;
|
||||
@@ -386,7 +385,6 @@ public class ConversationItem extends BaseConversationItem
|
||||
private void setBodyText(DcMsg messageRecord) {
|
||||
bodyText.setClickable(false);
|
||||
bodyText.setFocusable(false);
|
||||
bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, Prefs.getMessageBodyTextSize(context));
|
||||
|
||||
String text = messageRecord.getText();
|
||||
|
||||
|
||||
+10
-3
@@ -8,6 +8,8 @@ import android.util.TypedValue;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -34,14 +36,14 @@ public class AutoScaledEmojiTextView extends AppCompatTextView {
|
||||
public AutoScaledEmojiTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.textSize});
|
||||
originalFontSize = typedArray.getDimensionPixelSize(0, 0);
|
||||
originalFontSize = ViewUtil.pxToSp(context, typedArray.getDimensionPixelSize(0, 0));
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(@Nullable CharSequence text, BufferType type) {
|
||||
float scale = text != null ? getTextScale(text.toString()) : 1;
|
||||
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalFontSize * scale);
|
||||
super.setTextSize(TypedValue.COMPLEX_UNIT_SP, originalFontSize * scale);
|
||||
super.setText(text, type);
|
||||
}
|
||||
|
||||
@@ -52,7 +54,12 @@ public class AutoScaledEmojiTextView extends AppCompatTextView {
|
||||
|
||||
@Override
|
||||
public void setTextSize(int unit, float size) {
|
||||
originalFontSize = TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics());
|
||||
if (unit == TypedValue.COMPLEX_UNIT_SP) {
|
||||
originalFontSize = size;
|
||||
} else {
|
||||
float pxSize = TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics());
|
||||
originalFontSize = ViewUtil.pxToSp(getContext(), (int) pxSize);
|
||||
}
|
||||
super.setTextSize(unit, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ public class AppearancePreferenceFragment extends ListSummaryPreferenceFragment
|
||||
this.findPreference(Prefs.THEME_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
initializeListSummary((ListPreference)findPreference(Prefs.THEME_PREF));
|
||||
this.findPreference(Prefs.BACKGROUND_PREF).setOnPreferenceClickListener(new BackgroundClickListener());
|
||||
this.findPreference(Prefs.MESSAGE_BODY_TEXT_SIZE_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
initializeListSummary((ListPreference) findPreference(Prefs.MESSAGE_BODY_TEXT_SIZE_PREF));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,6 @@ public class Prefs {
|
||||
public static final String DOZE_ASKED_DIRECTLY = "pref_doze_asked_directly";
|
||||
public static final String ASKED_FOR_NOTIFICATION_PERMISSION= "pref_asked_for_notification_permission";
|
||||
private static final String IN_THREAD_NOTIFICATION_PREF = "pref_key_inthread_notifications";
|
||||
public static final String MESSAGE_BODY_TEXT_SIZE_PREF = "pref_message_body_text_size";
|
||||
|
||||
public static final String NOTIFICATION_PRIVACY_PREF = "pref_notification_privacy";
|
||||
public static final String NOTIFICATION_PRIORITY_PREF = "pref_notification_priority";
|
||||
@@ -104,10 +103,6 @@ public class Prefs {
|
||||
return Integer.valueOf(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(NotificationCompat.PRIORITY_HIGH)));
|
||||
}
|
||||
|
||||
public static int getMessageBodyTextSize(Context context) {
|
||||
return Integer.valueOf(getStringPreference(context, MESSAGE_BODY_TEXT_SIZE_PREF, "16"));
|
||||
}
|
||||
|
||||
public static void setDirectCaptureCameraId(Context context, int value) {
|
||||
setIntegerPreference(context, DIRECT_CAPTURE_CAMERA_ID, value);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -202,6 +204,18 @@ public class ViewUtil {
|
||||
return (int)((dp * context.getResources().getDisplayMetrics().density) + 0.5);
|
||||
}
|
||||
|
||||
public static float pxToSp(Context context, int px) {
|
||||
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
return TypedValue.deriveDimension(TypedValue.COMPLEX_UNIT_SP, px, metrics);
|
||||
} else {
|
||||
if (metrics.scaledDensity == 0) {
|
||||
return 0;
|
||||
}
|
||||
return px / metrics.scaledDensity;
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLayoutParams(@NonNull View view, int width, int height) {
|
||||
view.getLayoutParams().width = width;
|
||||
view.getLayoutParams().height = height;
|
||||
|
||||
@@ -175,20 +175,6 @@
|
||||
<item>#000000</item>
|
||||
</array>
|
||||
|
||||
<string-array name="pref_message_font_size_entries">
|
||||
<item>@string/small</item>
|
||||
<item>@string/normal</item>
|
||||
<item>@string/large</item>
|
||||
<item>@string/extra_large</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_message_font_size_values">
|
||||
<item>13</item>
|
||||
<item>16</item>
|
||||
<item>20</item>
|
||||
<item>30</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_notification_priority_entries">
|
||||
<item>@string/def</item>
|
||||
<item>@string/notify_priority_high</item>
|
||||
|
||||
@@ -736,6 +736,7 @@
|
||||
<string name="pref_app_access">App Access</string>
|
||||
<string name="pref_chats">Chats</string>
|
||||
<string name="pref_in_chat_sounds">In-Chat Sounds</string>
|
||||
<!-- deprecated -->
|
||||
<string name="pref_message_text_size">Message Font Size</string>
|
||||
<string name="pref_view_log">View Log</string>
|
||||
<string name="pref_saved_log">Saved the log to \"Downloads\" folder</string>
|
||||
|
||||
@@ -15,11 +15,4 @@
|
||||
android:key="pref_chat_background"
|
||||
android:title="@string/pref_background"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="pref_message_body_text_size"
|
||||
android:title="@string/pref_message_text_size"
|
||||
android:entries="@array/pref_message_font_size_entries"
|
||||
android:entryValues="@array/pref_message_font_size_values"
|
||||
android:defaultValue="16"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -15,11 +15,4 @@
|
||||
android:key="pref_chat_background"
|
||||
android:title="@string/pref_background"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="pref_message_body_text_size"
|
||||
android:title="@string/pref_message_text_size"
|
||||
android:entries="@array/pref_message_font_size_entries"
|
||||
android:entryValues="@array/pref_message_font_size_values"
|
||||
android:defaultValue="16"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
Reference in New Issue
Block a user