Hide root summary if rooted
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
<string name="about">关于</string>
|
||||
<string name="about_title">影梭(shadowsocks)%s</string>
|
||||
<string name="flush_dnscache">刷新 DNS 缓存</string>
|
||||
<string name="flush_dnscache_summary">需要 ROOT 权限</string>
|
||||
<string name="flush_dnscache_summary_disabled">需要 ROOT 权限</string>
|
||||
<string name="flushing">刷新中……</string>
|
||||
<string name="qrcode">二维码</string>
|
||||
<string name="add_profile">添加配置文件</string>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<string name="about_title">Shadowsocks %s</string>
|
||||
<string name="qrcode">QR Code</string>
|
||||
<string name="flush_dnscache">Flush DNS cache</string>
|
||||
<string name="flush_dnscache_summary">Requires ROOT permission</string>
|
||||
<string name="flush_dnscache_summary_disabled">Requires ROOT permission</string>
|
||||
<string name="flushing">Flushing</string>
|
||||
<string name="add_profile">Add Profile</string>
|
||||
<string name="action_export">Export to Clipboard</string>
|
||||
|
||||
@@ -104,8 +104,7 @@
|
||||
android:summary="@string/nat_summary"/>
|
||||
<Preference android:key="recovery" android:title="@string/recovery"
|
||||
android:summary="@string/recovery_summary"/>
|
||||
<Preference android:key="flush_dnscache" android:title="@string/flush_dnscache"
|
||||
android:summary="@string/flush_dnscache_summary"/>
|
||||
<Preference android:key="flush_dnscache" android:title="@string/flush_dnscache"/>
|
||||
<Preference android:key="about" android:title="@string/about"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.Locale
|
||||
import android.app.AlertDialog
|
||||
import android.content.{DialogInterface, Intent}
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.{Build, Bundle}
|
||||
import android.preference.{Preference, PreferenceFragment}
|
||||
import android.webkit.{WebViewClient, WebView}
|
||||
import com.github.shadowsocks.utils.Key
|
||||
@@ -30,7 +30,11 @@ class ShadowsocksSettings extends PreferenceFragment {
|
||||
true
|
||||
})
|
||||
|
||||
findPreference("flush_dnscache").setOnPreferenceClickListener((preference: Preference) => {
|
||||
val flush = findPreference("flush_dnscache")
|
||||
if (Build.VERSION.SDK_INT >= 17 && !ShadowsocksApplication.isRoot) {
|
||||
flush.setEnabled(false)
|
||||
flush.setSummary(R.string.flush_dnscache_summary_disabled)
|
||||
} else flush.setOnPreferenceClickListener((preference: Preference) => {
|
||||
ShadowsocksApplication.track(Shadowsocks.TAG, "flush_dnscache")
|
||||
activity.flushDnsCache()
|
||||
true
|
||||
|
||||
@@ -55,7 +55,7 @@ import android.util.{DisplayMetrics, Base64, Log}
|
||||
import android.view.View.MeasureSpec
|
||||
import android.view.{Gravity, View, Window}
|
||||
import android.widget.Toast
|
||||
import com.github.shadowsocks.BuildConfig
|
||||
import com.github.shadowsocks.{ShadowsocksApplication, BuildConfig}
|
||||
import org.xbill.DNS._
|
||||
|
||||
|
||||
@@ -155,24 +155,13 @@ object Utils {
|
||||
|
||||
// Blocked > 3 seconds
|
||||
def toggleAirplaneMode(context: Context) {
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
toggleAboveApiLevel17()
|
||||
} else {
|
||||
if (ShadowsocksApplication.isRoot) {
|
||||
Console.runRootCommand(Array("ndc resolver flushdefaultif", "ndc resolver flushif wlan0"))
|
||||
} else if (Build.VERSION.SDK_INT < 17) {
|
||||
toggleBelowApiLevel17(context)
|
||||
}
|
||||
}
|
||||
|
||||
private def toggleAboveApiLevel17() {
|
||||
// Android 4.2 and above
|
||||
|
||||
Console.runRootCommand(Array("ndc resolver flushdefaultif", "ndc resolver flushif wlan0"))
|
||||
|
||||
//Utils.runRootCommand("settings put global airplane_mode_on 1\n"
|
||||
// + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true\n"
|
||||
// + "settings put global airplane_mode_on 0\n"
|
||||
// + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\n")
|
||||
}
|
||||
|
||||
//noinspection ScalaDeprecation
|
||||
private def toggleBelowApiLevel17(context: Context) {
|
||||
// Android 4.2 below
|
||||
|
||||
Reference in New Issue
Block a user