List of usage examples for android.preference PreferenceManager setDefaultValues
public static void setDefaultValues(Context context, @XmlRes int resId, boolean readAgain)
From source file:com.lostrealm.lembretes.MealActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_meal); ButterKnife.bind(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); DownloadJob.scheduleExact();//from w w w . j a va 2 s . c o m NotificationJob.scheduleExact(); }
From source file:com.lugia.timetable.MasterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_master); // Set up preferences value of this app if we run it on first time PreferenceManager.setDefaultValues(MasterActivity.this, R.xml.setting_preference, false); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mFilename = null;// w ww .ja v a 2 s.c om mTimeTableFragment = new TimeTableFragment(); mSubjectListFragment = new SubjectListFragment(); getSupportFragmentManager().beginTransaction().add(R.id.container, mTimeTableFragment, "TimeTable") .add(R.id.container, mSubjectListFragment, "SubjectList").hide(mSubjectListFragment).commit(); mSpinnerAdapter = new TimeTableSpinnerAdapter(MasterActivity.this, actionBar.getSelectedNavigationIndex()); mSpinnerAdapter.setViewType(NAV_DAY); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); }
From source file:de.baumann.hhsmoodle.activities.Activity_splash.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPrefSec = new class_SecurePreferences(Activity_splash.this, "sharedPrefSec", "Ywn-YM.XK$b:/:&CsL8;=L,y4", true); if (sharedPref.getString("key_generated_01", "no").equals("no")) { char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!$%&/()=?;:_-.,+#*<>" .toCharArray();/* w ww .ja va 2 s. co m*/ StringBuilder sb = new StringBuilder(); Random random = new Random(); for (int i = 0; i < 16; i++) { char c = chars[random.nextInt(chars.length)]; sb.append(c); } Schedule_helper.insertDefaultBookmarks(Activity_splash.this); sharedPrefSec.put("key_encryption_01", sb.toString()); sharedPref.edit().putString("key_generated_01", "yes").apply(); } helper_security.decryptDatabases(Activity_splash.this); Schedule_helper.setAlarm(Activity_splash.this); helper_main.onStart(Activity_splash.this); TextInputLayout editUsernameLayout = (TextInputLayout) findViewById(R.id.editUsernameLayout); editUsernameLayout.setVisibility(View.INVISIBLE); TextInputLayout editPasswordLayout = (TextInputLayout) findViewById(R.id.editPasswordLayout); editPasswordLayout.setVisibility(View.INVISIBLE); editUsername = (EditText) findViewById(R.id.editUsername); assert editUsername != null; editUsername.setVisibility(View.INVISIBLE); editUsername.getBackground().mutate().setColorFilter( ContextCompat.getColor(Activity_splash.this, R.color.colorAccent), PorterDuff.Mode.SRC_ATOP); editPassword = (EditText) findViewById(R.id.editPassword); assert editPassword != null; editPassword.setVisibility(View.INVISIBLE); editPassword.getBackground().mutate().setColorFilter( ContextCompat.getColor(Activity_splash.this, R.color.colorAccent), PorterDuff.Mode.SRC_ATOP); Image = (ImageView) findViewById(R.id.image); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); assert fab != null; fab.setVisibility(View.INVISIBLE); boolean show = sharedPref.getBoolean("showIntroScreen_notShow", true); if (show) { helper_main.switchToActivity(Activity_splash.this, Activity_intro.class, true); } else { if (sharedPrefSec.getString("password") == null || sharedPrefSec.getString("username") == null || sharedPrefSec.getString("password").isEmpty() || sharedPrefSec.getString("username").isEmpty()) { editUsernameLayout.setVisibility(View.VISIBLE); editPasswordLayout.setVisibility(View.VISIBLE); editUsername.setVisibility(View.VISIBLE); editPassword.setVisibility(View.VISIBLE); editUsername.setText(sharedPrefSec.getString("username")); editPassword.setText(sharedPrefSec.getString("password")); fab.setVisibility(View.VISIBLE); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String Username = editUsername.getText().toString().trim(); String Password = editPassword.getText().toString().trim(); if (Username.isEmpty() || Password.isEmpty()) { Snackbar.make(Image, R.string.login_hint, Snackbar.LENGTH_LONG).show(); } else { sharedPrefSec.put("username", Username); sharedPrefSec.put("password", Password); new Handler().postDelayed(new Runnable() { public void run() { helper_main.switchToActivity(Activity_splash.this, HHS_MainScreen.class, true); } }, 500); } } }); } else { new Handler().postDelayed(new Runnable() { public void run() { helper_main.switchToActivity(Activity_splash.this, HHS_MainScreen.class, true); } }, 500); } } onNewIntent(getIntent()); }
From source file:dentex.youtube.downloader.menu.DonateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.leaveBreadcrumb("DonateActivity_onCreate"); this.setTitle(R.string.title_activity_donate); getWindow().requestFeature(Window.FEATURE_PROGRESS); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // Theme init Utils.themeInit(this); // Language init Utils.langInit(this); // Load default preferences values PreferenceManager.setDefaultValues(this, R.xml.donate, false); // Display the fragment as the main content. getFragmentManager().beginTransaction().replace(android.R.id.content, new DonateFragment()).commit(); setupActionBar();/* ww w . j a va2 s. c om*/ }
From source file:net.grayswander.rotationmanager.RotationManagerService.java
@Override protected void onServiceConnected() { super.onServiceConnected(); //Configure these here for compatibility with API 13 and below. AccessibilityServiceInfo config = new AccessibilityServiceInfo(); config.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; if (Build.VERSION.SDK_INT >= 16) //Just in case this helps config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS; setServiceInfo(config);//from w w w . j a v a 2 s. c om this.context = getApplicationContext(); PreferenceManager.setDefaultValues(context, R.xml.preferences, false); configuration = new Configuration(this.context); this.resources = context.getResources(); }
From source file:com.cloudkick.DashboardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); dashboard = new ListView(this); adapter = new NodesAdapter(this, R.layout.node_item, nodes); dashboard.setAdapter(adapter);//from w w w . j a va 2s.c o m dashboard.setOnItemClickListener(this); dashboard.setBackgroundColor(Color.WHITE); setContentView(dashboard); reloadAPI(); }
From source file:dentex.youtube.downloader.DonateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setTitle(R.string.title_activity_donate); settings = getSharedPreferences(PREFS_NAME, 0); getWindow().requestFeature(Window.FEATURE_PROGRESS); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // Theme init Utils.themeInit(this); // Language init Utils.langInit(this); // Load default preferences values PreferenceManager.setDefaultValues(this, R.xml.donate, false); // Display the fragment as the main content. getFragmentManager().beginTransaction().replace(android.R.id.content, new DonateFragment()).commit(); setupActionBar();/* w w w. j av a2 s. c o m*/ }
From source file:de.baumann.browser.popups.Popup_pass.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(ContextCompat.getColor(Popup_pass.this, R.color.colorThreeDark)); setContentView(R.layout.activity_popup); helper_main.onStart(Popup_pass.this); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPref.getBoolean("isOpened", false)) { helper_main.checkPin(Popup_pass.this); }//from w w w .j a v a2 s .c om try { mahEncryptor = MAHEncryptor.newInstance(sharedPref.getString("saved_key", "")); } catch (Exception e) { e.printStackTrace(); Snackbar.make(listView, R.string.toast_error, Snackbar.LENGTH_SHORT).show(); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } EditText editText = (EditText) findViewById(R.id.editText); editText.setVisibility(View.GONE); editText.setHint(R.string.app_search_hint); editText.clearFocus(); TextView urlBar = (TextView) findViewById(R.id.urlBar); urlBar.setText(R.string.app_title_passStorage); listView = (ListView) findViewById(R.id.list); //calling Notes_DbAdapter db = new DbAdapter_Pass(this); db.open(); setFilesList(); }
From source file:de.baumann.hhsmoodle.popup.Popup_note.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_popup); PreferenceManager.setDefaultValues(Popup_note.this, R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(Popup_note.this); lv = (ListView) findViewById(R.id.dialogList); //calling Notes_DbAdapter db = new Notes_DbAdapter(Popup_note.this); db.open();/* www . j a va 2 s . c o m*/ setNotesList(); }
From source file:de.escoand.readdaily.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // theme/*ww w . j a v a 2s . co m*/ PreferenceManager.setDefaultValues(this, R.xml.settings, false); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("readability", false)) setTheme(R.style.AppTheme_Readability); setContentView(R.layout.activity_drawer); // drawer layout = (DrawerLayout) findViewById(R.id.wrapper); ((NavigationView) findViewById(R.id.drawer)).setNavigationItemSelectedListener(this); layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); // toolbars toolbar = (Toolbar) findViewById(R.id.toolbar); toolbarRight = (Toolbar) findViewById(R.id.toolbar_right); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { layout.openDrawer(Gravity.LEFT); } }); toolbarRight.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { layout.closeDrawer(Gravity.RIGHT); } }); playerButton = toolbar.findViewById(R.id.toolbar_player); searchButton = (SearchView) toolbar.findViewById(R.id.toolbar_search); // search // ToDo make search work again ((SearchView) toolbar.findViewById(R.id.toolbar_search)).setOnQueryTextListener(new OnSearchListener()); // fragments handler.addDateListener(this); handler.addDateListener((OnDateSelectedListener) findViewById(R.id.content_pager)); handler.addDateListener( (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_voty)); handler.addDateListener( (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_intro)); handler.addDateListener( (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_footer)); // floating buttons if (findViewById(R.id.button_more) != null) findViewById(R.id.button_more).setOnClickListener(new OnMoreClickListener()); if (findViewById(R.id.button_intro) != null) findViewById(R.id.button_intro).setOnClickListener(new OnIntroClickListener()); if (findViewById(R.id.button_voty) != null) findViewById(R.id.button_voty).setOnClickListener(new OnVotyClickListener()); // registration PushInstanceService.doRegistration(this, true); // start store if no data if (!Database.getInstance(this).isAnyInstalled()) startActivity(new Intent(getApplication(), StoreActivity.class)); }