@@ -1461,22 +1461,29 @@ public static boolean hasOnlineProfile(){
14611461 }
14621462 return false ;
14631463 }
1464- public static void hasNoOnlineProfileDialog (Activity activity ){
1465- if (hasOnlineProfile ()){
1466- } else dialogOnUiThread (activity , activity .getString (R .string .no_minecraft_account_found ), activity .getString (R .string .feature_requires_java_account ));
1464+
1465+ public static void hasNoOnlineProfileDialog (Activity activity , @ Nullable Runnable run , @ Nullable String customTitle , @ Nullable String customMessage ){
1466+ if (hasOnlineProfile () && !Tools .isDemoProfile (activity )){
1467+ if (run != null ) { // Demo profile handling should be using customTitle and customMessage
1468+ run .run ();
1469+ }
1470+ } else { // If there is no online profile, show a dialog
1471+ customTitle = customTitle == null ? activity .getString (R .string .no_minecraft_account_found ) : customTitle ;
1472+ customMessage = customMessage == null ? activity .getString (R .string .feature_requires_java_account ) : customMessage ;
1473+ dialogOnUiThread (activity , customTitle , customMessage );
1474+ }
14671475 }
1468- public static void hasNoOnlineProfileDialog (Activity activity , String customTitle , String customMessage ){
1469- if (hasOnlineProfile ()){
1470- } else dialogOnUiThread (activity , customTitle , customMessage );
1476+
1477+ // Some boilerplate to reduce boilerplate elsewhere
1478+ public static void hasNoOnlineProfileDialog (Activity activity ){
1479+ hasNoOnlineProfileDialog (activity , null , null , null );
14711480 }
14721481 public static void hasNoOnlineProfileDialog (Activity activity , Runnable run ){
1473- if (hasOnlineProfile ()){
1474- run .run ();
1475- } else dialogOnUiThread (activity , activity .getString (R .string .no_minecraft_account_found ), activity .getString (R .string .feature_requires_java_account ));
1482+ hasNoOnlineProfileDialog (activity , run , null , null );
14761483 }
1477- public static void hasNoOnlineProfileDialog (Activity activity , Runnable run , String customTitle , String customMessage ){
1478- if (hasOnlineProfile ()){
1479- run .run ();
1480- } else dialogOnUiThread (activity , customTitle , customMessage );
1484+ public static void hasNoOnlineProfileDialog (Activity activity , String customTitle , String customMessage ){
1485+ hasNoOnlineProfileDialog (activity , null , customTitle , customMessage );
14811486 }
1487+
1488+
14821489}
0 commit comments