diff --git a/app/build.gradle b/app/build.gradle index 756a607..a041b9c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,6 +45,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3' implementation "androidx.room:room-runtime:$room_version" + implementation "androidx.preference:preference-ktx:1.1.0" implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0" implementation "com.charleskorn.kaml:kaml:0.14.0" implementation "com.google.android.material:material:1.2.0-alpha02" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ae35eae..4a0ebfa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -47,5 +47,17 @@ android:label="@string/clash_proxy_manage" android:exported="false" android:screenOrientation="portrait"/> + + + diff --git a/app/src/main/java/com/github/kr328/clash/MainActivity.kt b/app/src/main/java/com/github/kr328/clash/MainActivity.kt index 3608581..36ea4f3 100644 --- a/app/src/main/java/com/github/kr328/clash/MainActivity.kt +++ b/app/src/main/java/com/github/kr328/clash/MainActivity.kt @@ -36,6 +36,10 @@ class MainActivity : BaseActivity() { startActivity(Intent(this, ProfilesActivity::class.java)) } + activity_main_clash_settings.setOnClickListener { + startActivity(Intent(this, SettingMainActivity::class.java)) + } + activity_main_clash_status_icon.setImageResource(R.drawable.ic_clash_stopped) activity_main_clash_status_title.text = getString(R.string.clash_status_stopped) activity_main_clash_status_summary.text = getString(R.string.clash_status_click_to_start) diff --git a/app/src/main/java/com/github/kr328/clash/SettingAccessActivity.kt b/app/src/main/java/com/github/kr328/clash/SettingAccessActivity.kt new file mode 100644 index 0000000..e38126f --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/SettingAccessActivity.kt @@ -0,0 +1,41 @@ +package com.github.kr328.clash + +import android.os.Bundle +import android.view.View +import kotlinx.android.synthetic.main.activity_setting_access.* + +class SettingAccessActivity : BaseActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_setting_access) + + setSupportActionBar(activity_setting_access_toolbar) + + activity_setting_access_allow_all.setOnClickListener { + activity_setting_access_allow_all.isChecked = true + activity_setting_access_allow.isChecked = false + activity_setting_access_disallow.isChecked = false + + activity_setting_access_divider.visibility = View.GONE + activity_setting_access_app_list.visibility = View.GONE + } + + activity_setting_access_allow.setOnClickListener { + activity_setting_access_allow_all.isChecked = false + activity_setting_access_allow.isChecked = true + activity_setting_access_disallow.isChecked = false + + activity_setting_access_divider.visibility = View.VISIBLE + activity_setting_access_app_list.visibility = View.VISIBLE + } + + activity_setting_access_disallow.setOnClickListener { + activity_setting_access_allow_all.isChecked = false + activity_setting_access_allow.isChecked = false + activity_setting_access_disallow.isChecked = true + + activity_setting_access_divider.visibility = View.VISIBLE + activity_setting_access_app_list.visibility = View.VISIBLE + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/SettingMainActivity.kt b/app/src/main/java/com/github/kr328/clash/SettingMainActivity.kt new file mode 100644 index 0000000..4bcb48c --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/SettingMainActivity.kt @@ -0,0 +1,20 @@ +package com.github.kr328.clash + +import android.os.Bundle +import androidx.preference.PreferenceFragmentCompat +import kotlinx.android.synthetic.main.activity_setting_main.* + +class SettingMainActivity : BaseActivity() { + class Fragment : PreferenceFragmentCompat() { + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.setting_main, rootKey) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_setting_main) + + setSupportActionBar(activity_setting_main_toolbar) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/SettingProxyActivity.kt b/app/src/main/java/com/github/kr328/clash/SettingProxyActivity.kt new file mode 100644 index 0000000..9af586d --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/SettingProxyActivity.kt @@ -0,0 +1,37 @@ +package com.github.kr328.clash + +import android.os.Bundle +import android.view.View +import androidx.preference.PreferenceFragmentCompat +import kotlinx.android.synthetic.main.activity_setting_proxy.* + +class SettingProxyActivity : BaseActivity() { + class Fragment : PreferenceFragmentCompat() { + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.setting_proxy, rootKey) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_setting_proxy) + + setSupportActionBar(activity_setting_proxy_toolbar) + + activity_setting_proxy_vpn_mode.setOnClickListener { + activity_setting_proxy_vpn_mode.isChecked = true + activity_setting_proxy_proxy_only_mode.isChecked = false + + activity_setting_proxy_divider.visibility = View.VISIBLE + activity_setting_proxy_content.visibility = View.VISIBLE + } + + activity_setting_proxy_proxy_only_mode.setOnClickListener { + activity_setting_proxy_vpn_mode.isChecked = false + activity_setting_proxy_proxy_only_mode.isChecked = true + + activity_setting_proxy_divider.visibility = View.GONE + activity_setting_proxy_content.visibility = View.GONE + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/view/RadioFatItem.kt b/app/src/main/java/com/github/kr328/clash/view/RadioFatItem.kt index 170c369..de74018 100644 --- a/app/src/main/java/com/github/kr328/clash/view/RadioFatItem.kt +++ b/app/src/main/java/com/github/kr328/clash/view/RadioFatItem.kt @@ -79,7 +79,7 @@ class RadioFatItem @JvmOverloads constructor( operationClickable = findViewById(R.id.view_radio_fat_item_operation_clickable) } - context.theme.obtainStyledAttributes(attributeSet, R.styleable.FatItem, 0, 0).apply { + context.theme.obtainStyledAttributes(attributeSet, R.styleable.RadioFatItem, 0, 0).apply { try { title = getString(R.styleable.FatItem_title) summary = getString(R.styleable.FatItem_summary) diff --git a/app/src/main/res/drawable/ic_cloud.xml b/app/src/main/res/drawable/ic_cloud.xml new file mode 100644 index 0000000..0b9c887 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml index 98eb13f..24a5623 100644 --- a/app/src/main/res/drawable/ic_settings.xml +++ b/app/src/main/res/drawable/ic_settings.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/> diff --git a/app/src/main/res/drawable/ic_settings_color.xml b/app/src/main/res/drawable/ic_settings_color.xml new file mode 100644 index 0000000..b67a13a --- /dev/null +++ b/app/src/main/res/drawable/ic_settings_color.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_setting_access.xml b/app/src/main/res/layout/activity_setting_access.xml new file mode 100644 index 0000000..a44c6f7 --- /dev/null +++ b/app/src/main/res/layout/activity_setting_access.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting_main.xml b/app/src/main/res/layout/activity_setting_main.xml new file mode 100644 index 0000000..912cb8b --- /dev/null +++ b/app/src/main/res/layout/activity_setting_main.xml @@ -0,0 +1,23 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting_proxy.xml b/app/src/main/res/layout/activity_setting_proxy.xml new file mode 100644 index 0000000..04aeb32 --- /dev/null +++ b/app/src/main/res/layout/activity_setting_proxy.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/preference_main_item.xml b/app/src/main/res/layout/preference_main_item.xml new file mode 100644 index 0000000..c36b34a --- /dev/null +++ b/app/src/main/res/layout/preference_main_item.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/preference_proxy_item.xml b/app/src/main/res/layout/preference_proxy_item.xml new file mode 100644 index 0000000..1d76d68 --- /dev/null +++ b/app/src/main/res/layout/preference_proxy_item.xml @@ -0,0 +1,38 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_fat_item.xml b/app/src/main/res/layout/view_fat_item.xml index 491fc92..e0ec1f1 100644 --- a/app/src/main/res/layout/view_fat_item.xml +++ b/app/src/main/res/layout/view_fat_item.xml @@ -12,7 +12,7 @@ android:layout_centerVertical="true" android:layout_width="25dp" android:layout_height="25dp" - android:layout_marginStart="27.5dp" /> + android:layout_marginStart="22.5dp" /> diff --git a/app/src/main/res/layout/view_radio_fat_item.xml b/app/src/main/res/layout/view_radio_fat_item.xml index bb3ee99..6c8266b 100644 --- a/app/src/main/res/layout/view_radio_fat_item.xml +++ b/app/src/main/res/layout/view_radio_fat_item.xml @@ -15,7 +15,7 @@ android:layout_centerVertical="true" android:layout_width="30dp" android:layout_height="30dp" - android:layout_marginStart="24dp" /> + android:layout_marginStart="19dp" /> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 00b10cb..8cba8da 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,9 +1,21 @@ + + + + + - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 42acb5a..637ef2f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -43,4 +43,25 @@ Invalid Config: %s %s - %s + + Setting + Application + Proxy + + VPN Mode + Handle all system traffic + Proxy Only Mode + Start clash core only + VPN Settings + Access Control + Configure access permission for apps + IPv6 Support + Routing IPv6 traffic + + Allow All + Allow all apps access vpn + Allow + Allow follow apps access vpn + Disallow + Disallow follow apps access vpn diff --git a/app/src/main/res/xml/setting_main.xml b/app/src/main/res/xml/setting_main.xml new file mode 100644 index 0000000..04a0cd7 --- /dev/null +++ b/app/src/main/res/xml/setting_main.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/setting_proxy.xml b/app/src/main/res/xml/setting_proxy.xml new file mode 100644 index 0000000..2952819 --- /dev/null +++ b/app/src/main/res/xml/setting_proxy.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/service/src/main/res/values/arrays.xml b/service/src/main/res/values/arrays.xml index 9632e43..b58d5d7 100644 --- a/service/src/main/res/values/arrays.xml +++ b/service/src/main/res/values/arrays.xml @@ -1,72 +1,17 @@ - + - 1.0.0.0/8 - 2.0.0.0/7 - 4.0.0.0/6 + 0.0.0.0/5 8.0.0.0/7 11.0.0.0/8 12.0.0.0/6 16.0.0.0/4 32.0.0.0/3 - 64.0.0.0/3 - 96.0.0.0/6 - 100.0.0.0/10 - 100.128.0.0/9 - 101.0.0.0/8 - 102.0.0.0/7 - 104.0.0.0/5 - 112.0.0.0/10 - 112.64.0.0/11 - 112.96.0.0/12 - 112.112.0.0/13 - 112.120.0.0/14 - 112.124.0.0/19 - 112.124.32.0/21 - 112.124.40.0/22 - 112.124.44.0/23 - 112.124.46.0/24 - 112.124.48.0/20 - 112.124.64.0/18 - 112.124.128.0/17 - 112.125.0.0/16 - 112.126.0.0/15 - 112.128.0.0/9 - 113.0.0.0/8 - 114.0.0.0/10 - 114.64.0.0/11 - 114.96.0.0/12 - 114.112.0.0/15 - 114.114.0.0/18 - 114.114.64.0/19 - 114.114.96.0/20 - 114.114.112.0/23 - 114.114.115.0/24 - 114.114.116.0/22 - 114.114.120.0/21 - 114.114.128.0/17 - 114.115.0.0/16 - 114.116.0.0/14 - 114.120.0.0/13 - 114.128.0.0/9 - 115.0.0.0/8 - 116.0.0.0/6 - 120.0.0.0/6 - 124.0.0.0/7 - 126.0.0.0/8 + 64.0.0.0/2 128.0.0.0/3 160.0.0.0/5 - 168.0.0.0/8 - 169.0.0.0/9 - 169.128.0.0/10 - 169.192.0.0/11 - 169.224.0.0/12 - 169.240.0.0/13 - 169.248.0.0/14 - 169.252.0.0/15 - 169.255.0.0/16 - 170.0.0.0/7 + 168.0.0.0/6 172.0.0.0/12 172.32.0.0/11 172.64.0.0/10 @@ -74,39 +19,7 @@ 173.0.0.0/8 174.0.0.0/7 176.0.0.0/4 - 192.0.0.8/29 - 192.0.0.16/28 - 192.0.0.32/27 - 192.0.0.64/26 - 192.0.0.128/25 - 192.0.1.0/24 - 192.0.3.0/24 - 192.0.4.0/22 - 192.0.8.0/21 - 192.0.16.0/20 - 192.0.32.0/19 - 192.0.64.0/18 - 192.0.128.0/17 - 192.1.0.0/16 - 192.2.0.0/15 - 192.4.0.0/14 - 192.8.0.0/13 - 192.16.0.0/12 - 192.32.0.0/11 - 192.64.0.0/12 - 192.80.0.0/13 - 192.88.0.0/18 - 192.88.64.0/19 - 192.88.96.0/23 - 192.88.98.0/24 - 192.88.100.0/22 - 192.88.104.0/21 - 192.88.112.0/20 - 192.88.128.0/17 - 192.89.0.0/16 - 192.90.0.0/15 - 192.92.0.0/14 - 192.96.0.0/11 + 192.0.0.0/9 192.128.0.0/11 192.160.0.0/13 192.169.0.0/16 @@ -116,52 +29,14 @@ 192.192.0.0/10 193.0.0.0/8 194.0.0.0/7 - 196.0.0.0/7 - 198.0.0.0/12 - 198.16.0.0/15 - 198.18.0.0/16 - 198.20.0.0/14 - 198.24.0.0/13 - 198.32.0.0/12 - 198.48.0.0/15 - 198.50.0.0/16 - 198.51.0.0/18 - 198.51.64.0/19 - 198.51.96.0/22 - 198.51.101.0/24 - 198.51.102.0/23 - 198.51.104.0/21 - 198.51.112.0/20 - 198.51.128.0/17 - 198.52.0.0/14 - 198.56.0.0/13 - 198.64.0.0/10 - 198.128.0.0/9 - 199.0.0.0/8 - 200.0.0.0/7 - 202.0.0.0/8 - 203.0.0.0/18 - 203.0.64.0/19 - 203.0.96.0/20 - 203.0.112.0/24 - 203.0.114.0/23 - 203.0.116.0/22 - 203.0.120.0/21 - 203.0.128.0/17 - 203.1.0.0/16 - 203.2.0.0/15 - 203.4.0.0/14 - 203.8.0.0/13 - 203.16.0.0/12 - 203.32.0.0/11 - 203.64.0.0/10 - 203.128.0.0/9 - 204.0.0.0/6 + 196.0.0.0/6 + 200.0.0.0/5 208.0.0.0/4 + 224.0.0.0/3 com.github.kr328.clash com.android.networkstack - \ No newline at end of file +