Simplifications

This commit is contained in:
M66B
2020-10-30 09:51:59 +01:00
parent 8472d379d3
commit aea6a79019
25 changed files with 229 additions and 160 deletions

View File

@@ -22,6 +22,7 @@ package eu.faircode.email;
import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -334,7 +335,9 @@ public class FragmentOptions extends FragmentBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_setup, null);
final Context context = getContext();
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_setup, null);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
Group grp3 = dview.findViewById(R.id.grp3);
Group grp4 = dview.findViewById(R.id.grp4);
@@ -342,18 +345,18 @@ public class FragmentOptions extends FragmentBase {
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("setup_reminder", !isChecked).apply();
}
});
boolean hasPermissions = Helper.hasPermission(getContext(), Manifest.permission.READ_CONTACTS);
Boolean isIgnoring = Helper.isIgnoringOptimizations(getContext());
boolean hasPermissions = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
Boolean isIgnoring = Helper.isIgnoringOptimizations(context);
grp3.setVisibility(hasPermissions ? View.GONE : View.VISIBLE);
grp4.setVisibility(isIgnoring == null || isIgnoring ? View.GONE : View.VISIBLE);
return new AlertDialog.Builder(getContext())
return new AlertDialog.Builder(context)
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override