Skip to content

Commit

Permalink
[demo]optimize: show app version on settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfeng committed Oct 10, 2024
1 parent 4cac4c7 commit f0b8758
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "snow.music"
minSdk = 21
targetSdk = 35
versionCode = 5
versionName = "1.2.8"
versionCode = 6
versionName = "1.2.14"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Objects;

import snow.music.BuildConfig;
import snow.music.R;
import snow.music.dialog.MessageDialog;
import snow.music.service.AppPlayerService;
Expand All @@ -37,6 +40,7 @@ public class SettingActivity extends AppCompatActivity {
private View itemFollowSystem;
private View itemDarkModeOff;
private View itemDarkModeOn;
private TextView tvVersion;

private View itemPlayWithOtherApp;
private SwitchCompat swPlayWithOtherApp;
Expand Down Expand Up @@ -74,6 +78,7 @@ private void findViews() {
itemFollowSystem = findViewById(R.id.itemFollowSystem);
itemDarkModeOff = findViewById(R.id.itemDarkModeOff);
itemDarkModeOn = findViewById(R.id.itemDarkModeOn);
tvVersion = findViewById(R.id.tvVersion);

itemPlayWithOtherApp = findViewById(R.id.itemPlayWithOtherApp);
swPlayWithOtherApp = findViewById(R.id.swPlayWithOtherApp);
Expand Down Expand Up @@ -107,6 +112,8 @@ private void initViews() {

Boolean value = mSettingViewModel.getPlayWithOtherApp().getValue();
swPlayWithOtherApp.setChecked(Objects.requireNonNull(value));

tvVersion.setText(BuildConfig.VERSION_NAME);
}

private void addClickListener() {
Expand Down
44 changes: 35 additions & 9 deletions app/src/main/res/layout/activity_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
android:focusable="true"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingLeft="16dp"
android:paddingEnd="8dp"
android:paddingRight="8dp">
android:paddingEnd="8dp">

<TextView
android:layout_width="0dp"
Expand Down Expand Up @@ -109,9 +107,7 @@
android:focusable="true"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingLeft="16dp"
android:paddingEnd="8dp"
android:paddingRight="8dp">
android:paddingEnd="8dp">

<TextView
android:layout_width="0dp"
Expand Down Expand Up @@ -142,9 +138,7 @@
android:focusable="true"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingLeft="16dp"
android:paddingEnd="8dp"
android:paddingRight="8dp">
android:paddingEnd="8dp">

<TextView
android:layout_width="0dp"
Expand Down Expand Up @@ -219,6 +213,38 @@
android:textColor="@color/colorSecondaryText"
android:textStyle="bold" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="@color/colorSettingSpace" />

<LinearLayout
android:id="@+id/itemVersion"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/bg_list_item"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:text="@string/item_version"
android:textSize="15sp" />

<TextView
android:id="@+id/tvVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
tools:text="1.0.0"
tools:visibility="visible" />

</LinearLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<string name="item_dark_mode_on">暗色模式</string>
<string name="item_dark_mode_off">普通模式</string>
<string name="item_play_with_other_app">与游戏/其他APP同时播放</string>
<string name="item_version">版本</string>
<string name="description_play_with_other_app">开启之后,在其他应用播放音频、视频或者视频语言通话时,音乐不会自动暂停,将始终作为BGM保持播放,您可以在通知栏中手动暂停播放。</string>
<string name="toast_no_read_media_audio_permission">无音频媒体访问权限!</string>
<string name="description_read_phone_state_rationale">警告!为了避免忽略音频焦点后播放器不会在手机来电期间自动暂停播放,请授予应用读取手机状态权限!</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<string name="item_dark_mode_on">Dark mode</string>
<string name="item_dark_mode_off">Normal mode</string>
<string name="item_play_with_other_app">Background mode</string>
<string name="item_version">Version</string>
<string name="description_play_with_other_app">Music playback won\'t be paused by other apps in Background mode. You\'ll be able to pause music playback manually in the Notification shade.</string>
<string name="description_read_phone_state_rationale">Warning! In order to avoid that the player will not automatically pause playing when the phone calls after ignoring the audio focus, please grant the app the permission to read the phone status!</string>

Expand Down

0 comments on commit f0b8758

Please sign in to comment.