Java Code Examples for android.preference.Preference.OnPreferenceClickListener

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: LinphonePreferencesActivity.java

  21 
vote

private void addTransportChecboxesListener(){
  final List<CheckBoxPreference> checkboxes=Arrays.asList(findCheckbox(R.string.pref_transport_udp_key),findCheckbox(R.string.pref_transport_tcp_key),findCheckbox(R.string.pref_transport_tls_key));
  OnPreferenceChangeListener changedListener=new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      if ((Boolean)newValue) {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          p.setChecked(false);
        }
        return true;
      }
 else {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          if (p.isChecked())           return true;
        }
        return false;
      }
    }
  }
;
  OnPreferenceClickListener clickListener=new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      if (((CheckBoxPreference)preference).isChecked()) {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          if (p.isChecked())           return false;
        }
        return true;
      }
      return false;
    }
  }
;
  for (  CheckBoxPreference c : checkboxes) {
    c.setOnPreferenceChangeListener(changedListener);
    c.setOnPreferenceClickListener(clickListener);
  }
}
 

Example 2

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: PreferenceActivity.java

  21 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(R.xml.preferences);
  Preference editBookmarks=findPreference("editbookmarks");
  editBookmarks.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference pref){
      showDialog(DIALOG_DELETE_BOOKMARKS);
      return false;
    }
  }
);
  getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  changeListPreferenceSummaryToCurrentValue((ListPreference)findPreference("sortby"));
}
 

Example 3

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/ui/settings/.

Source file: CollectionSettingsHelper.java

  21 
vote

public void prepareClearHistory(Preference preference){
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      clearHistory();
      return true;
    }
  }
);
}
 

Example 4

From project droidtv, under directory /src/com/chrulri/droidtv/.

Source file: PreferencesActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.layout.preferences);
  Preference scanButton=findPreference(PreferenceUtils.KEY_SCANCHANNELS);
  scanButton.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      Intent settingsActivity=new Intent(getBaseContext(),ScanActivity.class);
      startActivity(settingsActivity);
      return true;
    }
  }
);
}
 

Example 5

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/app/.

Source file: SettingsActivity.java

  21 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.settings_fragment_sensors);
  findPreference(getText(R.string.pref_calibration)).setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    final Preference preference){
      startActivity(new Intent(getActivity(),CalibrationWizardActivity.class));
      return true;
    }
  }
);
}
 

Example 6

From project openbicing, under directory /src/net/homelinux/penecoptero/android/openbicing/app/.

Source file: SettingsActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getPreferenceManager().setSharedPreferencesName(OpenBicing.PREFERENCES_NAME);
  addPreferencesFromResource(R.xml.preferences);
  PreferenceScreen psLocation=(PreferenceScreen)this.findPreference("openbicing.preferences_location");
  psLocation.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      launchLocationSettings();
      return false;
    }
  }
);
}
 

Example 7

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/.

Source file: SeriesGuidePreferences.java

  21 
vote

protected static void setupSharingSettings(Context context,Preference getGluePref){
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  getGluePref.setEnabled(GetGlue.isAuthenticated(prefs));
  getGluePref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      fireTrackerEvent("Disonnect GetGlue");
      GetGlue.clearCredentials(prefs);
      preference.setEnabled(false);
      return true;
    }
  }
);
}
 

Example 8

From project Stroke5Keyboard-android, under directory /src/com/linkomnia/android/Stroke5/.

Source file: Setting.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.pref);
  Preference about=this.findPreference("about");
  about.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      showAboutBox();
      return true;
    }
  }
);
}
 

Example 9

From project zirco-browser, under directory /src/org/zirco/ui/activities/preferences/.

Source file: WeavePreferencesActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.layout.weave_preferences_activity);
  Preference weaveServerPref=(Preference)findPreference(Constants.PREFERENCE_WEAVE_SERVER);
  weaveServerPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      openWeaveServerActivity();
      return true;
    }
  }
);
}
 

Example 10

From project android-thaiime, under directory /inputmethodcommon/src/com/android/inputmethodcommon/.

Source file: InputMethodSettingsImpl.java

  20 
vote

/** 
 * Initialize internal states of this object.
 * @param context the context for this application.
 * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
 * @return true if this application is an IME and has two or more subtypes, false otherwise.
 */
public boolean init(final Context context,final PreferenceScreen prefScreen){
  mContext=context;
  mImm=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
  mImi=getMyImi(context,mImm);
  if (mImi == null || mImi.getSubtypeCount() <= 1) {
    return false;
  }
  mSubtypeEnablerPreference=new Preference(context);
  mSubtypeEnablerPreference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      final CharSequence title=getSubtypeEnablerTitle(context);
      final Intent intent=new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
      intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID,mImi.getId());
      if (!TextUtils.isEmpty(title)) {
        intent.putExtra(Intent.EXTRA_TITLE,title);
      }
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
      context.startActivity(intent);
      return true;
    }
  }
);
  prefScreen.addPreference(mSubtypeEnablerPreference);
  updateSubtypeEnabler();
  return true;
}
 

Example 11

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: VpnSettings.java

  20 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.vpn_settings);
  mVpnListContainer=(PreferenceCategory)findPreference(PREF_VPN_LIST);
  mAddVpn=(PreferenceScreen)findPreference(PREF_ADD_VPN);
  mAddVpn.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      startVpnTypeSelection();
      return true;
    }
  }
);
  registerForContextMenu(getListView());
  mVpnManager.registerConnectivityReceiver(mConnectivityReceiver);
  retrieveVpnListFromStorage();
  checkVpnConnectionStatusInBackground();
}
 

Example 12

From project androidZenWriter, under directory /src/com/javaposse/android/zenwriter/.

Source file: PrefsActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.zenpreferences);
  Preference backgroundPref=this.findPreference("backgroundpref");
  final PrefsActivity THIS=this;
  backgroundPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      return THIS.selectBackgroundImage(preference);
    }
  }
);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  if (prefs.getString("backgroundpref","").length() > 0) {
    backgroundPref.setSummary(new File(prefs.getString("backgroundpref","")).getName());
  }
}
 

Example 13

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: TextToSpeechSettings.java

  20 
vote

private void addEngineSpecificSettings(){
  PreferenceGroup enginesCategory=(PreferenceGroup)findPreference("tts_engines_section");
  Intent intent=new Intent("android.intent.action.START_TTS_ENGINE");
  ResolveInfo[] enginesArray=new ResolveInfo[0];
  PackageManager pm=getPackageManager();
  enginesArray=pm.queryIntentActivities(intent,0).toArray(enginesArray);
  for (int i=0; i < enginesArray.length; i++) {
    String prefKey="";
    final String pluginPackageName=enginesArray[i].activityInfo.packageName;
    if (!enginesArray[i].activityInfo.packageName.equals(SYSTEM_TTS)) {
      CheckBoxPreference chkbxPref=new CheckBoxPreference(this);
      prefKey=KEY_PLUGIN_ENABLED_PREFIX + pluginPackageName;
      chkbxPref.setKey(prefKey);
      chkbxPref.setTitle(enginesArray[i].loadLabel(pm));
      enginesCategory.addPreference(chkbxPref);
    }
    if (pluginHasSettings(pluginPackageName)) {
      Preference pref=new Preference(this);
      prefKey=KEY_PLUGIN_SETTINGS_PREFIX + pluginPackageName;
      pref.setKey(prefKey);
      pref.setTitle(enginesArray[i].loadLabel(pm));
      CharSequence settingsLabel=getResources().getString(R.string.tts_engine_name_settings,enginesArray[i].loadLabel(pm));
      pref.setSummary(settingsLabel);
      pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
        public boolean onPreferenceClick(        Preference preference){
          Intent i=new Intent();
          i.setClassName(pluginPackageName,pluginPackageName + ".EngineSettings");
          startActivity(i);
          return true;
        }
      }
);
      enginesCategory.addPreference(pref);
    }
  }
}
 

Example 14

From project android_packages_apps_phone, under directory /src/com/android/phone/sip/.

Source file: SipSettings.java

  20 
vote

private void registerForReceiveCallsCheckBox(){
  mButtonSipReceiveCalls=(CheckBoxPreference)findPreference(BUTTON_SIP_RECEIVE_CALLS);
  mButtonSipReceiveCalls.setChecked(mSipSharedPreferences.isReceivingCallsEnabled());
  mButtonSipReceiveCalls.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      final boolean enabled=((CheckBoxPreference)preference).isChecked();
      new Thread(new Runnable(){
        public void run(){
          handleSipReceiveCallsOption(enabled);
        }
      }
).start();
      return true;
    }
  }
);
}
 

Example 15

From project andstatus, under directory /src/org/andstatus/app/.

Source file: PreferencesActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  MyPreferences.setDefaultValues(R.xml.preferences,false);
  if (!MyPreferences.getSharedPreferences(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES,MODE_PRIVATE).getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES,false)) {
    Log.e(TAG,"Default values were not set?!");
  }
  mNotificationRingtone=(RingtonePreference)findPreference(MyPreferences.KEY_RINGTONE_PREFERENCE);
  mUseExternalStorage=(CheckBoxPreference)getPreferenceScreen().findPreference(MyPreferences.KEY_USE_EXTERNAL_STORAGE_NEW);
  mNotificationRingtone.setOnPreferenceChangeListener(this);
  Preference myPref=(Preference)findPreference("manage_accounts");
  myPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      AccountSettings.startManageAccountsActivity(PreferencesActivity.this);
      return false;
    }
  }
);
}
 

Example 16

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/ui/settings/.

Source file: AddOnSelector.java

  20 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(getPrefsLayoutResId());
  final Preference searcher=findPreference(SEARCH_MARKET_PACKS_PREF_KEY);
  searcher.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      if (preference.getKey().equals(SEARCH_MARKET_PACKS_PREF_KEY)) {
        if (allowExternalPacks()) {
          try {
            MainForm.searchMarketForAddons(AddOnSelector.this.getApplicationContext(),getAdditionalMarketQueryString());
          }
 catch (          Exception ex) {
            Toast.makeText(getApplicationContext(),getText(R.string.no_market_store_available),Toast.LENGTH_LONG).show();
            Log.e("ASK-SETTINGS","Failed to launch market!",ex);
          }
        }
 else {
          showDialog(DIALOG_NO_EXTERNAL_PACKS_FOR_NOW);
        }
        return true;
      }
      return false;
    }
  }
);
  mAddonsList=(ListPreference)findPreference(getString(getAddonsListPrefKeyResId()));
}
 

Example 17

From project bookmarktodesktop-android-application, under directory /src/be/vbsteven/bmtodesk/.

Source file: Preferences.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  setTheme(android.R.style.Theme_Light_NoTitleBar);
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.prefs);
  Preference pref=findPreference("WATCHINTROVID");
  pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.youtube.com/watch?v=RH4O019v2iA")));
      return true;
    }
  }
);
  pref=findPreference("CREATEACC");
  pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      startActivity(new Intent(getApplicationContext(),RegistrationActivity.class));
      return true;
    }
  }
);
}
 

Example 18

From project callmeter, under directory /src/de/ub0r/android/callmeter/ui/prefs/.

Source file: PreferencesPlain.java

  20 
vote

/** 
 * Load widget list. 
 */
@SuppressWarnings("deprecation") private void loadWidgets(){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  Preference p=this.findPreference("container");
  if (p != null && p instanceof PreferenceScreen) {
    PreferenceScreen ps=(PreferenceScreen)p;
    ps.removeAll();
    int[] ids=AppWidgetManager.getInstance(this).getAppWidgetIds(new ComponentName(this,StatsAppWidgetProvider.class));
    boolean added=false;
    if (ids != null && ids.length > 0) {
      for (      int id : ids) {
        if (prefs.getLong(StatsAppWidgetProvider.WIDGET_PLANID + id,-1) <= 0) {
          continue;
        }
        added=true;
        p=new Preference(this);
        p.setTitle(this.getString(R.string.widget_) + " #" + id);
        final int fid=id;
        p.setOnPreferenceClickListener(new OnPreferenceClickListener(){
          @Override public boolean onPreferenceClick(          final Preference preference){
            Intent i=new Intent(PreferencesPlain.this,StatsAppWidgetConfigure.class);
            i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,fid);
            PreferencesPlain.this.startActivity(i);
            return true;
          }
        }
);
        ps.addPreference(p);
      }
    }
    if (!added) {
      p=new Preference(this);
      p.setTitle(R.string.widgets_no_widgets_);
      p.setSummary(R.string.widgets_no_widgets_hint);
      ps.addPreference(p);
    }
  }
}
 

Example 19

From project CoinFlip, under directory /src/com/banasiak/coinflip/.

Source file: Settings.java

  20 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  Log.d(TAG,"onCreate");
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.settings);
  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));
      startActivity(goToMarket);
      return true;
    }
  }
);
  loadExtPkgCoins();
}
 

Example 20

From project frameworks_opt, under directory /inputmethodcommon/java/com/android/inputmethodcommon/.

Source file: InputMethodSettingsImpl.java

  20 
vote

/** 
 * Initialize internal states of this object.
 * @param context the context for this application.
 * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
 * @return true if this application is an IME and has two or more subtypes, false otherwise.
 */
public boolean init(final Context context,final PreferenceScreen prefScreen){
  mContext=context;
  mImm=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
  mImi=getMyImi(context,mImm);
  if (mImi == null || mImi.getSubtypeCount() <= 1) {
    return false;
  }
  mSubtypeEnablerPreference=new Preference(context);
  mSubtypeEnablerPreference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      final CharSequence title=getSubtypeEnablerTitle(context);
      final Intent intent=new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
      intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID,mImi.getId());
      if (!TextUtils.isEmpty(title)) {
        intent.putExtra(Intent.EXTRA_TITLE,title);
      }
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
      context.startActivity(intent);
      return true;
    }
  }
);
  prefScreen.addPreference(mSubtypeEnablerPreference);
  updateSubtypeEnabler();
  return true;
}
 

Example 21

From project HabReader, under directory /src/net/meiolania/apps/habrahabr/activities/.

Source file: PreferencesActivity.java

  20 
vote

private void donate(){
  final Preference donate=(Preference)findPreference("donate");
  billingObserver=new AbstractBillingObserver(this){
    public void onRequestPurchaseResponse(    String itemId,    ResponseCode response){
    }
    public void onPurchaseStateChanged(    String itemId,    PurchaseState state){
    }
    public void onBillingChecked(    boolean supported){
      if (!supported)       donate.setEnabled(false);
 else       if (!billingObserver.isTransactionsRestored())       BillingController.restoreTransactions(PreferencesActivity.this);
    }
  }
;
  BillingController.setConfiguration(new IConfiguration(){
    public String getPublicKey(){
      return PUBLIC_KEY;
    }
    public byte[] getObfuscationSalt(){
      return new byte[]{41,-90,-116,-41,66,-53,122,-110,-127,-96,-88,77,127,115,1,73,57,110,48,-116};
    }
  }
);
  BillingController.registerObserver(billingObserver);
  BillingController.checkBillingSupported(this);
  donate.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      BillingController.requestPurchase(PreferencesActivity.this,ANDROID_DONATE_ITEM,true);
      return false;
    }
  }
);
  boolean purchased=BillingController.isPurchased(this,ANDROID_DONATE_ITEM);
  if (purchased) {
    donate.setTitle(R.string.donate_thanks_preferences);
    donate.setEnabled(false);
  }
}
 

Example 22

From project LG-Optimus-2X-Black-Notifications, under directory /src/com/martinborjesson/o2xtouchlednotifications/ui/.

Source file: MainPreferences.java

  20 
vote

public CustomizablePreference(PreferenceScreen root,String pulseKey,String title){
  this.root=root;
  this.title=title;
  this.pulseKey=pulseKey;
  screen=getPreferenceManager().createPreferenceScreen(MainPreferences.this);
  screen.setOnPreferenceClickListener(this);
  screen.setPersistent(false);
  screen.setTitle(title);
  updateSummary(sharedPreferences.getBoolean(pulseKey + "." + Constants.PREFERENCE_KEY_CUSTOMIZED_PULSE,Constants.DEFAULT_CUSTOMIZED_PULSE));
{
    CheckBoxPreference cb=new CheckBoxPreference(MainPreferences.this);
    cb.setKey(pulseKey + "." + Constants.PREFERENCE_KEY_CUSTOMIZED_PULSE);
    cb.setDefaultValue(Constants.DEFAULT_CUSTOMIZED_PULSE);
    cb.setTitle(R.string.preference_title_customized_feedback);
    cb.setSummaryOn(R.string.preference_summaryon_customized_feedback);
    cb.setSummaryOff(R.string.preference_summaryoff_customized_feedback);
    cb.setOnPreferenceClickListener(new OnPreferenceClickListener(){
      @Override public boolean onPreferenceClick(      Preference preference){
        boolean checked=((CheckBoxPreference)preference).isChecked();
        updateSummary(checked);
        if (checked) {
          createFeedbackOptions(feedbackScreen,CustomizablePreference.this.pulseKey);
          updateTouchLEDButtonsOptions(MainService.toInt(sharedPreferences.getString(CustomizablePreference.this.pulseKey + "." + Constants.PREFERENCE_KEY_TOUCH_LED_MODE,String.valueOf(Constants.DEFAULT_PULSE_MODE)),Constants.DEFAULT_PULSE_MODE),CustomizablePreference.this.pulseKey);
        }
        ((BaseAdapter)CustomizablePreference.this.root.getRootAdapter()).notifyDataSetChanged();
        return true;
      }
    }
);
    screen.addPreference(cb);
  }
  feedbackScreen=getPreferenceManager().createPreferenceScreen(MainPreferences.this);
  feedbackScreen.setPersistent(false);
  feedbackScreen.setTitle(R.string.preference_title_customized_feedback_options);
  feedbackScreen.setSummary(R.string.preference_summary_customized_feedback_options);
  screen.addPreference(feedbackScreen);
  root.addPreference(screen);
}
 

Example 23

From project motelib, under directory /src/com/cafbit/motelib/settings/.

Source file: SettingsActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  MoteContext moteContext=MoteContext.getInstance(this);
  addPreferencesFromResource(moteContext.getSettingsXmlResource());
  Preference devicesPref=(Preference)findPreference("devicesPref");
  devicesPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      Intent intent=new Intent(SettingsActivity.this,DevicesActivity.class);
      startActivity(intent);
      return true;
    }
  }
);
  Preference resetPref=(Preference)findPreference("resetPref");
  resetPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      AlertDialog.Builder builder=new AlertDialog.Builder(SettingsActivity.this);
      builder.setPositiveButton("OK",new OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int which){
          MoteContext moteContext=MoteContext.getInstance(SettingsActivity.this);
          moteContext.coldReset();
          Toast.makeText(getBaseContext(),"Resetting to factory defaults...",Toast.LENGTH_LONG).show();
          SettingsActivity.this.finish();
        }
      }
);
      builder.setNegativeButton("Cancel",null);
      AlertDialog alertDialog=builder.create();
      alertDialog.setTitle("Are you sure?");
      alertDialog.setMessage("Are you sure you want to erase all configured devices, components, and other settings?");
      alertDialog.show();
      return true;
    }
  }
);
}
 

Example 24

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/ui/.

Source file: PrefActivity.java

  20 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.addPreferencesFromResource(R.xml.prefs);
  for (int i=0; i < getPreferenceScreen().getPreferenceCount(); i++) {
    initSummary(getPreferenceScreen().getPreference(i));
  }
  findPreference("login_name").setSummary(MWaterServer.getUsername(this));
  findPreference("logout").setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      MWaterServer.login(PrefActivity.this,null,null,new ArrayList<String>());
      Intent intent=new Intent(PrefActivity.this,SignupActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
      finish();
      return true;
    }
  }
);
}
 

Example 25

From project MWM-for-Android, under directory /src/org/metawatch/manager/.

Source file: Settings.java

  20 
vote

@Override protected void onStart(){
  Log.d(MetaWatch.TAG,"set onstart");
  editTextMac=(EditTextPreference)preferenceScreen.findPreference("MAC");
  editTextMac.setText(MetaWatchService.Preferences.watchMacAddress);
  discovery=preferenceScreen.findPreference("Discovery");
  discovery.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference arg0){
      Log.d(MetaWatch.TAG,"discovery click");
      startActivity(new Intent(context,DeviceSelection.class));
      return false;
    }
  }
);
  super.onStart();
}
 

Example 26

From project mythmote, under directory /src/tkj/android/homecontrol/mythmote/.

Source file: MythMotePreferences.java

  20 
vote

private static Preference createLocationPreference(final Activity context,String key,String name,String value){
  Preference pref=new Preference(context);
  pref.setKey(key);
  pref.setTitle(name);
  pref.setDefaultValue(value);
  pref.setEnabled(true);
  pref.setSummary(value);
  pref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      FrontendLocation location=new FrontendLocation();
      location.ID=Integer.parseInt(preference.getKey());
      MythMoteDbManager dbAdapter=new MythMoteDbManager(context);
      dbAdapter.open();
      Cursor cursor=dbAdapter.fetchFrontendLocation(location.ID);
      _idIndex=cursor.getColumnIndex(MythMoteDbHelper.KEY_ROWID);
      _addressIndex=cursor.getColumnIndex(MythMoteDbHelper.KEY_ADDRESS);
      _nameIndex=cursor.getColumnIndex(MythMoteDbHelper.KEY_NAME);
      _portIndex=cursor.getColumnIndex(MythMoteDbHelper.KEY_PORT);
      if (cursor != null && cursor.getCount() > 0) {
        location.Name=cursor.getString(_nameIndex);
        location.Address=cursor.getString(_addressIndex);
        location.Port=cursor.getInt(_portIndex);
        showLocationEditDialog(context,location);
      }
      return false;
    }
  }
);
  return pref;
}
 

Example 27

From project NotePad, under directory /src/com/nononsenseapps/notepad/prefs/.

Source file: SyncPrefs.java

  20 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.app_pref_sync);
  prefAccount=findPreference(KEY_ACCOUNT);
  prefSyncFreq=findPreference(KEY_SYNC_FREQ);
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(activity);
  sharedPrefs.registerOnSharedPreferenceChangeListener(this);
  setAccountTitle(sharedPrefs);
  setFreqSummary(sharedPrefs);
  prefAccount.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      showAccountDialog();
      return true;
    }
  }
);
}
 

Example 28

From project Notes, under directory /src/net/micode/notes/ui/.

Source file: NotesPreferenceActivity.java

  20 
vote

private void loadAccountPreference(){
  mAccountCategory.removeAll();
  Preference accountPref=new Preference(this);
  final String defaultAccount=getSyncAccountName(this);
  accountPref.setTitle(getString(R.string.preferences_account_title));
  accountPref.setSummary(getString(R.string.preferences_account_summary));
  accountPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      if (!GTaskSyncService.isSyncing()) {
        if (TextUtils.isEmpty(defaultAccount)) {
          showSelectAccountAlertDialog();
        }
 else {
          showChangeAccountConfirmAlertDialog();
        }
      }
 else {
        Toast.makeText(NotesPreferenceActivity.this,R.string.preferences_toast_cannot_change_account,Toast.LENGTH_SHORT).show();
      }
      return true;
    }
  }
);
  mAccountCategory.addPreference(accountPref);
}
 

Example 29

From project packages_apps_Phone_1, under directory /src/com/android/phone/sip/.

Source file: SipSettings.java

  20 
vote

private void registerForReceiveCallsCheckBox(){
  mButtonSipReceiveCalls=(CheckBoxPreference)findPreference(BUTTON_SIP_RECEIVE_CALLS);
  mButtonSipReceiveCalls.setChecked(mSipSharedPreferences.isReceivingCallsEnabled());
  mButtonSipReceiveCalls.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      final boolean enabled=((CheckBoxPreference)preference).isChecked();
      new Thread(new Runnable(){
        public void run(){
          handleSipReceiveCallsOption(enabled);
        }
      }
).start();
      return true;
    }
  }
);
}
 

Example 30

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/sip/.

Source file: SipSettings.java

  20 
vote

private void registerForReceiveCallsCheckBox(){
  mButtonSipReceiveCalls=(CheckBoxPreference)findPreference(BUTTON_SIP_RECEIVE_CALLS);
  mButtonSipReceiveCalls.setChecked(mSipSharedPreferences.isReceivingCallsEnabled());
  mButtonSipReceiveCalls.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      final boolean enabled=((CheckBoxPreference)preference).isChecked();
      new Thread(new Runnable(){
        public void run(){
          handleSipReceiveCallsOption(enabled);
        }
      }
).start();
      return true;
    }
  }
);
}
 

Example 31

From project platform_packages_apps_phone, under directory /src/com/android/phone/sip/.

Source file: SipSettings.java

  20 
vote

private void registerForReceiveCallsCheckBox(){
  mButtonSipReceiveCalls=(CheckBoxPreference)findPreference(BUTTON_SIP_RECEIVE_CALLS);
  mButtonSipReceiveCalls.setChecked(mSipSharedPreferences.isReceivingCallsEnabled());
  mButtonSipReceiveCalls.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      final boolean enabled=((CheckBoxPreference)preference).isChecked();
      new Thread(new Runnable(){
        public void run(){
          handleSipReceiveCallsOption(enabled);
        }
      }
).start();
      return true;
    }
  }
);
}
 

Example 32

From project ROM-Updater, under directory /src/org/elegosproject/romupdater/.

Source file: Preferences.java

  20 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  preferences=PreferenceManager.getDefaultSharedPreferences(this);
  Preference barcode=findPreference("repository_url_qr");
  Preference romList=findPreference("repository_list");
  romList.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      Intent repoList=new Intent(Preferences.this,RepositoriesList.class);
      startActivity(repoList);
      return false;
    }
  }
);
  barcode.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      Intent scanner=new Intent("com.google.zxing.client.android.SCAN");
      scanner.putExtra("SCAN_MODE","QR_CODE_MODE");
      try {
        startActivityForResult(scanner,0);
      }
 catch (      Exception e) {
        Log.e(TAG,e.toString());
        AlertDialog.Builder dialog=new AlertDialog.Builder(Preferences.this);
        dialog.setMessage(getString(R.string.barcode_scanner_not_found)).setCancelable(false).setPositiveButton(getString(R.string.OK),new DialogInterface.OnClickListener(){
          public void onClick(          DialogInterface dialog,          int which){
            dialog.dismiss();
          }
        }
);
        AlertDialog alert=dialog.create();
        alert.show();
      }
      return false;
    }
  }
);
}
 

Example 33

From project safe, under directory /Safe/src/org/openintents/safe/.

Source file: Preferences.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  frontdoor=new Intent(this,Safe.class);
  frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
  restartTimerIntent=new Intent(CryptoIntents.ACTION_RESTART_TIMER);
  addPreferencesFromResource(R.xml.preferences);
  Preference backupPathPref=findPreference(PREFERENCE_BACKUP_PATH);
  backupPathPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference pref){
      Intent intent=new Intent("org.openintents.action.PICK_FILE");
      intent.setData(Uri.parse("file://" + getBackupPath(Preferences.this)));
      intent.putExtra("org.openintents.extra.TITLE",R.string.backup_select_file);
      if (intentCallable(intent))       startActivityForResult(intent,REQUEST_BACKUP_FILENAME);
 else       askForFileManager();
      return false;
    }
  }
);
  Preference exportPathPref=findPreference(PREFERENCE_EXPORT_PATH);
  exportPathPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference pref){
      Intent intent=new Intent("org.openintents.action.PICK_FILE");
      intent.setData(Uri.parse("file://" + getExportPath(Preferences.this)));
      intent.putExtra("org.openintents.extra.TITLE",R.string.export_file_select);
      if (intentCallable(intent))       startActivityForResult(intent,REQUEST_EXPORT_FILENAME);
 else       askForFileManager();
      return false;
    }
  }
);
  getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  changePreferenceSummaryToCurrentValue(backupPathPref,getBackupPath(this));
  changePreferenceSummaryToCurrentValue(exportPathPref,getExportPath(this));
  if (CheckWrappers.mActionBarAvailable) {
    WrapActionBar bar=new WrapActionBar(this);
    bar.setDisplayHomeAsUpEnabled(true);
  }
}
 

Example 34

From project StrokeIME, under directory /src/org/strokeime/.

Source file: StrokeIMESettings.java

  20 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    mStrokeIMEVersion=getPackageManager().getPackageInfo(getPackageName(),0).versionName;
  }
 catch (  Exception ex) {
    throw new RuntimeException("This is impossible: " + ex.getMessage());
  }
  LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  mViewAbout=inflater.inflate(R.layout.about,null);
  addPreferencesFromResource(R.xml.prefs);
  mAboutPreference=(Preference)findPreference("about_preference");
  mAboutPreference.setSummary(String.format(getString(R.string.about_preference_summary),mStrokeIMEVersion));
  mAboutPreference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    Preference preference){
      showDialog(DIALOG_ABOUT);
      return true;
    }
  }
);
}
 

Example 35

From project ub0rlib, under directory /src/de/ub0r/android/lib/.

Source file: Market.java

  20 
vote

/** 
 * Set a  {@link OnPreferenceClickListener} to preference to launch any market app.
 * @param activity {@link Activity} to launch the {@link Intent}
 * @param preference {@link Preference} to set the {@link OnPreferenceClickListener} to
 * @param packagename package name to install
 * @param search search to look for; ignored if packagename is not null
 * @param alternativeLink alternative source to get the content
 */
public static void setOnPreferenceClickListener(final Activity activity,final Preference preference,final String packagename,final String search,final String alternativeLink){
  if (preference == null) {
    return;
  }
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    @Override public boolean onPreferenceClick(    final Preference preference){
      if (!TextUtils.isEmpty(packagename)) {
        installApp(activity,packagename,alternativeLink);
        return true;
      }
      if (!TextUtils.isEmpty(search)) {
        searchApp(activity,search,alternativeLink);
        return true;
      }
      return false;
    }
  }
);
}
 

Example 36

From project vlc-android, under directory /vlc-android/src/org/videolan/vlc/android/.

Source file: PreferencesActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  Preference directoriesPref=(Preference)findPreference("directories");
  directoriesPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      Intent intent=new Intent(MainActivity.getInstance(),BrowserActivity.class);
      startActivity(intent);
      return true;
    }
  }
);
  Preference clearHistoryPref=(Preference)findPreference("clear_history");
  clearHistoryPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      new AlertDialog.Builder(PreferencesActivity.this).setTitle(R.string.clear_history).setMessage(R.string.validation).setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int whichButton){
          DatabaseManager db=DatabaseManager.getInstance();
          db.clearSearchhistory();
        }
      }
).setNegativeButton(android.R.string.cancel,null).show();
      return true;
    }
  }
);
  Preference quitAppPref=(Preference)findPreference("quit_app");
  quitAppPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      System.exit(0);
      return true;
    }
  }
);
}