From ea7ede033dab6506f492f9d8ef02ee4860b89e71 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 13 Dec 2017 02:06:20 -0800 Subject: [PATCH] Fix #1497 --- .../java/com/github/shadowsocks/VpnRequestActivity.kt | 8 ++++---- .../main/java/com/github/shadowsocks/tasker/Settings.kt | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mobile/src/main/java/com/github/shadowsocks/VpnRequestActivity.kt b/mobile/src/main/java/com/github/shadowsocks/VpnRequestActivity.kt index 3fc746df..e232a26d 100644 --- a/mobile/src/main/java/com/github/shadowsocks/VpnRequestActivity.kt +++ b/mobile/src/main/java/com/github/shadowsocks/VpnRequestActivity.kt @@ -20,6 +20,7 @@ package com.github.shadowsocks +import android.app.Activity import android.app.KeyguardManager import android.content.BroadcastReceiver import android.content.Context @@ -28,14 +29,13 @@ import android.content.IntentFilter import android.net.VpnService import android.os.Bundle import android.os.PersistableBundle -import android.support.v7.app.AppCompatActivity import android.util.Log import com.github.shadowsocks.App.Companion.app import com.github.shadowsocks.aidl.IShadowsocksService import com.github.shadowsocks.bg.BaseService import com.github.shadowsocks.utils.broadcastReceiver -class VpnRequestActivity : AppCompatActivity(), ShadowsocksConnection.Interface { +class VpnRequestActivity : Activity(), ShadowsocksConnection.Interface { companion object { private const val TAG = "VpnRequestActivity" private const val REQUEST_CONNECT = 1 @@ -43,8 +43,8 @@ class VpnRequestActivity : AppCompatActivity(), ShadowsocksConnection.Interface private var receiver: BroadcastReceiver? = null - override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { - super.onCreate(savedInstanceState, persistentState) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) if (!BaseService.usingVpnMode) { finish() return diff --git a/mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt b/mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt index ec798dbc..9db24dd8 100644 --- a/mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt +++ b/mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt @@ -27,7 +27,7 @@ import com.github.shadowsocks.R import com.github.shadowsocks.database.ProfileManager import com.twofortyfouram.locale.api.Intent as ApiIntent -class Settings(bundle: Bundle) { +class Settings(bundle: Bundle?) { companion object { private val KEY_SWITCH_ON = "switch_on" private val KEY_PROFILE_ID = "profile_id" @@ -35,8 +35,8 @@ class Settings(bundle: Bundle) { fun fromIntent(intent: Intent) = Settings(intent.getBundleExtra(ApiIntent.EXTRA_BUNDLE)) } - var switchOn: Boolean = bundle.getBoolean(KEY_SWITCH_ON, true) - var profileId: Int = bundle.getInt(KEY_PROFILE_ID, -1) + var switchOn: Boolean = bundle?.getBoolean(KEY_SWITCH_ON, true) ?: false + var profileId: Int = bundle?.getInt(KEY_PROFILE_ID, -1) ?: -1 fun toIntent(context: Context): Intent { val bundle = Bundle()