Allow turning of browsing messages

Refs #138
pull/145/head
M66B 7 years ago
parent 6e351234eb
commit b123f54fd2

@ -654,6 +654,7 @@ public class FragmentMessages extends FragmentEx {
if (TextUtils.isEmpty(search)) { if (TextUtils.isEmpty(search)) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String sort = prefs.getString("sort", "time"); String sort = prefs.getString("sort", "time");
boolean browse = prefs.getBoolean("browse", true);
boolean debug = prefs.getBoolean("debug", false); boolean debug = prefs.getBoolean("debug", false);
if (messages != null) if (messages != null)
@ -693,7 +694,8 @@ public class FragmentMessages extends FragmentEx {
.build(); .build();
LivePagedListBuilder<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>( LivePagedListBuilder<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>(
db.message().pagedFolder(folder, sort, false, debug), config); db.message().pagedFolder(folder, sort, false, debug), config);
builder.setBoundaryCallback(searchCallback); if (browse)
builder.setBoundaryCallback(searchCallback);
messages = builder.build(); messages = builder.build();
break; break;

@ -34,6 +34,7 @@ import androidx.annotation.Nullable;
public class FragmentOptions extends FragmentEx { public class FragmentOptions extends FragmentEx {
private CheckBox cbAvatars; private CheckBox cbAvatars;
private CheckBox cbLight; private CheckBox cbLight;
private CheckBox cbBrowse;
private CheckBox cbDebug; private CheckBox cbDebug;
@Override @Override
@ -46,6 +47,7 @@ public class FragmentOptions extends FragmentEx {
// Get controls // Get controls
cbAvatars = view.findViewById(R.id.cbAvatars); cbAvatars = view.findViewById(R.id.cbAvatars);
cbLight = view.findViewById(R.id.cbLight); cbLight = view.findViewById(R.id.cbLight);
cbBrowse = view.findViewById(R.id.cbBrowse);
cbDebug = view.findViewById(R.id.cbDebug); cbDebug = view.findViewById(R.id.cbDebug);
// Wire controls // Wire controls
@ -68,6 +70,14 @@ public class FragmentOptions extends FragmentEx {
} }
}); });
cbBrowse.setChecked(prefs.getBoolean("browse", true));
cbBrowse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("browse", checked).apply();
}
});
cbDebug.setChecked(prefs.getBoolean("debug", false)); cbDebug.setChecked(prefs.getBoolean("debug", false));
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override

@ -103,6 +103,7 @@ public class FragmentSetup extends FragmentEx {
static final List<String> EXPORT_SETTINGS = Arrays.asList( static final List<String> EXPORT_SETTINGS = Arrays.asList(
"avatars", "avatars",
"light", "light",
"browse",
"sort" "sort"
); );

@ -31,6 +31,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" /> app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
<CheckBox
android:id="@+id/cbBrowse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_browse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLight" />
<CheckBox <CheckBox
android:id="@+id/cbDebug" android:id="@+id/cbDebug"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -39,6 +49,6 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_debug" android:text="@string/title_advanced_debug"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbLight" /> app:layout_constraintTop_toBottomOf="@id/cbBrowse" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

@ -78,6 +78,7 @@
<string name="title_advanced">Advanced options</string> <string name="title_advanced">Advanced options</string>
<string name="title_advanced_avatars">Show contact photos</string> <string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_light">Use notification light</string> <string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_browse">Browse message on the server</string>
<string name="title_advanced_debug">Debug mode</string> <string name="title_advanced_debug">Debug mode</string>
<string name="title_select">Select &#8230;</string> <string name="title_select">Select &#8230;</string>

Loading…
Cancel
Save