pull/32/head
gedoor 6 years ago
parent 69947c426d
commit 54e14fba60
  1. 11
      app/src/main/java/io/legado/app/App.kt
  2. 34
      app/src/main/java/io/legado/app/ui/about/AboutActivity.kt
  3. 15
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  4. 38
      app/src/main/res/layout/activity_about.xml
  5. 9
      app/src/main/res/menu/about.xml
  6. 2
      app/src/main/res/values/strings.xml
  7. 36
      app/src/main/res/xml/about.xml

@ -4,7 +4,6 @@ import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatDelegate
@ -32,16 +31,16 @@ class App : Application() {
private set
}
private var versionCode = 0
var versionCode = 0
var versionName = ""
override fun onCreate() {
super.onCreate()
INSTANCE = this
db = AppDatabase.createDatabase(INSTANCE)
versionCode = try {
packageManager.getPackageInfo(packageName, 0).versionCode
} catch (e: PackageManager.NameNotFoundException) {
0
packageManager.getPackageInfo(packageName, 0)?.let {
versionCode = it.versionCode
versionName = it.versionName
}
if (!ThemeStore.isConfigured(this, versionCode)) upThemeStore()
initNightTheme()

@ -1,10 +1,15 @@
package io.legado.app.ui.about
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.lifecycle.AndroidViewModel
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.utils.getViewModel
import org.jetbrains.anko.toast
class AboutActivity : BaseActivity<AndroidViewModel>() {
override val viewModel: AndroidViewModel
@ -13,7 +18,36 @@ class AboutActivity : BaseActivity<AndroidViewModel>() {
get() = R.layout.activity_about
override fun onViewModelCreated(viewModel: AndroidViewModel, savedInstanceState: Bundle?) {
val fTag = "aboutFragment"
var aboutFragment = supportFragmentManager.findFragmentByTag(fTag)
if (aboutFragment == null) aboutFragment = AboutFragment()
supportFragmentManager.beginTransaction()
.replace(R.id.fl_fragment, aboutFragment, fTag)
.commit()
}
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.about, menu)
return super.onCompatCreateOptionsMenu(menu)
}
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_scoring -> {
openIntent(Intent.ACTION_VIEW, "market://details?id=$packageName")
}
}
return super.onCompatOptionsItemSelected(item)
}
internal fun openIntent(intentName: String, address: String) {
try {
val intent = Intent(intentName)
intent.data = Uri.parse(address)
startActivity(intent)
} catch (e: Exception) {
toast(R.string.can_not_open)
}
}
}

@ -0,0 +1,15 @@
package io.legado.app.ui.about
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App
import io.legado.app.R
class AboutFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.about)
findPreference<Preference>("version")?.summary = App.INSTANCE.versionName
}
}

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="io.legado.app.ui.about.AboutActivity">
<io.legado.app.ui.widget.TitleBar
@ -11,5 +13,37 @@
android:layout_height="wrap_content"
app:title="@string/about" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardBackgroundColor="@color/background_card">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_app_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/about_description" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<FrameLayout
android:id="@+id/fl_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_scoring"
android:title="@string/scoring"
app:showAsAction="always" />
</menu>

@ -55,7 +55,7 @@
<string name="exit">退出</string>
<string name="exit_no_save">还未保存,是否继续编辑</string>
<string name="read_style">阅读样式设置</string>
<string name="version">版本</string>
<string name="local">本地</string>
<string name="search">搜索</string>
<string name="net_error_10001">没有网络</string>

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.preference.Preference
android:key="isNightTheme"
android:title="开发人员"
android:summary="gedoor, Invinciblelee, atbest, Antecer, mabDc"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="version"
android:title="@string/version"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="update_log"
android:title="@string/update_log"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="check_update"
android:title="@string/check_update"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="qq"
android:title="@string/join_qq_group"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="disclaimer"
android:title="@string/disclaimer"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen>
Loading…
Cancel
Save