Back to project page Gazetti_Newspaper_Reader.
The source code is released under:
MIT License
If you think the Android project Gazetti_Newspaper_Reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package in.sahildave.gazetti.preference; //from www .j av a 2 s .c om import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.view.MenuItem; import com.crashlytics.android.Crashlytics; import in.sahildave.gazetti.R; public class SettingsActivity extends PreferenceActivity { int ActionBarColorId = -1; private String app_ver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try{ app_ver = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { Crashlytics.logException(e); } } @SuppressLint("NewApi") @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); setupSimplePreferencesScreen(); ActionBarColorId = getIntent().getIntExtra("ActionBarColor", -1); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); if (ActionBarColorId != -1) { getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setBackgroundDrawable(new ColorDrawable(ActionBarColorId)); getActionBar().setDisplayShowTitleEnabled(true); } else { getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setBackgroundDrawable( new ColorDrawable(getResources().getColor(R.color.actionbar_default_color))); getActionBar().setDisplayShowTitleEnabled(true); } } // Feed Selector Preference feedSelectPref = (Preference) findPreference("feedSelectPref"); feedSelectPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent feedIntent = new Intent(SettingsActivity.this, FeedSelectSettingsActivity.class); if (ActionBarColorId != -1) { feedIntent.putExtra("ActionBarColor", ActionBarColorId); } startActivity(feedIntent); return true; } }); // License Section Preference licensePref = (Preference) findPreference("licensePref"); licensePref.setSummary("Build Version : "+app_ver); licensePref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent licenseIntent = new Intent(SettingsActivity.this, LicensesActivity.class); if (ActionBarColorId != -1) { licenseIntent.putExtra("ActionBarColor", ActionBarColorId); } startActivity(licenseIntent); return true; } }); // // About Me // Preference aboutPref = (Preference) findPreference("aboutPref"); // aboutPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { // public boolean onPreferenceClick(Preference preference) { // // Intent aboutMeIntent = new Intent(SettingsActivity.this, AboutMeActivity.class); // if (ActionBarColorId != -1) { // aboutMeIntent.putExtra("ActionBarColor", ActionBarColorId); // } // startActivity(aboutMeIntent); // return false; // } // }); } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { onBackPressed(); return true; } return super.onOptionsItemSelected(item); } private void setupSimplePreferencesScreen() { // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); } }