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:
* *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
* *show contact photos*: to hide contact photos
* *show identicons*: to show generated contact avatars
* *show message preview*: to show two lines of the message text
* *Unified inbox*: to disable the unified inbox and to list the folders selected for the unified inbox instead
* *Group by date*: show date header above messages with the same date
* *Conversation threading*: to disable conversation threading and to show individual messages instead
* *Show contact photos*: to hide contact photos
* *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
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 {
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));

@ -207,6 +207,18 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/swThreading"
android:layout_width="match_parent"
@ -216,7 +228,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_threading"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUnifiedHint"
app:layout_constraintTop_toBottomOf="@id/swDate"
app:switchPadding="12dp" />
<TextView

@ -129,6 +129,7 @@
<string name="title_advanced_browse">Browse messages on the server</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_avatars">Show contact photos</string>
<string name="title_advanced_identicons">Show identicons</string>

Loading…
Cancel
Save