pull/32/head
kunfei 5 years ago
parent a6f923a09a
commit a9a8d720e6
  1. 4
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 34
      app/src/main/java/io/legado/app/ui/readbook/config/MoreConfigDialog.kt
  3. 14
      app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt

@ -19,6 +19,7 @@ import io.legado.app.receiver.TimeElectricityReceiver
import io.legado.app.service.ReadAloudService import io.legado.app.service.ReadAloudService
import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.ui.readbook.config.MoreConfigDialog
import io.legado.app.ui.readbook.config.ReadStyleDialog import io.legado.app.ui.readbook.config.ReadStyleDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.widget.page.ChapterProvider import io.legado.app.ui.widget.page.ChapterProvider
@ -168,7 +169,8 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
} }
override fun showMoreSetting() { override fun showMoreSetting() {
runMenuOut()
MoreConfigDialog().show(supportFragmentManager, "moreConfig")
} }
override fun toast(id: Int) { override fun toast(id: Int) {

@ -1,15 +1,41 @@
package io.legado.app.ui.readbook.config package io.legado.app.ui.readbook.config
import android.os.Bundle import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.DialogFragment
import io.legado.app.R import io.legado.app.R
class MoreConfigDialog : PreferenceFragmentCompat() { class MoreConfigDialog : DialogFragment() {
private val readPreferTag = "readPreferenceFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreateView(
addPreferencesFromResource(R.xml.pref_config_read) inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = LinearLayout(context)
view.id = R.id.tag1
container?.addView(view)
return view
} }
override fun onStart() {
super.onStart()
val dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
dialog?.window?.setLayout((dm.widthPixels * 0.9).toInt(), (dm.heightPixels * 0.9).toInt())
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
var preferenceFragment = childFragmentManager.findFragmentByTag(readPreferTag)
if (preferenceFragment == null) preferenceFragment = ReadPreferenceFragment()
childFragmentManager.beginTransaction().replace(view.id, preferenceFragment, readPreferTag)
.commit()
}
} }

@ -0,0 +1,14 @@
package io.legado.app.ui.readbook.config
import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
class ReadPreferenceFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_config_read)
}
}
Loading…
Cancel
Save