From 93dbe0941e6bedb47dd98116b706313e3f4271ae Mon Sep 17 00:00:00 2001 From: renato97 Date: Tue, 25 Nov 2025 19:23:17 +0000 Subject: [PATCH] Update v9.4.6: Custom Update Dialog & Focus States --- app/build.gradle | 4 +- .../java/com/streamplayer/MainActivity.java | 52 +++++++++--- .../res/drawable/bg_dialog_button_primary.xml | 62 +++++++++++++++ .../drawable/bg_dialog_button_secondary.xml | 77 ++++++++++++++++++ app/src/main/res/layout/dialog_update.xml | 79 +++++++++++++++++++ dashboard/data/devices.json | 4 +- update-manifest.json | 12 +-- 7 files changed, 267 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/drawable/bg_dialog_button_primary.xml create mode 100644 app/src/main/res/drawable/bg_dialog_button_secondary.xml create mode 100644 app/src/main/res/layout/dialog_update.xml diff --git a/app/build.gradle b/app/build.gradle index 37d5973..5441d65 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.streamplayer" minSdk 21 targetSdk 33 - versionCode 94500 - versionName "9.4.5" + versionCode 94600 + versionName "9.4.6" buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"' } diff --git a/app/src/main/java/com/streamplayer/MainActivity.java b/app/src/main/java/com/streamplayer/MainActivity.java index 7e1dd5f..b36d16c 100644 --- a/app/src/main/java/com/streamplayer/MainActivity.java +++ b/app/src/main/java/com/streamplayer/MainActivity.java @@ -5,11 +5,11 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; +import android.graphics.drawable.ColorDrawable; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; @@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity { contentTitle = findViewById(R.id.content_title); eventsRefreshButton = findViewById(R.id.events_refresh_button); eventsRefreshButton.setOnClickListener(v -> manualRefreshEvents()); + applyFocusHighlight(eventsRefreshButton); channelAdapter = new ChannelAdapter( channel -> openPlayer(channel.getName(), channel.getPageUrl())); @@ -296,26 +297,41 @@ public class MainActivity extends AppCompatActivity { if (info == null) { return; } - showUpdateDialog(info, true); + showUpdateDialog(info); } - private void showUpdateDialog(UpdateManager.UpdateInfo info, boolean mandatory) { + private void showUpdateDialog(UpdateManager.UpdateInfo info) { if (isFinishing()) { return; } if (updateDialog != null && updateDialog.isShowing()) { updateDialog.dismiss(); } - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.ThemeOverlay_StreamPlayer_AlertDialog) - .setTitle(R.string.update_required_title) - .setMessage(buildUpdateMessage(info)) - .setPositiveButton(R.string.update_action_download, - (dialog, which) -> updateManager.downloadUpdate(MainActivity.this, info)) - .setNegativeButton(R.string.update_action_close_app, - (dialog, which) -> closeAppCompletely()) - .setCancelable(false); - updateDialog = builder.show(); - updateDialog.setCanceledOnTouchOutside(false); + View dialogView = getLayoutInflater().inflate(R.layout.dialog_update, null); + TextView titleView = dialogView.findViewById(R.id.update_title); + TextView messageView = dialogView.findViewById(R.id.update_message); + Button positiveButton = dialogView.findViewById(R.id.update_positive_button); + Button negativeButton = dialogView.findViewById(R.id.update_negative_button); + titleView.setText(R.string.update_required_title); + messageView.setText(buildUpdateMessage(info)); + AlertDialog dialog = new AlertDialog.Builder(this, R.style.ThemeOverlay_StreamPlayer_AlertDialog) + .setView(dialogView) + .setCancelable(false) + .create(); + dialog.setCanceledOnTouchOutside(false); + dialog.show(); + if (dialog.getWindow() != null) { + dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); + } + positiveButton.setOnClickListener(v -> { + dialog.dismiss(); + updateManager.downloadUpdate(MainActivity.this, info); + }); + negativeButton.setOnClickListener(v -> closeAppCompletely()); + applyFocusHighlight(positiveButton); + applyFocusHighlight(negativeButton); + positiveButton.requestFocus(); + updateDialog = dialog; } private CharSequence buildUpdateMessage(UpdateManager.UpdateInfo info) { @@ -394,6 +410,16 @@ public class MainActivity extends AppCompatActivity { Toast.makeText(this, R.string.device_blocked_copy_success, Toast.LENGTH_SHORT).show(); } + private void applyFocusHighlight(View view) { + if (view == null) { + return; + } + view.setOnFocusChangeListener((v, hasFocus) -> { + float scale = hasFocus ? 1.05f : 1f; + v.animate().scaleX(scale).scaleY(scale).setDuration(120).start(); + }); + } + private void startEventPrefetchScheduler() { if (eventPrefetchHandler == null) { eventPrefetchHandler = new Handler(Looper.getMainLooper()); diff --git a/app/src/main/res/drawable/bg_dialog_button_primary.xml b/app/src/main/res/drawable/bg_dialog_button_primary.xml new file mode 100644 index 0000000..9f798b1 --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button_primary.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_dialog_button_secondary.xml b/app/src/main/res/drawable/bg_dialog_button_secondary.xml new file mode 100644 index 0000000..c7caaf0 --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button_secondary.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_update.xml b/app/src/main/res/layout/dialog_update.xml new file mode 100644 index 0000000..8baf6be --- /dev/null +++ b/app/src/main/res/layout/dialog_update.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + +