Skip to content

Commit

Permalink
update to latest v2rayng and latest Xray Core
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jan 6, 2024
1 parent 3e3c696 commit ffcfe55
Show file tree
Hide file tree
Showing 47 changed files with 272 additions and 217 deletions.
11 changes: 6 additions & 5 deletions V2rayNG/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
buildToolsVersion "$buildToolsVer"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

defaultConfig {
Expand Down Expand Up @@ -190,6 +190,10 @@ dependencies {
implementation 'io.github.g00fy2.quickie:quickie-bundled:1.6.0'
implementation 'com.google.zxing:core:3.5.1'

def work_version = "2.8.1"

implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.work:work-multiprocess:$work_version"

//Hiddify
implementation fileTree(dir: 'jniLibs', include: ['*.so'], exclude: [ ])
Expand All @@ -211,10 +215,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.achartengine/achartengine
// implementation("org.achartengine:achartengine:1.2.0")
implementation files('libs/achartengine-1.2.0.jar')
def work_version = "2.8.1"

implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.work:work-multiprocess:$work_version"
implementation 'org.conscrypt:conscrypt-android:2.5.2'
// implementation("com.squareup.okhttp3:okhttp:5.0.+")
// implementation platform("org.http4k:http4k-bom:4.44.0.0"){
Expand Down
Binary file modified V2rayNG/app/libs/libv2ray-sources.jar
Binary file not shown.
Binary file modified V2rayNG/app/libs/libv2ray.aar
Binary file not shown.
9 changes: 3 additions & 6 deletions V2rayNG/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
android:name=".ui.HomeActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/AppThemeDayNight.NoActionBar">
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -206,11 +206,8 @@
<service android:name=".service.V2RayTestService"
android:exported="false"
android:label="@string/app_name"
android:process=":RunSoLibV2RayDaemon"></service>
<service
android:name=".service.V2RayTestService"
android:exported="false"
android:process=":RunSoLibV2RayDaemon"></service>
android:process=":RunSoLibV2RayDaemon"/>


<receiver
android:name=".receiver.WidgetProvider"
Expand Down
Binary file added V2rayNG/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/AngApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import com.google.firebase.FirebaseApp
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.messaging.ktx.messaging
import androidx.multidex.MultiDexApplication
import androidx.preference.PreferenceManager

import androidx.work.Configuration
import com.tencent.mmkv.MMKV
import com.v2ray.ang.util.HiddifyUtils
Expand Down Expand Up @@ -45,10 +44,10 @@ class AngApplication : MultiDexApplication(), Configuration.Provider {
super.onCreate()
appContext = applicationContext
// LeakCanary.install(this)
FirebaseApp.initializeApp(this);
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
// FirebaseApp.initializeApp(this);
// FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
// Thread.setDefaultUncaughtExceptionHandler(ExceptionHandler(this))
Firebase.messaging.subscribeToTopic("all")
// Firebase.messaging.subscribeToTopic("all")

val defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val update = defaultSharedPreferences.getInt(PREF_LAST_VERSION, 0) != BuildConfig.VERSION_CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data class SubscriptionItem(
var addedTime: Long = System.currentTimeMillis(),
var lastUpdated: Long = -1,
var autoUpdate: Boolean = false,
val updateInterval: Int? = null,
var updateInterval: Int? = null,

var used: Long = -1,
var total: Long = -1,
Expand All @@ -20,10 +20,10 @@ data class SubscriptionItem(


fun needUpdate(): Boolean {
if (url?.startsWith("http") != true) return false
if (update_interval < 0) return false
if (!url.startsWith("http")) return false
if (updateInterval==null || updateInterval!! < 0) return false
var hours = (System.currentTimeMillis() - lastUpdated) / (1000 * 60 * 60)
return (hours >= update_interval)
return (hours >= updateInterval!!)


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.tapadoo.alerter.Alerter
import com.v2ray.ang.AppConfig
import com.v2ray.ang.R
import com.v2ray.ang.extension.toast
import com.v2ray.ang.util.AngConfigManager
import com.v2ray.ang.util.HiddifyUtils
import com.v2ray.ang.util.MmkvManager
import com.v2ray.ang.util.Utils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

object SubscriptionUpdater {

Expand Down Expand Up @@ -57,21 +62,43 @@ object SubscriptionUpdater {
AppConfig.ANG_PACKAGE,
"subscription automatic update: ---${subscription.remarks}"
)
val configs = Utils.getUrlContentWithCustomUserAgent(subscription.url)
importBatchConfig(configs, i.first)
val configText = try {
Utils.getUrlContentWithCustomUserAgent(subscription.url)
} catch (e: Exception) {
notification.setContentText("Updating Failed ${subscription.remarks}")
Log.e(AppConfig.ANG_PACKAGE,e.toString(),e)
return Result.failure()
}

importBatchConfig(configText, i.first,false)


notification.setContentText("Updating ${subscription.remarks}")
}
notificationManager.cancel(3)
return Result.success()
}
}
private fun importBatchConfig(
response: Utils.Response?,
subid: String = "",
selectSub: Boolean,
append: Boolean = false
) {
var server=response?.content
val subid2 = if(subid.isNullOrEmpty()){
if (server?.startsWith("http") == true)"" else "default"
}else{
subid
}
HiddifyUtils.extract_package_info_from_response(response,subid)

fun importBatchConfig(server: String?, subid: String = "") {
val append = subid.isEmpty()

val count = AngConfigManager.importBatchConfig(server, subid, append)
val append = append||subid.isNullOrEmpty() || subid=="default"
var count = AngConfigManager.importBatchConfig(server, subid2, append, selectSub = selectSub)
if (count <= 0) {
AngConfigManager.importBatchConfig(Utils.decode(server!!), subid, append)
count = AngConfigManager.importBatchConfig(Utils.decode(server!!), subid2, append, selectSub = selectSub)
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ class HiddifyMainActivity(val hiddifyMainViewModel: HiddifyMainViewModel) : Base
HiddifyUtils.setMode(connect_mode)
onSelectSub(subid)
}
hiddifyMainViewModel.testAllRealPing()
// hiddifyMainViewModel.testAllRealPing()
Alerter.create(requireActivity())
.setIcon(com.google.android.material.R.drawable.mtrl_ic_check_mark)
.setBackgroundResource(R.drawable.bg_h_green)
Expand Down Expand Up @@ -807,14 +807,14 @@ class HiddifyMainActivity(val hiddifyMainViewModel: HiddifyMainViewModel) : Base
}
launch(Dispatchers.Main) {
importBatchConfig(configText, it.first,false)
hiddifyMainViewModel.testAllRealPing()
// hiddifyMainViewModel.testAllRealPing()
}
}
}
} catch (e: Exception) {
e.printStackTrace()
context.toast(R.string.title_sub_update_failed)
hiddifyMainViewModel. testAllRealPing()
// hiddifyMainViewModel. testAllRealPing()
return false
}
return true
Expand Down Expand Up @@ -1051,7 +1051,7 @@ class HiddifyMainActivity(val hiddifyMainViewModel: HiddifyMainViewModel) : Base
if (enableSubscription?.second?.needUpdate() == true) {
importConfigViaSub(HiddifyUtils.getSelectedSubId())
} else if (do_ping) {
hiddifyMainViewModel.testAllRealPing()
// hiddifyMainViewModel.testAllRealPing()
}
}else{
Alerter.create(requireActivity())
Expand Down
15 changes: 14 additions & 1 deletion V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.util.AttributeSet
import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -226,8 +227,10 @@ class HomeActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
R.id.logcat -> {
startActivity(Intent(this, LogcatActivity::class.java))
}
R.id.privacy_policy-> {
Utils.openUri(this, AppConfig.v2rayNGPrivacyPolicy)
}
}

return true
}

Expand Down Expand Up @@ -300,6 +303,16 @@ class HomeActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
fun gotoFragment(i: Int) {
binding.viewPager.setCurrentItem(i,true)
}


override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {

if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B) {
moveTaskToBack(false)
return true
}
return super.onKeyDown(keyCode, event)
}
}


69 changes: 18 additions & 51 deletions V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.view.*
import android.widget.AdapterView
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -122,12 +123,12 @@ class MainActivity(val mainViewModel: HiddifyMainViewModel) : BaseFragment(){
mItemTouchHelper?.attachToRecyclerView(binding.recyclerView)


val toggle = ActionBarDrawerToggle(
this, binding.drawerLayout, binding.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
binding.drawerLayout.addDrawerListener(toggle)
toggle.syncState()
binding.navView.setNavigationItemSelectedListener(this)
"v${BuildConfig.VERSION_NAME} (${SpeedtestUtil.getLibVersion()})".also { binding.version.text = it }
// val toggle = ActionBarDrawerToggle(
// this, binding.drawerLayout, binding.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
// binding.drawerLayout.addDrawerListener(toggle)
// toggle.syncState()
// binding.navView.setNavigationItemSelectedListener(this)
// "v${BuildConfig.VERSION_NAME} (${SpeedtestUtil.getLibVersion()})".also { binding.version.text = it }

setupViewModel()
// copyAssets()
Expand All @@ -149,6 +150,7 @@ class MainActivity(val mainViewModel: HiddifyMainViewModel) : BaseFragment(){
return binding.root
}


private fun setupViewModel() {
mainViewModel.updateListAction.observe(this) { index ->
if (index >= 0) {
Expand All @@ -161,20 +163,20 @@ class MainActivity(val mainViewModel: HiddifyMainViewModel) : BaseFragment(){
mainViewModel.isRunning.observe(this) { isRunning ->
adapter.isRunning = isRunning
if (isRunning) {
if (!Utils.getDarkModeStatus(this)) {
binding.fab.setImageResource(R.drawable.ic_stat_name)
}
binding.fab.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(this, R.color.color_fab_orange))
// if (!Utils.getDarkModeStatus(context!!)) {
// binding.fab.setImageResource(R.drawable.ic_stat_name)
// }
binding.fab.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.color_fab_orange))
setTestState(getString(R.string.connection_connected))
binding.layoutTest.isFocusable = true
binding.fab.text=getString(R.string.fab_connected) //hiddify
setTestState(getString(R.string.connection_test_testing)) //hiddify
mainViewModel.testCurrentServerRealPing()//hiddify
} else {
if (!Utils.getDarkModeStatus(this)) {
binding.fab.setImageResource(R.drawable.ic_stat_name)
}
binding.fab.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(this, R.color.color_fab_grey))
// if (!Utils.getDarkModeStatus(requireContext())) {
// binding.fab.setImageResource(R.drawable.ic_stat_name)
// }
binding.fab.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.color_fab_grey))
setTestState(getString(R.string.connection_not_connected))
binding.layoutTest.isFocusable = false
binding.fab.text=getString(R.string.fab_start)//hiddify
Expand Down Expand Up @@ -652,13 +654,7 @@ class MainActivity(val mainViewModel: HiddifyMainViewModel) : BaseFragment(){
// }
// }

override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B) {
moveTaskToBack(false)
return true
}
return super.onKeyDown(keyCode, event)
}



fun showCircle() {
Expand Down Expand Up @@ -745,34 +741,5 @@ class MainActivity(val mainViewModel: HiddifyMainViewModel) : BaseFragment(){
override fun onTitleClick(){
bottomSheetPresenter.show(parentFragmentManager,ProfilesBottomSheets.newInstance())
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
when (item.itemId) {
//R.id.server_profile -> activityClass = MainActivity::class.java
R.id.sub_setting -> {
startActivity(Intent(this, SubSettingActivity::class.java))
}
R.id.settings -> {
startActivity(Intent(this, SettingsActivity::class.java)
.putExtra("isRunning", mainViewModel.isRunning.value == true))
}
R.id.user_asset_setting -> {
startActivity(Intent(this, UserAssetActivity::class.java))
}
R.id.feedback -> {
Utils.openUri(this, AppConfig.v2rayNGIssues)
}
R.id.promotion -> {
Utils.openUri(this, "${Utils.decode(AppConfig.promotionUrl)}?t=${System.currentTimeMillis()}")
}
R.id.logcat -> {
startActivity(Intent(this, LogcatActivity::class.java))
}
R.id.privacy_policy-> {
Utils.openUri(this, AppConfig.v2rayNGPrivacyPolicy)
}
}
binding.drawerLayout.closeDrawer(GravityCompat.START)
return true
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class ServerActivity : BaseActivity() {
EConfigType.VLESS -> setContentView(R.layout.activity_server_vless)
EConfigType.TROJAN -> setContentView(R.layout.activity_server_trojan)
EConfigType.WIREGUARD -> setContentView(R.layout.activity_server_wireguard)
EConfigType.LowestPing -> return
EConfigType.LoadBalance -> return
EConfigType.Usage ->return

}
sp_network?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import com.v2ray.ang.viewmodel.SettingsViewModel
import java.util.*
import kotlin.system.exitProcess
import com.v2ray.ang.service.SubscriptionUpdater
import com.v2ray.ang.util.Utils
import com.v2ray.ang.viewmodel.SettingsViewModel
import java.util.concurrent.TimeUnit

class SettingsActivity : BaseActivity() {
Expand Down
Loading

0 comments on commit ffcfe55

Please sign in to comment.