Skip to content

Commit

Permalink
Merge branch 'Check-command-line' into dvhhVariant
Browse files Browse the repository at this point in the history
Conflicts:
	term/src/main/java/jackpal/androidterm/TermPreferences.java
  • Loading branch information
dvhh committed Apr 14, 2015
2 parents f7477d2 + 8f152a1 commit 65e9138
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions term/src/main/java/jackpal/androidterm/TermPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import jackpal.androidterm.compat.FileCompat;

import android.os.Bundle;
import android.preference.EditTextPreference;
import android.os.Environment;
import android.preference.Preference;
import android.preference.PreferenceActivity;
Expand All @@ -37,6 +40,9 @@
import android.view.MenuItem;
import android.widget.Toast;

import java.io.File;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -46,6 +52,7 @@
public class TermPreferences extends PreferenceActivity {
private static final String ACTIONBAR_KEY = "actionbar";
private static final String CATEGORY_SCREEN_KEY = "screen";
private static final String SHELL_KEY = "shell";

private static final String CUSTOM_FONT_CHOOSER_KEY ="custom_font_filepath";
private static final String CATEGORY_TEXT_KEY = "text_category";
Expand Down Expand Up @@ -109,6 +116,21 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

EditTextPreference shellPreference=(EditTextPreference)findPreference(SHELL_KEY);
if(shellPreference != null) {
shellPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if(newValue instanceof String) {
String value=(String) newValue;
File check=new File(value);
return check.exists() && FileCompat.canExecute(check);
}
return false;
}
});
}


/// Init custom font chooser
Preference fontSelector=findPreference(CUSTOM_FONT_CHOOSER_KEY);
Expand Down
3 changes: 3 additions & 0 deletions term/src/main/java/jackpal/androidterm/compat/FileCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

package jackpal.androidterm.compat;

import android.annotation.TargetApi;

import java.io.File;

/**
* Compatibility class for java.io.File
*/
public class FileCompat {
@TargetApi(9)
private static class Api9OrLater {
public static boolean canExecute(File file) {
return file.canExecute();
Expand Down

0 comments on commit 65e9138

Please sign in to comment.