Search in sources :

Example 16 with OnDismissAction

use of com.android.keyguard.KeyguardHostView.OnDismissAction 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 17 with OnDismissAction

use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by DirtyUnicorns.

the class BaseStatusBar method startNotificationGutsIntent.

private void startNotificationGutsIntent(final Intent intent, final int appUid) {
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    dismissKeyguardThenExecute(new OnDismissAction() {

        @Override
        public boolean onDismiss() {
            AsyncTask.execute(new Runnable() {

                public void run() {
                    try {
                        if (keyguardShowing) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(getActivityOptions(), new UserHandle(UserHandle.getUserId(appUid)));
                        overrideActivityPendingAppTransition(keyguardShowing);
                    } catch (RemoteException e) {
                    }
                }
            });
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true);
            return true;
        }
    }, false);
}
Also used : UserHandle(android.os.UserHandle) OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) RemoteException(android.os.RemoteException)

Example 18 with OnDismissAction

use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method startPendingIntentDismissingKeyguard.

public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
    if (!isDeviceProvisioned())
        return;
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    final boolean afterKeyguardGone = intent.isActivity() && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), mCurrentUserId);
    dismissKeyguardThenExecute(new OnDismissAction() {

        public boolean onDismiss() {
            new Thread() {

                @Override
                public void run() {
                    try {
                        if (keyguardShowing && !afterKeyguardGone) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        // The intent we are sending is for the application, which
                        // won't have permission to immediately start an activity after
                        // the user switches to home.  We know it is safe to do at this
                        // point, so make sure new activity switches are now allowed.
                        ActivityManagerNative.getDefault().resumeAppSwitches();
                    } catch (RemoteException e) {
                    }
                    try {
                        intent.send(null, 0, null, null, null, null, getActivityOptions());
                    } catch (PendingIntent.CanceledException e) {
                        // the stack trace isn't very helpful here.
                        // Just log the exception message.
                        Log.w(TAG, "Sending intent failed: " + e);
                    // TODO: Dismiss Keyguard.
                    }
                    if (intent.isActivity()) {
                        mAssistManager.hideAssist();
                        overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone);
                    }
                }
            }.start();
            // close the shade if it was open
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
            true);
            visibilityChanged(false);
            return true;
        }
    }, afterKeyguardGone);
}
Also used : OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) PendingIntent(android.app.PendingIntent) RemoteException(android.os.RemoteException)

Example 19 with OnDismissAction

use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method startNotificationGutsIntent.

private void startNotificationGutsIntent(final Intent intent, final int appUid) {
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    dismissKeyguardThenExecute(new OnDismissAction() {

        @Override
        public boolean onDismiss() {
            AsyncTask.execute(new Runnable() {

                public void run() {
                    try {
                        if (keyguardShowing) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(getActivityOptions(), new UserHandle(UserHandle.getUserId(appUid)));
                        overrideActivityPendingAppTransition(keyguardShowing);
                    } catch (RemoteException e) {
                    }
                }
            });
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true);
            return true;
        }
    }, false);
}
Also used : UserHandle(android.os.UserHandle) OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) RemoteException(android.os.RemoteException)

Example 20 with OnDismissAction

use of com.android.keyguard.KeyguardHostView.OnDismissAction in project android_frameworks_base by crdroidandroid.

the class PhoneStatusBar method executeRunnableDismissingKeyguard.

public void executeRunnableDismissingKeyguard(final Runnable runnable, final Runnable cancelAction, final boolean dismissShade, final boolean afterKeyguardGone, final boolean deferred) {
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    dismissKeyguardThenExecute(new OnDismissAction() {

        @Override
        public boolean onDismiss() {
            AsyncTask.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        if (keyguardShowing && !afterKeyguardGone) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        if (runnable != null) {
                            runnable.run();
                        }
                    } catch (RemoteException e) {
                    }
                }
            });
            if (dismissShade) {
                animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
                true);
            }
            return deferred;
        }
    }, cancelAction, afterKeyguardGone);
}
Also used : OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) RemoteException(android.os.RemoteException)

Aggregations

OnDismissAction (com.android.keyguard.KeyguardHostView.OnDismissAction)20 RemoteException (android.os.RemoteException)15 PendingIntent (android.app.PendingIntent)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 PackageManager (android.content.pm.PackageManager)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 Drawable (android.graphics.drawable.Drawable)5 UserHandle (android.os.UserHandle)5 StatusBarNotification (android.service.notification.StatusBarNotification)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)5 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)5 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)2 ActivityManager (android.app.ActivityManager)1 DialogInterface (android.content.DialogInterface)1 ViewGroup (android.view.ViewGroup)1 GestureAnywhereView (com.android.systemui.chaos.lab.gestureanywhere.GestureAnywhereView)1 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)1