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;
}
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);
}
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());
}
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);
}
}
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));
}
}
Aggregations