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