diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index eae8cc0468d095eba9427e7c73712615d030f29a..632cb693c5b808c862bb380028cf1a58df502080 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -571,7 +571,10 @@ public class MainActivity extends Activity { launchOnlineHelp(); } }); - showAlertDialog(alertDialog, "first time load dialog dismissed"); + /* On application start 20 millisecond delay is not enough for all screen rotating animation to be complete + (if user use the camera in portrait mode, then it moves from portrait to landscape & then again landscape to portrait). + 500 milliseconds delay would do the trick. */ + showAlertDialog(alertDialog, "first time load dialog dismissed", 500L); } setFirstTimeFlag(); @@ -1518,6 +1521,14 @@ public class MainActivity extends Activity { } private void showAlertDialog(AlertDialog.Builder alertDialog, final String logMessageOnDismiss) { + showAlertDialog(alertDialog, logMessageOnDismiss, -1L); + } + + /** + * @param delayInMs how much time in milliseconds should the alertDialog wait to popup. + * If delay <= 0, then use default delay time (20 milliseconds) + */ + private void showAlertDialog(AlertDialog.Builder alertDialog, final String logMessageOnDismiss, long delayInMs) { final AlertDialog alert = alertDialog.create(); alert.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override @@ -1531,6 +1542,10 @@ public class MainActivity extends Activity { showPreview(false); setWindowFlagsForSettings(); + if (delayInMs > 0) { + showAlert(alert, delayInMs); + return; + } showAlert(alert); } @@ -2942,7 +2957,7 @@ public class MainActivity extends Activity { * the dialog doesn't show properly if the phone is held in portrait. A workaround seems to be * to use postDelayed. Note that postOnAnimation() doesn't work. */ - public void showAlert(final AlertDialog alert) { + public void showAlert(final AlertDialog alert, long delayInMs) { if( MyDebug.LOG ) Log.d(TAG, "showAlert"); Handler handler = new Handler(); @@ -2950,7 +2965,11 @@ public class MainActivity extends Activity { public void run() { alert.show(); } - }, 20); + }, delayInMs); + } + + public void showAlert(final AlertDialog alert) { + showAlert(alert, 20L); // note that 1ms usually fixes the problem, but not always; 10ms seems fine, have set 20ms // just in case }