Search in sources :

Example 96 with SharedPreferences

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;
}
Also used : SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList)

Example 97 with SharedPreferences

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;
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 98 with SharedPreferences

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);
}
Also used : SharedPreferences(android.content.SharedPreferences) Button(android.widget.Button)

Example 99 with SharedPreferences

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();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 100 with SharedPreferences

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;
}
Also used : Bitmap(android.graphics.Bitmap) SharedPreferences(android.content.SharedPreferences) Canvas(android.graphics.Canvas) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

SharedPreferences (android.content.SharedPreferences)1762 Intent (android.content.Intent)221 View (android.view.View)110 Editor (android.content.SharedPreferences.Editor)100 TextView (android.widget.TextView)74 ArrayList (java.util.ArrayList)67 Context (android.content.Context)59 PendingIntent (android.app.PendingIntent)57 File (java.io.File)57 IOException (java.io.IOException)56 Bundle (android.os.Bundle)45 JSONException (org.json.JSONException)41 JSONObject (org.json.JSONObject)41 DialogInterface (android.content.DialogInterface)37 AdapterView (android.widget.AdapterView)34 ImageView (android.widget.ImageView)34 ListView (android.widget.ListView)34 SuppressLint (android.annotation.SuppressLint)33 JSONArray (run.wallet.common.json.JSONArray)33 ComponentName (android.content.ComponentName)31