Java Code Examples for android.preference.PreferenceManager#setDefaultValues()
The following examples show how to use
android.preference.PreferenceManager#setDefaultValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeedActivity.java From Abelana-Android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { //Must set content view before calling parent class in order for navigation drawer to work setContentView(R.layout.base_activity); super.onCreate(savedInstanceState); //Initializes the application with the proper default settings PreferenceManager.setDefaultValues(this, R.xml.preferences, false); //Replace the current fragment with the Feed/Camera fragment via transaction if (savedInstanceState == null) { getFragmentManager().beginTransaction() .replace(R.id.content_frame, new FeedFragment()) .commit(); } }
Example 2
Source File: SearchActivity.java From HayaiLauncher with Apache License 2.0 | 6 votes |
private void setupPreferences() { PreferenceManager.setDefaultValues(this, R.xml.preferences, false); if (mSharedPreferences.getBoolean(SettingsActivity.KEY_PREF_NOTIFICATION, false)) { final ShortcutNotificationManager shortcutNotificationManager = new ShortcutNotificationManager(); final String strPriority = mSharedPreferences.getString(SettingsActivity.KEY_PREF_NOTIFICATION_PRIORITY, "low"); final int priority = ShortcutNotificationManager.getPriorityFromString(strPriority); shortcutNotificationManager.showNotification(this, priority); } String order = mSharedPreferences.getString("pref_app_preferred_order", "recent"); mShouldOrderByUsages = order.equals("usage"); mShouldOrderByRecents = order.equals("recent"); mDisableIcons = mSharedPreferences.getBoolean("pref_disable_icons", false); mAutoKeyboard = mSharedPreferences.getBoolean("pref_autokeyboard", false); }
Example 3
Source File: SwitchPreference.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, "switch", MODE_PRIVATE, R.xml.default_values, false); // Load the preferences from an XML resource getPreferenceManager().setSharedPreferencesName("switch"); addPreferencesFromResource(R.xml.preference_switch); }
Example 4
Source File: ConnectActivity.java From homeassist with Apache License 2.0 | 5 votes |
@Override protected ErrorMessage doInBackground(Void... param) { // if (!CommonUtil.checkSignature(ConnectActivity.this)) { // return new ErrorMessage("Error", getString(R.string.error_corrupted)); // } // // if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) { // return new ErrorMessage("Error", getString(R.string.error_jellybean)); // } PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, false); mSharedPref = getAppController().getSharedPref(); int ids[] = AppWidgetManager.getInstance(ConnectActivity.this).getAppWidgetIds(new ComponentName(ConnectActivity.this, EntityWidgetProvider.class)); if (ids.length > 0) { ArrayList<String> appWidgetIds = new ArrayList<>(); for (int id : ids) { appWidgetIds.add(Integer.toString(id)); } DatabaseManager databaseManager = DatabaseManager.getInstance(ConnectActivity.this); databaseManager.forceCreate(); databaseManager.housekeepWidgets(appWidgetIds); } //mBundle = getIntent().getExtras(); return null; }
Example 5
Source File: SettingsFragment.java From NightWidget with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* set preferences */ addPreferencesFromResource(R.xml.preferences); addMedtronicOptionsListener(); PreferenceManager.setDefaultValues(context, R.xml.preferences, false); final ListPreference mon_type = (ListPreference) findPreference("monitor_type_widget"); final EditTextPreference med_id = (EditTextPreference) findPreference("medtronic_cgm_id_widget"); final ListPreference metric_type = (ListPreference) findPreference("metric_preference_widget"); final CustomSwitchPreference mmolDecimals = (CustomSwitchPreference)findPreference("mmolDecimals_widget"); int index = mon_type.findIndexOfValue(mon_type.getValue()); if (index == 1) { med_id.setEnabled(true); } else { med_id.setEnabled(false); } int index_met = metric_type.findIndexOfValue(PreferenceManager.getDefaultSharedPreferences(context).getString("metric_preference_widget", "1")); if (index_met == 0){ mmolDecimals.setEnabled(false); }else{ mmolDecimals.setEnabled(true); } // iterate through all preferences and update to saved value for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) { initSummary(getPreferenceScreen().getPreference(i)); } }
Example 6
Source File: Settings.java From andOTP with MIT License | 5 votes |
public void clear(boolean keep_auth) { AuthMethod authMethod = getAuthMethod(); String authCredentials = getAuthCredentials(); byte[] authSalt = getSalt(); int authIterations = getIterations(); boolean warningShown = getFirstTimeWarningShown(); SharedPreferences.Editor editor = settings.edit(); editor.clear(); editor.putBoolean(getResString(R.string.settings_key_security_backup_warning), warningShown); if (keep_auth) { editor.putString(getResString(R.string.settings_key_auth), authMethod.toString().toLowerCase()); if (! authCredentials.isEmpty()) { editor.putString(getResString(R.string.settings_key_auth_credentials), authCredentials); editor.putInt(getResString(R.string.settings_key_auth_iterations), authIterations); String encodedSalt = Base64.encodeToString(authSalt, Base64.URL_SAFE); editor.putString(getResString(R.string.settings_key_auth_salt), encodedSalt); } } editor.commit(); PreferenceManager.setDefaultValues(context, R.xml.preferences, true); }
Example 7
Source File: MainApplication.java From Android-Audio-Recorder with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); PreferenceManager.setDefaultValues(this, R.xml.pref_general, false); Context context = this; context.setTheme(getUserTheme()); }
Example 8
Source File: App.java From Multiwii-Remote with Apache License 2.0 | 5 votes |
@Override public void onCreate() { PreferenceManager.setDefaultValues(this, R.xml.preferences, false); prefs = PreferenceManager.getDefaultSharedPreferences(this); prefsEditor = prefs.edit(); sensors = new Sensors(getApplicationContext(), this); Init(); tts = new TTS(getApplicationContext()); varioSoundClass = new VarioSoundClass(); }
Example 9
Source File: MainActivity.java From CSCI4669-Fall15-Android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // set default values in the app's SharedPreferences PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // register listener for SharedPreferences changes PreferenceManager.getDefaultSharedPreferences(this). registerOnSharedPreferenceChangeListener( preferenceChangeListener); // determine screen size int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; // if device is a tablet, set phoneDevice to false if (screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE || screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE ) phoneDevice = false; // not a phone-sized device // if running on phone-sized device, allow only portrait orientation if (phoneDevice) setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
Example 10
Source File: MizuuApplication.java From Mizuu with Apache License 2.0 | 5 votes |
private void initializePreferences() { PreferenceManager.setDefaultValues(this, R.xml.advanced_prefs, false); PreferenceManager.setDefaultValues(this, R.xml.general_prefs, false); PreferenceManager.setDefaultValues(this, R.xml.identification_search_prefs, false); PreferenceManager.setDefaultValues(this, R.xml.other_prefs, false); PreferenceManager.setDefaultValues(this, R.xml.user_interface_prefs, false); }
Example 11
Source File: VideoListActivity.java From mobilecloud-15 with Apache License 2.0 | 5 votes |
/** * Hook method called when a new instance of Activity is created. * One time initialization code goes here, e.g., storing Views. * * @param Bundle * object that contains saved state information. */ @Override protected void onCreate(Bundle savedInstanceState) { // Initialize the default layout. setContentView(R.layout.video_list_activity); // Receiver for the notification. mUploadResultReceiver = new UploadResultReceiver(); PreferenceManager.setDefaultValues (this, R.xml.preferences, false); // Get reference to the ListView for displaying the results // entered. mVideosList = (ListView) findViewById(R.id.videoList); // Get reference to the Floating Action Button. mUploadVideoButton = (FloatingActionButton) findViewById(R.id.fabButton); // Displays a chooser dialog that gives options to // upload video from either by Gallery or by // VideoRecorder. mUploadVideoButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { displayChooserDialog(); } }); // Invoke the special onCreate() method in GenericActivity, // passing in the VideoOps class to instantiate/manage and // "this" to provide VideoOps with the VideoOps.View instance. super.onCreate(savedInstanceState, VideoOps.class, this); }
Example 12
Source File: AedictApp.java From aedict with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); // tests will create multiple instances of this class // if (instance != null) { // throw new IllegalStateException("Not a singleton"); // } instance = this; DialogUtils.resError = R.string.error; PreferenceManager.setDefaultValues(this, R.xml.preferences, true); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); apply(new Config(this)); ds = new DownloaderService(); bs = new BackgroundService(); }
Example 13
Source File: NavigationActivity.java From AvI with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_navigation); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Intent intent = getIntent(); if (intent != null) { handleIntentExtras(intent); } fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); //instantiate the fragmentManager and set the default view to profile fragmentManager = getFragmentManager(); if(fragmentManager.findFragmentByTag(fragmentTag) == null) { currentFragment = new ProfileFragment(); fragmentManager.beginTransaction() .replace(R.id.content_frame, (Fragment) currentFragment, fragmentTag) .commit(); }else{ currentFragment = (INavigationFragment) fragmentManager.findFragmentByTag(fragmentTag); } //initialize the default application settings PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Create an instance of GoogleAPIClient. if (googleApiClient == null) { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } }
Example 14
Source File: NavigationViewSettingsActivity.java From graphhopper-navigation-android with MIT License | 4 votes |
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.fragment_navigation_view_preferences); PreferenceManager.setDefaultValues(getActivity(), R.xml.fragment_navigation_view_preferences, false); }
Example 15
Source File: xdrip.java From xDrip with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate() { xdrip.context = getApplicationContext(); super.onCreate(); try { if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) { initCrashlytics(this); initBF(); } } catch (Exception e) { Log.e(TAG, e.toString()); } executor = new PlusAsyncExecutor(); PreferenceManager.setDefaultValues(this, R.xml.pref_general, true); PreferenceManager.setDefaultValues(this, R.xml.pref_data_sync, true); PreferenceManager.setDefaultValues(this, R.xml.pref_advanced_settings, true); PreferenceManager.setDefaultValues(this, R.xml.pref_notifications, true); PreferenceManager.setDefaultValues(this, R.xml.pref_data_source, true); PreferenceManager.setDefaultValues(this, R.xml.xdrip_plus_defaults, true); PreferenceManager.setDefaultValues(this, R.xml.xdrip_plus_prefs, true); checkForcedEnglish(xdrip.context); JoH.ratelimit("policy-never", 3600); // don't on first load new IdempotentMigrations(getApplicationContext()).performAll(); JobManager.create(this).addJobCreator(new XDripJobCreator()); DailyJob.schedule(); //SyncService.startSyncServiceSoon(); if (!isRunningTest()) { MissedReadingService.delayedLaunch(); NFCReaderX.handleHomeScreenScanPreference(getApplicationContext()); AlertType.fromSettings(getApplicationContext()); //new CollectionServiceStarter(getApplicationContext()).start(getApplicationContext()); CollectionServiceStarter.restartCollectionServiceBackground(); PlusSyncService.startSyncService(context, "xdrip.java"); if (Pref.getBoolean("motion_tracking_enabled", false)) { ActivityRecognizedService.startActivityRecogniser(getApplicationContext()); } BluetoothGlucoseMeter.startIfEnabled(); LeFunEntry.initialStartIfEnabled(); MiBandEntry.initialStartIfEnabled(); BlueJayEntry.initialStartIfEnabled(); XdripWebService.immortality(); VersionTracker.updateDevice(); } else { Log.d(TAG, "Detected running test mode, holding back on background processes"); } Reminder.firstInit(xdrip.getAppContext()); PluggableCalibration.invalidateCache(); }
Example 16
Source File: Utils.java From android-galaxyzoo with GNU General Public License v3.0 | 4 votes |
static void initDefaultPrefs(final Context context) { PreferenceManager.setDefaultValues(context, R.xml.preferences, false); }
Example 17
Source File: MainActivity.java From AndroidApp with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); UpgradeManager.doUpgrade(this); PreferenceManager.setDefaultValues(this, R.xml.main_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.me_preferences, false); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); setKeepScreenOn(sp.getBoolean(getString(R.string.setting_keepscreenon), false)); setContentView(R.layout.activity_main); mToolbar = (Toolbar) findViewById(R.id.main_toolbar); setSupportActionBar(mToolbar); setUpNavigation(); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener); EmonApplication.get().addAccountChangeListener(this); }
Example 18
Source File: MainActivity.java From privacy-friendly-interval-timer with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Init preferences PreferenceManager.setDefaultValues(this, R.xml.pref_notification, true); PreferenceManager.setDefaultValues(this, R.xml.pref_personalization, true); PreferenceManager.setDefaultValues(this, R.xml.pref_statistics, true); PreferenceManager.setDefaultValues(this, R.xml.pref_workout, true); this.settings = PreferenceManager.getDefaultSharedPreferences(this); //Set default values for the timer configurations setDefaultTimerValues(); //Set the GUI text this.workoutIntervalText = (TextView) this.findViewById(R.id.main_workout_interval_time); this.restIntervalText = (TextView) this.findViewById(R.id.main_rest_interval_time); this.setsText = (TextView) this.findViewById(R.id.main_sets_amount); this.workoutIntervalText.setText(formatTime(workoutTime)); this.restIntervalText.setText(formatTime(restTime)); this.setsText.setText(Integer.toString(sets)); //Start timer service overridePendingTransition(0, 0); startService(new Intent(this, TimerService.class)); //Schedule the next motivation notification (necessary if permission was not granted) if(NotificationHelper.isMotivationAlertEnabled(this)){ NotificationHelper.setMotivationAlert(this); } //Set the change listener for the switch button to turn block periodization on and off blockPeriodizationSwitchButton = (Switch) findViewById(R.id.main_block_periodization_switch); blockPeriodizationSwitchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isBlockPeriodization = isChecked; } }); //Suggest the user to enter his body data prefManager = new PrefManager(this); if(prefManager.isFirstTimeLaunch()){ prefManager.setFirstTimeLaunch(false); showPersonalizationAlert(); } }
Example 19
Source File: PreferencesActivity.java From orWall with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(getActivity(), R.xml.other_preferences, true); addPreferencesFromResource(R.xml.fragment_network_prefs); }
Example 20
Source File: TopicsPreferenceFragment.java From 4pdaClient-plus with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(android.os.Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); PreferenceManager.setDefaultValues(getActivity(), R.xml.topics_list_prefs, false); }