Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 7aa7c9c

Browse files
committed
add an outdated warning
1 parent 5cd6a28 commit 7aa7c9c

File tree

5 files changed

+164
-0
lines changed

5 files changed

+164
-0
lines changed

HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/MainActivity.java

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.afollestad.appthemeengine.ATE;
2525
import com.afollestad.appthemeengine.Config;
2626
import com.tungsten.hmclpe.R;
27+
import com.tungsten.hmclpe.launcher.dialogs.OutdatedWarningDialog;
2728
import com.tungsten.hmclpe.launcher.dialogs.VerifyDialog;
2829
import com.tungsten.hmclpe.launcher.dialogs.account.SkinPreviewDialog;
2930
import com.tungsten.hmclpe.manifest.AppManifest;
@@ -133,6 +134,8 @@ public void handleMessage(@NonNull Message msg) {
133134
exteriorConfig.apply(MainActivity.this);
134135
appBar.setBackgroundColor(launcherSetting.transBar ? getResources().getColor(R.color.launcher_ui_background) : Color.parseColor(ExteriorSettingUI.getThemeColor(MainActivity.this,launcherSetting.launcherTheme)));
135136

137+
OutdatedWarningDialog.init(MainActivity.this);
138+
136139
isLoaded = true;
137140
onLoad();
138141
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.tungsten.hmclpe.launcher.dialogs;
2+
3+
import android.annotation.SuppressLint;
4+
import android.app.Dialog;
5+
import android.content.Context;
6+
import android.content.Intent;
7+
import android.content.SharedPreferences;
8+
import android.net.Uri;
9+
import android.view.View;
10+
import android.widget.Button;
11+
import android.widget.CheckBox;
12+
13+
import androidx.annotation.NonNull;
14+
15+
import com.tungsten.hmclpe.R;
16+
17+
public class OutdatedWarningDialog extends Dialog implements View.OnClickListener {
18+
19+
private CheckBox checkBox;
20+
private Button pojav;
21+
private Button fcl;
22+
private Button positive;
23+
24+
public OutdatedWarningDialog(@NonNull Context context) {
25+
super(context);
26+
setCancelable(false);
27+
setContentView(R.layout.dialog_outdated_warning);
28+
29+
checkBox = findViewById(R.id.hide);
30+
pojav = findViewById(R.id.pojav);
31+
fcl = findViewById(R.id.fcl);
32+
positive = findViewById(R.id.positive);
33+
pojav.setOnClickListener(this);
34+
fcl.setOnClickListener(this);
35+
positive.setOnClickListener(this);
36+
}
37+
38+
public static void init(Context context) {
39+
SharedPreferences sharedPreferences = context.getSharedPreferences("warning", Context.MODE_PRIVATE);
40+
boolean shouldShow = sharedPreferences.getBoolean("outdated_warning", true);
41+
if (shouldShow) {
42+
OutdatedWarningDialog dialog = new OutdatedWarningDialog(context);
43+
dialog.show();
44+
}
45+
}
46+
47+
@Override
48+
public void onClick(View view) {
49+
if (view == pojav) {
50+
Uri uri = Uri.parse("https://github.com/PojavLauncherTeam/PojavLauncher");
51+
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
52+
getContext().startActivity(intent);
53+
}
54+
if (view == fcl) {
55+
Uri uri = Uri.parse("https://alist.8mi.tech/FCL");
56+
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
57+
getContext().startActivity(intent);
58+
}
59+
if (view == positive) {
60+
if (checkBox.isChecked()) {
61+
SharedPreferences sharedPreferences = getContext().getSharedPreferences("warning", Context.MODE_PRIVATE);
62+
@SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit();
63+
editor.putBoolean("outdated_warning", false);
64+
editor.apply();
65+
}
66+
dismiss();
67+
}
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:padding="15dp"
5+
android:layout_width="450dp"
6+
android:layout_height="wrap_content">
7+
8+
<TextView
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:textSize="@dimen/text_size_big"
12+
android:textColor="@color/colorPureBlack"
13+
android:textStyle="bold"
14+
android:text="@string/dialog_outdated_warning_title"/>
15+
16+
<TextView
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:layout_marginTop="10dp"
20+
android:textSize="@dimen/text_size_middle"
21+
android:textColor="@color/colorPureBlack"
22+
android:text="@string/dialog_outdated_warning_msg"/>
23+
24+
<LinearLayout
25+
android:layout_marginTop="10dp"
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
android:orientation="horizontal">
29+
30+
<CheckBox
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:layout_gravity="center"
34+
android:text="@string/dialog_outdated_warning_hide"
35+
android:id="@+id/hide"/>
36+
37+
<View
38+
android:layout_width="0dp"
39+
android:layout_height="0dp"
40+
android:layout_weight="1"/>
41+
42+
<Button
43+
android:singleLine="true"
44+
android:textAllCaps="false"
45+
android:layout_width="60dp"
46+
android:layout_height="40dp"
47+
android:gravity="center"
48+
android:text="Pojav"
49+
android:textSize="15sp"
50+
android:textColor="@color/colorLinkBlue"
51+
android:background="@drawable/launcher_button_parent"
52+
android:id="@+id/pojav"/>
53+
54+
<Button
55+
android:layout_marginStart="10dp"
56+
android:singleLine="true"
57+
android:textAllCaps="false"
58+
android:layout_width="60dp"
59+
android:layout_height="40dp"
60+
android:gravity="center"
61+
android:text="FCL"
62+
android:textSize="15sp"
63+
android:textColor="@color/colorLinkBlue"
64+
android:background="@drawable/launcher_button_parent"
65+
android:id="@+id/fcl"/>
66+
67+
<Button
68+
android:layout_marginStart="10dp"
69+
android:singleLine="true"
70+
android:textAllCaps="false"
71+
android:layout_width="60dp"
72+
android:layout_height="40dp"
73+
android:gravity="center"
74+
android:text="@string/dialog_outdated_warning_positive"
75+
android:textSize="15sp"
76+
android:textColor="@color/colorLinkBlue"
77+
android:background="@drawable/launcher_button_parent"
78+
android:id="@+id/positive"/>
79+
80+
</LinearLayout>
81+
82+
</LinearLayout>

HMCLPE/src/main/res/values-zh/strings.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<string name="dialog_outdated_warning_title">警告</string>
4+
<string name="dialog_outdated_warning_msg">HMCL-PE 已停止维护。 如果您想在 Android 设备上运行 Minecraft: Java 版并获得更好的体验,请下载 FoldCraftLauncher 或 PojavLauncher。</string>
5+
<string name="dialog_outdated_warning_hide">不再显示</string>
6+
<string name="dialog_outdated_warning_positive">我明白了</string>
7+
38
<string name="dialog_unknown_error_title">警告</string>
49
<string name="dialog_unknown_error_msg">启动器遇到无法处理的错误,请联系开发者解决。</string>
510
<string name="dialog_unknown_error_positive">确定</string>

HMCLPE/src/main/res/values/strings.xml

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<string name="version_name" translatable="false">v2.0.7</string>
77
<string name="app_bar_title" translatable="false">Hello Minecraft! Launcher Pocket Edition v2.0.7</string>
88

9+
<string name="dialog_outdated_warning_title">Warning</string>
10+
<string name="dialog_outdated_warning_msg">HMCL-PE has stopped maintenance. If you want to run Minecraft: Java Edition on Android devices and get a better experience, please download FoldCraftLauncher or PojavLauncher.</string>
11+
<string name="dialog_outdated_warning_hide">Don\'t show again</string>
12+
<string name="dialog_outdated_warning_positive">Got it</string>
13+
914
<string name="launcher_spinner_text" translatable="false">▲</string>
1015
<string name="dialog_add_offline_account_uuid" translatable="false">UUID</string>
1116
<string name="default_game_file_directory_list_pri_path" translatable="false">/storage/emulated/0/HMCLPE/.minecraft</string>

0 commit comments

Comments
 (0)