parent
769ced4e19
commit
919269de3e
@ -0,0 +1,99 @@ |
||||
package io.legado.app.ui.about |
||||
|
||||
import android.content.ClipData |
||||
import android.content.ClipboardManager |
||||
import android.content.Context |
||||
import android.content.Intent |
||||
import android.net.Uri |
||||
import android.os.Bundle |
||||
import android.view.View |
||||
import androidx.preference.Preference |
||||
import androidx.preference.PreferenceFragmentCompat |
||||
import io.legado.app.R |
||||
import io.legado.app.utils.ACache |
||||
import io.legado.app.utils.toast |
||||
import org.jetbrains.anko.longToast |
||||
import java.net.URLEncoder |
||||
|
||||
class DonateFragment : PreferenceFragmentCompat() { |
||||
|
||||
private val zfbHbRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbhbrwm.png" |
||||
private val zfbSkRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbskrwm.jpg" |
||||
private val wxZsRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/wxskrwm.jpg" |
||||
private val qqSkRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/qqskrwm.jpg" |
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { |
||||
addPreferencesFromResource(R.xml.donate) |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
listView.overScrollMode = View.OVER_SCROLL_NEVER |
||||
} |
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean { |
||||
when (preference?.key) { |
||||
"wxZsm" -> openIntent(Intent.ACTION_VIEW, wxZsRwmUrl) |
||||
"zfbHbRwm" -> openIntent(Intent.ACTION_VIEW, zfbHbRwmUrl) |
||||
"zfbSkRwm" -> openIntent(Intent.ACTION_VIEW, zfbSkRwmUrl) |
||||
"qqSkRwm" -> openIntent(Intent.ACTION_VIEW, qqSkRwmUrl) |
||||
"zfbSk" -> aliDonate(requireContext()) |
||||
"zfbHbSsm" -> getZfbHb(requireContext()) |
||||
"gzGzh" -> sendToClip("开源阅读软件") |
||||
} |
||||
return super.onPreferenceTreeClick(preference) |
||||
} |
||||
|
||||
@Suppress("SameParameterValue") |
||||
private 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) |
||||
} |
||||
} |
||||
|
||||
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) |
||||
} |
||||
} |
||||
|
||||
private fun getZfbHb(context: Context) { |
||||
sendToClip("537954522") |
||||
context.longToast("高级功能已开启\n红包码已复制\n支付宝首页搜索“537954522” 立即领红包") |
||||
try { |
||||
val packageManager = context.applicationContext.packageManager |
||||
val intent = packageManager.getLaunchIntentForPackage("com.eg.android.AlipayGphone")!! |
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
||||
context.startActivity(intent) |
||||
} catch (e: Exception) { |
||||
e.printStackTrace() |
||||
} finally { |
||||
ACache.get(requireContext(), cacheDir = false) |
||||
.put("proTime", System.currentTimeMillis()) |
||||
} |
||||
} |
||||
|
||||
private fun aliDonate(context: Context) { |
||||
try { |
||||
val qrCode = URLEncoder.encode( |
||||
"https://qr.alipay.com/tsx06677nwdk3javroq4ef0?_s=Dweb-other", |
||||
"utf-8" |
||||
) |
||||
val aliPayQr = |
||||
"alipayqr://platformapi/startapp?saId=10000007&qrcode=$qrCode&_t=${System.currentTimeMillis()}" |
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(aliPayQr)) |
||||
context.startActivity(intent) |
||||
} catch (e: Exception) { |
||||
e.printStackTrace() |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,4 +1,65 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<PreferenceScreen> |
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
||||
|
||||
</PreferenceScreen> |
||||
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory |
||||
android:title="微信" |
||||
app:iconSpaceReserved="false"> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="gzGzh" |
||||
android:title="关注公众号" |
||||
android:summary="关注[开源阅读软件]点击广告支持我" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="wxZsm" |
||||
android:title="微信赞赏码" |
||||
android:summary="点击打开" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory> |
||||
|
||||
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory |
||||
android:title="支付宝" |
||||
app:iconSpaceReserved="false"> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="zfbHbSsm" |
||||
android:title="支付宝红包搜索码" |
||||
android:summary="537954522 点击复制" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="zfbSk" |
||||
android:title="支付宝收款,支持红包" |
||||
android:summary="点击直接跳转支付宝" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="zfbHbRwm" |
||||
android:title="支付宝红包二维码" |
||||
android:summary="点击打开" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="zfbSkRwm" |
||||
android:title="支付宝收款二维码" |
||||
android:summary="点击打开" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory> |
||||
|
||||
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory |
||||
android:title="QQ" |
||||
app:iconSpaceReserved="false"> |
||||
|
||||
<androidx.preference.Preference |
||||
android:key="qqSkRwm" |
||||
android:title="QQ收款二维码" |
||||
android:summary="点击打开" |
||||
app:iconSpaceReserved="false" /> |
||||
|
||||
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory> |
||||
|
||||
</androidx.preference.PreferenceScreen> |
Loading…
Reference in new issue