pull/32/head
gedoor 6 years ago
parent 11c796456c
commit 794a27f079
  1. 35
      app/src/main/java/io/legado/app/lib/theme/view/ATEStockSwitch.kt
  2. 26
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt
  3. 98
      app/src/main/res/layout/item_book_source.xml
  4. 3
      app/src/main/res/values/ids.xml

@ -1,35 +0,0 @@
package io.legado.app.lib.theme.view
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.Switch
import androidx.appcompat.widget.SwitchCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore
/**
* @author Aidan Follestad (afollestad)
*/
class ATEStockSwitch : SwitchCompat {
constructor(context: Context) : super(context) {
init(context, null)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs)
}
private fun init(context: Context, attrs: AttributeSet?) {
ATH.setTint(this, ThemeStore.accentColor(context))
}
override fun isShown(): Boolean {
return parent != null && visibility == View.VISIBLE
}
}

@ -1,8 +1,10 @@
package io.legado.app.ui.main.booksource
import android.view.LayoutInflater
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.PopupMenu
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
@ -52,6 +54,30 @@ class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewH
checkedList.remove(bookSource.origin)
}
}
sw_enabled.isEnabled = bookSource.isEnabled
sw_enabled.setOnClickListener{
bookSource.isEnabled = sw_enabled.isEnabled
callback?.update(bookSource)
}
iv_more.setOnClickListener{
val popupMenu = PopupMenu(context, this)
popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit)
popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete)
popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top)
popupMenu.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_edit ->{
callback?.edit(bookSource)
true}
R.id.menu_del ->{
callback?.del(bookSource)
true}
R.id.menu_top ->{ true}
else -> {false}
}
}
popupMenu.show()
}
}
}

@ -1,73 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="16dp"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_book_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<io.legado.app.lib.theme.view.ATECheckBox
android:id="@+id/cb_book_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:text=""
android:textColor="@color/tv_text_default"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_edit_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/edit"
android:padding="8dp"
android:src="@drawable/ic_edit"
app:tint="@color/tv_text_default"/>
<ImageView
android:id="@+id/iv_top_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/to_top"
android:padding="8dp"
android:src="@drawable/ic_top_source"
app:tint="@color/tv_text_default"/>
<ImageView
android:id="@+id/iv_del_source"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/delete"
android:padding="8dp"
android:src="@drawable/ic_clear_all"
app:tint="@color/tv_text_default"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/btn_bg_press"/>
android:layout_gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:text=""
android:textColor="@color/tv_text_default"/>
<io.legado.app.lib.theme.view.ATESwitch
android:id="@+id/sw_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/iv_more"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/bg_ib_pre_round"
android:contentDescription="@string/to_top"
android:padding="8dp"
android:src="@drawable/ic_more_vert"
app:tint="@color/tv_text_default"/>
</LinearLayout>

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="menu_edit" type="id"/>
<item name="menu_del" type="id"/>
<item name="menu_top" type="id"/>
</resources>
Loading…
Cancel
Save