mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 21:57:19 +00:00
Added list item text size
This commit is contained in:
parent
dd26997b6b
commit
d69fe560e4
4 changed files with 29 additions and 19 deletions
|
@ -28,7 +28,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -112,7 +111,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private FragmentManager fragmentManager;
|
||||
private ViewType viewType;
|
||||
private boolean outgoing;
|
||||
private int zoom;
|
||||
private boolean internet;
|
||||
private IProperties properties;
|
||||
|
||||
|
@ -126,6 +124,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private boolean debug;
|
||||
|
||||
private int dp24;
|
||||
private float textSize;
|
||||
private int colorPrimary;
|
||||
private int colorAccent;
|
||||
private int textColorSecondary;
|
||||
|
@ -471,6 +470,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvSubject.setTypeface(null, typeface);
|
||||
tvCount.setTypeface(null, typeface);
|
||||
|
||||
if (textSize != 0) {
|
||||
tvFrom.setTextSize(textSize);
|
||||
tvSubject.setTextSize(textSize);
|
||||
}
|
||||
|
||||
int colorUnseen = (message.unseen > 0 ? colorUnread : textColorSecondary);
|
||||
tvFrom.setTextColor(colorUnseen);
|
||||
tvSize.setTextColor(colorUnseen);
|
||||
|
@ -540,20 +544,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
bnvActions.getMenu().getItem(i).setVisible(false);
|
||||
bnvActions.setVisibility(View.VISIBLE);
|
||||
|
||||
TypedArray ta;
|
||||
if (zoom == 0)
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Small, new int[]{android.R.attr.textSize});
|
||||
else if (zoom == 2)
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Large, new int[]{android.R.attr.textSize});
|
||||
else
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Medium, new int[]{android.R.attr.textSize});
|
||||
float textSize = ta.getDimension(0, 0);
|
||||
if (textSize != 0)
|
||||
tvBody.setTextSize(textSize / context.getResources().getDisplayMetrics().density);
|
||||
ta.recycle();
|
||||
tvBody.setTextSize(textSize);
|
||||
|
||||
Spanned body = properties.getBody(message.id);
|
||||
tvBody.setText(body);
|
||||
|
@ -1698,7 +1690,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.fragmentManager = fragmentManager;
|
||||
this.viewType = viewType;
|
||||
this.outgoing = outgoing;
|
||||
this.zoom = zoom;
|
||||
this.internet = (Helper.isMetered(context, false) != null);
|
||||
this.properties = properties;
|
||||
|
||||
|
@ -1715,6 +1706,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.debug = prefs.getBoolean("debug", false);
|
||||
|
||||
this.dp24 = Helper.dp2pixels(24, context);
|
||||
this.textSize = Helper.getTextSize(zoom, context);
|
||||
this.colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
|
||||
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
|
||||
|
@ -1734,7 +1726,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
void setZoom(int zoom) {
|
||||
this.zoom = zoom;
|
||||
textSize = Helper.getTextSize(zoom, context);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -1489,7 +1489,6 @@ public class FragmentMessages extends FragmentEx {
|
|||
folder >= 0 && viewType != AdapterMessage.ViewType.SEARCH);
|
||||
menu.findItem(R.id.menu_sort_on).setVisible(
|
||||
viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER);
|
||||
menu.findItem(R.id.menu_zoom).setVisible(viewType == AdapterMessage.ViewType.THREAD);
|
||||
menu.findItem(R.id.menu_folders).setVisible(primary >= 0);
|
||||
menu.findItem(R.id.menu_folders).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24);
|
||||
menu.findItem(R.id.menu_move_sent).setVisible(outbox);
|
||||
|
|
|
@ -177,6 +177,25 @@ public class Helper {
|
|||
return Math.round(dp * scale);
|
||||
}
|
||||
|
||||
static float getTextSize(int zoom, Context context) {
|
||||
TypedArray ta = null;
|
||||
try {
|
||||
if (zoom == 0)
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Small, new int[]{android.R.attr.textSize});
|
||||
else if (zoom == 2)
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Large, new int[]{android.R.attr.textSize});
|
||||
else
|
||||
ta = context.obtainStyledAttributes(
|
||||
R.style.TextAppearance_AppCompat_Medium, new int[]{android.R.attr.textSize});
|
||||
return ta.getDimension(0, 0) / context.getResources().getDisplayMetrics().density;
|
||||
} finally {
|
||||
if (ta != null)
|
||||
ta.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
static int resolveColor(Context context, int attr) {
|
||||
int[] attrs = new int[]{attr};
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
android:id="@+id/menu_folders"
|
||||
android:icon="@drawable/baseline_folder_open_24"
|
||||
android:title="@string/title_folder_primary"
|
||||
app:showAsAction="ifRoom" />
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_move_sent"
|
||||
|
|
Loading…
Reference in a new issue