Skip to content

Commit

Permalink
Minor Fixes, add English translate
Browse files Browse the repository at this point in the history
  • Loading branch information
romanvht committed Oct 20, 2024
1 parent d1af903 commit a0ec065
Show file tree
Hide file tree
Showing 39 changed files with 485 additions and 46 deletions.
8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ android {
compileSdk = 34

defaultConfig {
applicationId = "io.github.dovecoteescapee.byedpi"
applicationId = "io.github.romanvht.byedpi"
minSdk = 21
targetSdk = 34
versionCode = 10
versionName = "1.3.6"
versionName = "1.3.7"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -74,6 +74,7 @@ dependencies {
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-service:2.8.4")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:banner="@mipmap/ic_launcher_foreground"
android:logo="@mipmap/ic_launcher"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:banner="@mipmap/ic_banner"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.ByeDPI"
tools:targetApi="34">
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/assets/proxytest_cmds.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--fake -1 --ttl 10
-d 2 --auto=t -f 3
-f 1 -n ya.ru -s 3+h
--disorder 1 --fake 7
--split 2 --disorder 7
-o 2 --auto=t,r,a,s -d 2
-s1 -O3 -q1+s -s25+s -t8
-s1 -O3 -q1+s -s29+s -t8
--disoob 2 --tlsrec 3+sni
-q1+s -s25+s -o5+s -f-1 -S
-q1+s -s29+s -o5+s -f-1 -S
-q1+s -s25+s -o5+s -f-1 -S -As
-q1+s -s29+s -o5+s -f-1 -S -As
-s1 -q1 -Y -At -f-1 -r1+s -As
--disoob 2+sni --fake 517 --ttl 5
-n vk.com -q 1+s -O 1 -s 25+s -t 5
-n vk.com -q 1+s -O 1 -s 29+s -t 5
-s0 -o1 -Ar -o1 -At -f-1 -r1+s -As
-s1 -o1 -Ar -o1 -At -f-1 -r1+s -As
-s 2 -r 1+s -r 1+h -o 2 -f -1 -t 4
-s1 -q1 -a2 -Art -f-1 -r1+s -a3 -Asn
-s1 -d1 -o1 -Ar -o3 -At -f-1 -r1+s -As
-s1 -q1 -Y -a2 -Art -f-1 -r1+s -a3 -Asn
--split 2 --disorder 3 --fake -1 --ttl 5
-s 2 -M h,d -A torst -T 3 -f -1 -r 3+s -S
-n www.google.com -d 1+s -O 1 -s 25+s -t 5
-n www.google.com -q 1+s -O 1 -s 29+s -t 5
-n www.google.com -q 2+s -O 1 -s 25+s -t 5
-n www.google.com -q 2+s -O 1 -s 29+s -t 5
--split 2 --disoob 3+sni --fake 517 --ttl 5
--split 1 --disorder 3+sni --fake -1 --ttl 5
--split 2 --disorder 3+sni --fake -1 --ttl 5
-s0 -o1 -d1 -r1+s -Ar -o1 -At -f-1 -r1+s -As
--disoob 3+sni --split -1+host --tlsrec 1+sni
--split 2 --fake 0+e --ttl 5 --tls-sni=www.google.com
-s1 -q1 -Y -Ar -s5 -o1+s -At -f-1 -r1+s -As -s1 -o1+s -s-1 -An
--split 1 --disorder 3+s --mod-http=h,d --auto=torst --tlsrec 1+s
-s1 -q1 -Y -Ar -s5 -o25000+s -At -f-1 -r1+s -As -s1 -o1+s -s-1 -An -b+500
--split 1 --disorder 3+s --mod-http=h,d --auto=torst --tlsrec 1+s --tlsrec 3+sni
-s1 -o1 -Atr -f16 -l':\x16\x03\x01\x02\x87\x01\x00\x02\x83\x03\x03\x5f\x15\x63\xcb\x06' -As
-s1 -o1 -Ar -o1 -At -f32 -r1+s -l':\x16\x03\x01\x02\x87\x01\x00\x02\x83\x03\x03\x5f\x15\x63\xcb\x06\xea\x1c\xdd\x40\x76\xf5\x8c\x44\x50\x6e\x01\xf3\xa3\x83\xac\xc2' -As
--proto=udp --pf=443 --fake-data=':\xC2\x00\x00\x00\x01\x14\x2E\xE3\xE3\x5F\x6B\xBB\x23\xA8\xE6\x5D\xA9\x78\x21\xCF\xC2\x72\x4C\x8F\xC4\x5E\x14\x00\x00\x00\x00\xC5\x00\x00\x00\x00\x4C\x00\xA7\x00\x00\x00\x00\x00\x00\x44\x00\x00\x80\x00\x00\x00\x0D\xFC\xFA\x1D\xCD\x73\xBA\x2A\x90\x93\xB3\xEE\xF7\x43\xC5\x85\xDA\xFF\x45\x3C\x00\x00\x00\x00\x00\x00\x7C\x00\x9B\x00\xF6\x00\x00\xDD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x59\xA8\xE4\x00\x00\x00\x00\x00\x00\x00\x00\x7B\x00\x0F\x00\x00\x00\x48\x4E\x00\x00\x00\x06\xF3\x00\x00\x00\x00\xD9\x5A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' --udp-fake=10 --auto=none -s1 -o1
25 changes: 25 additions & 0 deletions app/src/main/assets/proxytest_sites.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
www.youtube.com
manifest.googlevideo.com
i.ytimg.com
yt3.ggpht.com
yt4.ggpht.com
signaler-pa.youtube.com
jnn-pa.googleapis.com
rr1---sn-4axm-n8vs.googlevideo.com
rr1---sn-gvnuxaxjvh-o8ge.googlevideo.com
rr1---sn-ug5onuxaxjvh-p3ul.googlevideo.com
rr1---sn-ug5onuxaxjvh-n8v6.googlevideo.com
rr4---sn-q4flrnsl.googlevideo.com
rr10---sn-gvnuxaxjvh-304z.googlevideo.com
rr14---sn-n8v7kn7r.googlevideo.com
rr16---sn-axq7sn76.googlevideo.com
rr1---sn-8ph2xajvh-5xge.googlevideo.com
rr1---sn-gvnuxaxjvh-5gie.googlevideo.com
rr12---sn-gvnuxaxjvh-bvwz.googlevideo.com
rr5---sn-n8v7knez.googlevideo.com
rr1---sn-u5uuxaxjvhg0-ocje.googlevideo.com
rr2---sn-q4fl6ndl.googlevideo.com
rr5---sn-gvnuxaxjvh-n8vk.googlevideo.com
rr4---sn-jvhnu5g-c35d.googlevideo.com
rr1---sn-q4fl6n6y.googlevideo.com
rr2---sn-hgn7ynek.googlevideo.com
Binary file removed app/src/main/ic_launcher-playstore.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import android.view.MenuItem
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.core.os.LocaleListCompat
import androidx.lifecycle.lifecycleScope
import io.github.dovecoteescapee.byedpi.R
import io.github.dovecoteescapee.byedpi.data.*
Expand Down Expand Up @@ -147,8 +149,10 @@ class MainActivity : AppCompatActivity() {
}
}

val theme = getPreferences()
.getString("app_theme", null)
val lang = getPreferences().getString("language", "system")
MainSettingsFragment.setLang(lang ?: "system")

val theme = getPreferences().getString("app_theme", null)
MainSettingsFragment.setTheme(theme ?: "system")

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
Expand All @@ -160,9 +164,7 @@ class MainActivity : AppCompatActivity() {
requestPermissions(arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1)
}

val autoConnect = getPreferences().getBoolean("auto_connect", false)

if(autoConnect) {
if (getPreferences().getBoolean("auto_connect", false) && appStatus.first != AppStatus.Running) {
this.start()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ class SettingsActivity : AppCompatActivity() {
}

R.id.action_reset_settings -> {
getPreferences().edit().clear().apply()
val prefs = getPreferences()
val currentLanguage = prefs.getString("language", "system")
val editor = prefs.edit()

editor.clear()
editor.putString("language", currentLanguage)
editor.apply()

supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
supportFragmentManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class AppSelectionFragment : Fragment() {
}
recyclerView.adapter = adapter
progressBar.visibility = View.GONE
searchView.visibility = View.VISIBLE
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.provider.Settings
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import androidx.preference.*
import io.github.dovecoteescapee.byedpi.BuildConfig
import io.github.dovecoteescapee.byedpi.R
Expand All @@ -18,6 +19,21 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
companion object {
private val TAG: String = MainSettingsFragment::class.java.simpleName

fun setLang(lang: String) {
val appLocale = localeByName(lang) ?: throw IllegalStateException("Invalid value for language: $lang")
AppCompatDelegate.setApplicationLocales(appLocale)
}

private fun localeByName(lang: String): LocaleListCompat? = when (lang) {
"system" -> LocaleListCompat.getEmptyLocaleList()
"ru" -> LocaleListCompat.forLanguageTags("ru")
"en" -> LocaleListCompat.forLanguageTags("en")
else -> {
Log.w(TAG, "Invalid value for language: $lang")
null
}
}

fun setTheme(name: String) =
themeByName(name)?.let {
AppCompatDelegate.setDefaultNightMode(it)
Expand Down Expand Up @@ -46,15 +62,21 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
it.isBlank() || checkNotLocalIp(it)
}

findPreferenceNotNull<ListPreference>("language")
.setOnPreferenceChangeListener { _, newValue ->
setLang(newValue as String)
true
}

findPreferenceNotNull<ListPreference>("app_theme")
.setOnPreferenceChangeListener { _, newValue ->
setTheme(newValue as String)
true
}

val switchCommandLineSettings = findPreferenceNotNull<SwitchPreference>(
"byedpi_enable_cmd_settings"
)
val accessibilityStatusPref = findPreferenceNotNull<Preference>("accessibility_service_status")
val switchCommandLineSettings = findPreferenceNotNull<SwitchPreference>("byedpi_enable_cmd_settings")

val uiSettings = findPreferenceNotNull<Preference>("byedpi_ui_settings")
val cmdSettings = findPreferenceNotNull<Preference>("byedpi_cmd_settings")

Expand All @@ -70,23 +92,13 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
true
}

findPreferenceNotNull<Preference>("version").summary = BuildConfig.VERSION_NAME

val accessibilityStatusPref = findPreference<Preference>("accessibility_service_status")
accessibilityStatusPref?.setOnPreferenceClickListener {
accessibilityStatusPref.setOnPreferenceClickListener {
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
startActivity(intent)
true
}

val selectedApps = findPreference<Preference>("selected_apps")
selectedApps?.setOnPreferenceClickListener {
parentFragmentManager.beginTransaction()
.replace(R.id.settings, AppSelectionFragment())
.addToBackStack(null)
.commit()
true
}
findPreferenceNotNull<Preference>("version").summary = BuildConfig.VERSION_NAME

updateAccessibilityStatus(accessibilityStatusPref)
updatePreferences()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class ByeDpiProxyService : LifecycleService() {
private const val NOTIFICATION_CHANNEL_ID: String = "ByeDPI Proxy"

private var status: ServiceStatus = ServiceStatus.Disconnected

fun getStatus(): ServiceStatus {
return status
}
}

override fun onCreate() {
Expand Down Expand Up @@ -73,6 +77,7 @@ class ByeDpiProxyService : LifecycleService() {
mutex.withLock {
startProxy()
}

updateStatus(ServiceStatus.Connected)
startForeground()
} catch (e: Exception) {
Expand All @@ -96,11 +101,12 @@ class ByeDpiProxyService : LifecycleService() {
}

private suspend fun stop() {
Log.i(TAG, "Stopping VPN")
Log.i(TAG, "Stopping")

mutex.withLock {
stopProxy()
}

updateStatus(ServiceStatus.Disconnected)
stopSelf()
}
Expand Down
Loading

0 comments on commit a0ec065

Please sign in to comment.