Android Open Source - TumblifeForAndroid Setting






From Project

Back to project page TumblifeForAndroid.

License

The source code is released under:

GNU General Public License

If you think the Android project TumblifeForAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jp.mitukiii.tumblife;
/*from ww w. j av a 2 s .  c  o  m*/
import java.io.File;
import jp.mitukiii.tumblife.R;
import jp.mitukiii.tumblife.model.TLSetting.DASHBOARD_TYPE;
import jp.mitukiii.tumblife.util.TLExplorer;
import jp.mitukiii.tumblife.util.TLLog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;

public class Setting extends PreferenceActivity
{ 
  protected Context context;

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.setting);

    context = this;

    ListPreference viewMode = (ListPreference) findPreference(getString(R.string.setting_dashboardtype_key));
    viewMode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
      @Override
      public boolean onPreferenceChange(Preference preference, Object newValue)
      {
        TLLog.d("onPreferenceChange");
        ListPreference viewMode = (ListPreference) preference;
        viewMode.setValue((String)newValue);
        togglePreference(preference);
        return true;
      }
    });
  }

  @Override
  protected void onResume()
  {
    super.onResume();
    togglePreference(findPreference(getString(R.string.setting_usepin_key)));
    togglePreference(findPreference(getString(R.string.setting_dashboardtype_key)));
  }

  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
  {
    if (getString(R.string.setting_hardkey_key).equals(preference.getKey())) {
      Intent intent = new Intent(context, HardkeySetting.class);
      startActivity(intent);
    } else if (getString(R.string.clearcache_key).equals(preference.getKey())) {
      clearCache();
    } else {
      togglePreference(preference);
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }

  protected void togglePreference(Preference preference)
  {
    String key = preference.getKey();
    if (getString(R.string.setting_usepin_key).equals(key)) {
      CheckBoxPreference usePin = (CheckBoxPreference) preference;
      ListPreference pinAction = (ListPreference) findPreference(getString(R.string.setting_pinaction_key));
      if (usePin.isChecked()) {
        pinAction.setEnabled(true);
      } else {
        pinAction.setEnabled(false);
      }
    } else if (getString(R.string.setting_dashboardtype_key).equals(key)) {
      ListPreference viewMode = (ListPreference) preference;
      CheckBoxPreference skipPhotos = (CheckBoxPreference) findPreference(getString(R.string.setting_skipphotos_key));
      if (DASHBOARD_TYPE.Default == DASHBOARD_TYPE.valueOf(viewMode.getValue())) {
        skipPhotos.setEnabled(true);
      } else {
        skipPhotos.setEnabled(false);
      }
    }
  }

  protected void clearCache()
  {
    App.isClearCached = true;

    final ProgressDialog progressDialog = new ProgressDialog(context);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setTitle(R.string.clearcache_now_title);
    progressDialog.setCancelable(false);
    progressDialog.show();

    final Handler handler = new Handler();

    new Thread() {
      public void run() {
        TLExplorer.deleteFiles(new File(TLExplorer.HTML_DIR).listFiles());
        TLExplorer.deleteFiles(new File(TLExplorer.IMAGE_DIR).listFiles());

        handler.post(new Runnable() {
          public void run() {
            progressDialog.dismiss();
          }
        });
      }
    }.start();
  }
}




Java Source Code List

jp.mitukiii.tumblife.App.java
jp.mitukiii.tumblife.HardkeySetting.java
jp.mitukiii.tumblife.KeyCodeMap.java
jp.mitukiii.tumblife.Main.java
jp.mitukiii.tumblife.Setting.java
jp.mitukiii.tumblife.exeption.TLAuthenticationFailureException.java
jp.mitukiii.tumblife.exeption.TLFailureException.java
jp.mitukiii.tumblife.exeption.TLParserException.java
jp.mitukiii.tumblife.exeption.TLSDCardNotFoundException.java
jp.mitukiii.tumblife.model.TLModel.java
jp.mitukiii.tumblife.model.TLPost.java
jp.mitukiii.tumblife.model.TLSetting.java
jp.mitukiii.tumblife.model.TLTumblelog.java
jp.mitukiii.tumblife.model.TLUser.java
jp.mitukiii.tumblife.parser.TLParser.java
jp.mitukiii.tumblife.parser.TLPostParser.java
jp.mitukiii.tumblife.parser.TLUserParser.java
jp.mitukiii.tumblife.tumblr.TLDashboardDelegate.java
jp.mitukiii.tumblife.tumblr.TLDashboardInterface.java
jp.mitukiii.tumblife.tumblr.TLDashboard.java
jp.mitukiii.tumblife.ui.TLWebViewClientDelegate.java
jp.mitukiii.tumblife.ui.TLWebViewClient.java
jp.mitukiii.tumblife.util.TLBrowser.java
jp.mitukiii.tumblife.util.TLConnection.java
jp.mitukiii.tumblife.util.TLExplorer.java
jp.mitukiii.tumblife.util.TLLog.java
jp.mitukiii.tumblife.util.TLPostFactory.java