Android Open Source - WlanLogin File Select Preference






From Project

Back to project page WlanLogin.

License

The source code is released under:

GNU General Public License

If you think the Android project WlanLogin 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.xii.relog.setting;
//from  w ww . ja v  a  2s  .co  m
import java.io.File;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Toast;
import jp.xii.relog.setting.FileListDialog;
import jp.xii.relog.setting.FileListDialog.onFileListDialogListener;


/**
 * ??????????????
 * @author Iori
 *
 * ???????
 * rootPath : ????????????????
 */
public class FileSelectPreference extends DialogPreference
  implements FileListDialog.onFileListDialogListener{

  private String _rootPath = "/";      //?????
  private String _defaultPath = "";    //??????????????????????
  
  /**
   * ???????
   * @param context
   * @param attrs
   */
  public FileSelectPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    
    //??????????????
    String default_value = attrs.getAttributeValue(null, "defaultValue");
    if(default_value == null){
      _defaultPath = "/";
    }else{
      _defaultPath = default_value;
    }
  }

  /**
   * ???????????????????????
   */
  @Override
  protected void onBindView(View view) {
    //???????????
    SharedPreferences pref = getSharedPreferences();
    if(pref == null){
    }else{
      _defaultPath = pref.getString(getKey(),  _defaultPath);
    }

    //???????????????
    setSummary((CharSequence) _defaultPath);

    //??????????????????????????????????????????????
    super.onBindView(view);
  }

  /**
   * ??????????????????
   */
  @Override
  protected void onClick(){
    //????????????onClick???????????????????????????
    FileListDialog dlg = new FileListDialog(getContext());
    //?????????
    dlg.setOnFileListDialogListener((onFileListDialogListener) this);
    //??????????????????
    //dlg.setDirectorySelect(true);
    //????????????????????????
    dlg.show( _rootPath, _rootPath);
    
  }


  /**
   * ?????????????????????
   */
  @Override
  public void onClickFileList(File file) {
    
    if(file == null){
      Toast.makeText(getContext(), "????????????????????????????????????", Toast.LENGTH_SHORT).show();
    }else{
      //??????????
      setDialogTitle((CharSequence)"???");
      setDialogMessage((CharSequence) file.getAbsolutePath());
      showDialog(null);
    }
  }
  

  /**
   * ??????????????????????????
   */
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);
    
    if(!positiveResult){
    }else{
      //??????
      SharedPreferences.Editor editor = getEditor();
      editor.putString(getKey(), (String) getDialogMessage());
      editor.commit();

      //???????
      notifyChanged();
    }
  }
  
}




Java Source Code List

jp.xii.relog.setting.FileListDialog.java
jp.xii.relog.setting.FileSelectPreference.java
net.shirayu.android.WlanLogin.AdvancePrefActivity.java
net.shirayu.android.WlanLogin.AuthData.java
net.shirayu.android.WlanLogin.AuthEditActivity.java
net.shirayu.android.WlanLogin.AuthInfoSQLitepenHelper.java
net.shirayu.android.WlanLogin.AuthManageActivity.java
net.shirayu.android.WlanLogin.Auther.java
net.shirayu.android.WlanLogin.AutoDetectActivity.java
net.shirayu.android.WlanLogin.Const.java
net.shirayu.android.WlanLogin.CopyrightInfoActivity.java
net.shirayu.android.WlanLogin.MyHttpClient.java
net.shirayu.android.WlanLogin.StartReceiver.java
net.shirayu.android.WlanLogin.WifiConnectReceiver.java
net.shirayu.android.WlanLogin.WlanAuthService.java
net.shirayu.android.WlanLogin.WlanLoginActivity.java