diff --git a/V2rayNG/app/build.gradle b/V2rayNG/app/build.gradle index 1775db0f..92d7a52c 100644 --- a/V2rayNG/app/build.gradle +++ b/V2rayNG/app/build.gradle @@ -1,8 +1,7 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -Properties props = new Properties() -props.load(new FileInputStream(new File('local.properties'))) +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} android { compileSdkVersion Integer.parseInt("$compileSdkVer") @@ -18,25 +17,8 @@ android { minSdkVersion 21 targetSdkVersion Integer.parseInt("$targetSdkVer") multiDexEnabled true - versionCode 506 - versionName "1.8.1" - } - - if (props["sign"]) { - signingConfigs { - release { - storeFile file("../key.jks") - keyAlias 'ang' - keyPassword '123456' - storePassword '123456' - } - debug { - storeFile file("../key.jks") - keyAlias 'ang' - keyPassword '123456' - storePassword '123456' - } - } + versionCode 510 + versionName "1.8.2" } buildTypes { @@ -44,19 +26,12 @@ android { minifyEnabled false zipAlignEnabled false shrinkResources false - if (props["sign"]) { - signingConfig signingConfigs.release - } ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' -// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { minifyEnabled false zipAlignEnabled false shrinkResources false - if (props["sign"]) { - signingConfig signingConfigs.release - } ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' } } @@ -98,6 +73,8 @@ android { buildFeatures { viewBinding true } + namespace 'com.v2ray.ang' + testNamespace 'com.v2ray.angTest' } dependencies { @@ -107,29 +84,29 @@ dependencies { // Androidx implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.preference:preference-ktx:1.2.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' - implementation 'androidx.fragment:fragment-ktx:1.5.2' + implementation 'androidx.recyclerview:recyclerview:1.3.0' + implementation 'androidx.fragment:fragment-ktx:1.5.6' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' // Androidx ktx - implementation 'androidx.activity:activity-ktx:1.5.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' + implementation 'androidx.activity:activity-ktx:1.7.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' //kotlin - implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" + implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.0" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" - implementation 'com.tencent:mmkv-static:1.2.12' - implementation 'com.google.code.gson:gson:2.8.9' - implementation 'io.reactivex:rxjava:1.3.4' + implementation 'com.tencent:mmkv-static:1.2.15' + implementation 'com.google.code.gson:gson:2.10.1' + implementation 'io.reactivex:rxjava:1.3.8' implementation 'io.reactivex:rxandroid:1.2.1' implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar' implementation 'me.dm7.barcodescanner:core:1.9.8' @@ -139,13 +116,4 @@ dependencies { implementation 'com.blacksquircle.ui:editorkit:2.1.1' implementation 'com.blacksquircle.ui:language-base:2.1.1' implementation 'com.blacksquircle.ui:language-json:2.1.1' -} - -//buildscript { -// repositories { -// google() -// mavenCentral() -// maven { url 'https://maven.google.com' } -// maven { url 'https://jitpack.io' } -// } -//} +} \ No newline at end of file diff --git a/V2rayNG/app/src/main/AndroidManifest.xml b/V2rayNG/app/src/main/AndroidManifest.xml index 29f9b3a9..799fc968 100644 --- a/V2rayNG/app/src/main/AndroidManifest.xml +++ b/V2rayNG/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> + + + = Build.VERSION_CODES.TIRAMISU) { + RxPermissions(this) + .request(Manifest.permission.POST_NOTIFICATIONS) + .subscribe { + if (!it) + toast(R.string.toast_permission_denied) + } + } } private fun setupViewModel() { @@ -627,11 +637,13 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList } } + @Deprecated("Deprecated in Java") override fun onBackPressed() { if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) { binding.drawerLayout.closeDrawer(GravityCompat.START) } else { - super.onBackPressed() + //super.onBackPressed() + onBackPressedDispatcher.onBackPressed() } } diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ScannerActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ScannerActivity.kt index bc3785ec..883f51b5 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ScannerActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ScannerActivity.kt @@ -7,6 +7,7 @@ import com.google.zxing.Result import me.dm7.barcodescanner.zxing.ZXingScannerView import android.content.Intent import android.graphics.BitmapFactory +import android.os.Build import android.view.Menu import android.view.MenuItem import androidx.activity.result.contract.ActivityResultContracts @@ -70,18 +71,23 @@ class ScannerActivity : BaseActivity(), ZXingScannerView.ResultHandler { override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) { R.id.select_photo -> { + val permission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + Manifest.permission.READ_MEDIA_IMAGES + } else { + Manifest.permission.READ_EXTERNAL_STORAGE + } RxPermissions(this) - .request(Manifest.permission.READ_EXTERNAL_STORAGE) - .subscribe { - if (it) { - try { - showFileChooser() - } catch (e: Exception) { - e.printStackTrace() - } - } else - toast(R.string.toast_permission_denied) - } + .request(permission) + .subscribe { + if (it) { + try { + showFileChooser() + } catch (e: Exception) { + e.printStackTrace() + } + } else + toast(R.string.toast_permission_denied) + } true } else -> super.onOptionsItemSelected(item) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt index 535c862a..6ab4f3e1 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ServerActivity.kt @@ -116,6 +116,7 @@ class ServerActivity : BaseActivity() { EConfigType.SOCKS -> setContentView(R.layout.activity_server_socks) EConfigType.VLESS -> setContentView(R.layout.activity_server_vless) EConfigType.TROJAN -> setContentView(R.layout.activity_server_trojan) + else -> setContentView(R.layout.activity_server_vmess) } sp_network?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { @@ -382,8 +383,8 @@ class ServerActivity : BaseActivity() { val sniField = et_sni?.text?.toString()?.trim() ?: return val allowInsecureField = sp_allow_insecure?.selectedItemPosition ?: return val streamSecurity = sp_stream_security?.selectedItemPosition ?: return - var utlsIndex = sp_stream_fingerprint?.selectedItemPosition ?: return - var alpnIndex = sp_stream_alpn?.selectedItemPosition ?: return + val utlsIndex = sp_stream_fingerprint?.selectedItemPosition ?: return + val alpnIndex = sp_stream_alpn?.selectedItemPosition ?: return val publicKey = et_public_key?.text?.toString()?.trim() ?: return val shortId = et_short_id?.text?.toString()?.trim() ?: return val spiderX = et_spider_x?.text?.toString()?.trim() ?: return @@ -421,14 +422,19 @@ class ServerActivity : BaseActivity() { } private fun transportTypes(network: String?): Array { - return if (network == "tcp") { - tcpTypes - } else if (network == "kcp" || network == "quic") { - kcpAndQuicTypes - } else if (network == "grpc") { - grpcModes - } else { - arrayOf("---") + return when (network) { + "tcp" -> { + tcpTypes + } + "kcp", "quic" -> { + kcpAndQuicTypes + } + "grpc" -> { + grpcModes + } + else -> { + arrayOf("---") + } } } @@ -437,7 +443,7 @@ class ServerActivity : BaseActivity() { */ private fun deleteServer(): Boolean { if (editGuid.isNotEmpty()) { - if (editGuid != mainStorage?.decodeString(MmkvManager.KEY_SELECTED_SERVER)) { + if (editGuid != mainStorage?.decodeString(KEY_SELECTED_SERVER)) { if (settingsStorage?.decodeBool(AppConfig.PREF_CONFIRM_REMOVE) == true) { AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm) .setPositiveButton(android.R.string.ok) { _, _ -> diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index ef852674..995d5573 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -49,6 +49,8 @@ Запрос узла (WS/H2) / Шифрование QUIC Путь (WS/H2) / Ключ QUIC / Сид KCP / Сервис gRPC TLS + Fingerprint + Alpn Разрешать небезопасные SNI Адрес @@ -59,6 +61,9 @@ Пользователь (необязательно) Шифрование Поток + PublicKey + ShortId + SpiderX Успешно Ошибка Ничего нет @@ -165,7 +170,7 @@ Очистить Перезапуск службы Удалить все профили - Delete duplicate config + Удалить дубликаты профилей Удалить сбойные профили (после проверки) Экспорт всех профилей в буфер обмена Группы @@ -179,7 +184,7 @@ Сортировка по результатам теста Фильтр профилей Все группы - Delete %d duplicate configurations + Удалено дубликатов профилей: %d Запуск службы Подтвердить diff --git a/V2rayNG/build.gradle b/V2rayNG/build.gradle index 96c7a55a..ab2b874f 100644 --- a/V2rayNG/build.gradle +++ b/V2rayNG/build.gradle @@ -1,31 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - google() - mavenCentral() - maven { url 'https://maven.google.com' } - maven { url 'https://jitpack.io' } - } - dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - maven { url 'https://maven.google.com' } - maven { url 'https://jitpack.io' } - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +plugins { + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false + id 'org.jetbrains.kotlin.android' version '1.8.0' apply false +} \ No newline at end of file diff --git a/V2rayNG/gradle.properties b/V2rayNG/gradle.properties index 1fa9a591..2fbe9156 100644 --- a/V2rayNG/gradle.properties +++ b/V2rayNG/gradle.properties @@ -1,22 +1,10 @@ -## Project-wide Gradle settings. -# -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx1024m -XX:MaxPermSize=256m - org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -# -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -#Fri Jun 02 14:08:42 CST 2017 -kotlinVersion=1.6.21 -buildToolsVer=31.0.0 -compileSdkVer=31 -targetSdkVer=31 + +buildToolsVer=33.0.2 +compileSdkVer=33 +targetSdkVer=33 kotlin.incremental=true android.useAndroidX=true android.enableJetifier=true +kotlin.code.style=official +android.nonTransitiveRClass=true +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 diff --git a/V2rayNG/gradle/wrapper/gradle-wrapper.properties b/V2rayNG/gradle/wrapper/gradle-wrapper.properties index 047ecba2..cc8f2bd5 100644 --- a/V2rayNG/gradle/wrapper/gradle-wrapper.properties +++ b/V2rayNG/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/V2rayNG/settings.gradle b/V2rayNG/settings.gradle index e7b4def4..2b0e1603 100644 --- a/V2rayNG/settings.gradle +++ b/V2rayNG/settings.gradle @@ -1 +1,17 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + jcenter() + } +} +rootProject.name = "V2rayNG" include ':app'