mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 12:24:26 +01:00
Added setting to disable date header
This commit is contained in:
@@ -40,11 +40,6 @@ import androidx.fragment.app.Fragment;
|
||||
abstract class ActivityBase extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private boolean contacts;
|
||||
|
||||
private static String[] SETTINGS_RESTART = new String[]{
|
||||
"unified", "threading", "avatars", "identicons", "preview", "addresses",
|
||||
"pull", "actionbar", "autoclose", "autonext", "confirm", "debug"
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.i("Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
|
||||
@@ -115,7 +110,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
finish();
|
||||
if (this.getClass().equals(ActivitySetup.class))
|
||||
startActivity(getIntent());
|
||||
} else if (!this.getClass().equals(ActivitySetup.class) && Arrays.asList(SETTINGS_RESTART).contains(key))
|
||||
} else if (!this.getClass().equals(ActivitySetup.class) &&
|
||||
Arrays.asList(FragmentOptions.OPTIONS_RESTART).contains(key))
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
private ViewType viewType;
|
||||
private boolean compact;
|
||||
private int zoom;
|
||||
private String sort;
|
||||
private boolean internet;
|
||||
private IProperties properties;
|
||||
|
||||
private boolean date;
|
||||
private boolean threading;
|
||||
private boolean contacts;
|
||||
private boolean avatars;
|
||||
@@ -2056,18 +2058,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
|
||||
AdapterMessage(Context context, LifecycleOwner owner,
|
||||
ViewType viewType, boolean compact, int zoom, IProperties properties) {
|
||||
ViewType viewType, boolean compact, int zoom, String sort, IProperties properties) {
|
||||
this.context = context;
|
||||
this.owner = owner;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.viewType = viewType;
|
||||
this.compact = compact;
|
||||
this.zoom = zoom;
|
||||
this.sort = sort;
|
||||
this.internet = (Helper.isMetered(context, false) != null);
|
||||
this.properties = properties;
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
this.date = prefs.getBoolean("date", true);
|
||||
this.threading = prefs.getBoolean("threading", true);
|
||||
this.contacts = (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED);
|
||||
@@ -2101,6 +2105,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
|
||||
boolean getDay(TupleMessageEx prev, TupleMessageEx cur) {
|
||||
if (!"time".equals(sort) || !date)
|
||||
return false;
|
||||
|
||||
if (prev == null)
|
||||
return true;
|
||||
|
||||
@@ -2132,6 +2139,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
}
|
||||
|
||||
void setSort(String sort) {
|
||||
if (!sort.equals(this.sort)) {
|
||||
this.sort = sort;
|
||||
// loadMessages will be called
|
||||
}
|
||||
}
|
||||
|
||||
void checkInternet() {
|
||||
boolean internet = (Helper.isMetered(context, false) != null);
|
||||
if (this.internet != internet) {
|
||||
|
||||
@@ -266,9 +266,11 @@ public class FragmentMessages extends FragmentBase {
|
||||
|
||||
boolean compact = prefs.getBoolean("compact", false);
|
||||
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
|
||||
String sort = prefs.getString("sort", "time");
|
||||
|
||||
adapter = new AdapterMessage(
|
||||
getContext(), getViewLifecycleOwner(),
|
||||
viewType, compact, zoom, iProperties);
|
||||
viewType, compact, zoom, sort, iProperties);
|
||||
|
||||
rvMessage.setAdapter(adapter);
|
||||
|
||||
@@ -1677,6 +1679,7 @@ public class FragmentMessages extends FragmentBase {
|
||||
private void onMenuSort(String sort) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putString("sort", sort).apply();
|
||||
adapter.setSort(sort);
|
||||
loadMessages();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
||||
private Spinner spDownload;
|
||||
|
||||
private SwitchCompat swUnified;
|
||||
private SwitchCompat swDate;
|
||||
private SwitchCompat swThreading;
|
||||
private SwitchCompat swAvatars;
|
||||
private SwitchCompat swIdenticons;
|
||||
@@ -86,10 +87,15 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
||||
|
||||
private Group grpNotification;
|
||||
|
||||
static String[] OPTIONS_RESTART = new String[]{
|
||||
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses",
|
||||
"pull", "actionbar", "autoclose", "autonext", "confirm", "debug"
|
||||
};
|
||||
|
||||
private final static String[] ADVANCED_OPTIONS = new String[]{
|
||||
"enabled", "updates",
|
||||
"metered", "download",
|
||||
"unified", "threading", "avatars", "identicons", "preview", "addresses",
|
||||
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses",
|
||||
"pull", "actionbar", "autoclose", "autonext",
|
||||
"autoread", "collapse", "automove", "confirm", "sender", "autoresize", "autosend",
|
||||
"light", "sound", "debug",
|
||||
@@ -115,6 +121,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
||||
spDownload = view.findViewById(R.id.spDownload);
|
||||
|
||||
swUnified = view.findViewById(R.id.swUnified);
|
||||
swDate = view.findViewById(R.id.swDate);
|
||||
swThreading = view.findViewById(R.id.swThreading);
|
||||
swAvatars = view.findViewById(R.id.swAvatars);
|
||||
swIdenticons = view.findViewById(R.id.swIdenticons);
|
||||
@@ -189,6 +196,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
||||
}
|
||||
});
|
||||
|
||||
swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("date", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -405,6 +419,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
||||
}
|
||||
|
||||
swUnified.setChecked(prefs.getBoolean("unified", true));
|
||||
swDate.setChecked(prefs.getBoolean("date", true));
|
||||
swThreading.setChecked(prefs.getBoolean("threading", true));
|
||||
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
||||
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
||||
|
||||
Reference in New Issue
Block a user