@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sketch_properties); // StackOverflow: http://stackoverflow.com/a/27455330/1628609 LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent(); toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); root.addView(toolbar, 0); toolbar.setNavigationOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); initOptionsMenu(toolbar.getMenu()); toolbar.setOnMenuItemClickListener(this); toolbar.setTitle(getGlobalState().getSketchName()); getGlobalState().setProperties(this); getWindow() .getDecorView() .setBackgroundColor(getResources().getColor(R.color.activity_background)); }
private void updateTitle() { final String newTitle = getTitle(); if (newTitle == null) { Log.d(LOGTAG, "No new title to show."); return; } final PreferenceActivity activity = (PreferenceActivity) getActivity(); if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) && activity.isMultiPane()) { // In a multi-pane activity, the title is "Settings", and the action // bar is along the top of the screen. We don't want to change those. activity.showBreadCrumbs(newTitle, newTitle); return; } Log.v(LOGTAG, "Setting activity title to " + newTitle); activity.setTitle(newTitle); if (Build.VERSION.SDK_INT >= 14) { final ActionBar actionBar = activity.getActionBar(); if (actionBar != null) { actionBar.setTitle(newTitle); } } }
@Override public void setListAdapter(ListAdapter adapter) { if (adapter == null) { super.setListAdapter(null); } else { super.setListAdapter(new HeaderAdapter(this, getHeaders(), mAuthenticatorHelper)); } }
@Override public void onItemSelected( final AdapterView<?> parent, final View view, final int pos, final long id) { final LocaleRenderer locale = (LocaleRenderer) parent.getItemAtPosition(pos); if (locale.isMoreLanguages()) { PreferenceActivity preferenceActivity = (PreferenceActivity) getActivity(); preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(this), true); } else { mContents.updateLocale(locale.getLocaleString()); } }
private void processArguments() { Bundle arguments = getArguments(); // Key. mPreferenceKey = arguments.getString(EXTRA_PREFERENCE_KEY); // Enabled. final boolean enabled = arguments.getBoolean(EXTRA_CHECKED); mToggleSwitch.setCheckedInternal(enabled); // Title. PreferenceActivity activity = (PreferenceActivity) getActivity(); if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) { mOldActivityTitle = getActivity().getTitle(); String title = arguments.getString(EXTRA_TITLE); getActivity().getActionBar().setTitle(title); } // Summary. String summary = arguments.getString(EXTRA_SUMMARY); mSummaryPreference.setSummary(summary); // Settings title and intent. String settingsTitle = arguments.getString(EXTRA_SETTINGS_TITLE); String settingsComponentName = arguments.getString(EXTRA_SETTINGS_COMPONENT_NAME); if (!TextUtils.isEmpty(settingsTitle) && !TextUtils.isEmpty(settingsComponentName)) { Intent settingsIntent = new Intent(Intent.ACTION_MAIN) .setComponent(ComponentName.unflattenFromString(settingsComponentName.toString())); if (!getPackageManager().queryIntentActivities(settingsIntent, 0).isEmpty()) { mSettingsTitle = settingsTitle; mSettingsIntent = settingsIntent; setHasOptionsMenu(true); } } // Enable warning title. mEnableWarningTitle = arguments.getCharSequence(AccessibilitySettings.EXTRA_ENABLE_WARNING_TITLE); // Enable warning message. mEnableWarningMessage = arguments.getCharSequence(AccessibilitySettings.EXTRA_ENABLE_WARNING_MESSAGE); // Disable warning title. mDisableWarningTitle = arguments.getString(AccessibilitySettings.EXTRA_DISABLE_WARNING_TITLE); // Disable warning message. mDisableWarningMessage = arguments.getString(AccessibilitySettings.EXTRA_DISABLE_WARNING_MESSAGE); }
// utility method used to start sub activity private void startApplicationDetailsActivity() { // start new fragment to display extended information Bundle args = new Bundle(); args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mCurrentPkgName); PreferenceActivity pa = (PreferenceActivity) getActivity(); pa.startPreferencePanel( InstalledAppDetails.class.getName(), args, R.string.application_info_label, null, this, INSTALLED_APP_DETAILS); }
private PreferenceScreen inflatePreferences(int preferencesResId) { ResName resName = shadowOf(realOject.getAssets()) .getResourceLoader() .getResourceIndex() .getResName(preferencesResId); String qualifiers = shadowOf(realOject.getResources().getConfiguration()).getQualifiers(); PreferenceNode preferenceNode = shadowOf(realOject.getAssets()).getResourceLoader().getPreferenceNode(resName, qualifiers); try { return (PreferenceScreen) preferenceBuilder.inflate(preferenceNode, realActivity, null); } catch (Exception e) { throw new RuntimeException("error inflating " + resName, e); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); taskDatabaseMap = TaskDatabaseMap.getInstance(this); addPreferencesFromResource(R.xml.preferences); initDurationPreference(ConfigType.TASK_DURATION); initDurationPreference(ConfigType.BREAK_DURATION); initDurationPreference(ConfigType.EVERY_FOURTH_BREAK_DURATION); ringTonePreference = (RingtonePreference) findPreference(ConfigType.NOTIFICATION_RINGTONE.name()); ringTonePreference.setOnPreferenceChangeListener( new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { updateRingtonePreferenceSummary((String) newValue); taskDatabaseMap.getPreferences().updateRingtone((String) newValue); return false; } }); String selectedRingtone = taskDatabaseMap.getPreferences().getRingtone(); if (selectedRingtone != null) { updateRingtonePreferenceSummary(selectedRingtone); } }
@SuppressWarnings("deprecation") @Override protected void onPause() { super.onPause(); // Unregister the listener whenever a key changes getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.option); geted = PreferenceManager.getDefaultSharedPreferences(this).edit(); geted.putBoolean("AI", false); geted.putString("name", Nom); geted.putString("surname", Prénom); geted.putString("nickname", Pseudonyme); geted.putString("IPadress", IPAdress); if (externe) { geted.putBoolean("externe", true); geted.putString("IPadress_ext", IPadress_ext); geted.putString("SSID", SSID); } else { geted.putBoolean("externe", false); } geted.putBoolean("shake", ShakeService); geted.putBoolean("event", EventService); geted.putBoolean("tts_pref", TTS); geted.putBoolean("update", Update_Com); geted.commit(); ListPreference lp = (ListPreference) findPreference("sexe"); lp.setEntries(Values); lp.setEntryValues(Values); if (Sexe < 3) lp.setValue(Values[Sexe]); finish(); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); addPreferencesFromResource(getIntent().getExtras().getInt("xml")); }
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref); }
@Override protected void onResume() { super.onResume(); if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) { mPhoneStateReceiver.registerIntent(); updateSignalStrength(); updateServiceState(mPhone.getServiceState()); updateDataState(); mTelephonyManager.listen( mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); if (mShowLatestAreaInfo) { registerReceiver( mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION), CB_AREA_INFO_SENDER_PERMISSION, null); // Ask CellBroadcastReceiver to broadcast the latest area info received Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION); sendBroadcastAsUser(getLatestIntent, UserHandle.ALL, CB_AREA_INFO_SENDER_PERMISSION); } } registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mHandler.sendEmptyMessage(EVENT_UPDATE_STATS); }
protected void onResume() { super.onResume(); registerReceiver(mReceiver, mIntentFilter); mNamePreference.resume(); mEnablerPreference.resume(); setScreenState(); }
@Override protected void onCreate(final Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); // set the self test summary with the configured value setDiagnosticsPrefSummary(findPreference(KEY_DIAGNOSTICS)); // add shared preferences change listener getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); // create a link to the market to search for additional coin packages final Preference downloadPref = getPreferenceManager().findPreference("download"); downloadPref.setOnPreferenceClickListener( new OnPreferenceClickListener() { public boolean onPreferenceClick(final Preference preference) { final Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=" + EXTPKG_QUERY)); startActivity(goToMarket); return true; } }); // load any external coin packages installed on the system loadExtPkgCoins(); }
@Override protected void onResume() { super.onResume(); // Set up a listener whenever a key changes getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceManager.getDefaultSharedPreferences(this) .registerOnSharedPreferenceChangeListener(this); }
@Override protected void onPause() { super.onPause(); PreferenceManager .getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(this); }
@Override protected void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(); filter.addAction(PROCESS_COMMAND_ACTION); registerReceiver(mReceiver, filter); }
@Override protected void onResume() { super.onResume(); loadPairedBTDevices(); loadSetPreferences(); }
@Override protected void onResume() { PreferenceScreen pref_root = getPreferenceManager().createPreferenceScreen(this); SharedPreferences config = getSharedPreferences(getPackageName(), MODE_WORLD_READABLE); String tunnels = config.getString("tunnels", ""); List<String> tunnels_list = Arrays.asList(tunnels.split("\n")); for (String tunnel : tunnels_list) { if (tunnel.length() == 0) continue; String remote_server = config.getString(String.format("tunnels.%s.remote_server", tunnel), "0.0.0.0"); String local_client = config.getString(String.format("tunnels.%s.local_client", tunnel), "0.0.0.0"); boolean config_autodetect = config.getBoolean(String.format("tunnels.%s.local_autodetect", tunnel), false); if (config_autodetect) { local_client = "<dynamic>"; } String tunnel_address = config.getString(String.format("tunnels.%s.tunnel_address", tunnel), "::0/0"); Preference pref = new Preference(this); pref.setKey(tunnel); pref.setTitle(String.format("%s - %s", local_client, remote_server)); pref.setSummary(tunnel_address); pref.setOnPreferenceClickListener(new TunnelPreferenceListener(this)); pref_root.addPreference(pref); } setPreferenceScreen(pref_root); super.onResume(); }
@Override protected void onResume() { super.onResume(); // Registers a callback to be invoked whenever a user changes a preference. getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Inflate UI preference options */ addPreferencesFromResource(R.xml.preferences_stopinfo); }
/** * OnStart method of the activity that establishes a connection with the service by binding to it */ @Override protected void onStart() { super.onStart(); Intent serviceIntent = new Intent(getApplicationContext(), TrafficService.class); startService(serviceIntent); bindService(serviceIntent, mConnection, BIND_AUTO_CREATE); }
@Override public void onDestroy() { super.onDestroy(); if (mListeningToAccountUpdates) { AccountManager.get(this).removeOnAccountsUpdatedListener(this); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { return; } switch (requestCode) { case ACTIVITY_SELECT_SERVER_URL: Uri serverUri = data.getData(); if (serverUri == null) { toast(getString(R.string.errorFailedGetServerUrl)); } else { long id = Long.parseLong(serverUri.getPathSegments().get(1)); String url = Utils.idToValue( this, Server.Columns.CONTENT_URI, Server.Columns._ID, Server.Columns.URL, id); if (url != null) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putString(getString(R.string.keyService), url); editor.commit(); } } break; } }
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); addPreferencesFromResource(R.xml.preferences); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); }
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.apn_settings); getListView().setItemsCanFocus(true); mExt = Utils.getMiscPlugin(this); mRcseExt = Utils.getRcseApnPlugin(this); if (mRcseExt != null) { mRcseExt.addRcseOnlyApnStateChanged(mListener); } else { Xlog.d(TAG, "mApnPlugin is null"); } initSimState(); mMobileStateFilter = getIntentFilter(); mReceiver = getBroadcastReceiver(); mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE); if (FeatureOption.MTK_MVNO_SUPPORT) { setSpn(); setIMSI(); setPnn(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); SharedPreferences p = MultiROMMgrApplication.getPreferences(); if (p.getString(GENERAL_DOWNLOAD_DIR, null) == null) Utils.setDownloadDir(Utils.getDefaultDownloadDir()); addPreferencesFromResource(R.xml.settings); addDevOptions(); p.registerOnSharedPreferenceChangeListener(this); updatePrefText(); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); Preference pref = findPreference(ABOUT_VERSION); pref.setSummary(pInfo.versionName); pref.setOnPreferenceClickListener(this); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Preference pref = findPreference(ABOUT_LICENSES); pref.setOnPreferenceClickListener(this); }