Skip to content

Commit

Permalink
Update project with cloned project
Browse files Browse the repository at this point in the history
  • Loading branch information
imannamdari committed Apr 21, 2023
1 parent 18e8dc1 commit 596cb9b
Show file tree
Hide file tree
Showing 31 changed files with 317 additions and 235 deletions.
82 changes: 25 additions & 57 deletions V2rayNG/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -18,45 +17,21 @@ android {
minSdkVersion 21
targetSdkVersion Integer.parseInt("$targetSdkVer")
multiDexEnabled true
versionCode 502
versionName "1.7.38"
}

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 514
versionName "1.8.3"
}

buildTypes {
release {
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'
}
}
Expand Down Expand Up @@ -98,6 +73,8 @@ android {
buildFeatures {
viewBinding true
}
namespace 'com.v2ray.ang'
testNamespace 'com.v2ray.angTest'
}

dependencies {
Expand All @@ -107,45 +84,36 @@ 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'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.github.jorgecastilloprz:fabprogresscircle:1.01@aar'
implementation 'me.drakeet.support:toastcompat:1.1.0'
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' }
// }
//}
implementation 'io.github.g00fy2.quickie:quickie-bundled:1.6.0'
implementation 'com.google.zxing:core:3.5.1'
}
6 changes: 4 additions & 2 deletions V2rayNG/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.v2ray.ang">
xmlns:tools="http://schemas.android.com/tools">

<supports-screens
android:anyDensity="true"
Expand All @@ -24,6 +23,9 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />


<application
android:name=".AngApplication"
Expand Down
1 change: 1 addition & 0 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object AppConfig {
const val PREF_PER_APP_PROXY_SET = "pref_per_app_proxy_set"
const val PREF_BYPASS_APPS = "pref_bypass_apps"
const val PREF_CONFIRM_REMOVE = "pref_confirm_remove"
const val PREF_START_SCAN_IMMEDIATE = "pref_start_scan_immediate"

const val HTTP_PROTOCOL: String = "http://"
const val HTTPS_PROTOCOL: String = "https://"
Expand Down
6 changes: 3 additions & 3 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ data class V2rayConfig(
var realitySettings: TlsSettingsBean? = null,
var grpcSettings: GrpcSettingsBean? = null,
val dsSettings: Any? = null,
val sockopt: sockoptBean? = sockoptBean()
val sockopt: Any? = null
) {

data class TcpSettingsBean(var header: HeaderBean = HeaderBean(),
Expand Down Expand Up @@ -194,7 +194,7 @@ data class V2rayConfig(
var enableEch: Boolean = true,
var echSetting: ECHSettingBean = ECHSettingBean(),
// REALITY settings
val show: Boolean = true,
val show: Boolean = false,
var publicKey: String? = null,
var shortId: String? = null,
var spiderX: String? = null) {
Expand Down Expand Up @@ -457,7 +457,7 @@ data class V2rayConfig(
var poolSize: Int = 10000) // roughly 10 times smaller than total ip pool

fun getProxyOutbound(): OutboundBean? {
outbounds.forEach { outbound ->
outbounds?.forEach { outbound ->
EConfigType.values().forEach {
if (outbound.protocol.equals(it.name, true)) {
return outbound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import com.google.zxing.WriterException
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.service.V2RayServiceManager
Expand Down Expand Up @@ -34,7 +33,7 @@ class TaskerReceiver : BroadcastReceiver() {
} else {
Utils.stopVService(context)
}
} catch (e: WriterException) {
} catch (e: Exception) {
e.printStackTrace()
}
}
Expand Down
23 changes: 21 additions & 2 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.text.TextUtils
import android.view.KeyEvent
import com.v2ray.ang.AppConfig
import android.content.res.ColorStateList
import android.os.Build
import com.google.android.material.navigation.NavigationView
import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
Expand Down Expand Up @@ -107,6 +108,15 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
setupViewModel()
copyAssets()
migrateLegacy()

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
RxPermissions(this)
.request(Manifest.permission.POST_NOTIFICATIONS)
.subscribe {
if (!it)
toast(R.string.toast_permission_denied)
}
}
}

private fun setupViewModel() {
Expand Down Expand Up @@ -297,7 +307,14 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
.show()
true
}

R.id.del_duplicate_config-> {
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
.setPositiveButton(android.R.string.ok) { _, _ ->
mainViewModel.removeDuplicateServer()
}
.show()
true
}
R.id.del_invalid_config -> {
AlertDialog.Builder(this).setMessage(R.string.del_config_comfirm)
.setPositiveButton(android.R.string.ok) { _, _ ->
Expand Down Expand Up @@ -620,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()
}
}

Expand Down
82 changes: 48 additions & 34 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/ScannerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,62 @@ package com.v2ray.ang.ui
import android.Manifest
import android.app.Activity
import android.os.Bundle
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
import com.google.zxing.BarcodeFormat
import com.tbruyelle.rxpermissions.RxPermissions
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.QRCodeDecoder
import io.github.g00fy2.quickie.QRResult
import io.github.g00fy2.quickie.ScanCustomCode
import io.github.g00fy2.quickie.config.ScannerConfig

class ScannerActivity : BaseActivity(), ZXingScannerView.ResultHandler {
class ScannerActivity : BaseActivity(){

private var mScannerView: ZXingScannerView? = null
private val scanQrCode = registerForActivityResult(ScanCustomCode(), ::handleResult)
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }

public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mScannerView = ZXingScannerView(this) // Programmatically initialize the scanner view

mScannerView?.setAutoFocus(true)
val formats = ArrayList<BarcodeFormat>()
formats.add(BarcodeFormat.QR_CODE)
mScannerView?.setFormats(formats)

setContentView(mScannerView) // Set the scanner view as the content view
if (settingsStorage?.decodeBool(AppConfig.PREF_START_SCAN_IMMEDIATE) == true) {
launchScan()
}

supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

public override fun onResume() {
super.onResume()
mScannerView!!.setResultHandler(this) // Register ourselves as a handler for scan results.
mScannerView!!.startCamera() // Start camera on resume
}

public override fun onPause() {
super.onPause()
mScannerView!!.stopCamera() // Stop camera on pause
}

override fun handleResult(rawResult: Result) {
// Do something with the result here
// Log.v(FragmentActivity.TAG, rawResult.text) // Prints scan results
// Log.v(FragmentActivity.TAG, rawResult.barcodeFormat.toString()) // Prints the scan format (qrcode, pdf417 etc.)

finished(rawResult.text)
private fun launchScan(){
scanQrCode.launch(
ScannerConfig.build {
setHapticSuccessFeedback(true) // enable (default) or disable haptic feedback when a barcode was detected
setShowTorchToggle(true) // show or hide (default) torch/flashlight toggle button
setShowCloseButton(true) // show or hide (default) close button
}
)
}

// If you would like to resume scanning, call this method below:
// mScannerView!!.resumeCameraPreview(this)
private fun handleResult(result: QRResult) {
if (result is QRResult.QRSuccess ) {
finished(result.content.rawValue)
} else {
finish()
}
}

private fun finished(text: String) {
Expand All @@ -69,19 +74,28 @@ class ScannerActivity : BaseActivity(), ZXingScannerView.ResultHandler {
}

override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.scan_code -> {
launchScan()
true
}
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)
Expand Down
Loading

0 comments on commit 596cb9b

Please sign in to comment.