Added setting to disable date header

pull/147/head
M66B 6 years ago
parent 7d697046ce
commit 84895b6077

@ -216,11 +216,12 @@ In the three dot overflow menu you can enable or disable or select:
In the display section of the advanced settings you can enable or disable: In the display section of the advanced settings you can enable or disable:
* *unified inbox*: to disable the unified inbox and to list the folders selected for the unified inbox instead * *Unified inbox*: to disable the unified inbox and to list the folders selected for the unified inbox instead
* *conversation threading*: to disable conversation threading and to show individual messages instead * *Group by date*: show date header above messages with the same date
* *show contact photos*: to hide contact photos * *Conversation threading*: to disable conversation threading and to show individual messages instead
* *show identicons*: to show generated contact avatars * *Show contact photos*: to hide contact photos
* *show message preview*: to show two lines of the message text * *Show identicons*: to show generated contact avatars
* *Show message preview*: to show two lines of the message text
* *Show address details by default*: to collapse the addresses section by default * *Show address details by default*: to collapse the addresses section by default
If the list of addresses is long, you can collapse the addresses section with the *less* icon at the top of the addresses section. If the list of addresses is long, you can collapse the addresses section with the *less* icon at the top of the addresses section.

@ -40,11 +40,6 @@ import androidx.fragment.app.Fragment;
abstract class ActivityBase extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { abstract class ActivityBase extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
private boolean contacts; private boolean contacts;
private static String[] SETTINGS_RESTART = new String[]{
"unified", "threading", "avatars", "identicons", "preview", "addresses",
"pull", "actionbar", "autoclose", "autonext", "confirm", "debug"
};
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.i("Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME); Log.i("Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
@ -115,7 +110,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
finish(); finish();
if (this.getClass().equals(ActivitySetup.class)) if (this.getClass().equals(ActivitySetup.class))
startActivity(getIntent()); 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(); finish();
} }

@ -118,9 +118,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ViewType viewType; private ViewType viewType;
private boolean compact; private boolean compact;
private int zoom; private int zoom;
private String sort;
private boolean internet; private boolean internet;
private IProperties properties; private IProperties properties;
private boolean date;
private boolean threading; private boolean threading;
private boolean contacts; private boolean contacts;
private boolean avatars; private boolean avatars;
@ -2056,18 +2058,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
AdapterMessage(Context context, LifecycleOwner owner, 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.context = context;
this.owner = owner; this.owner = owner;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.viewType = viewType; this.viewType = viewType;
this.compact = compact; this.compact = compact;
this.zoom = zoom; this.zoom = zoom;
this.sort = sort;
this.internet = (Helper.isMetered(context, false) != null); this.internet = (Helper.isMetered(context, false) != null);
this.properties = properties; this.properties = properties;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.date = prefs.getBoolean("date", true);
this.threading = prefs.getBoolean("threading", true); this.threading = prefs.getBoolean("threading", true);
this.contacts = (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) this.contacts = (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED); == PackageManager.PERMISSION_GRANTED);
@ -2101,6 +2105,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
boolean getDay(TupleMessageEx prev, TupleMessageEx cur) { boolean getDay(TupleMessageEx prev, TupleMessageEx cur) {
if (!"time".equals(sort) || !date)
return false;
if (prev == null) if (prev == null)
return true; 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() { void checkInternet() {
boolean internet = (Helper.isMetered(context, false) != null); boolean internet = (Helper.isMetered(context, false) != null);
if (this.internet != internet) { if (this.internet != internet) {

@ -266,9 +266,11 @@ public class FragmentMessages extends FragmentBase {
boolean compact = prefs.getBoolean("compact", false); boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("zoom", compact ? 0 : 1); int zoom = prefs.getInt("zoom", compact ? 0 : 1);
String sort = prefs.getString("sort", "time");
adapter = new AdapterMessage( adapter = new AdapterMessage(
getContext(), getViewLifecycleOwner(), getContext(), getViewLifecycleOwner(),
viewType, compact, zoom, iProperties); viewType, compact, zoom, sort, iProperties);
rvMessage.setAdapter(adapter); rvMessage.setAdapter(adapter);
@ -1677,6 +1679,7 @@ public class FragmentMessages extends FragmentBase {
private void onMenuSort(String sort) { private void onMenuSort(String sort) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putString("sort", sort).apply(); prefs.edit().putString("sort", sort).apply();
adapter.setSort(sort);
loadMessages(); loadMessages();
} }

@ -61,6 +61,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Spinner spDownload; private Spinner spDownload;
private SwitchCompat swUnified; private SwitchCompat swUnified;
private SwitchCompat swDate;
private SwitchCompat swThreading; private SwitchCompat swThreading;
private SwitchCompat swAvatars; private SwitchCompat swAvatars;
private SwitchCompat swIdenticons; private SwitchCompat swIdenticons;
@ -86,10 +87,15 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Group grpNotification; 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[]{ private final static String[] ADVANCED_OPTIONS = new String[]{
"enabled", "updates", "enabled", "updates",
"metered", "download", "metered", "download",
"unified", "threading", "avatars", "identicons", "preview", "addresses", "unified", "date", "threading", "avatars", "identicons", "preview", "addresses",
"pull", "actionbar", "autoclose", "autonext", "pull", "actionbar", "autoclose", "autonext",
"autoread", "collapse", "automove", "confirm", "sender", "autoresize", "autosend", "autoread", "collapse", "automove", "confirm", "sender", "autoresize", "autosend",
"light", "sound", "debug", "light", "sound", "debug",
@ -115,6 +121,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
spDownload = view.findViewById(R.id.spDownload); spDownload = view.findViewById(R.id.spDownload);
swUnified = view.findViewById(R.id.swUnified); swUnified = view.findViewById(R.id.swUnified);
swDate = view.findViewById(R.id.swDate);
swThreading = view.findViewById(R.id.swThreading); swThreading = view.findViewById(R.id.swThreading);
swAvatars = view.findViewById(R.id.swAvatars); swAvatars = view.findViewById(R.id.swAvatars);
swIdenticons = view.findViewById(R.id.swIdenticons); 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() { swThreading.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { 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)); swUnified.setChecked(prefs.getBoolean("unified", true));
swDate.setChecked(prefs.getBoolean("date", true));
swThreading.setChecked(prefs.getBoolean("threading", true)); swThreading.setChecked(prefs.getBoolean("threading", true));
swAvatars.setChecked(prefs.getBoolean("avatars", true)); swAvatars.setChecked(prefs.getBoolean("avatars", true));
swIdenticons.setChecked(prefs.getBoolean("identicons", false)); swIdenticons.setChecked(prefs.getBoolean("identicons", false));

@ -207,6 +207,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUnified" /> app:layout_constraintTop_toBottomOf="@id/swUnified" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_date_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUnifiedHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swThreading" android:id="@+id/swThreading"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -216,7 +228,7 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:text="@string/title_advanced_threading" android:text="@string/title_advanced_threading"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUnifiedHint" app:layout_constraintTop_toBottomOf="@id/swDate"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

@ -129,6 +129,7 @@
<string name="title_advanced_browse">Browse messages on the server</string> <string name="title_advanced_browse">Browse messages on the server</string>
<string name="title_advanced_unified">Unified inbox</string> <string name="title_advanced_unified">Unified inbox</string>
<string name="title_advanced_date_header">Group by date</string>
<string name="title_advanced_threading">Conversation threading</string> <string name="title_advanced_threading">Conversation threading</string>
<string name="title_advanced_avatars">Show contact photos</string> <string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_identicons">Show identicons</string> <string name="title_advanced_identicons">Show identicons</string>

Loading…
Cancel
Save