|
|
@ -1,5 +1,8 @@ |
|
|
|
package io.legado.app.ui.about |
|
|
|
package io.legado.app.ui.about |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.ClipData |
|
|
|
|
|
|
|
import android.content.ClipboardManager |
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
|
import android.net.Uri |
|
|
|
import android.net.Uri |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
@ -9,6 +12,7 @@ import androidx.preference.Preference |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
|
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
import io.legado.app.ui.widget.dialog.TextDialog |
|
|
|
import io.legado.app.ui.widget.dialog.TextDialog |
|
|
|
import io.legado.app.utils.toast |
|
|
|
import io.legado.app.utils.toast |
|
|
|
|
|
|
|
|
|
|
@ -16,11 +20,17 @@ class AboutFragment : PreferenceFragmentCompat() { |
|
|
|
|
|
|
|
|
|
|
|
private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" |
|
|
|
private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" |
|
|
|
private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" |
|
|
|
private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" |
|
|
|
|
|
|
|
private val qqGroups = linkedMapOf( |
|
|
|
|
|
|
|
Pair("(QQ群)701903217", "-iolizL4cbJSutKRpeImHlXlpLDZnzeF"), |
|
|
|
|
|
|
|
Pair("(QQ群)805192012", "6GlFKjLeIk5RhQnR3PNVDaKB6j10royo"), |
|
|
|
|
|
|
|
Pair("(QQ群)773736122", "5Bm5w6OgLupXnICbYvbgzpPUgf0UlsJF"), |
|
|
|
|
|
|
|
Pair("(QQ群)981838750", "g_Sgmp2nQPKqcZQ5qPcKLHziwX_mpps9") |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
|
|
|
addPreferencesFromResource(R.xml.about) |
|
|
|
addPreferencesFromResource(R.xml.about) |
|
|
|
findPreference<Preference>("check_update")?.summary = |
|
|
|
findPreference<Preference>("check_update")?.summary = |
|
|
|
getString(R.string.version) + " " + App.INSTANCE.versionName |
|
|
|
"${getString(R.string.version)} ${App.INSTANCE.versionName}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
@ -38,6 +48,7 @@ class AboutFragment : PreferenceFragmentCompat() { |
|
|
|
"home_page" -> openIntent(Intent.ACTION_VIEW, R.string.home_page_url) |
|
|
|
"home_page" -> openIntent(Intent.ACTION_VIEW, R.string.home_page_url) |
|
|
|
"license" -> openIntent(Intent.ACTION_VIEW, licenseUrl) |
|
|
|
"license" -> openIntent(Intent.ACTION_VIEW, licenseUrl) |
|
|
|
"disclaimer" -> openIntent(Intent.ACTION_VIEW, disclaimerUrl) |
|
|
|
"disclaimer" -> openIntent(Intent.ACTION_VIEW, disclaimerUrl) |
|
|
|
|
|
|
|
"qq" -> showQqGroups() |
|
|
|
} |
|
|
|
} |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
return super.onPreferenceTreeClick(preference) |
|
|
|
} |
|
|
|
} |
|
|
@ -62,4 +73,42 @@ class AboutFragment : PreferenceFragmentCompat() { |
|
|
|
TextDialog.show(childFragmentManager, log, TextDialog.MD) |
|
|
|
TextDialog.show(childFragmentManager, log, TextDialog.MD) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun showQqGroups() { |
|
|
|
|
|
|
|
alert(title = R.string.join_qq_group) { |
|
|
|
|
|
|
|
val names = arrayListOf<String>() |
|
|
|
|
|
|
|
qqGroups.forEach { |
|
|
|
|
|
|
|
names.add(it.key) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
items(names) { _, index -> |
|
|
|
|
|
|
|
qqGroups[names[index]]?.let { |
|
|
|
|
|
|
|
if (!joinQQGroup(it)) { |
|
|
|
|
|
|
|
sendToClip(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun joinQQGroup(key: String): Boolean { |
|
|
|
|
|
|
|
val intent = Intent() |
|
|
|
|
|
|
|
intent.data = |
|
|
|
|
|
|
|
Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D$key") |
|
|
|
|
|
|
|
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
|
|
|
|
|
|
|
return try { |
|
|
|
|
|
|
|
startActivity(intent) |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
} catch (e: java.lang.Exception) { |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun sendToClip(text: String) { |
|
|
|
|
|
|
|
val clipboard = |
|
|
|
|
|
|
|
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager |
|
|
|
|
|
|
|
val clipData = ClipData.newPlainText(null, text) |
|
|
|
|
|
|
|
clipboard?.let { |
|
|
|
|
|
|
|
clipboard.setPrimaryClip(clipData) |
|
|
|
|
|
|
|
toast(R.string.copy_complete) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |