Skip to content

Commit

Permalink
add an outdated warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Tungstend committed Feb 8, 2024
1 parent 5cd6a28 commit 7aa7c9c
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.afollestad.appthemeengine.ATE;
import com.afollestad.appthemeengine.Config;
import com.tungsten.hmclpe.R;
import com.tungsten.hmclpe.launcher.dialogs.OutdatedWarningDialog;
import com.tungsten.hmclpe.launcher.dialogs.VerifyDialog;
import com.tungsten.hmclpe.launcher.dialogs.account.SkinPreviewDialog;
import com.tungsten.hmclpe.manifest.AppManifest;
Expand Down Expand Up @@ -133,6 +134,8 @@ public void handleMessage(@NonNull Message msg) {
exteriorConfig.apply(MainActivity.this);
appBar.setBackgroundColor(launcherSetting.transBar ? getResources().getColor(R.color.launcher_ui_background) : Color.parseColor(ExteriorSettingUI.getThemeColor(MainActivity.this,launcherSetting.launcherTheme)));

OutdatedWarningDialog.init(MainActivity.this);

isLoaded = true;
onLoad();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.tungsten.hmclpe.launcher.dialogs;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;

import androidx.annotation.NonNull;

import com.tungsten.hmclpe.R;

public class OutdatedWarningDialog extends Dialog implements View.OnClickListener {

private CheckBox checkBox;
private Button pojav;
private Button fcl;
private Button positive;

public OutdatedWarningDialog(@NonNull Context context) {
super(context);
setCancelable(false);
setContentView(R.layout.dialog_outdated_warning);

checkBox = findViewById(R.id.hide);
pojav = findViewById(R.id.pojav);
fcl = findViewById(R.id.fcl);
positive = findViewById(R.id.positive);
pojav.setOnClickListener(this);
fcl.setOnClickListener(this);
positive.setOnClickListener(this);
}

public static void init(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences("warning", Context.MODE_PRIVATE);
boolean shouldShow = sharedPreferences.getBoolean("outdated_warning", true);
if (shouldShow) {
OutdatedWarningDialog dialog = new OutdatedWarningDialog(context);
dialog.show();
}
}

@Override
public void onClick(View view) {
if (view == pojav) {
Uri uri = Uri.parse("https://github.com/PojavLauncherTeam/PojavLauncher");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
getContext().startActivity(intent);
}
if (view == fcl) {
Uri uri = Uri.parse("https://alist.8mi.tech/FCL");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
getContext().startActivity(intent);
}
if (view == positive) {
if (checkBox.isChecked()) {
SharedPreferences sharedPreferences = getContext().getSharedPreferences("warning", Context.MODE_PRIVATE);
@SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("outdated_warning", false);
editor.apply();
}
dismiss();
}
}
}
82 changes: 82 additions & 0 deletions HMCLPE/src/main/res/layout/dialog_outdated_warning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="15dp"
android:layout_width="450dp"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_big"
android:textColor="@color/colorPureBlack"
android:textStyle="bold"
android:text="@string/dialog_outdated_warning_title"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="@dimen/text_size_middle"
android:textColor="@color/colorPureBlack"
android:text="@string/dialog_outdated_warning_msg"/>

<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/dialog_outdated_warning_hide"
android:id="@+id/hide"/>

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

<Button
android:singleLine="true"
android:textAllCaps="false"
android:layout_width="60dp"
android:layout_height="40dp"
android:gravity="center"
android:text="Pojav"
android:textSize="15sp"
android:textColor="@color/colorLinkBlue"
android:background="@drawable/launcher_button_parent"
android:id="@+id/pojav"/>

<Button
android:layout_marginStart="10dp"
android:singleLine="true"
android:textAllCaps="false"
android:layout_width="60dp"
android:layout_height="40dp"
android:gravity="center"
android:text="FCL"
android:textSize="15sp"
android:textColor="@color/colorLinkBlue"
android:background="@drawable/launcher_button_parent"
android:id="@+id/fcl"/>

<Button
android:layout_marginStart="10dp"
android:singleLine="true"
android:textAllCaps="false"
android:layout_width="60dp"
android:layout_height="40dp"
android:gravity="center"
android:text="@string/dialog_outdated_warning_positive"
android:textSize="15sp"
android:textColor="@color/colorLinkBlue"
android:background="@drawable/launcher_button_parent"
android:id="@+id/positive"/>

</LinearLayout>

</LinearLayout>
5 changes: 5 additions & 0 deletions HMCLPE/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="dialog_outdated_warning_title">警告</string>
<string name="dialog_outdated_warning_msg">HMCL-PE 已停止维护。 如果您想在 Android 设备上运行 Minecraft: Java 版并获得更好的体验,请下载 FoldCraftLauncher 或 PojavLauncher。</string>
<string name="dialog_outdated_warning_hide">不再显示</string>
<string name="dialog_outdated_warning_positive">我明白了</string>

<string name="dialog_unknown_error_title">警告</string>
<string name="dialog_unknown_error_msg">启动器遇到无法处理的错误,请联系开发者解决。</string>
<string name="dialog_unknown_error_positive">确定</string>
Expand Down
5 changes: 5 additions & 0 deletions HMCLPE/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<string name="version_name" translatable="false">v2.0.7</string>
<string name="app_bar_title" translatable="false">Hello Minecraft! Launcher Pocket Edition v2.0.7</string>

<string name="dialog_outdated_warning_title">Warning</string>
<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>
<string name="dialog_outdated_warning_hide">Don\'t show again</string>
<string name="dialog_outdated_warning_positive">Got it</string>

<string name="launcher_spinner_text" translatable="false">▲</string>
<string name="dialog_add_offline_account_uuid" translatable="false">UUID</string>
<string name="default_game_file_directory_list_pri_path" translatable="false">/storage/emulated/0/HMCLPE/.minecraft</string>
Expand Down

0 comments on commit 7aa7c9c

Please sign in to comment.