mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-04 03:43:55 +01:00
Revised account/identity setup
This commit is contained in:
@@ -29,14 +29,12 @@ import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
@@ -157,9 +155,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
setSubtitle(R.string.title_edit_account);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
final boolean insecure = prefs.getBoolean("insecure", false);
|
||||
|
||||
view = (ViewGroup) inflater.inflate(R.layout.fragment_account, container, false);
|
||||
|
||||
// Get controls
|
||||
@@ -218,8 +213,6 @@ public class FragmentAccount extends FragmentEx {
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long itemid) {
|
||||
Provider provider = (Provider) adapterView.getSelectedItem();
|
||||
grpServer.setVisibility(position == 1 ? View.VISIBLE : View.GONE);
|
||||
cbStartTls.setVisibility(position == 1 && insecure ? View.VISIBLE : View.GONE);
|
||||
cbInsecure.setVisibility(position == 1 && insecure ? View.VISIBLE : View.GONE);
|
||||
grpAuthorize.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
btnAuthorize.setVisibility(provider.type == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
@@ -21,12 +21,10 @@ package eu.faircode.email;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
@@ -115,6 +113,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
private ProgressBar pbSave;
|
||||
private ProgressBar pbWait;
|
||||
|
||||
private Group grpAuthorize;
|
||||
private Group grpAdvanced;
|
||||
|
||||
private long id = -1;
|
||||
@@ -136,9 +135,6 @@ public class FragmentIdentity extends FragmentEx {
|
||||
setSubtitle(R.string.title_edit_identity);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
final boolean insecure = prefs.getBoolean("insecure", false);
|
||||
|
||||
view = (ViewGroup) inflater.inflate(R.layout.fragment_identity, container, false);
|
||||
|
||||
// Get controls
|
||||
@@ -177,6 +173,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
pbWait = view.findViewById(R.id.pbWait);
|
||||
|
||||
grpAuthorize = view.findViewById(R.id.grpAuthorize);
|
||||
grpAdvanced = view.findViewById(R.id.grpAdvanced);
|
||||
|
||||
// Wire controls
|
||||
@@ -184,11 +181,10 @@ public class FragmentIdentity extends FragmentEx {
|
||||
spAccount.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
btnAdvanced.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
||||
grpAuthorize.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
||||
if (position == 0)
|
||||
grpAdvanced.setVisibility(View.GONE);
|
||||
tilPassword.setPasswordVisibilityToggleEnabled(position == 0);
|
||||
btnSave.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
Integer tag = (Integer) adapterView.getTag();
|
||||
if (tag != null && tag.equals(position))
|
||||
@@ -284,7 +280,6 @@ public class FragmentIdentity extends FragmentEx {
|
||||
public void onClick(View v) {
|
||||
int visibility = (grpAdvanced.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
grpAdvanced.setVisibility(visibility);
|
||||
cbInsecure.setVisibility(insecure ? visibility : View.GONE);
|
||||
if (visibility == View.VISIBLE)
|
||||
new Handler().post(new Runnable() {
|
||||
@Override
|
||||
@@ -606,9 +601,11 @@ public class FragmentIdentity extends FragmentEx {
|
||||
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
btnAdvanced.setVisibility(View.GONE);
|
||||
grpAdvanced.setVisibility(View.GONE);
|
||||
pbSave.setVisibility(View.GONE);
|
||||
|
||||
grpAuthorize.setVisibility(View.GONE);
|
||||
grpAdvanced.setVisibility(View.GONE);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
|
||||
private SwitchCompat swMetered;
|
||||
private Spinner spDownload;
|
||||
private SwitchCompat swInsecure;
|
||||
|
||||
private SwitchCompat swUnified;
|
||||
private SwitchCompat swThreading;
|
||||
@@ -94,7 +93,6 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
|
||||
swMetered = view.findViewById(R.id.swMetered);
|
||||
spDownload = view.findViewById(R.id.spDownload);
|
||||
swInsecure = view.findViewById(R.id.swInsecure);
|
||||
|
||||
swUnified = view.findViewById(R.id.swUnified);
|
||||
swThreading = view.findViewById(R.id.swThreading);
|
||||
@@ -161,14 +159,6 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
}
|
||||
});
|
||||
|
||||
swInsecure.setChecked(prefs.getBoolean("insecure", false));
|
||||
swInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("insecure", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swUnified.setChecked(prefs.getBoolean("unified", true));
|
||||
swUnified.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user