pull/32/head
parent
a6f923a09a
commit
a9a8d720e6
@ -1,15 +1,41 @@ |
||||
package io.legado.app.ui.readbook.config |
||||
|
||||
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 |
||||
|
||||
class MoreConfigDialog : PreferenceFragmentCompat() { |
||||
class MoreConfigDialog : DialogFragment() { |
||||
|
||||
private val readPreferTag = "readPreferenceFragment" |
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
||||
addPreferencesFromResource(R.xml.pref_config_read) |
||||
override fun onCreateView( |
||||
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…
Reference in new issue