Skip to content

Commit 974f430

Browse files
author
rRemix
committed
优化捐赠
1 parent 055c5de commit 974f430

File tree

10 files changed

+141
-69
lines changed

10 files changed

+141
-69
lines changed

Diff for: app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ android {
2626
minSdkVersion 19
2727
targetSdkVersion 33
2828

29-
versionCode 16101
29+
versionCode 16102
3030
versionName "1.6.1.0"
3131

3232
flavorDimensions "default"

Diff for: app/src/main/java/remix/myplayer/ui/activity/MainActivity.kt

+35-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import android.os.*
1111
import android.provider.Settings
1212
import android.text.TextUtils
1313
import android.view.Menu
14-
import android.view.MotionEvent
1514
import android.view.View
1615
import android.widget.TextView
1716
import androidx.drawerlayout.widget.DrawerLayout
@@ -70,6 +69,7 @@ import timber.log.Timber
7069
import java.io.File
7170
import java.lang.ref.WeakReference
7271
import java.util.*
72+
import java.util.concurrent.TimeUnit
7373

7474
/**
7575
*
@@ -141,19 +141,49 @@ class MainActivity : MenuActivity(), View.OnClickListener {
141141
intentFilter.addAction(ACTION_DISMISS_DIALOG)
142142
registerLocalReceiver(receiver, intentFilter)
143143

144-
//初始化控件
144+
// 初始化控件
145145
setUpToolbar()
146146
setUpPager()
147147
setUpTab()
148148
btn_add.setOnClickListener(this)
149-
//初始化测滑菜单
149+
// 初始化测滑菜单
150150
setUpDrawerLayout()
151151
setUpViewColor()
152-
//handler
152+
// 检查更新
153153
handler.postDelayed({ this.checkUpdate() }, 500)
154154

155-
//清除多选显示状态
155+
// 清除多选显示状态
156156
MultipleChoice.isActiveSomeWhere = false
157+
158+
// 捐赠
159+
checkDonation()
160+
}
161+
162+
private fun checkDonation(){
163+
if (!SPUtil.getValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.SUPPORT_NO_MORE_PROMPT, false) &&
164+
!SPUtil.getValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.WAS_SUPPORT, false)) {
165+
166+
val lastOpenTime = SPUtil.getValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.LAST_OPEN_TIME, System.currentTimeMillis())
167+
SPUtil.putValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.LAST_OPEN_TIME, System.currentTimeMillis())
168+
if (System.currentTimeMillis() - lastOpenTime >= TimeUnit.DAYS.toMillis(2)) {
169+
handler.postDelayed({
170+
Theme.getBaseDialog(this)
171+
.title(R.string.support_developer)
172+
.positiveText(R.string.go)
173+
.negativeText(R.string.cancel)
174+
.neutralText(R.string.no_more_prompt)
175+
.content(R.string.donate_tip)
176+
.onPositive { _, _ ->
177+
SPUtil.putValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.WAS_SUPPORT, true)
178+
startActivity(Intent(this, SupportActivity::class.java))
179+
}
180+
.onNeutral { _, _ ->
181+
SPUtil.putValue(this, SPUtil.OTHER_KEY.NAME, SPUtil.OTHER_KEY.SUPPORT_NO_MORE_PROMPT, true)
182+
}
183+
.show()
184+
}, 1500)
185+
}
186+
}
157187
}
158188

159189
override fun setStatusBarColor() {

Diff for: app/src/main/java/remix/myplayer/ui/activity/SupportActivity.kt

+31-22
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
3939

4040
private var billingProcessor: BillingProcessor? = null
4141
private var disposable: Disposable? = null
42+
private val googlePlay = App.IS_GOOGLEPLAY
4243

43-
private lateinit var loading: MaterialDialog
44+
// private lateinit var loading: MaterialDialog
4445

4546
override fun onCreate(savedInstanceState: Bundle?) {
4647
super.onCreate(savedInstanceState)
@@ -49,7 +50,7 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
4950
setUpToolbar(getString(R.string.support_develop))
5051

5152
val beans = ArrayList<Purchase>()
52-
if (!App.IS_GOOGLEPLAY) {
53+
if (!googlePlay) {
5354
beans.add(Purchase("wechat", "icon_wechat_donate", getString(R.string.wechat), ""))
5455
beans.add(Purchase("alipay", "icon_alipay_donate", getString(R.string.alipay), ""))
5556
beans.add(Purchase("paypal", "icon_paypal_donate", getString(R.string.paypal), ""))
@@ -61,14 +62,18 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
6162
}
6263

6364
override fun onItemClick(view: View?, position: Int) {
64-
if (App.IS_GOOGLEPLAY) {
65+
if (googlePlay) {
6566
billingProcessor?.purchase(this@SupportActivity, SKU_IDS[position])
6667
} else {
6768
when (position) {
6869
0 -> {
6970
//保存微信图片
7071
launch {
71-
Util.saveToAlbum(this@SupportActivity, R.drawable.icon_wechat_qrcode, "wechat_qrCode.png")
72+
Util.saveToAlbum(
73+
this@SupportActivity,
74+
R.drawable.icon_wechat_qrcode,
75+
"wechat_qrCode.png"
76+
)
7277
}
7378
}
7479
1 -> {
@@ -97,21 +102,21 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
97102
recyclerView.layoutManager = GridLayoutManager(this, 2)
98103
recyclerView.adapter = adapter
99104

100-
loading = Theme.getBaseDialog(this)
101-
.title(R.string.loading)
102-
.content(R.string.please_wait)
103-
.canceledOnTouchOutside(false)
104-
.progress(true, 0)
105-
.progressIndeterminateStyle(false).build()
105+
// loading = Theme.getBaseDialog(this)
106+
// .title(R.string.loading)
107+
// .content(R.string.please_wait)
108+
// .canceledOnTouchOutside(false)
109+
// .progress(true, 0)
110+
// .progressIndeterminateStyle(false).build()
106111

107112
billingProcessor = BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, this)
108113

109-
if (!App.IS_GOOGLEPLAY) {
114+
if (!googlePlay) {
110115
ad.visibility = View.VISIBLE
111116
ad_content.text = """
112117
如果你的手机并未下载过"快手极速版",并且是新用户,可通过以下步骤支持开发者:
113118
一.在安卓应用商店或AppStore下载"快手极速版"
114-
二.注册并登陆账号(微信\QQ\手机号码任意一种方式均可)
119+
二.注册并登陆账号(未登录过的微信\QQ\手机号码任意一种方式均可)
115120
三.点左上角"三"或者放大镜扫描下方二维码(可长按保存)
116121
四.半小时之内观看至少一分钟的视频即可帮助开发者获得奖励。另外,如果用户在第二天和连续七天观看一分钟的视频,开发者都可以获得奖励
117122
""".trimIndent()
@@ -129,15 +134,15 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
129134
private fun loadSkuDetails() {
130135
if (adapter.dataList.size > 3)
131136
return
132-
if (hasWindowFocus()) {
133-
loading.show()
134-
}
137+
// if (hasWindowFocus()) {
138+
// loading.show()
139+
// }
135140

136141
billingProcessor?.getPurchaseListingDetailsAsync(
137142
SKU_IDS,
138143
object : BillingProcessor.ISkuDetailsResponseListener {
139144
override fun onSkuDetailsResponse(products: MutableList<SkuDetails>?) {
140-
loading.dismiss()
145+
// loading.dismiss()
141146
if (products.isNullOrEmpty()) {
142147
return
143148
}
@@ -153,8 +158,10 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
153158
}
154159

155160
override fun onSkuDetailsError(error: String?) {
156-
ToastUtil.show(this@SupportActivity, R.string.error_occur, error)
157-
loading.dismiss()
161+
if (googlePlay) {
162+
ToastUtil.show(this@SupportActivity, R.string.error_occur, error)
163+
}
164+
// loading.dismiss()
158165
}
159166
})
160167
}
@@ -166,7 +173,7 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
166173

167174
override fun onPurchaseHistoryRestored() {
168175
Timber.v("onPurchaseHistoryRestored")
169-
Toast.makeText(this, R.string.restored_previous_purchases, Toast.LENGTH_SHORT).show()
176+
// Toast.makeText(this, R.string.restored_previous_purchases, Toast.LENGTH_SHORT).show()
170177
}
171178

172179
@SuppressLint("CheckResult")
@@ -187,14 +194,16 @@ class SupportActivity : ToolbarActivity(), BillingProcessor.IBillingHandler {
187194

188195
override fun onBillingError(errorCode: Int, error: Throwable?) {
189196
Timber.v("onBillingError")
190-
ToastUtil.show(this, R.string.error_occur, "code = $errorCode err = $error")
197+
if (googlePlay) {
198+
ToastUtil.show(this, R.string.error_occur, "code = $errorCode err = $error")
199+
}
191200
}
192201

193202
override fun onDestroy() {
194203
super.onDestroy()
195204
billingProcessor?.release()
196205
disposable?.dispose()
197-
if (loading.isShowing)
198-
loading.dismiss()
206+
// if (loading.isShowing)
207+
// loading.dismiss()
199208
}
200209
}

Diff for: app/src/main/java/remix/myplayer/util/SPUtil.java

+8
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,12 @@ public interface LYRIC_OFFSET_KEY {
267267

268268
String NAME = "LyricOffset";
269269
}
270+
271+
public interface OTHER_KEY {
272+
String NAME = "Other";
273+
274+
String LAST_OPEN_TIME = "last_open_time";
275+
String WAS_SUPPORT = "was_support";
276+
String SUPPORT_NO_MORE_PROMPT = "support_no_more_prompt";
277+
}
270278
}

Diff for: app/src/main/res/layout/activity_support_develop.xml

+51-41
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,59 @@
1515
app:layout_scrollFlags="scroll|enterAlways"/>
1616
</com.google.android.material.appbar.AppBarLayout>
1717

18-
<TextView
19-
android:layout_width="wrap_content"
20-
android:layout_height="wrap_content"
21-
android:layout_margin="@dimen/d12_size"
22-
android:textSize="@dimen/s18_size"
23-
android:textColor="?attr/text_color_primary"
24-
android:textStyle="bold"
25-
android:text="@string/donation"/>
26-
27-
<androidx.recyclerview.widget.RecyclerView
28-
android:id="@+id/recyclerView"
18+
<androidx.core.widget.NestedScrollView
2919
android:layout_width="match_parent"
30-
android:layout_height="wrap_content"
31-
android:overScrollMode="never"/>
32-
33-
<LinearLayout
34-
android:layout_width="wrap_content"
35-
android:layout_height="wrap_content"
36-
android:layout_marginTop="@dimen/d8_size"
37-
android:orientation="vertical"
38-
android:id="@+id/ad">
39-
<TextView
40-
android:layout_width="wrap_content"
41-
android:layout_height="wrap_content"
42-
android:layout_margin="@dimen/d12_size"
43-
android:textSize="@dimen/s18_size"
44-
android:textColor="?attr/text_color_primary"
45-
android:textStyle="bold"
46-
android:text="其他方式"/>
47-
<TextView
48-
android:id="@+id/ad_content"
49-
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content">
21+
<LinearLayout
22+
android:layout_width="match_parent"
5023
android:layout_height="wrap_content"
51-
android:textColor="?attr/text_color_secondary"
52-
android:layout_marginHorizontal="@dimen/d24_size" />
24+
android:orientation="vertical">
25+
<TextView
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:layout_margin="@dimen/d12_size"
29+
android:textSize="@dimen/s18_size"
30+
android:textColor="?attr/text_color_primary"
31+
android:textStyle="bold"
32+
android:text="@string/donation"/>
33+
34+
<androidx.recyclerview.widget.RecyclerView
35+
android:id="@+id/recyclerView"
36+
android:layout_width="match_parent"
37+
android:layout_height="wrap_content"
38+
android:overScrollMode="never"/>
39+
40+
<LinearLayout
41+
android:layout_width="wrap_content"
42+
android:layout_height="wrap_content"
43+
android:layout_marginTop="@dimen/d8_size"
44+
android:orientation="vertical"
45+
android:id="@+id/ad">
46+
<TextView
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:layout_margin="@dimen/d12_size"
50+
android:textSize="@dimen/s18_size"
51+
android:textColor="?attr/text_color_primary"
52+
android:textStyle="bold"
53+
android:text="其他方式"/>
54+
<TextView
55+
android:id="@+id/ad_content"
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:textColor="?attr/text_color_secondary"
59+
android:layout_marginHorizontal="@dimen/d24_size" />
60+
61+
<ImageView
62+
android:id="@+id/ad_qrcode"
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
android:layout_gravity="center_horizontal"
66+
android:layout_marginTop="@dimen/d16_size"
67+
android:src="@drawable/ad_qrcode"/>
68+
</LinearLayout>
69+
</LinearLayout>
70+
</androidx.core.widget.NestedScrollView>
5371

54-
<ImageView
55-
android:id="@+id/ad_qrcode"
56-
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:layout_gravity="center_horizontal"
59-
android:layout_marginTop="@dimen/d16_size"
60-
android:src="@drawable/ad_qrcode"/>
61-
</LinearLayout>
6272

6373
</LinearLayout>

Diff for: app/src/main/res/values-ja-rJP/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,7 @@
451451
<string name="lyric_font_size_huge">特大</string>
452452

453453
<string name="donation">寄付する</string>
454+
<string name="support_developer">開発者のサポート</string>
455+
<string name="no_more_prompt">再プロンプト</string>
456+
<string name="go">行く</string>
454457
</resources>

Diff for: app/src/main/res/values-zh-rCN/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,7 @@
451451
<string name="lyric_font_size_huge">超大</string>
452452

453453
<string name="donation">捐赠</string>
454+
<string name="support_developer">支持开发者</string>
455+
<string name="no_more_prompt">不再提示</string>
456+
<string name="go">前往</string>
454457
</resources>

Diff for: app/src/main/res/values-zh-rHK/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,7 @@
450450
<string name="lyric_font_size_huge">超大</string>
451451

452452
<string name="donation">捐贈</string>
453+
<string name="support_developer">支持開發者</string>
454+
<string name="no_more_prompt">不再提示</string>
455+
<string name="go">前往</string>
453456
</resources>

Diff for: app/src/main/res/values-zh-rTW/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,7 @@
451451
<string name="lyric_font_size_huge">超大</string>
452452

453453
<string name="donation">捐贈</string>
454+
<string name="support_developer">支持開發者</string>
455+
<string name="no_more_prompt">不再提示</string>
456+
<string name="go">前往</string>
454457
</resources>

Diff for: app/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,7 @@
451451
<string name="lyric_font_size_huge">Huge</string>
452452

453453
<string name="donation">Donation</string>
454+
<string name="support_developer">Support Developer</string>
455+
<string name="no_more_prompt">No more prompt</string>
456+
<string name="go">go</string>
454457
</resources>

0 commit comments

Comments
 (0)