private void changeWidgetStarredStatus() { SharedPreferences preference = PreferenceManager.getDefaultSharedPreferences(this); boolean isStarred = preference.getBoolean(AppWidget.WIDGET_IS_STARRED, false); preference.edit().putBoolean(AppWidget.WIDGET_IS_STARRED, !isStarred).apply(); AppWidget.updateAllAppWidget(this); }
@Override protected void onHandleIntent(Intent intent) { Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); sendBroadcast(it); this.intent = intent; if (intent == null) return; String clips = intent.getStringExtra(Intent.EXTRA_TEXT); int actionCode = intent.getIntExtra(ACTION_CODE, 0); Log.v(MyUtil.PACKAGE_NAME, "ACTION_CODE: " + actionCode); switch (actionCode) { case 0: break; case ACTION_COPY: copyText(clips); return; case ACTION_SHARE: shareText(clips); return; case ACTION_EDIT: editText(clips); return; case ACTION_STAR: starText(clips); return; case ACTION_OPEN_MAIN_DIALOG: openMainDialogActivity(); return; case ACTION_REFRESH_WIDGET: AppWidget.updateAllAppWidget(this); return; case ACTION_CHANGE_WIDGET_STAR: changeWidgetStarredStatus(); return; case ACTION_COMMENT: commentOnClip(clips); return; } }