pull/32/head
GKF 6 years ago
parent 304c099151
commit d066cda2c1
  1. 4
      app/build.gradle
  2. 5
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
  3. 6
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  4. 28
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  5. 2
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
  6. 5
      app/src/main/java/io/legado/app/utils/AlertDialogExtensions.kt
  7. 13
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt
  8. 39
      app/src/main/res/layout/dialog_input.xml
  9. 8
      app/src/main/res/values/styles.xml

@ -129,4 +129,8 @@ dependencies {
// //
implementation 'com.jaredrummler:colorpicker:1.1.0' implementation 'com.jaredrummler:colorpicker:1.1.0'
//
implementation 'com.afollestad.material-dialogs:core:3.0.0-rc3'
implementation 'com.afollestad.material-dialogs:input:3.0.0-rc3'
implementation 'com.afollestad.material-dialogs:files:3.0.0-rc3'
} }

@ -2,6 +2,7 @@ package io.legado.app.data.dao
import androidx.paging.DataSource import androidx.paging.DataSource
import androidx.room.Dao import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query import androidx.room.Query
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
@ -11,5 +12,9 @@ interface BookGroupDao {
@Query("SELECT * FROM book_groups ORDER BY `order`") @Query("SELECT * FROM book_groups ORDER BY `order`")
fun observeAll(): DataSource.Factory<Int, BookGroup> fun observeAll(): DataSource.Factory<Int, BookGroup>
@get:Query("SELECT MAX(groupId) FROM book_groups")
val maxId: Int
@Insert
fun insert(bookGroup: BookGroup)
} }

@ -54,7 +54,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
upTheme(false) upTheme(false)
} }
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(false) } .setNegativeButton(R.string.cancel) { _, _ -> upTheme(false) }
.show().upTint .show().upTint()
} }
} else { } else {
upTheme(false) upTheme(false)
@ -74,7 +74,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
upTheme(true) upTheme(true)
} }
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(true) } .setNegativeButton(R.string.cancel) { _, _ -> upTheme(true) }
.show().upTint .show().upTint()
} }
} else { } else {
upTheme(true) upTheme(true)
@ -105,7 +105,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
Handler().postDelayed({ activity?.recreate() }, 100) Handler().postDelayed({ activity?.recreate() }, 100)
} }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show().upTint .show().upTint()
} }
} }
} }

@ -9,6 +9,8 @@ import androidx.paging.LivePagedListBuilder
import androidx.paging.PagedList import androidx.paging.PagedList
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseFragment import io.legado.app.base.BaseFragment
@ -17,6 +19,8 @@ import io.legado.app.data.entities.BookGroup
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
import kotlinx.android.synthetic.main.fragment_bookshelf.* import kotlinx.android.synthetic.main.fragment_bookshelf.*
import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.android.synthetic.main.view_title_bar.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.anko.textColor import org.jetbrains.anko.textColor
class BookshelfFragment : BaseFragment(R.layout.fragment_bookshelf) { class BookshelfFragment : BaseFragment(R.layout.fragment_bookshelf) {
@ -42,6 +46,30 @@ class BookshelfFragment : BaseFragment(R.layout.fragment_bookshelf) {
rv_book_group.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) rv_book_group.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
bookGroupAdapter = BookGroupAdapter() bookGroupAdapter = BookGroupAdapter()
rv_book_group.adapter = bookGroupAdapter rv_book_group.adapter = bookGroupAdapter
bookGroupAdapter.callBack = object : BookGroupAdapter.CallBack {
override fun open(groupId: Int) {
when (groupId) {
-10 -> context?.let {
MaterialDialog(it).show {
title(text = "新建分组")
input(hint = "分组名称") { _, charSequence ->
run {
GlobalScope.launch {
App.db.bookGroupDao().insert(
BookGroup(
App.db.bookGroupDao().maxId + 1,
charSequence.toString()
)
)
}
}
}
positiveButton(R.string.ok)
}
}
}
}
}
rv_bookshelf.layoutManager = LinearLayoutManager(context) rv_bookshelf.layoutManager = LinearLayoutManager(context)
rv_bookshelf.addItemDecoration(DividerItemDecoration(rv_bookshelf.context, LinearLayoutManager.VERTICAL)) rv_bookshelf.addItemDecoration(DividerItemDecoration(rv_bookshelf.context, LinearLayoutManager.VERTICAL))
bookshelfAdapter = BookshelfAdapter() bookshelfAdapter = BookshelfAdapter()

@ -101,6 +101,6 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
} }
override fun edit(bookSource: BookSource) { override fun edit(bookSource: BookSource) {
context?.let { it.startActivity<SourceEditActivity>(Pair("data", bookSource.origin)) } context?.startActivity<SourceEditActivity>(Pair("data", bookSource.origin))
} }
} }

@ -3,5 +3,6 @@ package io.legado.app.utils
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
val AlertDialog.upTint: AlertDialog fun AlertDialog.upTint(): AlertDialog {
get() = ATH.setAlertDialogTint(this) return ATH.setAlertDialogTint(this)
}

@ -0,0 +1,13 @@
package io.legado.app.utils
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import io.legado.app.App
fun View.hidehideSoftInput() = run {
val imm = App.INSTANCE.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.let {
imm.hideSoftInputFromWindow(this.windowToken, 0)
}
}

@ -0,0 +1,39 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"/>
<io.legado.app.lib.theme.view.ATEAutoCompleteTextView
android:id="@+id/et_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:completionThreshold="0"
android:maxLines="5"
tools:ignore="LabelFor"/>
<TextView
android:id="@+id/tv_ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/selector_fillet_btn_bg"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:text="@string/ok"
android:textColor="@color/tv_text_default"/>
</LinearLayout>

@ -48,13 +48,7 @@
<item name="colorAccent">@color/md_grey_900</item> <item name="colorAccent">@color/md_grey_900</item>
</style> </style>
<style name="AppTheme.AlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert"> <style name="AppTheme.AlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert"/>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:background">@color/background_card</item>
<item name="android:textColor">@color/tv_text_default</item>
<item name="android:textColorPrimary">@color/tv_text_default</item>
<item name="textColorAlertDialogListItem">@color/tv_text_default</item>
</style>
//**************************************************************System //**************************************************************System
Style******************************************************************************// Style******************************************************************************//

Loading…
Cancel
Save