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

Commit ea656aea authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Extended Power Menu - Reboot" into ics

parents 67298dea 053ba995
Loading
Loading
Loading
Loading
+60 −15
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.storage.IMountShutdownObserver;
import com.android.internal.telephony.ITelephony;
import android.util.Log;
import android.view.WindowManager;
import android.view.KeyEvent;

public final class ShutdownThread extends Thread {
    // constants
@@ -107,10 +108,50 @@ public final class ShutdownThread extends Thread {
        Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);

        if (confirm) {
            final CloseDialogReceiver closer = new CloseDialogReceiver(context);
            final AlertDialog dialog = new AlertDialog.Builder(context)
            final AlertDialog dialog;
            // Set different dialog message based on whether or not we're rebooting
            if (mReboot) {
                dialog = new AlertDialog.Builder(context)
                        .setIcon(android.R.drawable.ic_dialog_alert)
                        .setTitle(com.android.internal.R.string.reboot_system)
                        .setSingleChoiceItems(com.android.internal.R.array.shutdown_reboot_options, 0, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                if (which < 0)
                                    return;

                                String actions[] = context.getResources().getStringArray(com.android.internal.R.array.shutdown_reboot_actions);

                                if (actions != null && which < actions.length)
                                    mRebootReason = actions[which];
                            }
                        })
                        .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                mReboot = true;
                                beginShutdownSequence(context);
                            }
                        })
                        .setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                mReboot = false;
                                dialog.cancel();
                            }
                        })
                        .create();
                        dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
                            public boolean onKey (DialogInterface dialog, int keyCode, KeyEvent event) {
                                if (keyCode == KeyEvent.KEYCODE_BACK) {
                                    mReboot = false;
                                    dialog.cancel();
                                }
                                return true;
                            }
                        });
            } else {
                dialog = new AlertDialog.Builder(context)
                        .setIcon(android.R.drawable.ic_dialog_alert)
                        .setTitle(com.android.internal.R.string.power_off)
                    .setMessage(resourceId)
                        .setMessage(com.android.internal.R.string.shutdown_confirm)
                        .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                beginShutdownSequence(context);
@@ -118,8 +159,7 @@ public final class ShutdownThread extends Thread {
                        })
                        .setNegativeButton(com.android.internal.R.string.no, null)
                        .create();
            closer.dialog = dialog;
            dialog.setOnDismissListener(closer);
            }
            dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
            dialog.show();
        } else {
@@ -175,8 +215,13 @@ public final class ShutdownThread extends Thread {
        // throw up an indeterminate system dialog to indicate radio is
        // shutting down.
        ProgressDialog pd = new ProgressDialog(context);
        if (mReboot) {
            pd.setTitle(context.getText(com.android.internal.R.string.reboot_system));
            pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress));
        } else {
            pd.setTitle(context.getText(com.android.internal.R.string.power_off));
            pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
        }
        pd.setIndeterminate(true);
        pd.setCancelable(false);
        pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
+3.6 KiB
Loading image diff...
+1.16 KiB
Loading image diff...
+3.29 KiB
Loading image diff...
+4.5 KiB
Loading image diff...
Loading