@Override
public void onReceive(Context context, Intent intent) {
int reminderId = intent.getIntExtra("NOTIFICATION_ID", 0);
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("checkBoxNagging", false)) {
Intent alarmIntent = new Intent(context, NagReceiver.class);
AlarmUtil.cancelAlarm(context, alarmIntent, reminderId);
}
// Close notification tray
Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.sendBroadcast(closeIntent);
Intent snoozeIntent = new Intent(context, SnoozeDialogActivity.class);
snoozeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
snoozeIntent.putExtra("NOTIFICATION_ID", reminderId);
context.startActivity(snoozeIntent);
}
java类android.preference.PreferenceManager的实例源码
SnoozeActionReceiver.java 文件源码
项目:SOS-The-Healthcare-Companion
阅读 72
收藏 0
点赞 0
评论 0
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 24
收藏 0
点赞 0
评论 0
/**
* Returns true if the user prefers to see notifications from Sunshine, false otherwise. This
* preference can be changed by the user within the SettingsFragment.
*
* @param context Used to access SharedPreferences
* @return true if the user prefers to see notifications, false otherwise
*/
public static boolean areNotificationsEnabled(Context context) {
/* Key for accessing the preference for showing notifications */
String displayNotificationsKey = context.getString(R.string.pref_enable_notifications_key);
/*
* In Sunshine, the user has the ability to say whether she would like notifications
* enabled or not. If no preference has been chosen, we want to be able to determine
* whether or not to show them. To do this, we reference a bool stored in bools.xml.
*/
boolean shouldDisplayNotificationsByDefault = context
.getResources()
.getBoolean(R.bool.show_notifications_by_default);
/* As usual, we use the default SharedPreferences to access the user's preferences */
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
/* If a value is stored with the key, we extract it here. If not, use a default. */
boolean shouldDisplayNotifications = sp
.getBoolean(displayNotificationsKey, shouldDisplayNotificationsByDefault);
return shouldDisplayNotifications;
}
ViewMatrixFragment.java 文件源码
项目:Matrix-Calculator-for-Android
阅读 109
收藏 0
点赞 0
评论 0
private String GetText(float res) {
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
DecimalFormat decimalFormat = new DecimalFormat("###############");
return decimalFormat.format(res);
} else {
switch (Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getContext()).getString("ROUNDIND_INFO", "0"))) {
case 0:
return String.valueOf(res);
case 1:
DecimalFormat single = new DecimalFormat("########.#");
return single.format(res);
case 2:
DecimalFormat Double = new DecimalFormat("########.##");
return Double.format(res);
case 3:
DecimalFormat triple = new DecimalFormat("########.###");
return triple.format(res);
default:
return String.valueOf(res);
}
}
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 22
收藏 0
点赞 0
评论 0
/**
* Returns the location coordinates associated with the location. Note that there is a
* possibility that these coordinates may not be set, which results in (0,0) being returned.
* Interestingly, (0,0) is in the middle of the ocean off the west coast of Africa.
*
* @param context used to access SharedPreferences
* @return an array containing the two coordinate values for the user's preferred location
*/
public static double[] getLocationCoordinates(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
double[] preferredCoordinates = new double[2];
/*
* This is a hack we have to resort to since you can't store doubles in SharedPreferences.
*
* Double.doubleToLongBits returns an integer corresponding to the bits of the given
* IEEE 754 double precision value.
*
* Double.longBitsToDouble does the opposite, converting a long (that represents a double)
* into the double itself.
*/
preferredCoordinates[0] = Double
.longBitsToDouble(sp.getLong(PREF_COORD_LAT, Double.doubleToRawLongBits(0.0)));
preferredCoordinates[1] = Double
.longBitsToDouble(sp.getLong(PREF_COORD_LONG, Double.doubleToRawLongBits(0.0)));
return preferredCoordinates;
}
Activity_settings_data.java 文件源码
项目:Kids-Portal-Android
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
frameLayout = (FrameLayout) getActivity().findViewById(R.id.content_frame);
try {
mahEncryptor = MAHEncryptor.newInstance(sharedPref.getString("saved_key", ""));
} catch (Exception e) {
e.printStackTrace();
Snackbar.make(frameLayout, getString(R.string.toast_error), Snackbar.LENGTH_LONG).show();
}
addPreferencesFromResource(R.xml.user_settings_data);
addBackup_dbListener();
addWhiteListListener();
}
MainActivity.java 文件源码
项目:buildAPKsSamples
阅读 16
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Sets up user interface elements.
setContentView(R.layout.main);
mCustomConfig = (CheckBox) findViewById(R.id.custom_app_limits);
final boolean customChecked =
PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
CUSTOM_CONFIG_KEY, false);
if (customChecked) mCustomConfig.setChecked(true);
mMultiEntryValue = (TextView) findViewById(R.id.multi_entry_id);
mChoiceEntryValue = (TextView) findViewById(R.id.choice_entry_id);
mBooleanEntryValue = (TextView) findViewById(R.id.boolean_entry_id);
}
FtcRobotControllerActivity.java 文件源码
项目:RobotIGS
阅读 18
收藏 0
点赞 0
评论 0
protected void readNetworkType(String fileName) {
NetworkType defaultNetworkType;
File directory = RobotConfigFileManager.CONFIG_FILES_DIR;
File networkTypeFile = new File(directory, fileName);
if (!networkTypeFile.exists()) {
if (Build.MODEL.equals(Device.MODEL_410C)) {
defaultNetworkType = NetworkType.SOFTAP;
} else {
defaultNetworkType = NetworkType.WIFIDIRECT;
}
writeNetworkTypeFile(NETWORK_TYPE_FILENAME, defaultNetworkType.toString());
}
String fileContents = readFile(networkTypeFile);
networkType = NetworkConnectionFactory.getTypeFromString(fileContents);
programmingModeController.setCurrentNetworkType(networkType);
// update the preferences
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = preferences.edit();
editor.putString(NetworkConnectionFactory.NETWORK_CONNECTION_TYPE, networkType.toString());
editor.commit();
}
Chilly.java 文件源码
项目:chilly
阅读 18
收藏 0
点赞 0
评论 0
public String getUserName() {
String ret = "";
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
String userstring = sharedPreferences.getString("trakt_user", "");
try {
JSONObject trakt_user = new JSONObject(userstring);
ret = trakt_user.getJSONObject("user").getString("username");
} catch (JSONException e) {
e.printStackTrace();
}
return ret;
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 27
收藏 0
点赞 0
评论 0
/**
* Returns the last time that a notification was shown (in UNIX time)
*
* @param context Used to access SharedPreferences
* @return UNIX time of when the last notification was shown
*/
public static long getLastNotificationTimeInMillis(Context context) {
/* Key for accessing the time at which Sunshine last displayed a notification */
String lastNotificationKey = context.getString(R.string.pref_last_notification);
/* As usual, we use the default SharedPreferences to access the user's preferences */
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
/*
* Here, we retrieve the time in milliseconds when the last notification was shown. If
* SharedPreferences doesn't have a value for lastNotificationKey, we return 0. The reason
* we return 0 is because we compare the value returned from this method to the current
* system time. If the difference between the last notification time and the current time
* is greater than one day, we will show a notification again. When we compare the two
* values, we subtract the last notification time from the current system time. If the
* time of the last notification was 0, the difference will always be greater than the
* number of milliseconds in a day and we will show another notification.
*/
long lastNotificationTime = sp.getLong(lastNotificationKey, 0);
return lastNotificationTime;
}
SplashScreenActivity.java 文件源码
项目:javaide
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// Here, this is the current activity
PreferenceManager.setDefaultValues(this, R.xml.pref_settings, false);
if (!permissionGranted()) {
requestPermissions();
} else {
if (systemInstalled()) {
startMainActivity();
} else {
installSystem();
}
}
}
Fragment_Reports.java 文件源码
项目:Kids-Portal-Android
阅读 64
收藏 0
点赞 0
评论 0
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_lists, container, false);
setHasOptionsMenu(true);
sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
editText = (EditText) getActivity().findViewById(R.id.editText);
listBar = (TextView) getActivity().findViewById(R.id.listBar);
listView = (ListView)rootView.findViewById(R.id.list);
viewPager = (class_CustomViewPager) getActivity().findViewById(R.id.viewpager);
//calling Notes_DbAdapter
db = new DbAdapter_Reports(getActivity());
db.open();
return rootView;
}
PreferencesUtil.java 文件源码
项目:ViewDebugHelper
阅读 27
收藏 0
点赞 0
评论 0
/** 设置Key对应的String值 */
public static boolean setStringValue(Context context,String key, String value) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = prefs.edit();
editor.putString(key, value);
return editor.commit();
}
MainSettingsActivity.java 文件源码
项目:an2linuxclient
阅读 24
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager.setDefaultValues(this, R.xml.main_preferences, false);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
PreferenceHelper.java 文件源码
项目:NightLight
阅读 27
收藏 0
点赞 0
评论 0
/**
* Saves location co-ordinates as string
* @param context ¯\_(ツ)_/¯
* @param longitude Longitude to be saved
* @param latitude Latitude to be saved
*/
public static void putLocation(Context context, double longitude, double latitude) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(Constants.LAST_LOC_LONGITUDE, "" + longitude)
.putString(Constants.LAST_LOC_LATITUDE, "" + latitude)
.apply();
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 23
收藏 0
点赞 0
评论 0
/**
* Returns true if the latitude and longitude values are available. The latitude and
* longitude will not be available until the lesson where the PlacePicker API is taught.
*
* @param context used to get the SharedPreferences
* @return true if lat/long are saved in SharedPreferences
*/
public static boolean isLocationLatLonAvailable(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
boolean spContainLatitude = sp.contains(PREF_COORD_LAT);
boolean spContainLongitude = sp.contains(PREF_COORD_LONG);
boolean spContainBothLatitudeAndLongitude = false;
if (spContainLatitude && spContainLongitude) {
spContainBothLatitudeAndLongitude = true;
}
return spContainBothLatitudeAndLongitude;
}
EditFragment.java 文件源码
项目:Matrix-Calculator-for-Android
阅读 20
收藏 0
点赞 0
评论 0
public int getLength() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean v = preferences.getBoolean("EXTRA_SMALL_FONT", false);
if (v)
return 8;
else
return 6;
}
SettingsActivity.java 文件源码
项目:BeHealthy
阅读 27
收藏 0
点赞 0
评论 0
private void bindPreferenceSummaryToValue(Preference preference) {
preference.setOnPreferenceChangeListener(this);
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(preference.getContext());
String preferenceString = preferences.getString(preference.getKey(), "");
onPreferenceChange(preference, preferenceString);
}
TVUtils.java 文件源码
项目:aos-Video
阅读 21
收藏 0
点赞 0
评论 0
public static boolean isTV(Context ct){
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ct);
String mode = mPreferences.getString("uimode", "0");
if (mode.equals("1"))
return false;
if (mode.equals("2"))
return true;
return ArchosFeatures.isTV(ct);
}
MakiReceiver.java 文件源码
项目:MakiLite
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onReceive(Context context, Intent intent) {
context = MakiApplication.getContextOfApplication();
Intent startIntent = new Intent(context, MakiNotifications.class);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (preferences.getBoolean("notifications_activated", false) || preferences.getBoolean("messages_activated", false)) {
context.startService(startIntent);
Log.d("NotificationReceiver", "Notifications started");
}else {
context.stopService(startIntent);
Log.d("PollReceiver", "Notifications canceled");
}
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 27
收藏 0
点赞 0
评论 0
/**
* Resets the location coordinates stores in SharedPreferences.
*
* @param context Context used to get the SharedPreferences
*/
public static void resetLocationCoordinates(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sp.edit();
editor.remove(PREF_COORD_LAT);
editor.remove(PREF_COORD_LONG);
editor.apply();
}
helper_editText.java 文件源码
项目:Kids-Portal-Android
阅读 39
收藏 0
点赞 0
评论 0
public static void editText_searchWeb (final EditText editText, final Activity activity) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
List<String> listItems = new ArrayList<>();
if (sharedPref.getBoolean("Google", true)) {
listItems.add("Google");
}if (sharedPref.getBoolean("Kiddle", true)) {
listItems.add("Kiddle");
}if (sharedPref.getBoolean("Kidrex", true)) {
listItems.add("Kidrex");
}if (sharedPref.getBoolean("Youtube", true)) {
listItems.add("Youtube");
}
final CharSequence[] options = listItems.toArray(new CharSequence[listItems.size()]);
new AlertDialog.Builder(activity)
.setTitle(R.string.action_searchChooseTitle)
.setItems(options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (options[item].equals("Google")) {
editText.setText(".G ");
}
if (options[item].equals("Kidrex")) {
editText.setText(".R ");
}
if (options[item].equals("Kiddle")) {
editText.setText(".K ");
}
if (options[item].equals("Youtube")) {
editText.setText(".Y ");
}
editText.setSelection(editText.length());
}
}).show();
}
SettingsActivity.java 文件源码
项目:Tasks
阅读 29
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
overridePendingTransition(0, 0);
PreferenceManager.setDefaultValues(this, R.xml.settings_xml, false);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new GeneralPreferenceFragment())
.commit();
}
RecyclerViewHeader.java 文件源码
项目:xrecyclerview
阅读 20
收藏 0
点赞 0
评论 0
private void initView(Context context) {
preferences = PreferenceManager.getDefaultSharedPreferences(context);
// 初始情况,设置下拉刷新view高度为0
LayoutParams lp = new LayoutParams(
LayoutParams.FILL_PARENT, 0);
mContainer = (LinearLayout) LayoutInflater.from(context).inflate(
R.layout.lfrecyclerview_header, null);
addView(mContainer, lp);
setGravity(Gravity.BOTTOM);
mArrowImageView = findViewById(R.id.lfrecyclerview_header_arrow);
mHintTextView = findViewById(R.id.lfrecyclerview_header_hint_textview);
mProgressBar = findViewById(R.id.lfrecyclerview_header_progressbar);
lfrecyclerview_header_time= findViewById(R.id.lfrecyclerview_header_time);
mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateUpAnim.setFillAfter(true);
mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateDownAnim.setFillAfter(true);
}
PoiDetailsFragment.java 文件源码
项目:Android-Development
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void onResume() {
super.onResume();
//this will refresh the osmdroid configuration on resuming.
//if you make changes to the configuration, use
//SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
//Configuration.getInstance().save(this, prefs);
Configuration.getInstance().load(getDialog().getContext(), PreferenceManager.getDefaultSharedPreferences(getDialog().getContext()));
}
SettingsActivity.java 文件源码
项目:SecScanQR
阅读 21
收藏 0
点赞 0
评论 0
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
*
* @see #sBindPreferenceSummaryToValueListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// Trigger the listener immediately with the preference's
// current value.
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
BootReceiver.java 文件源码
项目:EveryCoolPic
阅读 25
收藏 0
点赞 0
评论 0
@Override
public void onReceive(Context context, Intent intent) {
if (PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext())
.getBoolean("key_enable",false)) {
Utils.setEnable(true, context);
}
}
ServerOperationClassFragment.java 文件源码
项目:2017.1-Trezentos
阅读 16
收藏 0
点赞 0
评论 0
@Override
protected void onPreExecute() {
userClassControl =
UserClassControl.getInstance(getApplicationContext());
SharedPreferences session = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
email = session.getString("userEmail","");
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 28
收藏 0
点赞 0
评论 0
/**
* Resets the location coordinates stores in SharedPreferences.
*
* @param context Context used to get the SharedPreferences
*/
public static void resetLocationCoordinates(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sp.edit();
editor.remove(PREF_COORD_LAT);
editor.remove(PREF_COORD_LONG);
editor.apply();
}
SunshinePreferences.java 文件源码
项目:android-dev-challenge
阅读 24
收藏 0
点赞 0
评论 0
/**
* Returns true if the latitude and longitude values are available. The latitude and
* longitude will not be available until the lesson where the PlacePicker API is taught.
*
* @param context used to get the SharedPreferences
* @return true if lat/long are saved in SharedPreferences
*/
public static boolean isLocationLatLonAvailable(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
boolean spContainLatitude = sp.contains(PREF_COORD_LAT);
boolean spContainLongitude = sp.contains(PREF_COORD_LONG);
boolean spContainBothLatitudeAndLongitude = false;
if (spContainLatitude && spContainLongitude) {
spContainBothLatitudeAndLongitude = true;
}
return spContainBothLatitudeAndLongitude;
}
Utils.java 文件源码
项目:SimpleMarkdown
阅读 21
收藏 0
点赞 0
评论 0
public static boolean isAutosaveEnabled(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean(
"autosave",
true
);
}