Android Open Source - HomeMovies Screen Preferences






From Project

Back to project page HomeMovies.

License

The source code is released under:

MIT License

If you think the Android project HomeMovies 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 il.co.All4Students.homemovies;
/*from  w w w  .jav a  2s.c o m*/
import il.co.All4Students.homemovies.app.ApplicationPreference;
import il.co.All4Students.homemovies.util.log.util.AppLog;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

/**
 * Preferences screen
 * 
 * @author Arkadi Yoskovitz
 * @date 2013-02-08
 */
public class ScreenPreferences extends PreferenceActivity {
  // Attributes
  private ApplicationPreference mSettings;
  private String mLanguage;

  // System Events
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle aSavedState) {
    super.onCreate(aSavedState);
    addPreferencesFromResource(R.xml.screen_preferences);
  }

  @Override
  protected void onResume() {
    super.onResume();
    mSettings = new ApplicationPreference(ScreenPreferences.this);
    mLanguage = mSettings.getLanguage();
  }

  @Override
  public void onBackPressed() {
    super.onBackPressed();

    SharedPreferences sharedPrefs = PreferenceManager
        .getDefaultSharedPreferences(this);

    String subject = sharedPrefs.getString("AppPreffSubject",
        "Default Topic");
    String email = sharedPrefs.getString("AppPreffEmail",
        "John.Appleseed@iCloud.com");
    String language = sharedPrefs.getString("AppPreffLanguage", "EN");
    int sortMethod = Integer.parseInt(sharedPrefs.getString(
        "AppPreffSortMethods", "0"));
    boolean isColored = sharedPrefs.getBoolean("AppPreffEnableColor", true);
    boolean isPreview = sharedPrefs.getBoolean("AppPreffEnablePreview",
        true);
    boolean toLog = sharedPrefs.getBoolean("AppPreffEnableLog", false);
    boolean toClearLog = sharedPrefs.getBoolean("AppPreffEnableClearLog",
        true);

    if (email.length() == 0) {
      mSettings.setEmail("John.Appleseed@iCloud.com.com");
    }

    mSettings.setSubject(subject);
    mSettings.setEmail(email);
    mSettings.setLanguage(language);
    mSettings.setSortMethod(sortMethod);
    mSettings.setEnableColor(isColored);
    mSettings.setEnablePreview(isPreview);
    mSettings.setEnableLog(toLog);

    if (!mLanguage.equals(mSettings.getLanguage())) {
      AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

      mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000,
          PendingIntent.getActivity(getApplication()
              .getApplicationContext(), 0,
              new Intent(getIntent()),
              Intent.FLAG_ACTIVITY_NEW_TASK));
      System.exit(2);
    }

    if (!toClearLog) {
      AppLog.getAllLogs(ScreenPreferences.this);
    }

  }
}




Java Source Code List

il.co.All4Students.homemovies.OkCancelBar.java
il.co.All4Students.homemovies.ScreenEdit.java
il.co.All4Students.homemovies.ScreenGridDetail.java
il.co.All4Students.homemovies.ScreenGrid.java
il.co.All4Students.homemovies.ScreenMain.java
il.co.All4Students.homemovies.ScreenPreferences.java
il.co.All4Students.homemovies.ScreenWeb.java
il.co.All4Students.homemovies.app.AppConstants.java
il.co.All4Students.homemovies.app.ApplicationPreference.java
il.co.All4Students.homemovies.app.HomeProjectApplication.java
il.co.All4Students.homemovies.core.ItemCompareRTID.java
il.co.All4Students.homemovies.core.ItemCompareRank.java
il.co.All4Students.homemovies.core.ItemCompareSubject.java
il.co.All4Students.homemovies.core.Item.java
il.co.All4Students.homemovies.util.adapter.ItemListAdapter.java
il.co.All4Students.homemovies.util.adapter.ScreenGridAdapter.java
il.co.All4Students.homemovies.util.app.AppUtil.java
il.co.All4Students.homemovies.util.db.ItemsDbConstants.java
il.co.All4Students.homemovies.util.db.ItemsDbHelper.java
il.co.All4Students.homemovies.util.db.ItemsHandler.java
il.co.All4Students.homemovies.util.dialog.RankDialog.java
il.co.All4Students.homemovies.util.dialog.ShareDialog.java
il.co.All4Students.homemovies.util.email.EmailUtil.java
il.co.All4Students.homemovies.util.image.ExternalStorageLoader.java
il.co.All4Students.homemovies.util.imageWeb.FileCache.java
il.co.All4Students.homemovies.util.imageWeb.ImageLoader.java
il.co.All4Students.homemovies.util.imageWeb.MemoryCache.java
il.co.All4Students.homemovies.util.json.JSONHandler.java
il.co.All4Students.homemovies.util.json.JSONUtilWithTags.java
il.co.All4Students.homemovies.util.json.JSONUtil.java
il.co.All4Students.homemovies.util.log.db.LogDbConstants.java
il.co.All4Students.homemovies.util.log.db.LogDbHelper.java
il.co.All4Students.homemovies.util.log.db.LogHandler.java
il.co.All4Students.homemovies.util.log.util.AppLog.java