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