Android Open Source - PhoneProfiles_Eclipse Phone Profiles Preferences Activity






From Project

Back to project page PhoneProfiles_Eclipse.

License

The source code is released under:

Apache License

If you think the Android project PhoneProfiles_Eclipse 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 sk.henrichg.phoneprofiles;
//  ww  w  . j  av  a2s  . c o m
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceScreen;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;

public class PhoneProfilesPreferencesActivity extends ActionBarActivity
{

  private SharedPreferences preferences;
  
  private boolean showEditorPrefIndicator;
  private boolean showEditorHeader;
  private String activeLanguage;
  private String activeTheme;
  //private String activeBackgroundProfile;

  private boolean invalidateEditor = false;
   
  
  @Override 
  public void onCreate(Bundle savedInstanceState) {

    // must by called before super.onCreate() for PreferenceActivity
    GUIData.setTheme(this, false);
    GUIData.setLanguage(getBaseContext());
    
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.activity_phone_profiles_preferences);
    
    invalidateEditor = false;
    
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.title_activity_phone_profiles_preferences);
    
    
        preferences = getBaseContext().getSharedPreferences(GlobalData.APPLICATION_PREFS_NAME, MODE_PRIVATE);
        activeLanguage = preferences.getString(GlobalData.PREF_APPLICATION_LANGUAGE, "system");
        activeTheme = preferences.getString(GlobalData.PREF_APPLICATION_THEME, "material");
        showEditorPrefIndicator = preferences.getBoolean(GlobalData.PREF_APPLICATION_EDITOR_PREF_INDICATOR, true);
        showEditorHeader = preferences.getBoolean(GlobalData.PREF_APPLICATION_EDITOR_HEADER, true);
        //activeBackgroundProfile = preferences.getString(GlobalData.PREF_APPLICATION_BACKGROUND_PROFILE, "-999");
        
    
    if (savedInstanceState == null) {
      PhoneProfilesPreferencesFragment fragment = new PhoneProfilesPreferencesFragment();
      getFragmentManager().beginTransaction()
          .replace(R.id.activity_phone_profiles_preferences_container, fragment, "PhoneProfilesPreferencesFragment").commit();
    }
    
        
  }

  @Override
  public void onConfigurationChanged(Configuration newConfig)
  {
    super.onConfigurationChanged(newConfig);
    
    getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
    GUIData.reloadActivity(this, false);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    
    switch (item.getItemId()) {
    case android.R.id.home:
      finish();
      return true;
    default:
      return super.onOptionsItemSelected(item);
    }
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
    PhoneProfilesPreferencesFragment fragment = (PhoneProfilesPreferencesFragment)getFragmentManager().findFragmentById(R.id.activity_phone_profiles_preferences_container);
    if (fragment != null)
      fragment.doOnActivityResult(requestCode, resultCode, data);
  }
  
  @Override
  protected void onStart()
  {
    super.onStart();
  }
  
  @Override
  protected void onPause()
  {
    super.onPause();
  }

  @Override
  protected void onStop()
  {
    super.onStop();
    
    DataWrapper dataWrapper =  new DataWrapper(this.getBaseContext(), true, false, 0);
    dataWrapper.getActivateProfileHelper().initialize(this, getBaseContext());
    dataWrapper.getActivateProfileHelper().showNotification(dataWrapper.getActivatedProfileFromDB());
    dataWrapper.getActivateProfileHelper().updateWidget();
    dataWrapper.invalidateDataWrapper();
    
  }
  
  @Override
  protected void onDestroy()
  {
    super.onDestroy();
  }

  @Override
  public void finish() {
    
    GlobalData.loadPreferences(getBaseContext());
    
    if (activeLanguage != GlobalData.applicationLanguage)
    {
        //Log.d("PhoneProfilesPreferencesActivity.onPause","language changed");
      GUIData.setLanguage(getBaseContext());
      invalidateEditor = true;
    }
    else
    if (activeTheme != GlobalData.applicationTheme)
    {
        //Log.d("PhoneProfilesPreferencesActivity.onPause","theme changed");
        //EditorProfilesActivity.setTheme(this, false);
      invalidateEditor = true;
    }
    else
       if (showEditorPrefIndicator != GlobalData.applicationEditorPrefIndicator)
       {
           //Log.d("PhoneProfilesPreferencesActivity.onPause","invalidate");
         invalidateEditor = true;
       }
    else
       if (showEditorHeader != GlobalData.applicationEditorHeader)
       {
           //Log.d("PhoneProfilesPreferencesActivity.onPause","invalidate");
         invalidateEditor = true;
       }

    /*
    if (activeBackgroundProfile != GlobalData.applicationBackgroundProfile)
       {
         long lApplicationBackgroundProfile = Long.valueOf(GlobalData.applicationBackgroundProfile);
         if (lApplicationBackgroundProfile != GlobalData.PROFILE_NO_ACTIVATE)
         {
           DataWrapper dataWrapper = new DataWrapper(getBaseContext(), true, false, 0);
           if (dataWrapper.getActivatedProfile() == null)
           {
             dataWrapper.getActivateProfileHelper().initialize(null, getBaseContext());
             dataWrapper.activateProfile(lApplicationBackgroundProfile, GlobalData.STARTUP_SOURCE_SERVICE, null);
           }
           //invalidateEditor = true;
         }
       }
       */
    
    // for startActivityForResult
    Intent returnIntent = new Intent();
    returnIntent.putExtra(GlobalData.EXTRA_RESET_EDITOR, invalidateEditor);
    setResult(RESULT_OK,returnIntent);

      super.finish();
  }

  public void onPreferenceAttached(PreferenceScreen root, int xmlId) {
    
  }

}




Java Source Code List

sk.henrichg.phoneprofiles.ActivateProfileActivity.java
sk.henrichg.phoneprofiles.ActivateProfileHelper.java
sk.henrichg.phoneprofiles.ActivateProfileListAdapter.java
sk.henrichg.phoneprofiles.ActivateProfileListFragment.java
sk.henrichg.phoneprofiles.ApplicationsCache.java
sk.henrichg.phoneprofiles.ApplicationsPreferenceAdapter.java
sk.henrichg.phoneprofiles.ApplicationsPreferenceDialog.java
sk.henrichg.phoneprofiles.ApplicationsPreference.java
sk.henrichg.phoneprofiles.BackgroundActivateProfileActivity.java
sk.henrichg.phoneprofiles.BitmapManipulator.java
sk.henrichg.phoneprofiles.BootUpReceiver.java
sk.henrichg.phoneprofiles.BrightnessDialogPreference.java
sk.henrichg.phoneprofiles.BrightnessView.java
sk.henrichg.phoneprofiles.DashClockBroadcastReceiver.java
sk.henrichg.phoneprofiles.DataWrapper.java
sk.henrichg.phoneprofiles.DatabaseHandler.java
sk.henrichg.phoneprofiles.EditorProfileListAdapter.java
sk.henrichg.phoneprofiles.EditorProfileListFragment.java
sk.henrichg.phoneprofiles.EditorProfilesActivity.java
sk.henrichg.phoneprofiles.ExecuteRadioProfilePrefsService.java
sk.henrichg.phoneprofiles.ExecuteVolumeProfilePrefsService.java
sk.henrichg.phoneprofiles.FirstStartService.java
sk.henrichg.phoneprofiles.GUIData.java
sk.henrichg.phoneprofiles.GlobalData.java
sk.henrichg.phoneprofiles.IconWidgetProvider.java
sk.henrichg.phoneprofiles.ImageViewPreferenceAdapter.java
sk.henrichg.phoneprofiles.ImageViewPreferenceDialog.java
sk.henrichg.phoneprofiles.ImageViewPreference.java
sk.henrichg.phoneprofiles.KeyguardService.java
sk.henrichg.phoneprofiles.Keyguard.java
sk.henrichg.phoneprofiles.LocaleChangedReceiver.java
sk.henrichg.phoneprofiles.NumberPickerPreference.java
sk.henrichg.phoneprofiles.OneRowWidgetProvider.java
sk.henrichg.phoneprofiles.PackageReplacedReceiver.java
sk.henrichg.phoneprofiles.PhoneCallBroadcastReceiver.java
sk.henrichg.phoneprofiles.PhoneCallReceiver.java
sk.henrichg.phoneprofiles.PhoneProfilesDashClockExtension.java
sk.henrichg.phoneprofiles.PhoneProfilesHelper.java
sk.henrichg.phoneprofiles.PhoneProfilesPreferencesActivity.java
sk.henrichg.phoneprofiles.PhoneProfilesPreferencesFragment.java
sk.henrichg.phoneprofiles.ProfileDurationAlarmBroadcastReceiver.java
sk.henrichg.phoneprofiles.ProfileListWidgetFactory.java
sk.henrichg.phoneprofiles.ProfileListWidgetProvider.java
sk.henrichg.phoneprofiles.ProfileListWidgetService.java
sk.henrichg.phoneprofiles.ProfilePreferenceAdapter.java
sk.henrichg.phoneprofiles.ProfilePreferenceDialog.java
sk.henrichg.phoneprofiles.ProfilePreference.java
sk.henrichg.phoneprofiles.ProfilePreferencesFragmentActivity.java
sk.henrichg.phoneprofiles.ProfilePreferencesFragment.java
sk.henrichg.phoneprofiles.ProfilePreferencesIndicator.java
sk.henrichg.phoneprofiles.Profile.java
sk.henrichg.phoneprofiles.ReceiversService.java
sk.henrichg.phoneprofiles.RefreshGUIBroadcastReceiver.java
sk.henrichg.phoneprofiles.RemoteExportDataActivity.java
sk.henrichg.phoneprofiles.RemoveBrightnessViewBroadcastReceiver.java
sk.henrichg.phoneprofiles.ScreenOnOffBroadcastReceiver.java
sk.henrichg.phoneprofiles.ShortcutCreatorActivity.java
sk.henrichg.phoneprofiles.ShortcutCreatorListFragment.java
sk.henrichg.phoneprofiles.ShortcutProfileListAdapter.java
sk.henrichg.phoneprofiles.UpgradePPHelperActivity.java
sk.henrichg.phoneprofiles.VolumeDialogPreference.java