Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Little fix and change
Browse files Browse the repository at this point in the history
  • Loading branch information
AnGgIt86 committed Sep 26, 2024
1 parent cf35b2d commit c1ee5e8
Show file tree
Hide file tree
Showing 6 changed files with 261 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import android.widget.AdapterView
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.neko.v2ray.AppConfig
import com.neko.v2ray.R
import com.neko.v2ray.databinding.ActivityRoutingSettingBinding
Expand All @@ -33,8 +35,10 @@ class RoutingSettingActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)

title = getString(R.string.routing_settings_title)
val toolbar = findViewById<MaterialToolbar>(R.id.toolbar)
val toolbarLayout = findViewById<CollapsingToolbarLayout>(R.id.collapsing_toolbar)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

binding.recyclerView.setHasFixedSize(true)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) :
holder.itemRoutingSettingBinding.domainIp.text = (ruleset.domain ?: ruleset.ip ?: ruleset.port)?.toString()
holder.itemRoutingSettingBinding.outboundTag.text = ruleset.outboundTag
holder.itemRoutingSettingBinding.chkEnable.isChecked = ruleset.enabled
holder.itemRoutingSettingBinding.autoUpdateCheck.isChecked = ruleset.enabled
holder.itemView.setBackgroundColor(Color.TRANSPARENT)

holder.itemRoutingSettingBinding.layoutEdit.setOnClickListener {
Expand All @@ -35,11 +34,6 @@ class RoutingSettingRecyclerAdapter(val activity: RoutingSettingActivity) :
ruleset.enabled = isChecked
SettingsManager.saveRoutingRuleset(position, ruleset)
}

holder.itemRoutingSettingBinding.autoUpdateCheck.setOnCheckedChangeListener { _, isChecked ->
ruleset.enabled = isChecked
SettingsManager.saveRoutingRuleset(position, ruleset)
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MainViewHolder {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_routing_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/server_lab_remarks"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_remarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/server_lab_remarks"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Expand All @@ -303,6 +305,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/routing_settings_domain"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_domain"
Expand All @@ -323,6 +326,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:hint="@string/routing_settings_ip"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_ip"
Expand All @@ -335,11 +339,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/routing_settings_port"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_port"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/routing_settings_port"
android:inputType="number" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Expand All @@ -353,6 +359,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/routing_settings_protocol"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_protocol"
Expand All @@ -372,6 +379,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/routing_settings_network"
app:expandedHintEnabled="false"
style="@style/Outline_TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_network"
Expand Down
159 changes: 100 additions & 59 deletions app/src/main/res/layout/activity_routing_setting.xml
Original file line number Diff line number Diff line change
@@ -1,70 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/main_content"
android:fitsSystemWindows="true"
tools:context=".ui.RoutingSettingActivity">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:theme="@style/AppTheme.AppBarOverlay"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:theme="@style/Uwu.Material3.CollapsingToolbar"
android:id="@+id/collapsing_toolbar"
android:background="?attr/colorThemeUwu"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
app:contentScrim="?attr/colorThemeUwu"
app:expandedTitleMarginBottom="24.0dip"
app:expandedTitleMarginEnd="24.0dip"
app:expandedTitleMarginStart="24.0dip"
app:expandedTitleTextAppearance="@style/CollapsingToolbarTitle.Expanded"
app:extraMultilineHeightEnabled="true"
app:forceApplySystemWindowInsetTop="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:maxLines="3"
app:scrimAnimationDuration="50"
app:statusBarScrim="@null"
app:title="@string/routing_settings_title"
app:titleCollapseMode="scale"
app:toolbarId="@+id/toolbar">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/cardview_margin"
android:orientation="horizontal"
card_view:cardCornerRadius="5dp">

android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.appcompat.widget.ActionBarContextView
android:theme="?attr/actionModeTheme"
android:id="@+id/action_context_bar"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:background="@drawable/uwu_background_lengkung"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.cardview.widget.CardView
android:paddingTop="16.0dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16.0dip"
android:layout_marginBottom="0.0dip"
android:layout_marginStart="16.0dip"
android:layout_marginEnd="16.0dip"
app:cardBackgroundColor="#00000000"
app:cardCornerRadius="28.0dip"
app:cardElevation="0.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:paddingStart="@dimen/padding_start"
android:paddingEnd="@dimen/padding_end"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routing_settings_domain_strategy" />

<Spinner
android:id="@+id/sp_domain_strategy"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:background="@drawable/uwu_tab_indicator"
android:backgroundTint="@color/uwu_bg_card"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height"
android:entries="@array/routing_domain_strategy" />
android:layout_height="wrap_content"
android:layout_margin="8.0dip">
<Spinner
android:entries="@array/routing_domain_strategy"
android:id="@+id/sp_domain_strategy"
android:focusable="true"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="@dimen/edit_height" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/padding_start"
android:layout_marginTop="@dimen/layout_margin_top_height"
android:layout_marginBottom="@dimen/layout_margin_top_height"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/routing_settings_rule_title"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
android:fillViewport="true"
android:layout_marginStart="-16.0dip"
android:layout_marginEnd="-16.0dip"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0.0dip"
android:layout_marginBottom="0.0dip" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_recycler_routing_setting" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading

0 comments on commit c1ee5e8

Please sign in to comment.