diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 750f6139d..a78b9ae50 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -1,7 +1,7 @@ ## 更新日志 * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 -* 弄了个企业公众号[开源阅读](),后面弄好后会把原来的开源阅读软件迁移过来 +* 弄了个企业公众号[开源阅读](),后面弄好后会把原来的[开源阅读软件]()迁移过来 **2020/03/19** * 美化界面我的 by yangyxd diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt index 9b619c551..101b6678a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt @@ -6,24 +6,14 @@ import android.content.res.TypedArray import android.graphics.Color import android.os.Bundle import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.LinearLayout -import android.widget.TextView import androidx.annotation.ColorInt import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog -import androidx.appcompat.widget.SwitchCompat -import androidx.core.view.isVisible import androidx.fragment.app.FragmentActivity import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import com.jaredrummler.android.colorpicker.* import io.legado.app.lib.theme.ATH -import io.legado.app.lib.theme.accentColor -import org.jetbrains.anko.layoutInflater -import org.jetbrains.anko.px2dip class ColorPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs), ColorPickerDialogListener { @@ -121,12 +111,12 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex } override fun onBindViewHolder(holder: PreferenceViewHolder) { - super.onBindViewHolder(holder) val v = io.legado.app.ui.widget.prefs.Preference.bindView(context, holder, icon, title, summary, widgetLayoutResource, io.legado.app.R.id.cpv_preference_preview_color_panel, 30, 30) if (v is ColorPanelView) { - v?.color = color + v.color = color } + super.onBindViewHolder(holder) } override fun onSetInitialValue(defaultValue: Any?) { diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/EditTextPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/EditTextPreference.kt index b914afcf5..8c0e39da3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/EditTextPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/EditTextPreference.kt @@ -14,9 +14,8 @@ class EditTextPreference(context: Context, attrs: AttributeSet) : androidx.prefe } override fun onBindViewHolder(holder: PreferenceViewHolder?) { + Preference.bindView(context, holder, icon, title, summary, null, null) super.onBindViewHolder(holder) - val txt = if (text == null || text.isEmpty()) summary else text - val v = Preference.bindView(context, holder, icon, title, txt, null, null) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index 2e043b4c3..fa8b4eeb7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -10,22 +10,17 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView -import android.widget.TextView -import androidx.core.view.isVisible import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentActivity import androidx.preference.ListPreference import androidx.preference.PreferenceViewHolder import androidx.recyclerview.widget.LinearLayoutManager -import com.jaredrummler.android.colorpicker.ColorPanelView import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter -import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getCompatDrawable import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.item_icon_preference.view.* -import org.jetbrains.anko.layoutInflater import org.jetbrains.anko.sdk27.listeners.onClick @@ -34,7 +29,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference private val mEntryDrawables = arrayListOf() init { - layoutResource = io.legado.app.R.layout.view_preference + layoutResource = R.layout.view_preference widgetLayoutResource = R.layout.view_icon val a = context.theme.obtainStyledAttributes(attrs, R.styleable.IconListPreference, 0, 0) @@ -63,7 +58,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference val selectedIndex = findIndexOfValue(value) if (selectedIndex >= 0) { val drawable = mEntryDrawables[selectedIndex] - v?.setImageDrawable(drawable) + v.setImageDrawable(drawable) } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/NameListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/NameListPreference.kt index f4c1ccac2..0763c8474 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/NameListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/NameListPreference.kt @@ -16,10 +16,10 @@ class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference } override fun onBindViewHolder(holder: PreferenceViewHolder?) { - super.onBindViewHolder(holder) val v = Preference.bindView(context, holder, icon, title, summary, widgetLayoutResource, R.id.text_view) if (v is TextView) { - v?.text = entry + v.text = entry } + super.onBindViewHolder(holder) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt index 30603c89d..0190dcd9f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt @@ -1,33 +1,17 @@ package io.legado.app.ui.widget.prefs import android.content.Context -import android.content.ContextWrapper -import android.content.res.TypedArray -import android.graphics.Color import android.graphics.drawable.Drawable -import android.media.Image -import android.os.Bundle import android.util.AttributeSet import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView -import androidx.annotation.ColorInt -import androidx.annotation.StringRes -import androidx.appcompat.app.AlertDialog -import androidx.appcompat.widget.SwitchCompat import androidx.core.view.isVisible -import androidx.core.view.updateLayoutParams -import androidx.fragment.app.FragmentActivity -import androidx.preference.Preference import androidx.preference.PreferenceViewHolder -import com.jaredrummler.android.colorpicker.* -import io.legado.app.lib.theme.ATH import io.legado.app.R import io.legado.app.lib.theme.accentColor -import org.jetbrains.anko.imageBitmap import org.jetbrains.anko.layoutInflater import kotlin.math.roundToInt @@ -44,21 +28,21 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr weightWidth: Int = 0, weightHeight: Int = 0): T? { if (it == null) return null val view = it.findViewById(R.id.preference_title) - if (view is TextView) { // && !view.isInEditMode + if (view is TextView) { view.text = title view.isVisible = title != null && title.isNotEmpty() - val tv_summary = it.findViewById(R.id.preference_desc) - if(tv_summary is TextView) { - tv_summary.text = summary - tv_summary.isVisible = summary != null && summary.isNotEmpty() + val tvSummary = it.findViewById(R.id.preference_desc) + if (tvSummary is TextView) { + tvSummary.text = summary + tvSummary.isVisible = summary != null && summary.isNotEmpty() } - val _icon = it.findViewById(R.id.preference_icon) - if (_icon is ImageView) { - _icon.isVisible = icon != null && icon.isVisible - _icon.setImageDrawable(icon) - _icon.setColorFilter(context.accentColor) + val iconView = it.findViewById(R.id.preference_icon) + if (iconView is ImageView) { + iconView.isVisible = icon != null && icon.isVisible + iconView.setImageDrawable(icon) + iconView.setColorFilter(context.accentColor) } } @@ -72,7 +56,7 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr lay.removeAllViews() lay.addView(childView) lay.isVisible = true - v = lay.findViewById(viewId) + v = lay.findViewById(viewId) } if (weightWidth > 0 || weightHeight > 0) { @@ -94,8 +78,8 @@ class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Pr } override fun onBindViewHolder(holder: PreferenceViewHolder?) { - super.onBindViewHolder(holder) bindView(context, holder, icon, title, summary, null, null) + super.onBindViewHolder(holder) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt index 91532bbb5..2f6becfc2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt @@ -17,11 +17,19 @@ class SwitchPreference(context: Context, attrs: AttributeSet) : } override fun onBindViewHolder(holder: PreferenceViewHolder?) { - super.onBindViewHolder(holder) - val v = Preference.bindView(context, holder, icon, title, summary, widgetLayoutResource, R.id.switchWidget) + val v = Preference.bindView( + context, + holder, + icon, + title, + summary, + widgetLayoutResource, + R.id.switchWidget + ) if (v is SwitchCompat) { ATH.setTint(v, context.accentColor) } + super.onBindViewHolder(holder) } }