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;
}
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));
}
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);
}
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();
}
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();
}
}
Aggregations