Search in sources :

Example 71 with RemoteViews

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

the class AppWidgetHost method createView.

/**
     * Create the AppWidgetHostView for the given widget.
     * The AppWidgetHost retains a pointer to the newly-created View.
     */
public final AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) {
    AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
    view.setOnClickHandler(mOnClickHandler);
    view.setAppWidget(appWidgetId, appWidget);
    synchronized (mViews) {
        mViews.put(appWidgetId, view);
    }
    RemoteViews views;
    try {
        views = sService.getAppWidgetViews(mContextOpPackageName, appWidgetId);
    } catch (RemoteException e) {
        throw new RuntimeException("system server dead?", e);
    }
    view.updateAppWidget(views);
    return view;
}
Also used : RemoteViews(android.widget.RemoteViews) RemoteException(android.os.RemoteException)

Example 72 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 73 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)

Example 74 with RemoteViews

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

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 75 with RemoteViews

use of android.widget.RemoteViews in project NetGuard by M66B.

the class WidgetLockdown method update.

private static void update(int[] appWidgetIds, AppWidgetManager appWidgetManager, Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean lockdown = prefs.getBoolean("lockdown", false);
    try {
        try {
            PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(lockdown ? WidgetAdmin.INTENT_LOCKDOWN_OFF : WidgetAdmin.INTENT_LOCKDOWN_ON), PendingIntent.FLAG_UPDATE_CURRENT);
            for (int id : appWidgetIds) {
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widgetlockdown);
                views.setOnClickPendingIntent(R.id.ivEnabled, pi);
                views.setImageViewResource(R.id.ivEnabled, lockdown ? R.drawable.ic_lock_outline_white_24dp : R.drawable.ic_lock_open_white_24dp);
                appWidgetManager.updateAppWidget(id, views);
            }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
    }
}
Also used : RemoteViews(android.widget.RemoteViews) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Aggregations

RemoteViews (android.widget.RemoteViews)211 Intent (android.content.Intent)83 PendingIntent (android.app.PendingIntent)75 TextView (android.widget.TextView)35 Test (org.junit.Test)35 View (android.view.View)32 Notification (android.app.Notification)30 SmallTest (android.support.test.filters.SmallTest)30 ImageView (android.widget.ImageView)28 AppWidgetManager (android.appwidget.AppWidgetManager)25 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