Refactoring

This commit is contained in:
M66B 2020-03-11 11:57:46 +01:00
parent 619238232b
commit 0d8ba072f2
4 changed files with 30 additions and 31 deletions

View File

@ -128,6 +128,18 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
static final int REQUEST_IMPORT_CERTIFICATE = 7; static final int REQUEST_IMPORT_CERTIFICATE = 7;
static final int REQUEST_OAUTH = 8; 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_GMAIL = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_GMAIL";
static final String ACTION_QUICK_OAUTH = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_OAUTH"; static final String ACTION_QUICK_OAUTH = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_OAUTH";
static final String ACTION_QUICK_SETUP = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_SETUP"; static final String ACTION_QUICK_SETUP = BuildConfig.APPLICATION_ID + ".ACTION_QUICK_SETUP";

View File

@ -162,10 +162,6 @@ public class FragmentAccount extends FragmentBase {
private String certificate = null; private String certificate = null;
private boolean saving = false; 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_ASK = -1L;
static final Long SWIPE_ACTION_SEEN = -2L; static final Long SWIPE_ACTION_SEEN = -2L;
static final Long SWIPE_ACTION_SNOOZE = -3L; static final Long SWIPE_ACTION_SNOOZE = -3L;
@ -398,7 +394,7 @@ public class FragmentAccount extends FragmentBase {
FragmentDialogColor fragment = new FragmentDialogColor(); FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(FragmentAccount.this, REQUEST_COLOR); fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_COLOR);
fragment.show(getParentFragmentManager(), "account:color"); fragment.show(getParentFragmentManager(), "account:color");
} }
}); });
@ -1240,7 +1236,7 @@ public class FragmentAccount extends FragmentBase {
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentAccount.this, REQUEST_SAVE); fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_SAVE);
fragment.show(getParentFragmentManager(), "account:save"); fragment.show(getParentFragmentManager(), "account:save");
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
getParentFragmentManager().popBackStack(); getParentFragmentManager().popBackStack();
@ -1573,7 +1569,7 @@ public class FragmentAccount extends FragmentBase {
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentAccount.this, REQUEST_DELETE); fragment.setTargetFragment(FragmentAccount.this, ActivitySetup.REQUEST_ACCOUNT_DELETE);
fragment.show(getParentFragmentManager(), "account:delete"); fragment.show(getParentFragmentManager(), "account:delete");
} }
@ -1583,7 +1579,7 @@ public class FragmentAccount extends FragmentBase {
try { try {
switch (requestCode) { switch (requestCode) {
case REQUEST_COLOR: case ActivitySetup.REQUEST_ACCOUNT_COLOR:
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) { if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args"); Bundle args = data.getBundleExtra("args");
@ -1592,7 +1588,7 @@ public class FragmentAccount extends FragmentBase {
startActivity(new Intent(getContext(), ActivityBilling.class)); startActivity(new Intent(getContext(), ActivityBilling.class));
} }
break; break;
case REQUEST_SAVE: case ActivitySetup.REQUEST_ACCOUNT_SAVE:
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
final boolean save = (btnSave.getVisibility() == View.VISIBLE); final boolean save = (btnSave.getVisibility() == View.VISIBLE);
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@ -1608,7 +1604,7 @@ public class FragmentAccount extends FragmentBase {
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getParentFragmentManager().popBackStack(); getParentFragmentManager().popBackStack();
break; break;
case REQUEST_DELETE: case ActivitySetup.REQUEST_ACCOUNT_DELETE:
if (resultCode == RESULT_OK) if (resultCode == RESULT_OK)
onDelete(); onDelete();
break; break;

View File

@ -32,7 +32,6 @@ import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -135,11 +134,6 @@ public class FragmentIdentity extends FragmentBase {
private String signature = null; private String signature = null;
private boolean saving = false; 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 @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -329,7 +323,7 @@ public class FragmentIdentity extends FragmentBase {
FragmentDialogColor fragment = new FragmentDialogColor(); FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_COLOR); fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_COLOR);
fragment.show(getParentFragmentManager(), "identity:color"); fragment.show(getParentFragmentManager(), "identity:color");
} }
}); });
@ -341,7 +335,7 @@ public class FragmentIdentity extends FragmentBase {
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getContext(), ActivitySignature.class); Intent intent = new Intent(getContext(), ActivitySignature.class);
intent.putExtra("html", signature); intent.putExtra("html", signature);
startActivityForResult(intent, REQUEST_SIGNATURE); startActivityForResult(intent, ActivitySetup.REQUEST_IDENITY_SIGNATURE);
} }
}); });
@ -870,7 +864,7 @@ public class FragmentIdentity extends FragmentBase {
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_SAVE); fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_SAVE);
fragment.show(getParentFragmentManager(), "identity:save"); fragment.show(getParentFragmentManager(), "identity:save");
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getParentFragmentManager().popBackStack(); getParentFragmentManager().popBackStack();
@ -1194,7 +1188,7 @@ public class FragmentIdentity extends FragmentBase {
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_DELETE); fragment.setTargetFragment(FragmentIdentity.this, ActivitySetup.REQUEST_IDENTITY_DELETE);
fragment.show(getParentFragmentManager(), "identity:delete"); fragment.show(getParentFragmentManager(), "identity:delete");
} }
@ -1204,7 +1198,7 @@ public class FragmentIdentity extends FragmentBase {
try { try {
switch (requestCode) { switch (requestCode) {
case REQUEST_COLOR: case ActivitySetup.REQUEST_IDENTITY_COLOR:
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) { if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args"); Bundle args = data.getBundleExtra("args");
@ -1213,7 +1207,7 @@ public class FragmentIdentity extends FragmentBase {
startActivity(new Intent(getContext(), ActivityBilling.class)); startActivity(new Intent(getContext(), ActivityBilling.class));
} }
break; break;
case REQUEST_SAVE: case ActivitySetup.REQUEST_IDENTITY_SAVE:
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@Override @Override
@ -1225,11 +1219,11 @@ public class FragmentIdentity extends FragmentBase {
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) } else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getParentFragmentManager().popBackStack(); getParentFragmentManager().popBackStack();
break; break;
case REQUEST_DELETE: case ActivitySetup.REQUEST_IDENTITY_DELETE:
if (resultCode == RESULT_OK) if (resultCode == RESULT_OK)
onDelete(); onDelete();
break; break;
case REQUEST_SIGNATURE: case ActivitySetup.REQUEST_IDENITY_SIGNATURE:
if (resultCode == RESULT_OK) if (resultCode == RESULT_OK)
onHtml(data.getExtras()); onHtml(data.getExtras());
break; break;

View File

@ -95,9 +95,6 @@ public class FragmentPop extends FragmentBase {
private long id = -1; private long id = -1;
private boolean saving = false; private boolean saving = false;
private static final int REQUEST_COLOR = 1;
private static final int REQUEST_DELETE = 2;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -180,7 +177,7 @@ public class FragmentPop extends FragmentBase {
FragmentDialogColor fragment = new FragmentDialogColor(); FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(FragmentPop.this, REQUEST_COLOR); fragment.setTargetFragment(FragmentPop.this, ActivitySetup.REQUEST_POP_COLOR);
fragment.show(getParentFragmentManager(), "account:color"); fragment.show(getParentFragmentManager(), "account:color");
} }
}); });
@ -601,7 +598,7 @@ public class FragmentPop extends FragmentBase {
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentPop.this, REQUEST_DELETE); fragment.setTargetFragment(FragmentPop.this, ActivitySetup.REQUEST_POP_DELETE);
fragment.show(getParentFragmentManager(), "account:delete"); fragment.show(getParentFragmentManager(), "account:delete");
} }
@ -611,7 +608,7 @@ public class FragmentPop extends FragmentBase {
try { try {
switch (requestCode) { switch (requestCode) {
case REQUEST_COLOR: case ActivitySetup.REQUEST_POP_COLOR:
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) { if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args"); Bundle args = data.getBundleExtra("args");
@ -620,7 +617,7 @@ public class FragmentPop extends FragmentBase {
startActivity(new Intent(getContext(), ActivityBilling.class)); startActivity(new Intent(getContext(), ActivityBilling.class));
} }
break; break;
case REQUEST_DELETE: case ActivitySetup.REQUEST_POP_DELETE:
if (resultCode == RESULT_OK) if (resultCode == RESULT_OK)
onDelete(); onDelete();
break; break;