Browse Source

Added option to enable showing contact photos

Default disabled
Resf #61
main
M66B 6 years ago
parent
commit
17c4bad2a3
4 changed files with 31 additions and 5 deletions
  1. +9
    -4
      app/src/main/java/eu/faircode/email/AdapterMessage.java
  2. +10
    -0
      app/src/main/java/eu/faircode/email/FragmentOptions.java
  3. +11
    -1
      app/src/main/res/layout/fragment_options.xml
  4. +1
    -0
      app/src/main/res/values/strings.xml

+ 9
- 4
app/src/main/java/eu/faircode/email/AdapterMessage.java View File

@ -24,6 +24,7 @@ import android.content.ContentResolver;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -66,8 +67,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private LifecycleOwner owner; private LifecycleOwner owner;
private ViewType viewType; private ViewType viewType;
private boolean avatars;
private boolean debug; private boolean debug;
private boolean hasContactsPermission;
private DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.LONG); private DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.LONG);
enum ViewType {UNIFIED, FOLDER, THREAD, SEARCH} enum ViewType {UNIFIED, FOLDER, THREAD, SEARCH}
@ -135,7 +136,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
pbLoading.setVisibility(View.GONE); pbLoading.setVisibility(View.GONE);
ivAvatar.setVisibility(View.GONE); ivAvatar.setVisibility(View.GONE);
if (hasContactsPermission && message.from != null && message.from.length > 0) {
if (avatars && message.from != null && message.from.length > 0) {
itemView.setHasTransientState(true); itemView.setHasTransientState(true);
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -339,8 +340,12 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
this.context = context; this.context = context;
this.owner = owner; this.owner = owner;
this.viewType = viewType; this.viewType = viewType;
this.hasContactsPermission = (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED);
this.debug = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("debug", false);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.avatars = (prefs.getBoolean("avatars", false) &&
ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED);
this.debug = prefs.getBoolean("debug", false);
} }
private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK = private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK =


+ 10
- 0
app/src/main/java/eu/faircode/email/FragmentOptions.java View File

@ -38,6 +38,7 @@ public class FragmentOptions extends FragmentEx {
private TextView tvCustomTabs; private TextView tvCustomTabs;
private CheckBox cbSanitize; private CheckBox cbSanitize;
private CheckBox cbCompressImap; private CheckBox cbCompressImap;
private CheckBox cbAvatars;
private CheckBox cbDebug; private CheckBox cbDebug;
@Override @Override
@ -52,6 +53,7 @@ public class FragmentOptions extends FragmentEx {
tvCustomTabs = view.findViewById(R.id.tvCustomTabs); tvCustomTabs = view.findViewById(R.id.tvCustomTabs);
cbSanitize = view.findViewById(R.id.cbSanitize); cbSanitize = view.findViewById(R.id.cbSanitize);
cbCompressImap = view.findViewById(R.id.cbCompressImap); cbCompressImap = view.findViewById(R.id.cbCompressImap);
cbAvatars = view.findViewById(R.id.cbAvatars);
cbDebug = view.findViewById(R.id.cbDebug); cbDebug = view.findViewById(R.id.cbDebug);
// Wire controls // Wire controls
@ -82,6 +84,14 @@ public class FragmentOptions extends FragmentEx {
} }
}); });
cbAvatars.setChecked(prefs.getBoolean("avatars", false));
cbAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("avatars", 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


+ 11
- 1
app/src/main/res/layout/fragment_options.xml View File

@ -51,6 +51,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSanitize" /> app:layout_constraintTop_toBottomOf="@id/cbSanitize" />
<CheckBox
android:id="@+id/cbAvatars"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_avatars"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbCompressImap" />
<CheckBox <CheckBox
android:id="@+id/cbDebug" android:id="@+id/cbDebug"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -59,6 +69,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/cbCompressImap" />
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -76,6 +76,7 @@
<string name="title_advanced_customtabs">Instead of <a href="https://developer.chrome.com/multidevice/android/customtabs">Chrome Custom Tabs</a></string> <string name="title_advanced_customtabs">Instead of <a href="https://developer.chrome.com/multidevice/android/customtabs">Chrome Custom Tabs</a></string>
<string name="title_advanced_sanitize">Remove HTML formatting from messages</string> <string name="title_advanced_sanitize">Remove HTML formatting from messages</string>
<string name="title_advanced_compress_imap">Compress IMAP data</string> <string name="title_advanced_compress_imap">Compress IMAP data</string>
<string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_debug">Debug</string> <string name="title_advanced_debug">Debug</string>
<string name="title_select">Select &#8230;</string> <string name="title_select">Select &#8230;</string>


Loading…
Cancel
Save