@@ -45,16 +45,19 @@ public class CheckKeysActivity extends BaseActivity implements View.OnClickListe
4545 LoaderManager .LoaderCallbacks <LoaderResult > {
4646
4747 public static final int RESULT_NEGATIVE = 10 ;
48+ public static final int RESULT_NEUTRAL = 11 ;
4849
4950 public static final String KEY_EXTRA_PRIVATE_KEYS = GeneralUtil .generateUniqueExtraKey (
5051 "KEY_EXTRA_PRIVATE_KEYS" , CheckKeysActivity .class );
5152 public static final String KEY_EXTRA_BOTTOM_TITLE = GeneralUtil .generateUniqueExtraKey (
5253 "KEY_EXTRA_BOTTOM_TITLE" , CheckKeysActivity .class );
53- public static final String KEY_EXTRA_CHECK_BUTTON_TITLE = GeneralUtil .generateUniqueExtraKey (
54- "KEY_EXTRA_CHECK_BUTTON_TITLE" , CheckKeysActivity .class );
55- public static final String KEY_EXTRA_NEGATIVE_ACTION_BUTTON_TITLE =
54+ public static final String KEY_EXTRA_POSITIVE_BUTTON_TITLE = GeneralUtil .generateUniqueExtraKey (
55+ "KEY_EXTRA_POSITIVE_BUTTON_TITLE" , CheckKeysActivity .class );
56+ public static final String KEY_EXTRA_NEUTRAL_BUTTON_TITLE = GeneralUtil .generateUniqueExtraKey (
57+ "KEY_EXTRA_NEUTRAL_BUTTON_TITLE" , CheckKeysActivity .class );
58+ public static final String KEY_EXTRA_NEGATIVE_BUTTON_TITLE =
5659 GeneralUtil .generateUniqueExtraKey (
57- "KEY_EXTRA_NEGATIVE_ACTION_BUTTON_TITLE " , CheckKeysActivity .class );
60+ "KEY_EXTRA_NEGATIVE_BUTTON_TITLE " , CheckKeysActivity .class );
5861 public static final String KEY_EXTRA_IS_THROW_ERROR_IF_DUPLICATE_FOUND =
5962 GeneralUtil .generateUniqueExtraKey (
6063 "KEY_EXTRA_IS_THROW_ERROR_IF_DUPLICATE_FOUND" , CheckKeysActivity .class );
@@ -63,19 +66,29 @@ public class CheckKeysActivity extends BaseActivity implements View.OnClickListe
6366 private EditText editTextKeyPassword ;
6467 private View progressBar ;
6568 private String bottomTitle ;
66- private String checkButtonTitle ;
67- private String anotherAccountButtonTitle ;
69+ private String positiveButtonTitle ;
70+ private String neutralButtonTitle ;
71+ private String negativeButtonTitle ;
6872 private boolean isThrowErrorIfDuplicateFound ;
6973
7074 public static Intent newIntent (Context context , ArrayList <KeyDetails > privateKeys ,
71- String bottomTitle , String checkButtonTitle ,
72- String negativeActionButtonTitle ,
75+ String bottomTitle , String positiveButtonTitle ,
76+ String negativeButtonTitle ,
77+ boolean isThrowErrorIfDuplicateFound ) {
78+ return newIntent (context , privateKeys , bottomTitle , positiveButtonTitle , null , negativeButtonTitle ,
79+ isThrowErrorIfDuplicateFound );
80+ }
81+
82+ public static Intent newIntent (Context context , ArrayList <KeyDetails > privateKeys ,
83+ String bottomTitle , String positiveButtonTitle ,
84+ String neutralButtonTitle , String negativeButtonTitle ,
7385 boolean isThrowErrorIfDuplicateFound ) {
7486 Intent intent = new Intent (context , CheckKeysActivity .class );
7587 intent .putExtra (KEY_EXTRA_PRIVATE_KEYS , privateKeys );
7688 intent .putExtra (KEY_EXTRA_BOTTOM_TITLE , bottomTitle );
77- intent .putExtra (KEY_EXTRA_CHECK_BUTTON_TITLE , checkButtonTitle );
78- intent .putExtra (KEY_EXTRA_NEGATIVE_ACTION_BUTTON_TITLE , negativeActionButtonTitle );
89+ intent .putExtra (KEY_EXTRA_POSITIVE_BUTTON_TITLE , positiveButtonTitle );
90+ intent .putExtra (KEY_EXTRA_NEUTRAL_BUTTON_TITLE , neutralButtonTitle );
91+ intent .putExtra (KEY_EXTRA_NEGATIVE_BUTTON_TITLE , negativeButtonTitle );
7992 intent .putExtra (KEY_EXTRA_IS_THROW_ERROR_IF_DUPLICATE_FOUND , isThrowErrorIfDuplicateFound );
8093 return intent ;
8194 }
@@ -99,14 +112,13 @@ public View getRootView() {
99112 public void onCreate (@ Nullable Bundle savedInstanceState ) {
100113 super .onCreate (savedInstanceState );
101114 if (getIntent () != null ) {
102- this .privateKeyDetailsList = getIntent ().getParcelableArrayListExtra
103- (KEY_EXTRA_PRIVATE_KEYS );
115+ this .privateKeyDetailsList = getIntent ().getParcelableArrayListExtra (KEY_EXTRA_PRIVATE_KEYS );
104116 this .bottomTitle = getIntent ().getStringExtra (KEY_EXTRA_BOTTOM_TITLE );
105- this .checkButtonTitle = getIntent ().getStringExtra (KEY_EXTRA_CHECK_BUTTON_TITLE );
106- this .anotherAccountButtonTitle = getIntent ().getStringExtra
107- ( KEY_EXTRA_NEGATIVE_ACTION_BUTTON_TITLE );
108- this .isThrowErrorIfDuplicateFound = getIntent ().getBooleanExtra (
109- KEY_EXTRA_IS_THROW_ERROR_IF_DUPLICATE_FOUND , false );
117+ this .positiveButtonTitle = getIntent ().getStringExtra (KEY_EXTRA_POSITIVE_BUTTON_TITLE );
118+ this .neutralButtonTitle = getIntent ().getStringExtra ( KEY_EXTRA_NEUTRAL_BUTTON_TITLE );
119+ this . negativeButtonTitle = getIntent (). getStringExtra ( KEY_EXTRA_NEGATIVE_BUTTON_TITLE );
120+ this .isThrowErrorIfDuplicateFound = getIntent ().getBooleanExtra
121+ ( KEY_EXTRA_IS_THROW_ERROR_IF_DUPLICATE_FOUND , false );
110122 }
111123
112124 initViews ();
@@ -115,12 +127,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
115127 @ Override
116128 public void onClick (View v ) {
117129 switch (v .getId ()) {
118- case R .id .buttonCheck :
130+ case R .id .buttonPositiveAction :
119131 UIUtil .hideSoftInput (this , editTextKeyPassword );
120132 if (privateKeyDetailsList != null && !privateKeyDetailsList .isEmpty ()) {
121133 if (TextUtils .isEmpty (editTextKeyPassword .getText ().toString ())) {
122- showInfoSnackbar (editTextKeyPassword ,
123- getString (R .string .passphrase_must_be_non_empty ));
134+ showInfoSnackbar (editTextKeyPassword , getString (R .string .passphrase_must_be_non_empty ));
124135 } else {
125136 if (getSnackBar () != null ) {
126137 getSnackBar ().dismiss ();
@@ -132,6 +143,11 @@ public void onClick(View v) {
132143 }
133144 break ;
134145
146+ case R .id .buttonNeutralAction :
147+ setResult (RESULT_NEUTRAL );
148+ finish ();
149+ break ;
150+
135151 case R .id .buttonNegativeAction :
136152 setResult (RESULT_NEGATIVE );
137153 finish ();
@@ -183,33 +199,38 @@ public void handleSuccessLoaderResult(int loaderId, Object result) {
183199 setResult (Activity .RESULT_OK );
184200 finish ();
185201 } else {
186- showInfoSnackbar (getRootView (), getString (R .string
187- .password_is_incorrect ));
202+ showInfoSnackbar (getRootView (), getString (R .string .password_is_incorrect ));
188203 }
189204 break ;
190205 }
191206 }
192207
193208 private void initViews () {
194- if (findViewById (R .id .buttonCheck ) != null ) {
195- Button buttonCheck = (Button ) findViewById (R .id .buttonCheck );
196- buttonCheck .setText (checkButtonTitle );
197- buttonCheck .setOnClickListener (this );
209+ if (findViewById (R .id .buttonPositiveAction ) != null ) {
210+ Button buttonPositiveAction = findViewById (R .id .buttonPositiveAction );
211+ buttonPositiveAction .setText (positiveButtonTitle );
212+ buttonPositiveAction .setOnClickListener (this );
213+ }
214+
215+ if (!TextUtils .isEmpty (neutralButtonTitle ) && findViewById (R .id .buttonNeutralAction ) != null ) {
216+ Button buttonNeutralAction = findViewById (R .id .buttonNeutralAction );
217+ buttonNeutralAction .setVisibility (View .VISIBLE );
218+ buttonNeutralAction .setText (neutralButtonTitle );
219+ buttonNeutralAction .setOnClickListener (this );
198220 }
199221
200222 if (findViewById (R .id .buttonNegativeAction ) != null ) {
201- Button buttonSelectAnotherAccount =
202- (Button ) findViewById (R .id .buttonNegativeAction );
203- buttonSelectAnotherAccount .setText (anotherAccountButtonTitle );
204- buttonSelectAnotherAccount .setOnClickListener (this );
223+ Button buttonNegativeAction = findViewById (R .id .buttonNegativeAction );
224+ buttonNegativeAction .setText (negativeButtonTitle );
225+ buttonNegativeAction .setOnClickListener (this );
205226 }
206227
207- TextView textViewCheckKeysTitle = ( TextView ) findViewById (R .id .textViewCheckKeysTitle );
228+ TextView textViewCheckKeysTitle = findViewById (R .id .textViewCheckKeysTitle );
208229 if (textViewCheckKeysTitle != null ) {
209230 textViewCheckKeysTitle .setText (bottomTitle );
210231 }
211232
212- editTextKeyPassword = ( EditText ) findViewById (R .id .editTextKeyPassword );
233+ editTextKeyPassword = findViewById (R .id .editTextKeyPassword );
213234 progressBar = findViewById (R .id .progressBar );
214235 }
215236}
0 commit comments