|
|
@ -55,9 +55,7 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
private TextView tvPermissionsDone;
|
|
|
|
private TextView tvPermissionsDone;
|
|
|
|
|
|
|
|
|
|
|
|
private CheckBox cbDarkTheme;
|
|
|
|
private CheckBox cbDarkTheme;
|
|
|
|
|
|
|
|
private CheckBox cbDebug;
|
|
|
|
private Button btnAccountManage;
|
|
|
|
|
|
|
|
private Button btnIdentityManage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
|
private ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
|
|
|
|
|
|
|
|
@ -85,77 +83,26 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
tvPermissionsDone = view.findViewById(R.id.tvPermissionsDone);
|
|
|
|
tvPermissionsDone = view.findViewById(R.id.tvPermissionsDone);
|
|
|
|
|
|
|
|
|
|
|
|
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
|
|
|
|
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
|
|
|
|
|
|
|
|
cbDebug = view.findViewById(R.id.cbDebug);
|
|
|
|
btnAccountManage = view.findViewById(R.id.btnAccountManage);
|
|
|
|
|
|
|
|
btnIdentityManage = view.findViewById(R.id.btnIdentityManage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wire controls
|
|
|
|
// Wire controls
|
|
|
|
|
|
|
|
|
|
|
|
btnAccount.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnAccount.setOnClickListener(new View.OnClickListener() {
|
|
|
|
private boolean once;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
public void onClick(View view) {
|
|
|
|
once = false;
|
|
|
|
|
|
|
|
btnAccount.setEnabled(false);
|
|
|
|
|
|
|
|
pbAccount.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB.getInstance(getContext()).account().liveFirstAccount().observe(FragmentSetup.this, new Observer<EntityAccount>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onChanged(@Nullable EntityAccount account) {
|
|
|
|
|
|
|
|
if (!once) {
|
|
|
|
|
|
|
|
once = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
if (account != null)
|
|
|
|
|
|
|
|
args.putLong("id", account.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentAccount fragment = new FragmentAccount();
|
|
|
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("account");
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentAccounts()).addToBackStack("accounts");
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
|
|
|
|
|
|
|
|
btnAccount.setEnabled(true);
|
|
|
|
|
|
|
|
pbAccount.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnIdentity.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnIdentity.setOnClickListener(new View.OnClickListener() {
|
|
|
|
private boolean once;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
public void onClick(View view) {
|
|
|
|
once = false;
|
|
|
|
|
|
|
|
btnIdentity.setEnabled(false);
|
|
|
|
|
|
|
|
pbIdentity.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB.getInstance(getContext()).identity().liveFirstIdentity().observe(FragmentSetup.this, new Observer<EntityIdentity>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onChanged(@Nullable EntityIdentity identity) {
|
|
|
|
|
|
|
|
if (!once) {
|
|
|
|
|
|
|
|
once = true;
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
if (identity != null)
|
|
|
|
|
|
|
|
args.putLong("id", identity.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentIdentity fragment = new FragmentIdentity();
|
|
|
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("identity");
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentIdentities()).addToBackStack("identities");
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
btnIdentity.setEnabled(true);
|
|
|
|
|
|
|
|
pbIdentity.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnPermissions.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnPermissions.setOnClickListener(new View.OnClickListener() {
|
|
|
@ -165,27 +112,8 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnAccountManage.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
//getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentAccounts()).addToBackStack("accounts");
|
|
|
|
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnIdentityManage.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
//getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
|
|
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentIdentities()).addToBackStack("identities");
|
|
|
|
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
boolean dark = "dark".equals(theme);
|
|
|
|
boolean dark = "dark".equals(theme);
|
|
|
|
cbDarkTheme.setTag(dark);
|
|
|
|
cbDarkTheme.setTag(dark);
|
|
|
@ -201,6 +129,14 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cbDebug.setChecked(prefs.getBoolean("debug", false));
|
|
|
|
|
|
|
|
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
|
|
|
|
prefs.edit().putBoolean("debug", checked).apply();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
// Initialize
|
|
|
|
|
|
|
|
|
|
|
|
pbAccount.setVisibility(View.GONE);
|
|
|
|
pbAccount.setVisibility(View.GONE);
|
|
|
@ -231,7 +167,7 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
onRequestPermissionsResult(0, permissions, grantResults);
|
|
|
|
onRequestPermissionsResult(0, permissions, grantResults);
|
|
|
|
|
|
|
|
|
|
|
|
// Creat outbox
|
|
|
|
// Create outbox
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|