Android Open Source - Text-Edit-for-Android Edit Preferences






From Project

Back to project page Text-Edit-for-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project Text-Edit-for-Android 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 org.paulmach.textedit;
//from w  w w .  j  a  va2s. c o m
import java.io.File;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;


/* EditPreferences
 *     Simple activity that just displays the preferences
 *     nothing really different here */
public class EditPreferences extends PreferenceActivity
{    
  public void onCreate(Bundle savedInstanceState)
  {  
    super.onCreate(savedInstanceState);  

    // add preferences
    addPreferencesFromResource(R.xml.preferences);    
    
    // default dir value to display
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String current = sharedPref.getString("defaultdir", "/sdcard/");

    Preference p = findPreference("defaultdir");
    p.setSummary(current);
  }
  
  /****************************************************************
   * onActivityResult()
   *     results of a launched activity */
  protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
    super.onActivityResult(requestCode, resultCode, data);

    String location = data.getAction();
    
    File f = new File(location);
    if (f.toString().equals("/"))
      location = "/";
    else if (f.isDirectory())
      location = f.toString() + "/";  
    else if (f.getParent().toString().equals("/"))
      location = "/";
    else
      location = f.getParent() + "/";
    
    // save the directory
    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit();
    editor.putString("defaultdir", location);
    editor.commit();
    
    // update the display
    Preference p = findPreference("defaultdir");
    p.setSummary(location);    
  }
} // end class EditPreferences





Java Source Code List

org.paulmach.textedit.ClearRecentFileListPreference.java
org.paulmach.textedit.ClearSearchSuggestions.java
org.paulmach.textedit.ColorPreference.java
org.paulmach.textedit.DefaultDirPreference.java
org.paulmach.textedit.EditPreferences.java
org.paulmach.textedit.FileAutoCompleteArrayAdapter.java
org.paulmach.textedit.FileBrowser.java
org.paulmach.textedit.FileViewArrayAdapter.java
org.paulmach.textedit.FontSizePreference.java
org.paulmach.textedit.FontTypePreference.java
org.paulmach.textedit.SearchSuggestions.java
org.paulmach.textedit.WarrantyPreference.java
org.paulmach.textedit.pmTextEdit.java