diff --git a/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/MainActivity.java b/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/MainActivity.java index fbe21a5a..a5e9de74 100644 --- a/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/MainActivity.java +++ b/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/MainActivity.java @@ -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; @@ -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(); } diff --git a/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/dialogs/OutdatedWarningDialog.java b/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/dialogs/OutdatedWarningDialog.java new file mode 100644 index 00000000..a007d9e6 --- /dev/null +++ b/HMCLPE/src/main/java/com/tungsten/hmclpe/launcher/dialogs/OutdatedWarningDialog.java @@ -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(); + } + } +} diff --git a/HMCLPE/src/main/res/layout/dialog_outdated_warning.xml b/HMCLPE/src/main/res/layout/dialog_outdated_warning.xml new file mode 100644 index 00000000..1158e047 --- /dev/null +++ b/HMCLPE/src/main/res/layout/dialog_outdated_warning.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + +