X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Ffonbot%2FFonBotPreferenceActivity.java;h=eae2b0f714acf1e6a49b8afe882e11412393c5ad;hb=6378595ca19bc3b4552e937e6715e0e5b2e02245;hp=8754825fb430e1f892296b3a009f53f97f7da8e8;hpb=957f71184c0e535794763fc73102fe3289cf47ed;p=fonbot.git diff --git a/src/ro/ieval/fonbot/FonBotPreferenceActivity.java b/src/ro/ieval/fonbot/FonBotPreferenceActivity.java index 8754825..eae2b0f 100644 --- a/src/ro/ieval/fonbot/FonBotPreferenceActivity.java +++ b/src/ro/ieval/fonbot/FonBotPreferenceActivity.java @@ -106,17 +106,19 @@ public final class FonBotPreferenceActivity extends PreferenceActivity { return true; try { + final String privapp = android.os.Build.VERSION.SDK_INT < 19 ? "app" : "priv-app"; final String remountCommand="mount -o remount,rw /system"; - final String copyToSystemCommand="cp "+info.sourceDir+" /system/app/FonBot.apk"; - final String chmodSystemCommand="chmod 644 /system/app/FonBot.apk"; + final String copyToSystemCommand="cp "+info.sourceDir+" /system/" + privapp + "/FonBot.apk"; + final String chmodSystemCommand="chmod 644 /system/" + privapp + "/FonBot.apk"; + final String rmSystemCommand="rm /system/" + privapp + "/FonBot.apk"; final String copyToUserCommand="cp "+info.sourceDir+" /data/app/FonBot.apk"; final String chmodUserCommand="chmod 644 /data/app/FonBot.apk"; - final String rmCommand="rm "+info.sourceDir; + final String rmUserCommand="rm "+info.sourceDir; if(isChecked){ Runtime.getRuntime().exec(new String[]{ "su", "-c", - remountCommand+';'+copyToSystemCommand+';'+chmodSystemCommand+';'+rmCommand + remountCommand+';'+copyToSystemCommand+';'+chmodSystemCommand+';'+rmUserCommand }).waitFor(); Toast.makeText(FonBotPreferenceActivity.this, @@ -124,9 +126,8 @@ public final class FonBotPreferenceActivity extends PreferenceActivity { } else { Runtime.getRuntime().exec(new String[]{ "su", "-c", - remountCommand+';'+copyToUserCommand+';'+chmodUserCommand+';'+rmCommand + remountCommand+';'+copyToUserCommand+';'+chmodUserCommand+';'+rmSystemCommand }).waitFor(); - Toast.makeText(FonBotPreferenceActivity.this, "Reboot to make FonBot a non-system application", Toast.LENGTH_LONG).show(); } @@ -139,6 +140,19 @@ public final class FonBotPreferenceActivity extends PreferenceActivity { } }); + final EditTextPreference protocolPreference=(EditTextPreference) findPreference("protocol"); + protocolPreference.setSummary(protocolPreference.getText()); + protocolPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(final @Nullable Preference preference, final @Nullable Object newValue) { + if(newValue==null) + return false; + + protocolPreference.setSummary(newValue.toString()); + return true; + } + }); + final EditTextPreference hostnamePreference=(EditTextPreference) findPreference("hostname"); hostnamePreference.setSummary(hostnamePreference.getText()); hostnamePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {