diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt index 2b422985..ba45042c 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/AppConfig.kt @@ -12,7 +12,6 @@ object AppConfig { /** Legacy configuration keys. */ const val ANG_CONFIG = "ang_config" - const val PREF_INAPP_BUY_IS_PREMIUM = "pref_inapp_buy_is_premium" /** Preferences mapped to MMKV storage. */ const val PREF_SNIFFING_ENABLED = "pref_sniffing_enabled" diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/helper/CustomDividerItemDecoration.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/helper/CustomDividerItemDecoration.kt new file mode 100644 index 00000000..0f6d37c0 --- /dev/null +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/helper/CustomDividerItemDecoration.kt @@ -0,0 +1,68 @@ +package com.v2ray.ang.helper + +import android.graphics.Canvas +import android.graphics.Rect +import android.graphics.drawable.Drawable +import android.view.View +import androidx.recyclerview.widget.RecyclerView + +class CustomDividerItemDecoration( + private val divider: Drawable, + private val orientation: Int +) : RecyclerView.ItemDecoration() { + + override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) { + if (orientation == RecyclerView.VERTICAL) { + drawVerticalDividers(canvas, parent) + } else { + drawHorizontalDividers(canvas, parent) + } + } + + private fun drawVerticalDividers(canvas: Canvas, parent: RecyclerView) { + val left = parent.paddingLeft + val right = parent.width - parent.paddingRight + + val childCount = parent.childCount + for (i in 0 until childCount - 1) { + val child = parent.getChildAt(i) + val params = child.layoutParams as RecyclerView.LayoutParams + + val top = child.bottom + params.bottomMargin + val bottom = top + divider.intrinsicHeight + + divider.setBounds(left, top, right, bottom) + divider.draw(canvas) + } + } + + private fun drawHorizontalDividers(canvas: Canvas, parent: RecyclerView) { + val top = parent.paddingTop + val bottom = parent.height - parent.paddingBottom + + val childCount = parent.childCount + for (i in 0 until childCount - 1) { + val child = parent.getChildAt(i) + val params = child.layoutParams as RecyclerView.LayoutParams + + val left = child.right + params.rightMargin + val right = left + divider.intrinsicWidth + + divider.setBounds(left, top, right, bottom) + divider.draw(canvas) + } + } + + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State + ) { + if (orientation == RecyclerView.VERTICAL) { + outRect.set(0, 0, 0, divider.intrinsicHeight) + } else { + outRect.set(0, 0, divider.intrinsicWidth, 0) + } + } +} \ No newline at end of file diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/BaseActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/BaseActivity.kt index 46287ceb..0cd7f647 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/BaseActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/BaseActivity.kt @@ -6,11 +6,16 @@ import android.os.Bundle import android.view.MenuItem import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.core.view.WindowCompat +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.RecyclerView import com.v2ray.ang.handler.SettingsManager +import com.v2ray.ang.helper.CustomDividerItemDecoration import com.v2ray.ang.util.MyContextWrapper import com.v2ray.ang.util.Utils + abstract class BaseActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -37,4 +42,24 @@ abstract class BaseActivity : AppCompatActivity() { override fun attachBaseContext(newBase: Context?) { super.attachBaseContext(MyContextWrapper.wrap(newBase ?: return, SettingsManager.getLocale())) } + + /** + * Adds a custom divider to a RecyclerView. + * + * @param recyclerView The target RecyclerView to which the divider will be added. + * @param context The context used to access resources. + * @param drawableResId The resource ID of the drawable to be used as the divider. + * @param orientation The orientation of the divider (DividerItemDecoration.VERTICAL or DividerItemDecoration.HORIZONTAL). + */ + fun addCustomDividerToRecyclerView(recyclerView: RecyclerView, context: Context?, drawableResId: Int, orientation: Int = DividerItemDecoration.VERTICAL) { + // Get the drawable from resources + val drawable = ContextCompat.getDrawable(context!!, drawableResId) + requireNotNull(drawable) { "Drawable resource not found" } + + // Create a DividerItemDecoration with the specified orientation + val dividerItemDecoration = CustomDividerItemDecoration(drawable, orientation) + + // Add the divider to the RecyclerView + recyclerView.addItemDecoration(dividerItemDecoration) + } } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/LogcatActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/LogcatActivity.kt index b275c348..3ee5b399 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/LogcatActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/LogcatActivity.kt @@ -5,7 +5,6 @@ import android.view.Menu import android.view.MenuItem import androidx.appcompat.widget.SearchView import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.v2ray.ang.AppConfig.ANG_PACKAGE @@ -34,8 +33,8 @@ class LogcatActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshListener { binding.recyclerView.setHasFixedSize(true) binding.recyclerView.layoutManager = LinearLayoutManager(this) + addCustomDividerToRecyclerView(binding.recyclerView, this, R.drawable.custom_divider) binding.recyclerView.adapter = adapter - binding.recyclerView.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL)) binding.refreshLayout.setOnRefreshListener(this) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt index 6d441abf..25618841 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt @@ -163,6 +163,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList binding.recyclerView.setHasFixedSize(true) binding.recyclerView.layoutManager = LinearLayoutManager(this) + addCustomDividerToRecyclerView(binding.recyclerView, this, R.drawable.custom_divider) binding.recyclerView.adapter = adapter mItemTouchHelper = ItemTouchHelper(SimpleItemTouchHelperCallback(adapter)) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainRecyclerAdapter.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainRecyclerAdapter.kt index 54cdecf8..f1b2cb82 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainRecyclerAdapter.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainRecyclerAdapter.kt @@ -178,7 +178,6 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter + + + + + + + + \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/layout/activity_bypass_list.xml b/V2rayNG/app/src/main/res/layout/activity_bypass_list.xml index 2665430a..5c23332d 100644 --- a/V2rayNG/app/src/main/res/layout/activity_bypass_list.xml +++ b/V2rayNG/app/src/main/res/layout/activity_bypass_list.xml @@ -41,6 +41,7 @@ android:maxLines="2" android:text="@string/title_pref_per_app_proxy" android:textAppearance="@style/TextAppearance.AppCompat.Small" + android:textColor="@color/colorAccent" app:theme="@style/BrandedSwitch" /> @@ -60,6 +61,7 @@ android:layout_height="wrap_content" android:text="@string/switch_bypass_apps_mode" android:textAppearance="@style/TextAppearance.AppCompat.Small" + android:textColor="@color/colorAccent" app:theme="@style/BrandedSwitch" /> @@ -77,9 +79,9 @@ diff --git a/V2rayNG/app/src/main/res/layout/activity_main.xml b/V2rayNG/app/src/main/res/layout/activity_main.xml index 9e0ae6e0..71e1c527 100644 --- a/V2rayNG/app/src/main/res/layout/activity_main.xml +++ b/V2rayNG/app/src/main/res/layout/activity_main.xml @@ -47,7 +47,7 @@ diff --git a/V2rayNG/app/src/main/res/layout/activity_routing_setting.xml b/V2rayNG/app/src/main/res/layout/activity_routing_setting.xml index 825c1c50..3032d6ce 100644 --- a/V2rayNG/app/src/main/res/layout/activity_routing_setting.xml +++ b/V2rayNG/app/src/main/res/layout/activity_routing_setting.xml @@ -17,41 +17,32 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:layout_margin="@dimen/layout_margin_top_height" + android:orientation="vertical"> - + android:text="@string/routing_settings_domain_strategy" /> - + + - - - + android:orientation="vertical" + android:paddingStart="@dimen/padding_start"> + android:focusable="true" + android:gravity="center_vertical"> + android:layout_width="@dimen/server_height" + android:layout_height="@dimen/server_height" + android:padding="@dimen/padding" /> + android:orientation="vertical"> + android:layout_height="wrap_content" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + android:maxLines="1" /> - + android:padding="@dimen/padding"/> \ No newline at end of file diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_logcat.xml b/V2rayNG/app/src/main/res/layout/item_recycler_logcat.xml index 927a79ed..fb1b6827 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_logcat.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_logcat.xml @@ -9,9 +9,11 @@ android:orientation="vertical"> + android:layout_margin="@dimen/layout_margin_spacing" + android:paddingTop="@dimen/layout_margin_spacing" + android:paddingBottom="@dimen/layout_margin_spacing"> - + android:layout_height="@dimen/server_height" + android:layout_gravity="center" + android:layout_margin="@dimen/layout_margin_spacing" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:gravity="center" + android:nextFocusRight="@+id/layout_share" + android:orientation="horizontal"> + android:orientation="vertical" /> + + - - + android:orientation="vertical"> - + android:maxLines="2" + android:minLines="1" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> - + - + - + + + + + + + + + + + + + + + + + + android:layout_height="@dimen/png_height" + app:srcCompat="@drawable/ic_share_24dp" /> + + + + + + + + + + + + android:layout_gravity="right" + android:orientation="vertical" + android:paddingBottom="4dp" + android:paddingEnd="@dimen/padding_end"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:lines="1" + android:textAppearance="@style/TextAppearance.AppCompat.Small" + android:textColor="@color/colorConfigType" + android:textSize="10sp" /> - - + + + diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml b/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml index daf1020f..71976d0f 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_routing_setting.xml @@ -6,113 +6,108 @@ android:layout_height="wrap_content" android:gravity="center_vertical"> - + android:paddingTop="@dimen/layout_margin_spacing" + android:paddingBottom="@dimen/layout_margin_spacing"> + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" + android:paddingStart="@dimen/padding_start"> + + + + + + + + + + + + + + + + - - - - - - - - - - - - + android:padding="@dimen/layout_margin_spacing"> + + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/layout_margin_spacing" + android:orientation="horizontal"> - - - - - - - - - + app:theme="@style/BrandedSwitch" /> - - + + + diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_sub_setting.xml b/V2rayNG/app/src/main/res/layout/item_recycler_sub_setting.xml index 663c53ab..a2e335be 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_sub_setting.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_sub_setting.xml @@ -6,115 +6,109 @@ android:layout_height="wrap_content" android:gravity="center_vertical"> - + android:paddingTop="@dimen/layout_margin_spacing" + android:paddingBottom="@dimen/layout_margin_spacing"> + + + + + + + + + android:orientation="vertical" + android:paddingStart="@dimen/padding_start" + android:paddingEnd="@dimen/padding_end"> + android:gravity="center" + android:orientation="horizontal"> - + android:background="?attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:focusable="true" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/layout_margin_spacing"> - + + + + + android:background="?attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:focusable="true" + android:gravity="center" + android:nextFocusLeft="@+id/info_container" + android:orientation="vertical" + android:padding="@dimen/layout_margin_spacing"> + + + + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/layout_margin_spacing" + android:orientation="horizontal"> - - - - - - - - - - - - - - - - - - - + app:theme="@style/BrandedSwitch" /> + - diff --git a/V2rayNG/app/src/main/res/layout/item_recycler_user_asset.xml b/V2rayNG/app/src/main/res/layout/item_recycler_user_asset.xml index cf1bf597..1fe9deb2 100644 --- a/V2rayNG/app/src/main/res/layout/item_recycler_user_asset.xml +++ b/V2rayNG/app/src/main/res/layout/item_recycler_user_asset.xml @@ -5,90 +5,84 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_margin="@dimen/layout_margin_spacing" + android:background="?attr/selectableItemBackground" + android:gravity="center" + android:orientation="horizontal" + android:padding="@dimen/nav_header_vertical_spacing"> + android:layout_weight="1" + android:orientation="vertical" + android:paddingStart="@dimen/padding_start"> + android:orientation="vertical"> - + android:maxLines="2" + android:minLines="1" + android:textAppearance="@style/TextAppearance.AppCompat.Subhead" + tools:text="Placeholder.dat" /> - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/V2rayNG/app/src/main/res/values-night/colors.xml b/V2rayNG/app/src/main/res/values-night/colors.xml index 35b55f82..ff1c835f 100644 --- a/V2rayNG/app/src/main/res/values-night/colors.xml +++ b/V2rayNG/app/src/main/res/values-night/colors.xml @@ -3,6 +3,7 @@ #f97910 #646464 #BDBDBD + #424242 #212121 #FFFFFF diff --git a/V2rayNG/app/src/main/res/values/colors.xml b/V2rayNG/app/src/main/res/values/colors.xml index 4d6f262c..8e328f84 100644 --- a/V2rayNG/app/src/main/res/values/colors.xml +++ b/V2rayNG/app/src/main/res/values/colors.xml @@ -7,6 +7,7 @@ #f97910 #9C9C9C #727272 + #E0E0E0 #F5F5F5 #000000 diff --git a/V2rayNG/app/src/main/res/values/dimens.xml b/V2rayNG/app/src/main/res/values/dimens.xml index 84a8a180..313fa475 100644 --- a/V2rayNG/app/src/main/res/values/dimens.xml +++ b/V2rayNG/app/src/main/res/values/dimens.xml @@ -1,6 +1,6 @@ - 50dp + 64dp 16dp 16dp 8dp