Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc2c1ff7 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '5246-Fix_initial_dialog_not_responsive_issue' into 'master'

5246-Fix_initial_dialog_not_responsive_issue

See merge request !30
parents 9c7ddc9c 5e009679
Loading
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -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
    }