Back to project page EBrowser.
The source code is released under:
GNU General Public License
If you think the Android project EBrowser listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Zirco Browser for Android/*from w w w . java 2 s . c o m*/ * * Copyright (C) 2010 J. Devauchelle and contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 3 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package org.zirco.ui.activities.preferences; import com.mrpej.ebrowser.R; import org.zirco.utils.Constants; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.preference.PreferenceManager; /** * Search url preference chooser activity. */ public class SearchUrlPreferenceActivity extends BaseSpinnerCustomPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override protected int getSpinnerPromptId() { return R.string.SearchUrlPreferenceActivity_Prompt; } @Override protected int getSpinnerValuesArrayId() { return R.array.SearchUrlValues; } @Override protected void setSpinnerValueFromPreferences() { String currentSearchUrl = PreferenceManager.getDefaultSharedPreferences(this).getString(Constants.PREFERENCES_GENERAL_SEARCH_URL, Constants.URL_SEARCH_GOOGLE); if (currentSearchUrl.equals(Constants.URL_SEARCH_GOOGLE)) { mSpinner.setSelection(0); mCustomEditText.setEnabled(false); mCustomEditText.setText(Constants.URL_SEARCH_GOOGLE); } else if (currentSearchUrl.equals(Constants.URL_SEARCH_WIKIPEDIA)) { mSpinner.setSelection(1); mCustomEditText.setEnabled(false); mCustomEditText.setText(Constants.URL_SEARCH_WIKIPEDIA); } else { mSpinner.setSelection(2); mCustomEditText.setEnabled(true); mCustomEditText.setText(currentSearchUrl); } } @Override protected void onSpinnerItemSelected(int position) { switch (position) { case 0: mCustomEditText.setEnabled(false); mCustomEditText.setText(Constants.URL_SEARCH_GOOGLE); break; case 1: mCustomEditText.setEnabled(false); mCustomEditText.setText(Constants.URL_SEARCH_WIKIPEDIA); break; case 2: { mCustomEditText.setEnabled(true); if ((mCustomEditText.getText().toString().equals(Constants.URL_SEARCH_GOOGLE)) || (mCustomEditText.getText().toString().equals(Constants.URL_SEARCH_WIKIPEDIA))) { mCustomEditText.setText(null); } break; } default: mCustomEditText.setEnabled(false); mCustomEditText.setText(Constants.URL_SEARCH_GOOGLE); break; } } @Override protected void onOk() { Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putString(Constants.PREFERENCES_GENERAL_SEARCH_URL, mCustomEditText.getText().toString()); editor.commit(); } }