Skip to content

Commit 7a507fe

Browse files
author
xiaoborui
committed
新增设置淡入淡出
1 parent f7efdee commit 7a507fe

File tree

7 files changed

+97
-37
lines changed

7 files changed

+97
-37
lines changed

app/src/google/kotlin/remix/myplayer/ui/activity/SupportActivity.kt

+18-18
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,24 @@ class SupportActivity : ToolbarActivity(), BillingClientStateListener, Purchases
109109

110110
billingClient.startConnection(this)
111111

112-
if (!googlePlay) {
113-
binding.ad.visibility = View.VISIBLE
114-
binding.adContent.text = """
115-
如果你的手机并未下载过"快手极速版",并且是新用户,可通过以下步骤支持开发者:
116-
一.在安卓应用商店或AppStore下载"快手极速版"
117-
二.注册并登陆账号(未登录过的微信\QQ\手机号码任意一种方式均可)
118-
三.点左上角"三"或者放大镜扫描下方二维码(可长按保存)
119-
四.半小时之内观看至少一分钟的视频即可帮助开发者获得奖励。另外,如果用户在第二天和连续七天观看一分钟的视频,开发者都可以获得奖励
120-
""".trimIndent()
121-
binding.adQrcode.setOnLongClickListener {
122-
launch {
123-
Util.saveToAlbum(this@SupportActivity, R.drawable.ad_qrcode, "a_ad_qrCode.png")
124-
}
125-
return@setOnLongClickListener true
126-
}
127-
} else {
128-
binding.ad.visibility = View.GONE
129-
}
112+
// if (!googlePlay) {
113+
// binding.ad.visibility = View.VISIBLE
114+
// binding.adContent.text = """
115+
// 如果你的手机并未下载过"快手极速版",并且是新用户,可通过以下步骤支持开发者:
116+
// 一.在安卓应用商店或AppStore下载"快手极速版"
117+
// 二.注册并登陆账号(未登录过的微信\QQ\手机号码任意一种方式均可)
118+
// 三.点左上角"三"或者放大镜扫描下方二维码(可长按保存)
119+
// 四.半小时之内观看至少一分钟的视频即可帮助开发者获得奖励。另外,如果用户在第二天和连续七天观看一分钟的视频,开发者都可以获得奖励
120+
// """.trimIndent()
121+
// binding.adQrcode.setOnLongClickListener {
122+
// launch {
123+
// Util.saveToAlbum(this@SupportActivity, R.drawable.ad_qrcode, "a_ad_qrCode.png")
124+
// }
125+
// return@setOnLongClickListener true
126+
// }
127+
// } else {
128+
// binding.ad.visibility = View.GONE
129+
// }
130130
}
131131

132132
private fun launchBillingFlow(productDetails: ProductDetails) {

app/src/main/java/remix/myplayer/service/MusicService.kt

+14-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ class MusicService : BaseService(), Playback, MusicEventCallback,
396396
/**
397397
* 锁屏
398398
*/
399-
private var lockScreen: Int = CLOSE_LOCKSCREEN
399+
private var lockScreen = CLOSE_LOCKSCREEN
400+
401+
private var crossFade = true
400402

401403
override fun onTaskRemoved(rootIntent: Intent) {
402404
super.onTaskRemoved(rootIntent)
@@ -493,6 +495,10 @@ class MusicService : BaseService(), Playback, MusicEventCallback,
493495
speed = java.lang.Float.parseFloat(SPUtil.getValue(this, SETTING_KEY.NAME, SETTING_KEY.SPEED, "1.0"))
494496
setSpeed(speed)
495497
}
498+
// 淡入淡出
499+
SETTING_KEY.CROSS_FADE -> {
500+
crossFade = SPUtil.getValue(this, SETTING_KEY.NAME, SETTING_KEY.CROSS_FADE, true)
501+
}
496502
}
497503
}
498504

@@ -893,7 +899,7 @@ class MusicService : BaseService(), Playback, MusicEventCallback,
893899
// setSpeed(speed)
894900

895901
//渐变
896-
if (fadeIn) {
902+
if (fadeIn && crossFade) {
897903
volumeController.fadeIn()
898904
} else {
899905
volumeController.directTo(1f)
@@ -934,7 +940,11 @@ class MusicService : BaseService(), Playback, MusicEventCallback,
934940
}
935941
isPlaying = false
936942
uiHandler.sendEmptyMessage(UPDATE_META_DATA)
937-
volumeController.fadeOut()
943+
if (crossFade) {
944+
volumeController.fadeOut()
945+
} else {
946+
mediaPlayer.pause()
947+
}
938948
}
939949
}
940950

@@ -1619,6 +1629,7 @@ class MusicService : BaseService(), Playback, MusicEventCallback,
16191629
speed = java.lang.Float.parseFloat(SPUtil.getValue(this, SETTING_KEY.NAME, SETTING_KEY.SPEED, "1.0"))
16201630
playAtBreakPoint = SPUtil.getValue(service, SETTING_KEY.NAME, SETTING_KEY.PLAY_AT_BREAKPOINT, false)
16211631
lastProgress = SPUtil.getValue(service, SETTING_KEY.NAME, SETTING_KEY.LAST_PLAY_PROGRESS, 0)
1632+
crossFade = SPUtil.getValue(this, SETTING_KEY.NAME, SETTING_KEY.CROSS_FADE, true)
16221633

16231634
//读取播放列表
16241635
playQueue.restoreIfNecessary()

app/src/main/java/remix/myplayer/ui/activity/SettingActivity.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class SettingActivity : ToolbarActivity(), ColorChooserDialog.ColorCallback,
157157
SETTING_KEY.SHOW_DISPLAYNAME,
158158
SETTING_KEY.FORCE_SORT,
159159
SETTING_KEY.BLACK_THEME,
160-
SETTING_KEY.AUDIO_FOCUS
160+
SETTING_KEY.AUDIO_FOCUS,
161+
SETTING_KEY.CROSS_FADE
161162
)
162163
arrayOf(
163164
binding.settingNavaigationSwitch,
@@ -172,7 +173,8 @@ class SettingActivity : ToolbarActivity(), ColorChooserDialog.ColorCallback,
172173
binding.settingDisplaynameSwitch,
173174
binding.settingForceSortSwitch,
174175
binding.settingBlackThemeSwitch,
175-
binding.settingAudioFocusSwitch
176+
binding.settingAudioFocusSwitch,
177+
binding.settingCrossfadeSwitch
176178
).forEachIndexed { index, view ->
177179
TintHelper.setTintAuto(view, ThemeStore.accentColor, false)
178180

app/src/main/java/remix/myplayer/util/SPUtil.java

+2
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ public interface SETTING_KEY {
273273
// 黑色主题
274274
String BLACK_THEME = "black_theme";
275275
String VERSION = "version";
276+
// 淡入淡出
277+
String CROSS_FADE = "cross_fade";
276278
int NEWEST_VERSION = 3;
277279
}
278280

app/src/main/res/layout/activity_setting.xml

+44
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,50 @@
489489
android:textOn="" />
490490
</RelativeLayout>
491491

492+
<RelativeLayout
493+
android:id="@+id/setting_crossfade_container"
494+
android:layout_width="match_parent"
495+
android:layout_height="wrap_content"
496+
android:background="?attr/background_rect_ripple"
497+
android:paddingVertical="@dimen/d10_size">
498+
499+
<LinearLayout
500+
android:layout_width="match_parent"
501+
android:layout_height="wrap_content"
502+
android:layout_centerVertical="true"
503+
android:layout_marginStart="@dimen/d16_size"
504+
android:layout_marginEnd="@dimen/d16_size"
505+
android:layout_toStartOf="@+id/setting_audio_focus_switch"
506+
android:gravity="center_vertical"
507+
android:orientation="vertical">
508+
509+
<TextView
510+
android:layout_width="wrap_content"
511+
android:layout_height="wrap_content"
512+
android:layout_marginBottom="@dimen/d2_size"
513+
android:text="淡入淡出"
514+
android:textColor="?attr/text_color_primary"
515+
android:textSize="@dimen/s16_size" />
516+
517+
<TextView
518+
android:layout_width="wrap_content"
519+
android:layout_height="wrap_content"
520+
android:text="播放、暂停时使用淡入淡出效果"
521+
android:textColor="?attr/text_color_secondary"
522+
android:textSize="@dimen/s14_size" />
523+
</LinearLayout>
524+
525+
<androidx.appcompat.widget.SwitchCompat
526+
android:id="@+id/setting_crossfade_switch"
527+
android:layout_width="wrap_content"
528+
android:layout_height="wrap_content"
529+
android:layout_alignParentEnd="true"
530+
android:layout_centerVertical="true"
531+
android:layout_marginEnd="@dimen/d14_size"
532+
android:textOff=""
533+
android:textOn="" />
534+
</RelativeLayout>
535+
492536
<LinearLayout
493537
android:id="@+id/setting_auto_play_headset_container"
494538
android:layout_width="match_parent"

app/src/main/res/layout/activity_support_develop.xml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
android:layout_height="wrap_content"
4343
android:layout_marginTop="@dimen/d8_size"
4444
android:orientation="vertical"
45+
android:visibility="gone"
4546
android:id="@+id/ad">
4647
<TextView
4748
android:layout_width="wrap_content"

app/src/nonGoogle/kotlin/remix/myplayer/ui/activity/SupportActivity.kt

+14-14
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ class SupportActivity : ToolbarActivity() {
7474
binding.recyclerView.layoutManager = GridLayoutManager(this, 2)
7575
binding.recyclerView.adapter = adapter
7676

77-
binding.ad.visibility = View.VISIBLE
78-
binding.adContent.text = """
79-
如果你的手机并未下载过"快手极速版",并且是新用户,可通过以下步骤支持开发者:
80-
一.在安卓应用商店或AppStore下载"快手极速版"
81-
二.注册并登陆账号(未登录过的微信\QQ\手机号码任意一种方式均可)
82-
三.点左上角"三"或者放大镜扫描下方二维码(可长按保存)
83-
四.半小时之内观看至少一分钟的视频即可帮助开发者获得奖励。另外,如果用户在第二天和连续七天观看一分钟的视频,开发者都可以获得奖励
84-
""".trimIndent()
85-
binding.adQrcode.setOnLongClickListener {
86-
launch {
87-
Util.saveToAlbum(this@SupportActivity, R.drawable.ad_qrcode, "a_ad_qrCode.png")
88-
}
89-
return@setOnLongClickListener true
90-
}
77+
// binding.ad.visibility = View.VISIBLE
78+
// binding.adContent.text = """
79+
// 如果你的手机并未下载过"快手极速版",并且是新用户,可通过以下步骤支持开发者:
80+
// 一.在安卓应用商店或AppStore下载"快手极速版"
81+
// 二.注册并登陆账号(未登录过的微信\QQ\手机号码任意一种方式均可)
82+
// 三.点左上角"三"或者放大镜扫描下方二维码(可长按保存)
83+
// 四.半小时之内观看至少一分钟的视频即可帮助开发者获得奖励。另外,如果用户在第二天和连续七天观看一分钟的视频,开发者都可以获得奖励
84+
// """.trimIndent()
85+
// binding.adQrcode.setOnLongClickListener {
86+
// launch {
87+
// Util.saveToAlbum(this@SupportActivity, R.drawable.ad_qrcode, "a_ad_qrCode.png")
88+
// }
89+
// return@setOnLongClickListener true
90+
// }
9191
}
9292
}

0 commit comments

Comments
 (0)