feat: 优化代码

pull/379/head
kunfei 5 years ago
parent 5613d2c215
commit 5d8df47bb4
  1. 8
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  2. 6
      app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt
  3. 12
      app/src/main/res/menu/main_my.xml

@ -24,6 +24,7 @@ import io.legado.app.ui.config.ConfigActivity
import io.legado.app.ui.config.ConfigViewModel
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.ui.widget.prefs.NameListPreference
import io.legado.app.ui.widget.prefs.PreferenceCategory
import io.legado.app.ui.widget.prefs.SwitchPreference
@ -48,9 +49,10 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
override fun onCompatOptionsItemSelected(item: MenuItem) {
when (item.itemId) {
R.id.menu_help -> startActivity<AboutActivity>()
R.id.menu_backup -> BackupRestoreUi.backup(this)
R.id.menu_restore -> BackupRestoreUi.restore(this)
R.id.menu_help -> {
val text = String(requireContext().assets.open("help.md").readBytes())
TextDialog.show(childFragmentManager, text, TextDialog.MD)
}
}
}

@ -77,11 +77,17 @@ class TextDialog : BaseDialogFragment() {
time -= 1000
badge_view.setBadgeCount((time / 1000).toInt())
if (time <= 0) {
view.post {
dialog?.setCancelable(true)
}
}
}
}
} else {
view.post {
dialog?.setCancelable(true)
}
}
}
}

@ -10,16 +10,4 @@
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/menu_backup"
android:title="@string/backup"
android:icon="@drawable/ic_backup"
app:showAsAction="always" />
<item
android:id="@+id/menu_restore"
android:title="@string/restore"
android:icon="@drawable/ic_restore"
app:showAsAction="always" />
</menu>

Loading…
Cancel
Save