Added select default address extra button

pull/217/head
M66B 9 months ago
parent c3cf7e892c
commit 27a45dcc92

@ -88,15 +88,16 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
static final int REQUEST_IMPORT_CERTIFICATE = 6; static final int REQUEST_IMPORT_CERTIFICATE = 6;
static final int REQUEST_OAUTH = 7; static final int REQUEST_OAUTH = 7;
static final int REQUEST_STILL = 8; static final int REQUEST_STILL = 8;
static final int REQUEST_SELECT_IDENTITY = 9; static final int REQUEST_DEFAULT_IDENTITY = 9;
static final int REQUEST_EDIT_SIGNATURE = 10; static final int REQUEST_SELECT_IDENTITY = 10;
static final int REQUEST_CHANGE_PASSWORD = 11; static final int REQUEST_EDIT_SIGNATURE = 11;
static final int REQUEST_EDIT_ACCOUNT_COLOR = 12; static final int REQUEST_CHANGE_PASSWORD = 12;
static final int REQUEST_DELETE_ACCOUNT = 13; static final int REQUEST_EDIT_ACCOUNT_COLOR = 13;
static final int REQUEST_EDIT_IDENITY_COLOR = 14; static final int REQUEST_DELETE_ACCOUNT = 14;
static final int REQUEST_IMPORT_PROVIDERS = 15; static final int REQUEST_EDIT_IDENITY_COLOR = 15;
static final int REQUEST_GRAPH_CONTACTS = 16; static final int REQUEST_IMPORT_PROVIDERS = 16;
static final int REQUEST_GRAPH_CONTACTS_OAUTH = 17; static final int REQUEST_GRAPH_CONTACTS = 17;
static final int REQUEST_GRAPH_CONTACTS_OAUTH = 18;
static final int REQUEST_DEBUG_INFO = 7000; static final int REQUEST_DEBUG_INFO = 7000;
static final int PI_CONNECTION = 1; static final int PI_CONNECTION = 1;

@ -128,6 +128,7 @@ import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@ -3426,7 +3427,7 @@ public class FragmentCompose extends FragmentBase {
break; break;
case REQUEST_SELECT_IDENTITY: case REQUEST_SELECT_IDENTITY:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onSelectIdentity(data.getBundleExtra("args")); onSelectIdentity(getContext(), getViewLifecycleOwner(), getParentFragmentManager(), data.getBundleExtra("args"));
break; break;
case REQUEST_PRINT: case REQUEST_PRINT:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
@ -5003,10 +5004,11 @@ public class FragmentCompose extends FragmentBase {
}.serial().execute(this, args, "compose:picked"); }.serial().execute(this, args, "compose:picked");
} }
private void onSelectIdentity(Bundle args) { static void onSelectIdentity(Context context, LifecycleOwner owner, FragmentManager fm, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
Log.i("MMM id="+id);
if (id < 0) { if (id < 0) {
getContext().startActivity(new Intent(getContext(), ActivitySetup.class) context.startActivity(new Intent(context, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("manual", true) .putExtra("manual", true)
.putExtra("scroll", true)); .putExtra("scroll", true));
@ -5041,14 +5043,14 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
protected void onExecuted(Bundle args, EntityIdentity identity) { protected void onExecuted(Bundle args, EntityIdentity identity) {
ToastEx.makeText(getContext(), R.string.title_completed, Toast.LENGTH_LONG).show(); ToastEx.makeText(context, R.string.title_completed, Toast.LENGTH_LONG).show();
} }
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(fm, ex);
} }
}.serial().execute(this, args, "select:identity"); }.serial().execute(context, owner, args, "select:identity");
} }
private void onPrint(Bundle args) { private void onPrint(Bundle args) {

@ -148,6 +148,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
private CardView cardExtra; private CardView cardExtra;
private TextView tvExtra; private TextView tvExtra;
private Button btnNotification; private Button btnNotification;
private Button btnDefaultIdentity;
private Button btnSignature; private Button btnSignature;
private Button btnReorderAccounts; private Button btnReorderAccounts;
private Button btnReorderFolders; private Button btnReorderFolders;
@ -244,6 +245,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
cardExtra = view.findViewById(R.id.cardExtra); cardExtra = view.findViewById(R.id.cardExtra);
tvExtra = view.findViewById(R.id.tvExtra); tvExtra = view.findViewById(R.id.tvExtra);
btnNotification = view.findViewById(R.id.btnNotification); btnNotification = view.findViewById(R.id.btnNotification);
btnDefaultIdentity = view.findViewById(R.id.btnDefaultIdentity);
btnSignature = view.findViewById(R.id.btnSignature); btnSignature = view.findViewById(R.id.btnSignature);
btnReorderAccounts = view.findViewById(R.id.btnReorderAccounts); btnReorderAccounts = view.findViewById(R.id.btnReorderAccounts);
btnReorderFolders = view.findViewById(R.id.btnReorderFolders); btnReorderFolders = view.findViewById(R.id.btnReorderFolders);
@ -765,13 +767,23 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
} }
}); });
btnDefaultIdentity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentDialogSelectIdentity fragment = new FragmentDialogSelectIdentity();
fragment.setArguments(new Bundle());
fragment.setTargetFragment(FragmentSetup.this, ActivitySetup.REQUEST_DEFAULT_IDENTITY);
fragment.show(getParentFragmentManager(), "select:identity:default");
}
});
btnSignature.setOnClickListener(new View.OnClickListener() { btnSignature.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
FragmentDialogSelectIdentity fragment = new FragmentDialogSelectIdentity(); FragmentDialogSelectIdentity fragment = new FragmentDialogSelectIdentity();
fragment.setArguments(new Bundle()); fragment.setArguments(new Bundle());
fragment.setTargetFragment(FragmentSetup.this, ActivitySetup.REQUEST_SELECT_IDENTITY); fragment.setTargetFragment(FragmentSetup.this, ActivitySetup.REQUEST_SELECT_IDENTITY);
fragment.show(getParentFragmentManager(), "select:identity"); fragment.show(getParentFragmentManager(), "select:identity:signature");
} }
}); });
@ -1141,6 +1153,10 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
try { try {
switch (requestCode) { switch (requestCode) {
case ActivitySetup.REQUEST_DEFAULT_IDENTITY:
if (resultCode == RESULT_OK && data != null)
onSelectDefaultIdentity(data.getBundleExtra("args"));
break;
case ActivitySetup.REQUEST_SELECT_IDENTITY: case ActivitySetup.REQUEST_SELECT_IDENTITY:
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
onSelectIdentity(data.getBundleExtra("args")); onSelectIdentity(data.getBundleExtra("args"));
@ -1226,6 +1242,10 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
btnPermissions.setText(all ? R.string.title_setup_manage : R.string.title_setup_grant); btnPermissions.setText(all ? R.string.title_setup_manage : R.string.title_setup_grant);
} }
private void onSelectDefaultIdentity(Bundle args) {
FragmentCompose.onSelectIdentity(getContext(), getViewLifecycleOwner(), getParentFragmentManager(), args);
}
private void onSelectIdentity(Bundle args) { private void onSelectIdentity(Bundle args) {
Intent intent = new Intent(getContext(), ActivitySignature.class); Intent intent = new Intent(getContext(), ActivitySignature.class);
intent.putExtra("id", args.getLong("id")); intent.putExtra("id", args.getLong("id"));

@ -1111,6 +1111,19 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnNotification" /> app:layout_constraintTop_toBottomOf="@id/btnNotification" />
<Button
android:id="@+id/btnDefaultIdentity"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_person_24"
android:drawablePadding="6dp"
android:tag="disable"
android:text="@string/title_select_default_identity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotificationHint" />
<Button <Button
android:id="@+id/btnSignature" android:id="@+id/btnSignature"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -1122,7 +1135,7 @@
android:tag="disable" android:tag="disable"
android:text="@string/title_edit_signature" android:text="@string/title_edit_signature"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotificationHint" /> app:layout_constraintTop_toBottomOf="@id/btnDefaultIdentity" />
<Button <Button
android:id="@+id/btnReorderAccounts" android:id="@+id/btnReorderAccounts"

Loading…
Cancel
Save