99import android .app .Activity ;
1010import android .app .ProgressDialog ;
1111import android .content .Context ;
12+ import android .content .DialogInterface ;
1213import android .content .Intent ;
1314import android .content .SharedPreferences ;
1415import android .content .pm .PackageManager ;
3839import java .util .Locale ;
3940
4041import androidx .annotation .NonNull ;
42+ import androidx .appcompat .app .AlertDialog ;
4143import androidx .appcompat .app .AppCompatActivity ;
4244import androidx .core .app .ActivityCompat ;
4345import androidx .core .content .ContextCompat ;
@@ -420,7 +422,6 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
420422 }
421423 activateSignal (preferences .getSignalUsername (), text );
422424 onRemoteNotificationParameterChange ();
423- checkSignalUsernameVerification ();
424425 break ;
425426 }
426427 case PreferenceManager .REMOTE_PHONE_NUMBER :
@@ -615,7 +616,7 @@ public void onSuccess(@NonNull String msg) {
615616 if (isAdded () && getActivity () != null ) {
616617 progressDialog .dismiss ();
617618 }
618- Toast . makeText ( getContext (), msg , Toast . LENGTH_SHORT ). show ();
619+ showRegistrationSuccessDialog ();
619620 }
620621
621622 @ Override
@@ -637,7 +638,8 @@ public void onSuccess(@NonNull String msg) {
637638 }
638639 // mark that the current registered signal username is verified
639640 preferences .setVerifiedSignalUsername (preferences .getSignalUsername ());
640- Toast .makeText (getContext (), msg , Toast .LENGTH_SHORT ).show ();
641+ checkSignalUsernameVerification ();
642+ showVerificationSuccessDialog ();
641643 }
642644
643645 @ Override
@@ -651,6 +653,34 @@ public void onFailure(@NonNull String msg) {
651653 }
652654 }
653655
656+ private void showRegistrationSuccessDialog () {
657+ if (!isAdded () || getActivity () == null ) {
658+ return ;
659+ }
660+
661+ new AlertDialog .Builder (getActivity ())
662+ .setTitle (R .string .registration_successful )
663+ .setMessage (getString (R .string .signal_reg_success_desc , preferences .getSignalUsername ()))
664+ .setPositiveButton (R .string .verify , (dialog , which ) -> {
665+ dialog .dismiss ();
666+ findPreference (PreferenceManager .VERIFY_SIGNAL ).performClick ();
667+ })
668+ .setNegativeButton (R .string .ok , (dialog , which ) -> dialog .dismiss ())
669+ .show ();
670+ }
671+
672+ private void showVerificationSuccessDialog () {
673+ if (!isAdded () || getActivity () == null ) {
674+ return ;
675+ }
676+
677+ new AlertDialog .Builder (getActivity ())
678+ .setTitle (R .string .verification_successful )
679+ .setMessage (R .string .signal_verification_success_desc )
680+ .setPositiveButton (R .string .ok , (dialog , which ) -> dialog .dismiss ())
681+ .show ();
682+ }
683+
654684 private void resetSignal (String username ) {
655685 if (checkValidString ((username ))) {
656686 SignalSender sender = SignalSender .getInstance (mActivity , username .trim ());
0 commit comments