mirror of
https://github.com/fumiama/copymanga.git
synced 2026-06-04 23:10:23 +08:00
@@ -8,8 +8,8 @@ android {
|
||||
applicationId 'top.fumiama.copymanga'
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 34
|
||||
versionCode 51
|
||||
versionName '2.2.3'
|
||||
versionCode 52
|
||||
versionName '2.2.4'
|
||||
resourceConfigurations += ['zh', 'zh-rCN']
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -34,6 +34,7 @@ import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.navigateUp
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.input.input
|
||||
import com.bumptech.glide.Glide
|
||||
@@ -60,7 +61,6 @@ import top.fumiama.dmzj.copymanga.BuildConfig
|
||||
import top.fumiama.dmzj.copymanga.R
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.lang.Thread.sleep
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@@ -98,6 +98,22 @@ class MainActivity : AppCompatActivity() {
|
||||
)
|
||||
setupActionBarWithNavController(navController!!, appBarConfiguration)
|
||||
nav_view.setupWithNavController(navController!!)
|
||||
PreferenceManager.getDefaultSharedPreferences(this)?.apply {
|
||||
if (contains("settings_cat_general_sb_startup_menu")) getString("settings_cat_general_sb_startup_menu", "0")?.toInt()?.let {
|
||||
if (it > 0) {
|
||||
Log.d("MyMain", "nav 2 dest $it")
|
||||
navController!!.navigate(listOf(
|
||||
R.id.nav_home,
|
||||
R.id.nav_sort,
|
||||
R.id.nav_rank,
|
||||
R.id.nav_sub,
|
||||
R.id.nav_history,
|
||||
R.id.nav_new_download,
|
||||
R.id.nav_settings
|
||||
)[it])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headPic = File(getExternalFilesDir(""), "headPic")
|
||||
drawer_layout.addDrawerListener(object : DrawerLayout.DrawerListener {
|
||||
@@ -109,14 +125,18 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onDrawerOpened(drawerView: View) {
|
||||
Log.d("MyMain", "onDrawerOpened")
|
||||
isDrawerClosed = false
|
||||
DownloadFragment.currentDir = getExternalFilesDir("")
|
||||
refreshUserInfo()
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
DownloadFragment.currentDir = getExternalFilesDir("")
|
||||
refreshUserInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {}
|
||||
override fun onDrawerStateChanged(newState: Int) {}
|
||||
})
|
||||
checkUpdate(false)
|
||||
goCheckUpdate(false)
|
||||
|
||||
ime = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
||||
@@ -204,17 +224,21 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshUserInfo() {
|
||||
suspend fun refreshUserInfo() = withContext(Dispatchers.IO) {
|
||||
getPreferences(MODE_PRIVATE)?.apply {
|
||||
val name = getString("nickname", getString("username", ""))
|
||||
val avatar = getString("avatar", "")
|
||||
if(name != "") navttitle.text = name
|
||||
else navttitle.setText(R.string.noLogin)
|
||||
if(avatar != "")
|
||||
Glide.with(this@MainActivity).load(avatar)
|
||||
.apply(RequestOptions.bitmapTransform(CircleCrop()))
|
||||
.into(navhicon)
|
||||
else navhicon.setImageResource(R.mipmap.ic_launcher)
|
||||
navttitle.apply { post {
|
||||
if(name != "") text = name
|
||||
else setText(R.string.noLogin)
|
||||
} }
|
||||
navhicon.apply ic@ { post {
|
||||
if(avatar != "")
|
||||
Glide.with(this@MainActivity).load(avatar)
|
||||
.apply(RequestOptions.bitmapTransform(CircleCrop()))
|
||||
.into(this@ic)
|
||||
else setImageResource(R.mipmap.ic_launcher)
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +355,7 @@ class MainActivity : AppCompatActivity() {
|
||||
.getIntent(this))
|
||||
}
|
||||
|
||||
private fun checkUpdate(ignoreSkip: Boolean) {
|
||||
private fun goCheckUpdate(ignoreSkip: Boolean) {
|
||||
lifecycleScope.launch {
|
||||
Update.checkUpdate(this@MainActivity, toolsBox, ignoreSkip)
|
||||
}
|
||||
@@ -344,7 +368,7 @@ class MainActivity : AppCompatActivity() {
|
||||
dl.setIcon(R.mipmap.ic_launcher)
|
||||
dl.setPositiveButton(android.R.string.ok) { _, _ -> }
|
||||
dl.setNeutralButton(R.string.check_update) {_, _ ->
|
||||
checkUpdate(true)
|
||||
goCheckUpdate(true)
|
||||
}
|
||||
dl.show()
|
||||
}
|
||||
|
||||
@@ -137,18 +137,21 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun queryCollect() {
|
||||
MainActivity.shelf?.query(book?.path!!)?.let { b ->
|
||||
mBookHandler?.collect = b.results?.collect?:-2
|
||||
Log.d("MyBF", "get collect of ${book?.path} = ${mBookHandler?.collect}")
|
||||
tic.text = b.results?.browse?.chapter_name?.let { name ->
|
||||
getString(R.string.text_format_cloud_read_to).format(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun setAddToShelf() {
|
||||
if(mBookHandler?.chapterNames?.isNotEmpty() != true) return
|
||||
lifecycleScope.launch {
|
||||
MainActivity.shelf?.query(book?.path!!)?.let { b ->
|
||||
mBookHandler?.collect = b.results?.collect?:-2
|
||||
Log.d("MyBF", "get collect of ${book?.path} = ${mBookHandler?.collect}")
|
||||
tic.text = b.results?.browse?.chapter_name?.let { name ->
|
||||
getString(R.string.text_format_cloud_read_to).format(name)
|
||||
}
|
||||
}
|
||||
|
||||
queryCollect()
|
||||
mBookHandler?.collect?.let { collect ->
|
||||
if (collect > 0) {
|
||||
this@BookFragment.lbbsub.setText(R.string.button_sub_subscribed)
|
||||
@@ -171,6 +174,7 @@ class BookFragment: NoBackRefreshFragment(R.layout.fragment_book) {
|
||||
val re = MainActivity.shelf?.add(uuid)
|
||||
Toast.makeText(context, re, Toast.LENGTH_SHORT).show()
|
||||
if (re == "修改成功") {
|
||||
queryCollect()
|
||||
this@BookFragment.lbbsub.setText(R.string.button_sub_subscribed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,22 @@
|
||||
<item>1200</item>
|
||||
<item>800</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
<string-array name="menus">
|
||||
<item>@string/menu_home</item>
|
||||
<item>@string/menu_sort</item>
|
||||
<item>@string/menu_rank</item>
|
||||
<item>@string/menu_sub</item>
|
||||
<item>@string/menu_history</item>
|
||||
<item>@string/menu_download</item>
|
||||
<item>@string/action_settings</item>
|
||||
</string-array>
|
||||
<string-array name="menu_ids">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE resources [
|
||||
<!ENTITY hosturl "api.copymanga.tv">
|
||||
]>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
<string name="app_name">拷贝漫画</string>
|
||||
|
||||
<string name="action_settings">设定</string>
|
||||
@@ -130,6 +130,10 @@
|
||||
<string name="author">作者</string>
|
||||
<string name="caption">标签</string>
|
||||
|
||||
<string name="settings_cat_general">通用</string>
|
||||
<string name="settings_cat_general_sb_title_startup_menu">启动时显示</string>
|
||||
<string name="settings_cat_general_sb_summary_startup_menu">默认主页</string>
|
||||
|
||||
<string name="settings_cat_net">网络</string>
|
||||
<string name="settings_cat_net_sb_title_image_resolution">图片分辨率</string>
|
||||
<string name="settings_cat_net_sb_summary_image_resolution">默认1500</string>
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:title="@string/settings_cat_general">
|
||||
<ListPreference
|
||||
android:max="6"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="settings_cat_general_sb_startup_menu"
|
||||
app:selectable="true"
|
||||
app:summary="@string/settings_cat_general_sb_summary_startup_menu"
|
||||
app:title="@string/settings_cat_general_sb_title_startup_menu"
|
||||
app:entries="@array/menus"
|
||||
app:entryValues="@array/menu_ids"
|
||||
android:defaultValue="0"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
app:iconSpaceReserved="false"
|
||||
app:title="@string/settings_cat_net">
|
||||
|
||||
Reference in New Issue
Block a user