use of android.appwidget.AppWidgetManager in project k-9 by k9mail.
the class UnreadWidgetConfiguration method onAccountSelected.
@Override
protected void onAccountSelected(BaseAccount account) {
// Save widget configuration
String accountUuid = account.getUuid();
saveAccountUuid(this, mAppWidgetId, accountUuid);
// Update widget
Context context = getApplicationContext();
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
UnreadWidgetProvider.updateWidget(context, appWidgetManager, mAppWidgetId, accountUuid);
// Let the caller know that the configuration was successful
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
finish();
}
use of android.appwidget.AppWidgetManager in project k-9 by k9mail.
the class UnreadWidgetProvider method updateUnreadCount.
/**
* Trigger update for all of our unread widgets.
*
* @param context
* The {@code Context} object to use for the broadcast intent.
*/
public static void updateUnreadCount(Context context) {
Context appContext = context.getApplicationContext();
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(appContext);
ComponentName thisWidget = new ComponentName(appContext, UnreadWidgetProvider.class);
int[] widgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
Intent intent = new Intent(context, UnreadWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
context.sendBroadcast(intent);
}
use of android.appwidget.AppWidgetManager in project Shuttle by timusus.
the class BaseWidgetConfigure method onClick.
@Override
public void onClick(View view) {
if (view.getId() == R.id.btn_done) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
RemoteViews remoteViews = new RemoteViews(this.getPackageName(), mLayoutId);
BaseWidgetProvider.setupButtons(this, remoteViews, mAppWidgetId, getRootViewId());
appWidgetManager.updateAppWidget(mAppWidgetId, remoteViews);
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, resultValue);
// Send broadcast intent to any running MediaPlaybackService so it can
// wrap around with an immediate update.
Intent updateIntent = new Intent(MusicService.ServiceCommand.SERVICE_COMMAND);
updateIntent.putExtra(MusicService.MediaButtonCommand.CMD_NAME, getUpdateCommandString());
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { mAppWidgetId });
updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
sendBroadcast(updateIntent);
finish();
}
if (view.getId() == R.id.btn_background_color) {
DialogUtils.showCustomColorPickerDialog(this, ColorUtils.adjustAlpha(mBackgroundColor, mAlpha), color -> {
mBackgroundColor = color;
mPrefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_BACKGROUND_COLOR + mAppWidgetId, color).apply();
Fragment fragment = mPagerAdapter.getRegisteredFragment(mPager.getCurrentItem());
if (fragment != null) {
View fragmentView = fragment.getView();
if (fragmentView != null) {
View layout = fragmentView.findViewById(getRootViewId());
layout.setBackgroundColor(ColorUtils.adjustAlpha(mBackgroundColor, mAlpha));
}
}
});
}
if (view.getId() == R.id.btn_text_color) {
DialogUtils.showCustomColorPickerDialog(this, mTextColor, color -> {
mTextColor = color;
mPrefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_TEXT_COLOR + mAppWidgetId, color).apply();
Fragment fragment = mPagerAdapter.getRegisteredFragment(mPager.getCurrentItem());
if (fragment != null) {
View widgetView = fragment.getView();
if (widgetView != null) {
TextView text1 = (TextView) widgetView.findViewById(R.id.text1);
TextView text2 = (TextView) widgetView.findViewById(R.id.text2);
TextView text3 = (TextView) widgetView.findViewById(R.id.text3);
if (text1 != null) {
text1.setTextColor(mTextColor);
}
if (text2 != null) {
text2.setTextColor(mTextColor);
}
if (text3 != null) {
text3.setTextColor(mTextColor);
}
}
}
});
}
}
use of android.appwidget.AppWidgetManager in project qksms by moezbhatti.
the class WidgetProvider method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "onReceive intent: " + intent);
String action = intent.getAction();
// needs to update.
if (ACTION_NOTIFY_DATASET_CHANGED.equals(action)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
// We need to update all Mms appwidgets on the home screen.
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.conversation_list);
} else {
super.onReceive(context, intent);
}
}
use of android.appwidget.AppWidgetManager in project Fairphone by Kwamecorp.
the class GappsInstallerHelper method updateGoogleAppsIntallerWidgets.
private void updateGoogleAppsIntallerWidgets() {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(mContext, GoogleAppsInstallerWidget.class));
if (appWidgetIds.length > 0) {
new GoogleAppsInstallerWidget().onUpdate(mContext, appWidgetManager, appWidgetIds);
}
}
Aggregations