Search in sources :

Example 21 with SystemUIDialog

use of com.android.systemui.statusbar.phone.SystemUIDialog in project android_frameworks_base by ResurrectionRemix.

the class TunerService method showResetRequest.

public static final void showResetRequest(final Context context, final Runnable onDisabled) {
    SystemUIDialog dialog = new SystemUIDialog(context);
    dialog.setShowForAllUsers(true);
    dialog.setMessage(R.string.remove_from_settings_prompt);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.cancel), (OnClickListener) null);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.guest_exit_guest_dialog_remove), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Tell the tuner (in main SysUI process) to clear all its settings.
            context.sendBroadcast(new Intent(TunerService.ACTION_CLEAR));
            // Disable access to tuner.
            TunerService.setTunerEnabled(context, false);
            // Make them sit through the warning dialog again.
            Settings.Secure.putInt(context.getContentResolver(), TunerFragment.SETTING_SEEN_TUNER_WARNING, 0);
            if (onDisabled != null) {
                onDisabled.run();
            }
        }
    });
    dialog.show();
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 22 with SystemUIDialog

use of com.android.systemui.statusbar.phone.SystemUIDialog in project android_frameworks_base by ResurrectionRemix.

the class QSFooter method createDialog.

private void createDialog() {
    final String deviceOwnerPackage = mSecurityController.getDeviceOwnerName();
    final String profileOwnerPackage = mSecurityController.getProfileOwnerName();
    final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
    final String primaryVpn = mSecurityController.getPrimaryVpnName();
    final String profileVpn = mSecurityController.getProfileVpnName();
    boolean hasProfileOwner = mSecurityController.hasProfileOwner();
    boolean isBranded = deviceOwnerPackage == null && mSecurityController.isVpnBranded();
    mDialog = new SystemUIDialog(mContext);
    if (!isBranded) {
        mDialog.setTitle(getTitle(deviceOwnerPackage));
    }
    CharSequence msg = getMessage(deviceOwnerPackage, profileOwnerPackage, primaryVpn, profileVpn, hasProfileOwner, isBranded);
    if (deviceOwnerPackage == null) {
        mDialog.setMessage(msg);
        if (mSecurityController.isVpnEnabled() && !mSecurityController.isVpnRestricted()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
        }
    } else {
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.quick_settings_footer_dialog, null, false);
        mDialog.setView(dialogView);
        TextView deviceOwnerWarning = (TextView) dialogView.findViewById(R.id.device_owner_warning);
        deviceOwnerWarning.setText(msg);
        // Make the link "learn more" clickable.
        deviceOwnerWarning.setMovementMethod(new LinkMovementMethod());
        if (primaryVpn == null) {
            dialogView.findViewById(R.id.vpn_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_warning).setVisibility(View.GONE);
        } else {
            final SpannableStringBuilder message = new SpannableStringBuilder();
            message.append(mContext.getString(R.string.monitoring_description_do_body_vpn, primaryVpn));
            if (!mSecurityController.isVpnRestricted()) {
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings_separator));
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings), new VpnSpan(), 0);
            }
            TextView vpnWarning = (TextView) dialogView.findViewById(R.id.vpn_warning);
            vpnWarning.setText(message);
            // Make the link "Open VPN Settings" clickable.
            vpnWarning.setMovementMethod(new LinkMovementMethod());
        }
        if (!isNetworkLoggingEnabled) {
            dialogView.findViewById(R.id.network_logging_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_warning).setVisibility(View.GONE);
        }
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(isBranded), this);
    mDialog.show();
    mDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 23 with SystemUIDialog

use of com.android.systemui.statusbar.phone.SystemUIDialog in project android_frameworks_base by ResurrectionRemix.

the class PowerNotificationWarnings method showStartSaverConfirmation.

private void showStartSaverConfirmation() {
    if (mSaverConfirmation != null)
        return;
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setTitle(R.string.battery_saver_confirmation_title);
    d.setMessage(com.android.internal.R.string.battery_saver_description);
    d.setNegativeButton(android.R.string.cancel, null);
    d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
    d.setShowForAllUsers(true);
    d.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mSaverConfirmation = null;
        }
    });
    d.show();
    mSaverConfirmation = d;
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 24 with SystemUIDialog

use of com.android.systemui.statusbar.phone.SystemUIDialog in project android_frameworks_base by ResurrectionRemix.

the class BaseStatusBar method bindGuts.

private void bindGuts(final ExpandableNotificationRow row) {
    row.inflateGuts();
    final StatusBarNotification sbn = row.getStatusBarNotification();
    PackageManager pmUser = getPackageManagerForUser(mContext, sbn.getUser().getIdentifier());
    row.setTag(sbn.getPackageName());
    final NotificationGuts guts = row.getGuts();
    guts.setClosedListener(this);
    final String pkg = sbn.getPackageName();
    String appname = pkg;
    Drawable pkgicon = null;
    int appUid = -1;
    try {
        final ApplicationInfo info = pmUser.getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
        if (info != null) {
            appname = String.valueOf(pmUser.getApplicationLabel(info));
            pkgicon = pmUser.getApplicationIcon(info);
            appUid = info.uid;
        }
    } catch (NameNotFoundException e) {
        // app is gone, just show package name and generic icon
        pkgicon = pmUser.getDefaultActivityIcon();
    }
    ((ImageView) guts.findViewById(R.id.app_icon)).setImageDrawable(pkgicon);
    ((TextView) guts.findViewById(R.id.pkgname)).setText(appname);
    final TextView settingsButton = (TextView) guts.findViewById(R.id.more_settings);
    ViewGroup buttonParent = (ViewGroup) settingsButton.getParent();
    final TextView killButton = (TextView) LayoutInflater.from(settingsButton.getContext()).inflate(R.layout.kill_button, buttonParent, false);
    if (buttonParent.findViewById(R.id.notification_inspect_kill) == null) {
        // only add once
        buttonParent.addView(killButton, buttonParent.indexOfChild(settingsButton));
    }
    if (appUid >= 0) {
        final int appUidF = appUid;
        settingsButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO);
                guts.resetFalsingCheck();
                startAppNotificationSettingsActivity(pkg, appUidF);
            }
        });
        settingsButton.setText(R.string.notification_more_settings);
        if (isThisASystemPackage(pkg, pmUser)) {
            killButton.setVisibility(View.GONE);
        } else {
            boolean killButtonEnabled = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.NOTIFICATION_GUTS_KILL_APP_BUTTON, 0, UserHandle.USER_CURRENT) != 0;
            killButton.setVisibility(killButtonEnabled ? View.VISIBLE : View.GONE);
            killButton.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
                        // Don't do anything
                        return;
                    }
                    final SystemUIDialog killDialog = new SystemUIDialog(mContext);
                    killDialog.setTitle(mContext.getText(R.string.force_stop_dlg_title));
                    killDialog.setMessage(mContext.getText(R.string.force_stop_dlg_text));
                    killDialog.setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            // kill pkg
                            ActivityManager actMan = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
                            actMan.forceStopPackage(pkg);
                        }
                    });
                    killDialog.setNegativeButton(R.string.dlg_cancel, null);
                    killDialog.show();
                }
            });
            killButton.setText(R.string.kill);
        }
    } else {
        settingsButton.setVisibility(View.GONE);
        killButton.setVisibility(View.GONE);
    }
    guts.bindImportance(pmUser, sbn, mNonBlockablePkgs, mNotificationData.getImportance(sbn.getKey()));
    final TextView doneButton = (TextView) guts.findViewById(R.id.done);
    doneButton.setText(R.string.notification_done);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // If the user has security enabled, show challenge if the setting is changed.
            if (guts.hasImportanceChanged() && isLockscreenPublicMode() && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
                OnDismissAction dismissAction = new OnDismissAction() {

                    @Override
                    public boolean onDismiss() {
                        saveImportanceCloseControls(sbn, row, guts, v);
                        return true;
                    }
                };
                onLockedNotificationImportanceChange(dismissAction);
            } else {
                saveImportanceCloseControls(sbn, row, guts, v);
            }
        }
    });
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) ApplicationInfo(android.content.pm.ApplicationInfo) OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) ActivityManager(android.app.ActivityManager) GestureAnywhereView(com.android.systemui.chaos.lab.gestureanywhere.GestureAnywhereView) ImageView(android.widget.ImageView) NotificationPanelView(com.android.systemui.statusbar.phone.NotificationPanelView) View(android.view.View) RemoteInputView(com.android.systemui.statusbar.policy.RemoteInputView) TextView(android.widget.TextView) NavigationBarView(com.android.systemui.statusbar.phone.NavigationBarView) StatusBarNotification(android.service.notification.StatusBarNotification) PackageManager(android.content.pm.PackageManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 25 with SystemUIDialog

use of com.android.systemui.statusbar.phone.SystemUIDialog in project android_frameworks_base by DirtyUnicorns.

the class QSFooter method createDialog.

private void createDialog() {
    final String deviceOwnerPackage = mSecurityController.getDeviceOwnerName();
    final String profileOwnerPackage = mSecurityController.getProfileOwnerName();
    final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
    final String primaryVpn = mSecurityController.getPrimaryVpnName();
    final String profileVpn = mSecurityController.getProfileVpnName();
    boolean hasProfileOwner = mSecurityController.hasProfileOwner();
    boolean isBranded = deviceOwnerPackage == null && mSecurityController.isVpnBranded();
    mDialog = new SystemUIDialog(mContext);
    if (!isBranded) {
        mDialog.setTitle(getTitle(deviceOwnerPackage));
    }
    CharSequence msg = getMessage(deviceOwnerPackage, profileOwnerPackage, primaryVpn, profileVpn, hasProfileOwner, isBranded);
    if (deviceOwnerPackage == null) {
        mDialog.setMessage(msg);
        if (mSecurityController.isVpnEnabled() && !mSecurityController.isVpnRestricted()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
        }
    } else {
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.quick_settings_footer_dialog, null, false);
        mDialog.setView(dialogView);
        TextView deviceOwnerWarning = (TextView) dialogView.findViewById(R.id.device_owner_warning);
        deviceOwnerWarning.setText(msg);
        // Make the link "learn more" clickable.
        deviceOwnerWarning.setMovementMethod(new LinkMovementMethod());
        if (primaryVpn == null) {
            dialogView.findViewById(R.id.vpn_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_warning).setVisibility(View.GONE);
        } else {
            final SpannableStringBuilder message = new SpannableStringBuilder();
            message.append(mContext.getString(R.string.monitoring_description_do_body_vpn, primaryVpn));
            if (!mSecurityController.isVpnRestricted()) {
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings_separator));
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings), new VpnSpan(), 0);
            }
            TextView vpnWarning = (TextView) dialogView.findViewById(R.id.vpn_warning);
            vpnWarning.setText(message);
            // Make the link "Open VPN Settings" clickable.
            vpnWarning.setMovementMethod(new LinkMovementMethod());
        }
        if (!isNetworkLoggingEnabled) {
            dialogView.findViewById(R.id.network_logging_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_warning).setVisibility(View.GONE);
        }
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(isBranded), this);
    mDialog.show();
    mDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder)

Aggregations

SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)28 DialogInterface (android.content.DialogInterface)19 OnClickListener (android.content.DialogInterface.OnClickListener)9 OnDismissListener (android.content.DialogInterface.OnDismissListener)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 Intent (android.content.Intent)4 SpannableStringBuilder (android.text.SpannableStringBuilder)4 LinkMovementMethod (android.text.method.LinkMovementMethod)4 ActivityManager (android.app.ActivityManager)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Drawable (android.graphics.drawable.Drawable)1 StatusBarNotification (android.service.notification.StatusBarNotification)1 ViewGroup (android.view.ViewGroup)1 OnDismissAction (com.android.keyguard.KeyguardHostView.OnDismissAction)1 GestureAnywhereView (com.android.systemui.chaos.lab.gestureanywhere.GestureAnywhereView)1 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)1