Commit c7fc4095 authored by Mygod's avatar Mygod

Remove compatibility code for Jelly Bean

parent 41d585ae
...@@ -92,8 +92,7 @@ ...@@ -92,8 +92,7 @@
<string name="share_message_nfc_disabled">Сканировать QR код\nAndroid Beam отключен</string> <string name="share_message_nfc_disabled">Сканировать QR код\nAndroid Beam отключен</string>
<string name="turn_on_nfc">Включить NFC &amp; Android Beam</string> <string name="turn_on_nfc">Включить NFC &amp; Android Beam</string>
<string name="flush_dnscache">Очистить кэш DNS</string> <string name="flush_dnscache">Очистить кэш DNS</string>
<string name="flush_dnscache_summary">Работает только в режиме NAT</string> <string name="flush_dnscache_summary">Работает только в режиме NAT. Требует наличия ROOT прав.</string>
<string name="flush_dnscache_summary_root">Работает только в режиме NAT. Требует наличия ROOT прав.</string>
<string name="flush_dnscache_no_root">Очистка кэша DNS не работает без налиичя ROOT прав</string> <string name="flush_dnscache_no_root">Очистка кэша DNS не работает без налиичя ROOT прав</string>
<string name="flushing">Очистка</string> <string name="flushing">Очистка</string>
<string name="add_profile">Добавить Профиль</string> <string name="add_profile">Добавить Профиль</string>
......
...@@ -58,8 +58,7 @@ ...@@ -58,8 +58,7 @@
<string name="about">关于</string> <string name="about">关于</string>
<string name="about_title">影梭(shadowsocks)%s</string> <string name="about_title">影梭(shadowsocks)%s</string>
<string name="flush_dnscache">刷新 DNS 缓存</string> <string name="flush_dnscache">刷新 DNS 缓存</string>
<string name="flush_dnscache_summary">只需在 NAT 模式下使用</string> <string name="flush_dnscache_summary">只需在 NAT 模式下使用,需要 ROOT 权限</string>
<string name="flush_dnscache_summary_root">只需在 NAT 模式下使用,需要 ROOT 权限</string>
<string name="flush_dnscache_no_root">在没有 ROOT 权限的情况下无法刷新 DNS 缓存</string> <string name="flush_dnscache_no_root">在没有 ROOT 权限的情况下无法刷新 DNS 缓存</string>
<string name="flushing">刷新中……</string> <string name="flushing">刷新中……</string>
<string name="share">分享</string> <string name="share">分享</string>
......
...@@ -59,8 +59,7 @@ ...@@ -59,8 +59,7 @@
<string name="about">關於</string> <string name="about">關於</string>
<string name="about_title">Shadowsocks %s</string> <string name="about_title">Shadowsocks %s</string>
<string name="flush_dnscache">清除 DNS 快取</string> <string name="flush_dnscache">清除 DNS 快取</string>
<string name="flush_dnscache_summary">僅在 NAT 模式可用</string> <string name="flush_dnscache_summary">僅在 NAT 模式可用,需要 ROOT 權限</string>
<string name="flush_dnscache_summary_root">僅在 NAT 模式可用,需要 ROOT 權限</string>
<string name="flush_dnscache_no_root">在無 ROOT 權限時清除 DNS 快取無法進行</string> <string name="flush_dnscache_no_root">在無 ROOT 權限時清除 DNS 快取無法進行</string>
<string name="flushing">清除中……</string> <string name="flushing">清除中……</string>
<string name="share">分享</string> <string name="share">分享</string>
......
...@@ -98,8 +98,7 @@ ...@@ -98,8 +98,7 @@
<string name="share_message_nfc_disabled">Scan QR code\nAndroid Beam is disabled</string> <string name="share_message_nfc_disabled">Scan QR code\nAndroid Beam is disabled</string>
<string name="turn_on_nfc">Turn on NFC &amp; Android Beam</string> <string name="turn_on_nfc">Turn on NFC &amp; Android Beam</string>
<string name="flush_dnscache">Flush DNS cache</string> <string name="flush_dnscache">Flush DNS cache</string>
<string name="flush_dnscache_summary">Only useful in NAT mode</string> <string name="flush_dnscache_summary">Only useful in NAT mode. Requires ROOT permission.</string>
<string name="flush_dnscache_summary_root">Only useful in NAT mode. Requires ROOT permission.</string>
<string name="flush_dnscache_no_root">Flush DNS cache cannot proceed without ROOT permission</string> <string name="flush_dnscache_no_root">Flush DNS cache cannot proceed without ROOT permission</string>
<string name="flushing">Flushing</string> <string name="flushing">Flushing</string>
<string name="add_profile">Add Profile</string> <string name="add_profile">Add Profile</string>
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
android:summary="@string/recovery_summary"/> android:summary="@string/recovery_summary"/>
<Preference android:key="flush_dnscache" <Preference android:key="flush_dnscache"
android:title="@string/flush_dnscache" android:title="@string/flush_dnscache"
android:summary="@string/flush_dnscache_summary_root"/> android:summary="@string/flush_dnscache_summary"/>
<Preference android:key="about" android:title="@string/about"/> <Preference android:key="about" android:title="@string/about"/>
</PreferenceCategory> </PreferenceCategory>
......
...@@ -500,11 +500,8 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext { ...@@ -500,11 +500,8 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
clearDialog() clearDialog()
} }
private var _isDestroyed: Boolean = _
override def isDestroyed = if (Build.VERSION.SDK_INT >= 17) super.isDestroyed else _isDestroyed
override def onDestroy() { override def onDestroy() {
super.onDestroy() super.onDestroy()
_isDestroyed = true
detachService() detachService()
new BackupManager(this).dataChanged() new BackupManager(this).dataChanged()
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)
......
...@@ -5,7 +5,7 @@ import java.util.Locale ...@@ -5,7 +5,7 @@ import java.util.Locale
import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.content.{Intent, SharedPreferences} import android.content.{Intent, SharedPreferences}
import android.net.Uri import android.net.Uri
import android.os.{Build, Bundle} import android.os.Bundle
import android.preference.{Preference, PreferenceFragment, SwitchPreference} import android.preference.{Preference, PreferenceFragment, SwitchPreference}
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.webkit.{WebView, WebViewClient} import android.webkit.{WebView, WebViewClient}
...@@ -160,9 +160,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -160,9 +160,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
true true
}) })
val flush = findPreference("flush_dnscache") findPreference("flush_dnscache").setOnPreferenceClickListener(_ => {
if (Build.VERSION.SDK_INT < 17) flush.setSummary(R.string.flush_dnscache_summary)
flush.setOnPreferenceClickListener(_ => {
app.track(TAG, "flush_dnscache") app.track(TAG, "flush_dnscache")
activity.flushDnsCache() activity.flushDnsCache()
true true
......
...@@ -46,7 +46,6 @@ import android.content.pm.PackageManager ...@@ -46,7 +46,6 @@ import android.content.pm.PackageManager
import android.content.{Context, Intent} import android.content.{Context, Intent}
import android.graphics._ import android.graphics._
import android.os.Build import android.os.Build
import android.provider.Settings
import android.util.{Base64, DisplayMetrics, Log} import android.util.{Base64, DisplayMetrics, Log}
import android.view.View.MeasureSpec import android.view.View.MeasureSpec
import android.view.{Gravity, View, Window} import android.view.{Gravity, View, Window}
...@@ -128,25 +127,7 @@ object Utils { ...@@ -128,25 +127,7 @@ object Utils {
// Blocked > 3 seconds // Blocked > 3 seconds
def toggleAirplaneMode(context: Context) = { def toggleAirplaneMode(context: Context) = {
val result = Shell.SU.run(FLUSH_DNS) val result = Shell.SU.run(FLUSH_DNS)
if (result != null && !result.isEmpty) true else if (Build.VERSION.SDK_INT < 17) { result != null && !result.isEmpty
toggleBelowApiLevel17(context)
true
} else false
}
//noinspection ScalaDeprecation
private def toggleBelowApiLevel17(context: Context) {
// Android 4.2 below
Settings.System.putInt(context.getContentResolver, Settings.System.AIRPLANE_MODE_ON, 1)
val enableIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED)
enableIntent.putExtra("state", true)
context.sendBroadcast(enableIntent)
Thread.sleep(3000)
Settings.System.putInt(context.getContentResolver, Settings.System.AIRPLANE_MODE_ON, 0)
val disableIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED)
disableIntent.putExtra("state", false)
context.sendBroadcast(disableIntent)
} }
def resolve(host: String, addrType: Int): Option[String] = { def resolve(host: String, addrType: Int): Option[String] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment