Search in sources :

Example 91 with RemoteViews

use of android.widget.RemoteViews in project android_frameworks_base by crdroidandroid.

the class AppWidgetServiceImpl method maskWidgetsViewsLocked.

/**
     * Mask the target widget belonging to the specified provider, or all active widgets
     * of the provider if target widget == null.
     */
private void maskWidgetsViewsLocked(Provider provider, Widget targetWidget) {
    final int widgetCount = provider.widgets.size();
    if (widgetCount == 0) {
        return;
    }
    final String providerPackage = provider.info.provider.getPackageName();
    final int providerUserId = provider.getUserId();
    Bitmap iconBitmap = createMaskedWidgetBitmap(providerPackage, providerUserId);
    if (iconBitmap == null) {
        return;
    }
    final boolean showBadge;
    final Intent onClickIntent;
    final long identity = Binder.clearCallingIdentity();
    try {
        if (provider.maskedBySuspendedPackage) {
            UserInfo userInfo = mUserManager.getUserInfo(providerUserId);
            showBadge = userInfo.isManagedProfile();
            onClickIntent = mDevicePolicyManagerInternal.createPackageSuspendedDialogIntent(providerPackage, providerUserId);
        } else if (provider.maskedByQuietProfile) {
            showBadge = true;
            onClickIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(providerUserId);
        } else /* provider.maskedByLockedProfile */
        {
            showBadge = true;
            onClickIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, null, providerUserId);
            if (onClickIntent != null) {
                onClickIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            }
        }
        for (int j = 0; j < widgetCount; j++) {
            Widget widget = provider.widgets.get(j);
            if (targetWidget != null && targetWidget != widget)
                continue;
            PendingIntent intent = null;
            if (onClickIntent != null) {
                intent = PendingIntent.getActivity(mContext, widget.appWidgetId, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
            }
            RemoteViews views = createMaskedWidgetRemoteViews(iconBitmap, showBadge, intent);
            if (widget.replaceWithMaskedViewsLocked(views)) {
                scheduleNotifyUpdateAppWidgetLocked(widget, widget.getEffectiveViewsLocked());
            }
        }
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : Bitmap(android.graphics.Bitmap) RemoteViews(android.widget.RemoteViews) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) UserInfo(android.content.pm.UserInfo) PendingIntent(android.app.PendingIntent) Point(android.graphics.Point)

Example 92 with RemoteViews

use of android.widget.RemoteViews in project android_frameworks_base by crdroidandroid.

the class BaseStatusBar method updatePublicContentView.

protected void updatePublicContentView(Entry entry, StatusBarNotification sbn) {
    final RemoteViews publicContentView = entry.cachedPublicContentView;
    View inflatedView = entry.getPublicContentView();
    if (entry.autoRedacted && publicContentView != null && inflatedView != null) {
        final boolean disabledByPolicy = !adminAllowsUnredactedNotifications(entry.notification.getUserId());
        String notificationHiddenText = mContext.getString(disabledByPolicy ? com.android.internal.R.string.notification_hidden_by_policy_text : com.android.internal.R.string.notification_hidden_text);
        TextView titleView = (TextView) inflatedView.findViewById(android.R.id.title);
        if (titleView != null && !titleView.getText().toString().equals(notificationHiddenText)) {
            publicContentView.setTextViewText(android.R.id.title, notificationHiddenText);
            publicContentView.reapply(sbn.getPackageContext(mContext), inflatedView, mOnClickHandler);
            entry.row.onNotificationUpdated(entry);
        }
    }
}
Also used : RemoteViews(android.widget.RemoteViews) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) RemoteInputView(com.android.systemui.statusbar.policy.RemoteInputView) TextView(android.widget.TextView) NavigationBarView(com.android.systemui.statusbar.phone.NavigationBarView)

Example 93 with RemoteViews

use of android.widget.RemoteViews in project android_frameworks_base by crdroidandroid.

the class TestAppWidgetProvider method onReceive.

public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d(TAG, "intent=" + intent);
    if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
        Log.d(TAG, "ENABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
        Log.d(TAG, "DISABLED");
    } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
        Log.d(TAG, "UPDATE");
        // BEGIN_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
        Bundle extras = intent.getExtras();
        int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        // END_INCLUDE(getExtra_EXTRA_APPWIDGET_IDS)
        SharedPreferences prefs = context.getSharedPreferences(TestAppWidgetProvider.PREFS_NAME, 0);
        String prefix = prefs.getString(PREF_PREFIX_KEY, "hai");
        AppWidgetManager gm = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_appwidget);
        views.setTextViewText(R.id.oh_hai_text, prefix + ": " + SystemClock.elapsedRealtime());
        if (false) {
            gm.updateAppWidget(appWidgetIds, views);
        } else {
            gm.updateAppWidget(new ComponentName("com.android.tests.appwidgethost", "com.android.tests.appwidgethost.TestAppWidgetProvider"), views);
        }
    }
}
Also used : RemoteViews(android.widget.RemoteViews) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) ComponentName(android.content.ComponentName)

Example 94 with RemoteViews

use of android.widget.RemoteViews in project android_frameworks_base by AOSPA.

the class RemoteViewsTest method clone_originalCanStillBeApplied.

@Test
public void clone_originalCanStillBeApplied() {
    RemoteViews original = new RemoteViews(mPackage, R.layout.remote_views_test);
    RemoteViews clone = original.clone();
    clone.apply(mContext, mContainer);
}
Also used : RemoteViews(android.widget.RemoteViews) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 95 with RemoteViews

use of android.widget.RemoteViews in project android_frameworks_base by AOSPA.

the class RemoteViewsTest method clone_clones.

@Test
public void clone_clones() {
    RemoteViews original = new RemoteViews(mPackage, R.layout.remote_views_test);
    RemoteViews clone = original.clone();
    original.setTextViewText(R.id.text, "test");
    View inflated = clone.apply(mContext, mContainer);
    TextView textView = (TextView) inflated.findViewById(R.id.text);
    assertEquals("", textView.getText());
}
Also used : RemoteViews(android.widget.RemoteViews) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Aggregations

RemoteViews (android.widget.RemoteViews)217 Intent (android.content.Intent)86 PendingIntent (android.app.PendingIntent)77 TextView (android.widget.TextView)35 Test (org.junit.Test)35 Notification (android.app.Notification)30 SmallTest (android.support.test.filters.SmallTest)30 View (android.view.View)29 ImageView (android.widget.ImageView)28 AppWidgetManager (android.appwidget.AppWidgetManager)26 ComponentName (android.content.ComponentName)24 Bitmap (android.graphics.Bitmap)24 Bundle (android.os.Bundle)16 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)15 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)15 NotificationCompat (android.support.v4.app.NotificationCompat)14 Resources (android.content.res.Resources)12 StatusBarNotification (android.service.notification.StatusBarNotification)12 SharedPreferences (android.content.SharedPreferences)11 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)11