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