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

Commit

Permalink
Optimized UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AnGgIt86 committed Sep 23, 2024
1 parent 0daea33 commit 7ba9122
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
val subItem = mActivity.subscriptions[position].second
holder.itemSubSettingBinding.tvName.text = subItem.remarks
holder.itemSubSettingBinding.tvUrl.text = subItem.url
if (subItem.enabled) {
holder.itemSubSettingBinding.chkEnable.setBackgroundResource(R.drawable.uwu_selected_indicator)
} else {
holder.itemSubSettingBinding.chkEnable.setBackgroundResource(0)
}
holder.itemSubSettingBinding.chkEnable.isChecked = subItem.enabled
holder.itemView.setBackgroundColor(Color.TRANSPARENT)

holder.itemSubSettingBinding.layoutEdit.setOnClickListener {
Expand All @@ -46,10 +42,9 @@ class SubSettingRecyclerAdapter(val activity: SubSettingActivity) :
.putExtra("subId", subId)
)
}
holder.itemSubSettingBinding.infoContainer.setOnClickListener {
subItem.enabled = !subItem.enabled
holder.itemSubSettingBinding.chkEnable.setOnCheckedChangeListener { _, isChecked ->
subItem.enabled = isChecked
subStorage?.encode(subId, Gson().toJson(subItem))
notifyItemChanged(position)
}

if (TextUtils.isEmpty(subItem.url)) {
Expand Down
164 changes: 125 additions & 39 deletions app/src/main/res/layout/activity_sub_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,128 @@
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:orientation="horizontal"
android:background="@drawable/uwu_bg_sin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0.0dip"
android:layout_marginBottom="16.0dip"
android:layout_marginStart="16.0dip"
android:layout_marginEnd="16.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="0.0dip"
android:layout_height="match_parent"
android:layout_weight="1.0">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8.0dip"
android:layout_marginBottom="8.0dip"
android:layout_marginStart="8.0dip"
android:layout_marginEnd="4.0dip"
app:cardBackgroundColor="?attr/colorPrimaryContainer"
app:cardCornerRadius="24.0dip"
app:cardElevation="0.0dip"
app:strokeWidth="0.0dip">
<FrameLayout
android:background="#00000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_gravity="center"
android:orientation="vertical"
android:paddingTop="18.0dip"
android:paddingBottom="16.0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:paddingStart="16.0dip"
android:paddingEnd="16.0dip">
<com.neko.switchbutton.SwitchButton
android:gravity="center"
android:layout_gravity="center"
android:id="@+id/chk_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:kswAnimationDuration="300"
app:kswBackDrawable="@drawable/uwu_switch_track"
app:kswThumbDrawable="@drawable/uwu_switch_thumb" />
<com.neko.marquee.text.AutoMarqueeTextView
android:gravity="center"
android:layout_gravity="center"
android:textColor="?android:textColorPrimary"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_marginTop="8.0dip"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_setting_enable"
android:layout_below="@+id/chk_enable"
android:marqueeRepeatLimit="marquee_forever" />
</LinearLayout>
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0.0dip"
android:layout_height="match_parent"
android:layout_weight="1.0">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8.0dip"
android:layout_marginBottom="8.0dip"
android:layout_marginStart="4.0dip"
android:layout_marginEnd="8.0dip"
app:cardBackgroundColor="?attr/colorPrimaryContainer"
app:cardCornerRadius="24.0dip"
app:cardElevation="0.0dip"
app:strokeWidth="0.0dip">
<FrameLayout
android:background="#00000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_gravity="center"
android:orientation="vertical"
android:paddingTop="18.0dip"
android:paddingBottom="16.0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:paddingStart="16.0dip"
android:paddingEnd="16.0dip">
<com.neko.switchbutton.SwitchButton
android:gravity="center"
android:layout_gravity="center"
android:id="@+id/auto_update_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:kswAnimationDuration="300"
app:kswBackDrawable="@drawable/uwu_switch_track"
app:kswThumbDrawable="@drawable/uwu_switch_thumb" />
<com.neko.marquee.text.AutoMarqueeTextView
android:gravity="center"
android:layout_gravity="center"
android:textColor="?android:textColorPrimary"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_marginTop="8.0dip"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_auto_update"
android:layout_below="@+id/auto_update_check"
android:marqueeRepeatLimit="marquee_forever" />
</LinearLayout>
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:background="@drawable/uwu_card_view_rounded"
Expand Down Expand Up @@ -312,47 +434,11 @@
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip"
android:maxLines="10"
android:minLines="2"
android:minLines="1"
android:inputType="textMultiLine"
tools:ignore="TextFields" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8.0dip"
android:layout_marginBottom="8.0dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_setting_enable"
android:layout_weight="1.0" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/chk_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="2.0dip"
android:paddingEnd="6.0dip" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8.0dip"
android:layout_marginBottom="8.0dip">
<TextView
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:text="@string/sub_auto_update"
android:layout_weight="1.0" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/auto_update_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="2.0dip"
android:paddingEnd="6.0dip" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
Expand All @@ -372,7 +458,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip"
android:maxLines="10"
android:minLines="5"
android:minLines="1"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Expand All @@ -395,7 +481,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip"
android:maxLines="10"
android:minLines="5"
android:minLines="1"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Expand Down
31 changes: 13 additions & 18 deletions app/src/main/res/layout/item_recycler_sub_setting.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center_vertical"
android:id="@+id/item_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:orientation="horizontal"
android:id="@+id/item_cardview"
Expand All @@ -32,27 +31,23 @@
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:id="@+id/chk_enable"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:background="@drawable/uwu_google_shape"
android:layout_width="45.0dip"
android:layout_height="45.0dip"
android:layout_width="55.0dip"
android:layout_height="55.0dip"
android:layout_marginStart="16.0dip"
android:layout_marginEnd="5.0dip"
android:backgroundTint="?attr/colorThemeUwu">
<androidx.preference.internal.PreferenceImageView
<com.neko.switchbutton.SwitchButton
android:gravity="center"
android:layout_width="25.0dip"
android:layout_height="25.0dip"
android:layout_marginTop="10.0dip"
android:src="@drawable/ic_social_emoji_symbols"
android:tint="?colorIcon"
android:layout_marginStart="10.0dip"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_gravity="center"
android:id="@+id/chk_enable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:kswAnimationDuration="300"
app:kswBackDrawable="@drawable/uwu_switch_track"
app:kswThumbDrawable="@drawable/uwu_switch_thumb" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
Expand Down

0 comments on commit 7ba9122

Please sign in to comment.