From a4b48591fc1553a610895c10667bfbb509e3d08e Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 11 Mar 2020 12:30:23 +0100 Subject: [PATCH] Revert "Refactoring" This reverts commit 0d8ba072f2a116b716f72fd7de2d51097c4b9479. --- .../java/eu/faircode/email/ActivitySetup.java | 12 ---------- .../eu/faircode/email/FragmentAccount.java | 16 +++++++++----- .../eu/faircode/email/FragmentIdentity.java | 22 ++++++++++++------- .../java/eu/faircode/email/FragmentPop.java | 11 ++++++---- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index bab824328e..b5155022ad 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -128,18 +128,6 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac static final int REQUEST_IMPORT_CERTIFICATE = 7; static final int REQUEST_OAUTH = 8; - static final int REQUEST_ACCOUNT_COLOR = 21; - static final int REQUEST_ACCOUNT_SAVE = 22; - static final int REQUEST_ACCOUNT_DELETE = 23; - - static final int REQUEST_IDENTITY_COLOR = 31; - static final int REQUEST_IDENTITY_SAVE = 32; - static final int REQUEST_IDENTITY_DELETE = 33; - static final int REQUEST_IDENITY_SIGNATURE = 34; - - static final int REQUEST_POP_COLOR = 41; - static final int REQUEST_POP_DELETE = 42; - static final String ACTION_QUICK_GMAIL = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_GMAIL"; static final String ACTION_QUICK_OAUTH = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_OAUTH"; static final String ACTION_QUICK_SETUP = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_SETUP"; diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 810abc1820..ba6feeb5c9 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -162,6 +162,10 @@ public class FragmentAccount extends FragmentBase { private String certificate = null; private boolean saving = false; + private static final int REQUEST_COLOR = 1; + private static final int REQUEST_SAVE = 2; + private static final int REQUEST_DELETE = 3; + static final Long SWIPE_ACTION_ASK = -1L; static final Long SWIPE_ACTION_SEEN = -2L; static final Long SWIPE_ACTION_SNOOZE = -3L; @@ -394,7 +398,7 @@ public class FragmentAccount extends FragmentBase { FragmentDialogColor fragment = new FragmentDialogColor(); fragment.setArguments(args); - fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_COLOR); + fragment.setTargetFragment(FragmentAccount.this, REQUEST_COLOR); fragment.show(getParentFragmentManager(), "account:color"); } }); @@ -1236,7 +1240,7 @@ public class FragmentAccount extends FragmentBase { FragmentDialogAsk fragment = new FragmentDialogAsk(); fragment.setArguments(aargs); - fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_SAVE); + fragment.setTargetFragment(FragmentAccount.this, REQUEST_SAVE); fragment.show(getParentFragmentManager(), "account:save"); } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { getParentFragmentManager().popBackStack(); @@ -1569,7 +1573,7 @@ public class FragmentAccount extends FragmentBase { FragmentDialogAsk fragment = new FragmentDialogAsk(); fragment.setArguments(aargs); - fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_DELETE); + fragment.setTargetFragment(FragmentAccount.this, REQUEST_DELETE); fragment.show(getParentFragmentManager(), "account:delete"); } @@ -1579,7 +1583,7 @@ public class FragmentAccount extends FragmentBase { try { switch (requestCode) { - case ActivitySetup.REQUEST_ACCOUNT_COLOR: + case REQUEST_COLOR: if (resultCode == RESULT_OK && data != null) { if (ActivityBilling.isPro(getContext())) { Bundle args = data.getBundleExtra("args"); @@ -1588,7 +1592,7 @@ public class FragmentAccount extends FragmentBase { startActivity(new Intent(getContext(), ActivityBilling.class)); } break; - case ActivitySetup.REQUEST_ACCOUNT_SAVE: + case REQUEST_SAVE: if (resultCode == RESULT_OK) { final boolean save = (btnSave.getVisibility() == View.VISIBLE); new Handler().post(new Runnable() { @@ -1604,7 +1608,7 @@ public class FragmentAccount extends FragmentBase { } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) getParentFragmentManager().popBackStack(); break; - case ActivitySetup.REQUEST_ACCOUNT_DELETE: + case REQUEST_DELETE: if (resultCode == RESULT_OK) onDelete(); break; diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 5b556c43ae..890737b257 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -32,6 +32,7 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.LinkMovementMethod; +import android.util.Patterns; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; @@ -134,6 +135,11 @@ public class FragmentIdentity extends FragmentBase { private String signature = null; private boolean saving = false; + private static final int REQUEST_COLOR = 1; + private static final int REQUEST_SAVE = 2; + private static final int REQUEST_DELETE = 3; + private static final int REQUEST_SIGNATURE = 4; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -323,7 +329,7 @@ public class FragmentIdentity extends FragmentBase { FragmentDialogColor fragment = new FragmentDialogColor(); fragment.setArguments(args); - fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_COLOR); + fragment.setTargetFragment(FragmentIdentity.this, REQUEST_COLOR); fragment.show(getParentFragmentManager(), "identity:color"); } }); @@ -335,7 +341,7 @@ public class FragmentIdentity extends FragmentBase { public void onClick(View v) { Intent intent = new Intent(getContext(), ActivitySignature.class); intent.putExtra("html", signature); - startActivityForResult(intent, ActivitySetup.REQUEST_IDENITY_SIGNATURE); + startActivityForResult(intent, REQUEST_SIGNATURE); } }); @@ -864,7 +870,7 @@ public class FragmentIdentity extends FragmentBase { FragmentDialogAsk fragment = new FragmentDialogAsk(); fragment.setArguments(aargs); - fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_SAVE); + fragment.setTargetFragment(FragmentIdentity.this, REQUEST_SAVE); fragment.show(getParentFragmentManager(), "identity:save"); } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) getParentFragmentManager().popBackStack(); @@ -1188,7 +1194,7 @@ public class FragmentIdentity extends FragmentBase { FragmentDialogAsk fragment = new FragmentDialogAsk(); fragment.setArguments(aargs); - fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_DELETE); + fragment.setTargetFragment(FragmentIdentity.this, REQUEST_DELETE); fragment.show(getParentFragmentManager(), "identity:delete"); } @@ -1198,7 +1204,7 @@ public class FragmentIdentity extends FragmentBase { try { switch (requestCode) { - case ActivitySetup.REQUEST_IDENTITY_COLOR: + case REQUEST_COLOR: if (resultCode == RESULT_OK && data != null) { if (ActivityBilling.isPro(getContext())) { Bundle args = data.getBundleExtra("args"); @@ -1207,7 +1213,7 @@ public class FragmentIdentity extends FragmentBase { startActivity(new Intent(getContext(), ActivityBilling.class)); } break; - case ActivitySetup.REQUEST_IDENTITY_SAVE: + case REQUEST_SAVE: if (resultCode == RESULT_OK) { new Handler().post(new Runnable() { @Override @@ -1219,11 +1225,11 @@ public class FragmentIdentity extends FragmentBase { } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) getParentFragmentManager().popBackStack(); break; - case ActivitySetup.REQUEST_IDENTITY_DELETE: + case REQUEST_DELETE: if (resultCode == RESULT_OK) onDelete(); break; - case ActivitySetup.REQUEST_IDENITY_SIGNATURE: + case REQUEST_SIGNATURE: if (resultCode == RESULT_OK) onHtml(data.getExtras()); break; diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index 6461d2ca03..6d4a9d1b10 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -95,6 +95,9 @@ public class FragmentPop extends FragmentBase { private long id = -1; private boolean saving = false; + private static final int REQUEST_COLOR = 1; + private static final int REQUEST_DELETE = 2; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -177,7 +180,7 @@ public class FragmentPop extends FragmentBase { FragmentDialogColor fragment = new FragmentDialogColor(); fragment.setArguments(args); - fragment.setTargetFragment(FragmentPop.this, ActivitySetup.REQUEST_POP_COLOR); + fragment.setTargetFragment(FragmentPop.this, REQUEST_COLOR); fragment.show(getParentFragmentManager(), "account:color"); } }); @@ -598,7 +601,7 @@ public class FragmentPop extends FragmentBase { FragmentDialogAsk fragment = new FragmentDialogAsk(); fragment.setArguments(aargs); - fragment.setTargetFragment(FragmentPop.this, ActivitySetup.REQUEST_POP_DELETE); + fragment.setTargetFragment(FragmentPop.this, REQUEST_DELETE); fragment.show(getParentFragmentManager(), "account:delete"); } @@ -608,7 +611,7 @@ public class FragmentPop extends FragmentBase { try { switch (requestCode) { - case ActivitySetup.REQUEST_POP_COLOR: + case REQUEST_COLOR: if (resultCode == RESULT_OK && data != null) { if (ActivityBilling.isPro(getContext())) { Bundle args = data.getBundleExtra("args"); @@ -617,7 +620,7 @@ public class FragmentPop extends FragmentBase { startActivity(new Intent(getContext(), ActivityBilling.class)); } break; - case ActivitySetup.REQUEST_POP_DELETE: + case REQUEST_DELETE: if (resultCode == RESULT_OK) onDelete(); break;