Update to API 29

This commit is contained in:
Mygod 2019-06-23 13:44:36 +08:00
parent 3daf980174
commit 090bf141b0
6 changed files with 11 additions and 15 deletions

View file

@ -18,11 +18,11 @@ def getCurrentFlavor() {
} }
android { android {
compileSdkVersion 28 compileSdkVersion 29
defaultConfig { defaultConfig {
applicationId "com.github.shadowsocks.plugin.v2ray" applicationId "com.github.shadowsocks.plugin.v2ray"
minSdkVersion rootProject.minSdkVersion minSdkVersion rootProject.minSdkVersion
targetSdkVersion 28 targetSdkVersion 29
versionCode 1020000 versionCode 1020000
versionName "1.2.0" versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -64,7 +64,7 @@ tasks.whenTaskAdded { task ->
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.preference:preference:1.1.0-beta01" implementation "androidx.preference:preference:1.1.0-beta01"
implementation 'com.github.shadowsocks:plugin:1.2.0' implementation 'com.github.shadowsocks:plugin:1.3.0'
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0' implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'

@ -1 +1 @@
Subproject commit e5ada302d39b0aef8e167701c94596e41e805ec1 Subproject commit c7017f45bb1e12cf1e4b739bcb8f42f3eb8b22cd

View file

@ -32,7 +32,7 @@ class BinaryProvider : NativePluginProvider() {
provider.addPath("v2ray", 0b111101101) provider.addPath("v2ray", 0b111101101)
} }
override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libv2ray.so" override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libv2ray.so"
override fun openFile(uri: Uri?): ParcelFileDescriptor = when (uri?.path) { override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) {
"/v2ray" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY) "/v2ray" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY)
else -> throw FileNotFoundException() else -> throw FileNotFoundException()
} }

View file

@ -22,7 +22,6 @@ package com.github.shadowsocks.plugin.v2ray
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.view.View
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.preference.EditTextPreferenceDialogFragmentCompat import androidx.preference.EditTextPreferenceDialogFragmentCompat
@ -35,7 +34,7 @@ class CertificatePreferenceDialogFragment : EditTextPreferenceDialogFragmentComp
override fun onPrepareDialogBuilder(builder: AlertDialog.Builder) { override fun onPrepareDialogBuilder(builder: AlertDialog.Builder) {
super.onPrepareDialogBuilder(builder) super.onPrepareDialogBuilder(builder)
builder.setNeutralButton("Browse…") { _, _ -> builder.setNeutralButton(R.string.browse) { _, _ ->
val activity = requireActivity() val activity = requireActivity()
try { try {
targetFragment!!.startActivityForResult(Intent(Intent.ACTION_GET_CONTENT).apply { targetFragment!!.startActivityForResult(Intent(Intent.ACTION_GET_CONTENT).apply {
@ -44,9 +43,8 @@ class CertificatePreferenceDialogFragment : EditTextPreferenceDialogFragmentComp
}, ConfigFragment.REQUEST_BROWSE_CERTIFICATE) }, ConfigFragment.REQUEST_BROWSE_CERTIFICATE)
return@setNeutralButton return@setNeutralButton
} catch (_: ActivityNotFoundException) { } catch (_: SecurityException) { } } catch (_: ActivityNotFoundException) { } catch (_: SecurityException) { }
Snackbar.make(activity.findViewById<View>(R.id.content), Snackbar.make(activity.findViewById(R.id.content), R.string.file_manager_missing, Snackbar.LENGTH_SHORT)
"Please install a file manager like MiXplorer", .show()
Snackbar.LENGTH_SHORT).show()
} }
} }
} }

View file

@ -25,14 +25,12 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.InputFilter import android.text.InputFilter
import android.text.InputType import android.text.InputType
import android.view.View
import androidx.preference.EditTextPreference import androidx.preference.EditTextPreference
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.shadowsocks.plugin.PluginOptions import com.github.shadowsocks.plugin.PluginOptions
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import java.lang.RuntimeException
class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener { class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener {
companion object { companion object {
@ -116,8 +114,8 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
certRaw.text = activity.contentResolver.openInputStream(data!!.data!!)!! certRaw.text = activity.contentResolver.openInputStream(data!!.data!!)!!
.bufferedReader().readText() .bufferedReader().readText()
} catch (e: RuntimeException) { } catch (e: RuntimeException) {
Snackbar.make(activity.findViewById<View>(R.id.content), e.localizedMessage, Snackbar.LENGTH_LONG) Snackbar.make(activity.findViewById(R.id.content), e.localizedMessage ?: e.javaClass.name,
.show() Snackbar.LENGTH_LONG).show()
} }
} }
else -> super.onActivityResult(requestCode, resultCode, data) else -> super.onActivityResult(requestCode, resultCode, data)

View file

@ -4,7 +4,7 @@ apply plugin: 'com.github.ben-manes.versions'
buildscript { buildscript {
ext { ext {
kotlinVersion = '1.3.31' kotlinVersion = '1.3.40'
minSdkVersion = 21 minSdkVersion = 21
} }
repositories { repositories {