Search in sources :

Example 46 with SharedPreferences

use of android.content.SharedPreferences in project glimmr by brk3.

the class AppListener method getMinutes.

private int getMinutes(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String intervalPref = prefs.getString(Constants.KEY_INTERVALS_LIST_PREFERENCE, "60");
    try {
        mMinutes = Integer.parseInt(intervalPref);
    } catch (NumberFormatException e) {
        Log.e(TAG, String.format("scheduleAlarms: can't parse '%s' " + "as intervalPref", intervalPref));
        e.printStackTrace();
    }
    return mMinutes;
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 47 with SharedPreferences

use of android.content.SharedPreferences in project glimmr by brk3.

the class PhotoViewerActivity method startSlideshow.

private void startSlideshow() {
    final Handler handler = new Handler();
    SharedPreferences defaultSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    final int delay_m = Integer.parseInt(defaultSharedPrefs.getString(Constants.KEY_SLIDESHOW_INTERVAL, "3")) * 1000;
    if (BuildConfig.DEBUG)
        Log.d(TAG, "slideshow delay: " + delay_m);
    mTimer = new Timer();
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mTimer.scheduleAtFixedRate(new TimerTask() {

        @Override
        public void run() {
            handler.post(new Runnable() {

                @Override
                public void run() {
                    int currentPosition = mPager.getCurrentItem();
                    currentPosition++;
                    if (currentPosition >= mAdapter.getCount()) {
                        currentPosition = 0;
                    }
                    mPager.setCurrentItem(currentPosition);
                }
            });
        }
    }, delay_m, delay_m);
    BusProvider.getInstance().post(new PhotoViewerVisibilityChangeEvent(!mActionBar.isShowing(), this));
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) SharedPreferences(android.content.SharedPreferences) Handler(android.os.Handler) PhotoViewerVisibilityChangeEvent(com.bourke.glimmr.fragments.viewer.PhotoViewerFragment.PhotoViewerVisibilityChangeEvent)

Example 48 with SharedPreferences

use of android.content.SharedPreferences in project platform_frameworks_base by android.

the class CachedBluetoothDevice method fetchMessageRejectionCount.

private void fetchMessageRejectionCount() {
    SharedPreferences preference = mContext.getSharedPreferences(MESSAGE_REJECTION_COUNT_PREFS_NAME, Context.MODE_PRIVATE);
    mMessageRejectionCount = preference.getInt(mDevice.getAddress(), 0);
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 49 with SharedPreferences

use of android.content.SharedPreferences in project platform_frameworks_base by android.

the class CachedBluetoothDevice method migratePhonebookPermissionChoice.

// Migrates data from old data store (in Settings app's shared preferences) to new (in Bluetooth
// app's shared preferences).
private void migratePhonebookPermissionChoice() {
    SharedPreferences preferences = mContext.getSharedPreferences("bluetooth_phonebook_permission", Context.MODE_PRIVATE);
    if (!preferences.contains(mDevice.getAddress())) {
        return;
    }
    if (mDevice.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_UNKNOWN) {
        int oldPermission = preferences.getInt(mDevice.getAddress(), ACCESS_UNKNOWN);
        if (oldPermission == ACCESS_ALLOWED) {
            mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
        } else if (oldPermission == ACCESS_REJECTED) {
            mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
        }
    }
    SharedPreferences.Editor editor = preferences.edit();
    editor.remove(mDevice.getAddress());
    editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 50 with SharedPreferences

use of android.content.SharedPreferences in project platform_frameworks_base by android.

the class WallpaperBackupAgent method onRestoreFinished.

// We use the default onRestoreFile() implementation that will recreate our stage files,
// then post-process in onRestoreFinished() to apply the new wallpaper.
@Override
public void onRestoreFinished() {
    if (DEBUG) {
        Slog.v(TAG, "onRestoreFinished()");
    }
    final File filesDir = getFilesDir();
    final File infoStage = new File(filesDir, INFO_STAGE);
    final File imageStage = new File(filesDir, IMAGE_STAGE);
    final File lockImageStage = new File(filesDir, LOCK_IMAGE_STAGE);
    // If we restored separate lock imagery, the system wallpaper should be
    // applied as system-only; but if there's no separate lock image, make
    // sure to apply the restored system wallpaper as both.
    final int sysWhich = FLAG_SYSTEM | (lockImageStage.exists() ? 0 : FLAG_LOCK);
    try {
        // First off, revert to the factory state
        mWm.clear(FLAG_SYSTEM | FLAG_LOCK);
        // It is valid for the imagery to be absent; it means that we were not permitted
        // to back up the original image on the source device, or there was no user-supplied
        // wallpaper image present.
        restoreFromStage(imageStage, infoStage, "wp", sysWhich);
        restoreFromStage(lockImageStage, infoStage, "kwp", FLAG_LOCK);
        // And reset to the wallpaper service we should be using
        ComponentName wpService = parseWallpaperComponent(infoStage, "wp");
        if (servicePackageExists(wpService)) {
            if (DEBUG) {
                Slog.i(TAG, "Using wallpaper service " + wpService);
            }
            mWm.setWallpaperComponent(wpService, UserHandle.USER_SYSTEM);
        } else {
            if (DEBUG) {
                Slog.v(TAG, "Can't use wallpaper service " + wpService);
            }
        }
    } catch (Exception e) {
        Slog.e(TAG, "Unable to restore wallpaper: " + e.getMessage());
    } finally {
        if (DEBUG) {
            Slog.v(TAG, "Restore finished; clearing backup bookkeeping");
        }
        infoStage.delete();
        imageStage.delete();
        lockImageStage.delete();
        SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        prefs.edit().putInt(SYSTEM_GENERATION, -1).putInt(LOCK_GENERATION, -1).commit();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) File(java.io.File) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

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