调整我的UI

pull/169/head
yangyxd 5 years ago
parent 18cf6814bc
commit 6e97e11435
  1. 7
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  2. 6
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  3. 12
      app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt
  4. 12
      app/src/main/res/layout/view_preference.xml
  5. 2
      app/src/main/res/values/colors.xml
  6. 2
      app/src/main/res/xml/pref_config_read.xml
  7. 9
      app/src/main/res/xml/pref_config_theme.xml
  8. 11
      app/src/main/res/xml/pref_main.xml

@ -19,6 +19,7 @@ import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ColorUtils
import io.legado.app.ui.widget.number.NumberPickerDialog
import io.legado.app.ui.widget.prefs.IconListPreference
import io.legado.app.ui.widget.prefs.NameListPreference
import io.legado.app.utils.*
@ -33,6 +34,12 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
preferenceScreen.removePreference(it)
}
}
findPreference<NameListPreference>(PreferKey.themeMode)?.let {
it.setOnPreferenceChangeListener { _, _ ->
view?.post { App.INSTANCE.applyDayNight() }
true
}
}
upPreferenceSummary("barElevation", AppConfig.elevation.toString())
}

@ -79,12 +79,6 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
observeEvent<Boolean>(EventBus.WEB_SERVICE_STOP) {
webServicePre?.isChecked = false
}
findPreference<NameListPreference>(PreferKey.themeMode)?.let {
it.setOnPreferenceChangeListener { _, _ ->
view?.post { App.INSTANCE.applyDayNight() }
true
}
}
if (requireContext().channel == "google") {
findPreference<PreferenceCategory>("aboutCategory")
?.removePreference(findPreference("donate"))

@ -44,11 +44,17 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr
iconView.setImageDrawable(icon)
iconView.setColorFilter(context.accentColor)
}
val paddingView = it.findViewById(R.id.preference_padding)
if (paddingView != null) {
paddingView.isVisible = view.isVisible && tvSummary != null && tvSummary.isVisible
}
}
if (weightLayoutRes != null && weightLayoutRes != 0 && viewId != null && viewId != 0) {
val lay = it.findViewById(R.id.preference_widget)
if (lay is FrameLayout) {
var needRequestLayout = false
var v = it.itemView.findViewById<T>(viewId)
if (v == null) {
val inflater: LayoutInflater = context.layoutInflater
@ -57,7 +63,8 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr
lay.addView(childView)
lay.isVisible = true
v = lay.findViewById(viewId)
}
} else
needRequestLayout = true
if (weightWidth > 0 || weightHeight > 0) {
val lp = lay.layoutParams
@ -66,7 +73,8 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr
if (weightWidth > 0)
lp.width = (context.resources.displayMetrics.density * weightWidth).roundToInt()
lay.layoutParams = lp
}
} else if (needRequestLayout)
v.requestLayout()
return v
}

@ -7,7 +7,7 @@
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:paddingBottom="10dp"
android:minHeight="42dp"
android:clickable="true"
android:orientation="horizontal"
@ -27,11 +27,11 @@
android:orientation="vertical"
android:layout_weight="1.0"
android:layout_width="0dp"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<TextView
android:id="@+id/preference_title"
android:paddingBottom="8dp"
android:singleLine="true"
android:textSize="16sp"
android:text="@string/title"
@ -39,9 +39,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:id="@+id/preference_padding"
android:layout_width="match_parent"
android:layout_height="6dp" />
<TextView
android:id="@+id/preference_desc"
android:paddingBottom="8dp"
android:textSize="14sp"
android:textColor="@color/tv_text_summary"
android:text="@string/default1"
@ -54,8 +58,6 @@
android:orientation="vertical"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:visibility="gone"
android:gravity="right|center_vertical"
android:layout_width="wrap_content"

@ -16,7 +16,7 @@
<color name="background">@color/md_grey_50</color>
<color name="background_card">@color/md_grey_100</color>
<color name="background_menu">@color/md_grey_200</color>
<color name="background_prefs">@color/md_grey_50</color>
<color name="background_prefs">#7fffffff</color>
<color name="transparent">#00000000</color>
<color name="transparent10">#10000000</color>

@ -60,7 +60,7 @@
android:key="selectText"
app:iconSpaceReserved="false" />
<Preference
<io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey"
android:title="@string/custom_page_key"
app:iconSpaceReserved="false" />

@ -12,6 +12,15 @@
app:icons="@array/icons"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:defaultValue="0"
android:entries="@array/theme_mode"
android:entryValues="@array/theme_mode_v"
android:key="themeMode"
android:title="@string/theme_mode"
android:summary="@string/theme_mode_desc"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:key="transparentStatusBar"

@ -20,16 +20,6 @@
android:icon="@drawable/ic_cfg_replace"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:defaultValue="0"
android:entries="@array/theme_mode"
android:entryValues="@array/theme_mode_v"
android:key="themeMode"
android:title="@string/theme_mode"
android:summary="@string/theme_mode_desc"
android:icon="@drawable/ic_cfg_theme"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="isEInkMode"
@ -48,7 +38,6 @@
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.PreferenceCategory
android:title="@string/setting"
app:iconSpaceReserved="false"
app:allowDividerAbove="true"
app:allowDividerBelow="false" >

Loading…
Cancel
Save