From bfd5a72b5281d8e818b10a6d911cf27d50b8c620 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sun, 2 Oct 2016 15:40:18 +0200 Subject: [PATCH] Identity creation dialog improvements --- app/build.gradle | 2 +- .../dialog/AddIdentityDialogFragment.java | 94 ++++++++---------- .../dialog_add_deterministic_identity.xml | 4 +- .../main/res/layout/dialog_add_identity.xml | 98 +++++++++---------- .../main/res/layout/fragment_import_input.xml | 2 +- .../res/values-de/library_jabit_strings.xml | 5 +- app/src/main/res/values-de/strings.xml | 85 ++++++++-------- .../main/res/values/library_jabit_strings.xml | 4 +- app/src/main/res/values/strings.xml | 11 ++- 9 files changed, 150 insertions(+), 155 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1865a08..a7c4f4a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,7 +65,7 @@ dependencies { testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' - compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8' + compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' } idea.module { diff --git a/app/src/main/java/ch/dissem/apps/abit/dialog/AddIdentityDialogFragment.java b/app/src/main/java/ch/dissem/apps/abit/dialog/AddIdentityDialogFragment.java index 56f0ee6..f404c9c 100644 --- a/app/src/main/java/ch/dissem/apps/abit/dialog/AddIdentityDialogFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/dialog/AddIdentityDialogFragment.java @@ -28,6 +28,7 @@ import android.support.v7.app.AppCompatDialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast; @@ -39,14 +40,11 @@ import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.payload.Pubkey; -import static android.app.Activity.RESULT_OK; - /** * @author Christian Basler */ public class AddIdentityDialogFragment extends AppCompatDialogFragment { - private static final int IMPORT_IDENTITY_RESULT_CODE = 1; private BitmessageContext bmc; @Override @@ -61,57 +59,49 @@ public class AddIdentityDialogFragment extends AppCompatDialogFragment { savedInstanceState) { getDialog().setTitle(R.string.add_identity); View view = inflater.inflate(R.layout.dialog_add_identity, container, false); - view.findViewById(R.id.create_identity) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dismiss(); - Toast.makeText(getActivity(), - R.string.toast_long_running_operation, - Toast.LENGTH_SHORT).show(); - new AsyncTask() { - @Override - protected BitmessageAddress doInBackground(Void... args) { - return bmc.createIdentity(false, Pubkey.Feature.DOES_ACK); - } - - @Override - protected void onPostExecute(BitmessageAddress chan) { - Toast.makeText(getActivity(), - R.string.toast_identity_created, - Toast.LENGTH_SHORT).show(); - MainActivity mainActivity = MainActivity.getInstance(); - if (mainActivity != null) { - mainActivity.addIdentityEntry(chan); + final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup); + view.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + switch (radioGroup.getCheckedRadioButtonId()) { + case R.id.create_identity: + Toast.makeText(getActivity(), + R.string.toast_long_running_operation, + Toast.LENGTH_SHORT).show(); + new AsyncTask() { + @Override + protected BitmessageAddress doInBackground(Void... args) { + return bmc.createIdentity(false, Pubkey.Feature.DOES_ACK); } - } - }.execute(); + + @Override + protected void onPostExecute(BitmessageAddress chan) { + Toast.makeText(getActivity(), + R.string.toast_identity_created, + Toast.LENGTH_SHORT).show(); + MainActivity mainActivity = MainActivity.getInstance(); + if (mainActivity != null) { + mainActivity.addIdentityEntry(chan); + } + } + }.execute(); + break; + case R.id.import_identity: + startActivity(new Intent(getActivity(), ImportIdentityActivity.class)); + break; + case R.id.add_chan: + addChanDialog(); + break; + case R.id.add_deterministic_address: + new DeterministicIdentityDialogFragment().show(getFragmentManager(), + "dialog"); + break; + default: + return; } - }); - view.findViewById(R.id.import_identity) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dismiss(); - startActivity(new Intent(getActivity(), ImportIdentityActivity.class)); - } - }); - view.findViewById(R.id.add_deterministic_address) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dismiss(); - new DeterministicIdentityDialogFragment().show(getFragmentManager(), "dialog"); - } - }); - view.findViewById(R.id.add_chan) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dismiss(); - addChanDialog(); - } - }); + dismiss(); + } + }); view.findViewById(R.id.dismiss) .setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/res/layout/dialog_add_deterministic_identity.xml b/app/src/main/res/layout/dialog_add_deterministic_identity.xml index 2b2fd1f..5df7bfa 100644 --- a/app/src/main/res/layout/dialog_add_deterministic_identity.xml +++ b/app/src/main/res/layout/dialog_add_deterministic_identity.xml @@ -70,7 +70,7 @@ @@ -88,7 +88,7 @@ + android:paddingTop="18dp"> -