use of android.content.SharedPreferences in project NotificationPeekPort by lzanita09.
the class AppList method restoreBlackList.
/**
* Restore black list from SharedPreferences.
*
* @return List of {@link com.reindeercrafts.notificationpeek.blacklist.AppInfo}.
*/
private ArrayList<AppInfo> restoreBlackList() {
ArrayList<AppInfo> blackList = new ArrayList<AppInfo>();
SharedPreferences blackListPref = PreferenceManager.getDefaultSharedPreferences(mContext);
Set<String> blackListSet = blackListPref.getStringSet(BLACK_LIST_PREF, new HashSet<String>());
for (String blockedAppStr : blackListSet) {
AppInfo appInfo = AppInfo.fromString(blockedAppStr);
if (appInfo.getPackageName().equals(AppInfo.EVERYTHING_PKG)) {
blackList.add(0, appInfo);
} else {
blackList.add(AppInfo.fromString(blockedAppStr));
}
}
return blackList;
}
use of android.content.SharedPreferences in project NotificationPeekPort by lzanita09.
the class AppList method removeFromBlackList.
public void removeFromBlackList(AppInfo appInfo) {
mCurrentBlackList.remove(appInfo);
if (appInfo.getPackageName().equals(AppInfo.EVERYTHING_PKG)) {
// If the removed item is "Everything", we also remove all related preferences.
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
preferences.edit().remove(PreferenceKeys.PREF_QUIET_HOUR).remove(PreferenceKeys.PREF_DISABLE_PEEK).apply();
mQuietHourChanged = true;
}
mBlackListChanged = true;
}
use of android.content.SharedPreferences in project NotificationPeekPort by lzanita09.
the class EverythingCard method init.
private void init(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean isPeekDisabled = preferences.getBoolean(PreferenceKeys.PREF_DISABLE_PEEK, false);
String quietHourStr = preferences.getString(PreferenceKeys.PREF_QUIET_HOUR, PreferenceKeys.PREF_QUIET_HOUR_DEF);
boolean isQuietHourSet = !quietHourStr.equals(PreferenceKeys.PREF_QUIET_HOUR_DEF);
mOptionsShowing = !(isPeekDisabled || isQuietHourSet);
mQuietHour = QuietHour.createQuietHour(quietHourStr);
LayoutInflater.from(context).inflate(R.layout.everything_card, this, true);
mPanelSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher);
if (!mOptionsShowing) {
mPanelSwitcher.setVisibility(GONE);
}
mFromBtn = (Button) findViewById(R.id.quiet_hour_from_btn);
mFromBtn.setOnClickListener(this);
mToBtn = (Button) findViewById(R.id.quiet_hour_to_btn);
mToBtn.setOnClickListener(this);
Button mQuietHourBtn = (Button) findViewById(R.id.quiet_hour_btn);
mQuietHourBtn.setOnClickListener(this);
Button mDisableBtn = (Button) findViewById(R.id.as_is_btn);
mDisableBtn.setOnClickListener(this);
mFromToText = (TextView) findViewById(R.id.from_to_text);
if (isQuietHourSet) {
displayTime();
}
mFromToText.setOnClickListener(this);
}
use of android.content.SharedPreferences in project NotificationPeekPort by lzanita09.
the class EverythingCard method storeQuietHour.
/* Store instance's QuietHour object. */
private void storeQuietHour() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
preferences.edit().putString(PreferenceKeys.PREF_QUIET_HOUR, mQuietHour.toString()).apply();
}
use of android.content.SharedPreferences in project NotificationPeekPort by lzanita09.
the class WallpaperFactory method getPrefSystemWallpaper.
/**
* Create a bitmap that is blurred and dimmed with the amount that user has selected.
*
* @return Background bitmap.
*/
public Bitmap getPrefSystemWallpaper() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
float radius = preferences.getFloat(PreferenceKeys.PREF_RADIUS, ImageBlurrer.MAX_SUPPORTED_BLUR_PIXELS);
int dim = preferences.getInt(PreferenceKeys.PREF_DIM, DEFAULT_MAX_DIM);
DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
// Blur
ImageBlurrer imageBlurrer = new ImageBlurrer(mContext);
Bitmap blurred = imageBlurrer.blurBitmap(drawableToBitmap(mWallpaperManager.getFastDrawable(), displayMetrics.widthPixels), radius);
// Dim
Canvas c = new Canvas(blurred);
c.drawColor(Color.argb(255 - dim, 0, 0, 0));
return blurred;
}
Aggregations