Java Code Examples for android.support.v7.preference.PreferenceManager#setDefaultValues()

The following examples show how to use android.support.v7.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: MainActivity.java    From TimeTable with GNU General Public License v3.0 6 votes vote down vote up
private void initAll() {
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    setupFragments();
    setupCustomDialog();
    setupSevenDaysPref();

    if(switchSevenDays) changeFragments(true);

    setDailyAlarm();
}
 
Example 2
Source File: MainActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = 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();
        }
    });
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean switchPref = sharedPref.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false);
    Toast.makeText(this, switchPref.toString(), Toast.LENGTH_SHORT).show();
}
 
Example 3
Source File: SplashActivity.java    From IslamicLibraryAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Intent intent = getIntent();
    if (intent.getBooleanExtra(SettingsActivity.KEY_KILL_APP, false)) {
        finish();
        System.exit(0);
    }
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
    ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    mProgressBar = findViewById(R.id.progressBar1);
    mTextView = findViewById(R.id.progressTextView);
    mProgressValue = findViewById(R.id.progressValueTextView);
    checkStorage();
}
 
Example 4
Source File: App.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
private void setupPreference() {
    PreferenceManager.setDefaultValues(this, R.xml.fasthub_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.about_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.behaviour_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.customization_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.language_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.notification_settings, false);
}
 
Example 5
Source File: WalrusApplication.java    From Walrus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);

    context = getApplicationContext();

    PreferenceManager.setDefaultValues(this, R.xml.preferences_chameleon_mini_rev_g, false);
    PreferenceManager.setDefaultValues(this, R.xml.preferences_chameleon_mini_rev_e_rebooted, false);

    HIDCardData.setup(context);

    LocalBroadcastManager.getInstance(this).registerReceiver(
            new DeviceChangedBroadcastHandler(),
            new IntentFilter(CardDeviceManager.ACTION_UPDATE));

    if (BuildConfig.DEBUG) {
        CardDeviceManager.INSTANCE.addDebugDevice(this);
    }

    new Thread(new Runnable() {
        @Override
        public void run() {
            CardDeviceManager.INSTANCE.scanForDevices(WalrusApplication.this);
        }
    }).start();
}
 
Example 6
Source File: App.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onCreate() {
    super.onCreate();
    instance = this;
    SugarContext.init(this.getApplicationContext());
    FileHelper.initFolderName(getString(R.string.app_name));
    TypeFaceHelper.generateTypeface(this.getApplicationContext());
    PreferenceManager.setDefaultValues(this, R.xml.fa_settings, false);
    FirebaseDatabase.getInstance().setPersistenceEnabled(false);
}
 
Example 7
Source File: Preferences.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
private Preferences(Context context) {
    PreferenceManager.setDefaultValues(context, R.xml.preferences, true);
    preferences = PreferenceManager.getDefaultSharedPreferences(context);
    preferences.registerOnSharedPreferenceChangeListener(this);
    SharedPreferences.Editor editor = preferences.edit();
    if (preferences.getString(PREF_LOCAL_REPO_NAME, null) == null) {
        editor.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName());
    }
    if (!preferences.contains(PREF_AUTO_DOWNLOAD_INSTALL_UPDATES)) {
        editor.putBoolean(PREF_AUTO_DOWNLOAD_INSTALL_UPDATES,
                PrivilegedInstaller.isExtensionInstalledCorrectly(context)
                        != PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES);
    }
    editor.apply();
}
 
Example 8
Source File: Preferences.java    From ShaderEditor with MIT License 5 votes vote down vote up
public void init(Context context) {
	systemBarColor = ContextCompat.getColor(
			context,
			R.color.primary_dark_translucent);

	PreferenceManager.setDefaultValues(
			context,
			R.xml.preferences,
			false);

	preferences = PreferenceManager.getDefaultSharedPreferences(
			context);

	update();
}
 
Example 9
Source File: CustomThemeModel.java    From NumberPadTimePicker with Apache License 2.0 4 votes vote down vote up
private CustomThemeModel(Context context) {
    PreferenceManager.setDefaultValues(context, R.xml.preferences, false);
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
}
 
Example 10
Source File: CustomThemeModel.java    From NumberPadTimePicker with Apache License 2.0 4 votes vote down vote up
public void resetToDefaults(Context context) {
    sharedPrefs.edit().clear().apply();
    PreferenceManager.setDefaultValues(context, R.xml.preferences, true);
}