From b4cda7ac8b82a0793d2da0a7fe6991c668f47f54 Mon Sep 17 00:00:00 2001 From: Geronimo Ferruccio Date: Sun, 15 Dec 2024 19:35:04 -0300 Subject: [PATCH 1/4] Allow HTML in Dialog messages --- src/com/reco1l/osu/ui/Dialog.kt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/com/reco1l/osu/ui/Dialog.kt b/src/com/reco1l/osu/ui/Dialog.kt index d7127521e..2f5d875fb 100644 --- a/src/com/reco1l/osu/ui/Dialog.kt +++ b/src/com/reco1l/osu/ui/Dialog.kt @@ -1,6 +1,8 @@ package com.reco1l.osu.ui import android.graphics.Color +import android.text.Html +import android.text.method.LinkMovementMethod import android.view.ContextThemeWrapper import android.view.Gravity.* import android.view.View @@ -8,6 +10,7 @@ import android.widget.Button import android.widget.EditText import android.widget.LinearLayout import android.widget.TextView +import androidx.core.text.HtmlCompat import androidx.core.view.isVisible import androidx.core.widget.doOnTextChanged import com.edlplan.framework.easing.Easing @@ -39,6 +42,8 @@ open class MessageDialog : BaseFragment() { protected var message: CharSequence = "" + protected var isHTMLMessage = false + protected var allowDismiss = true protected var onDismiss: (() -> Unit)? = null @@ -49,7 +54,16 @@ open class MessageDialog : BaseFragment() { override fun onLoadView() { findViewById(R.id.title)!!.text = title - findViewById(R.id.message)?.text = message + + if (isHTMLMessage) { + findViewById(R.id.message)?.apply { + text = HtmlCompat.fromHtml(message.toString(), HtmlCompat.FROM_HTML_MODE_LEGACY) + isClickable = true + movementMethod = LinkMovementMethod.getInstance() + } + } else { + findViewById(R.id.message)?.text = message + } val buttonLayout = findViewById(R.id.button_layout)!! @@ -97,8 +111,10 @@ open class MessageDialog : BaseFragment() { /** * The text to be show displayed in the dialog message. */ - fun setMessage(text: String): MessageDialog { + @JvmOverloads + fun setMessage(text: String, isHTML: Boolean = false): MessageDialog { message = text + isHTMLMessage = isHTML return this } From d80de64d5d97bb8c99bedb0718879a2eb2e097cf Mon Sep 17 00:00:00 2001 From: Geronimo Ferruccio Date: Sun, 15 Dec 2024 19:35:41 -0300 Subject: [PATCH 2/4] Replace main menu texts with a dialog --- src/ru/nsu/ccfit/zuev/osu/MainScene.java | 96 ++++++++---------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/src/ru/nsu/ccfit/zuev/osu/MainScene.java b/src/ru/nsu/ccfit/zuev/osu/MainScene.java index e1b3e0e3b..302b3bc82 100644 --- a/src/ru/nsu/ccfit/zuev/osu/MainScene.java +++ b/src/ru/nsu/ccfit/zuev/osu/MainScene.java @@ -1,12 +1,11 @@ package ru.nsu.ccfit.zuev.osu; import android.content.Context; -import android.content.Intent; import android.graphics.PointF; -import android.net.Uri; import android.os.PowerManager; import android.util.Log; +import com.reco1l.andengine.shape.RoundedBox; import com.reco1l.osu.data.BeatmapInfo; import com.reco1l.osu.Execution; import com.reco1l.osu.ui.entity.MainMenu; @@ -51,7 +50,6 @@ import java.util.Arrays; import java.util.LinkedList; -import java.util.Locale; import java.util.TimerTask; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -172,66 +170,49 @@ public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, menu = new MainMenu(this); - final Text author = new Text(10, 530, ResourceManager - .getInstance().getFont("font"), - String.format( - Locale.getDefault(), - "osu!droid %s\nby osu!droid Team\nosu! is © peppy 2007-2024", - BuildConfig.VERSION_NAME + " (" + BuildConfig.BUILD_TYPE + ")" - )) { + // Only show build type if it's not release + String versionString = BuildConfig.VERSION_NAME + String.format(" (%s)", BuildConfig.BUILD_TYPE).replace(" (release)", ""); + RoundedBox box = new RoundedBox() { - @Override - public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { - if (pSceneTouchEvent.isActionDown()) { + { + Text versionText = new Text(10f, 2f, ResourceManager.getInstance().getFont("font"), "osu!droid " + versionString); + attachChild(versionText); - new MessageDialog() - .setMessage(context.getString(com.osudroid.resources.R.string.dialog_visit_osu_website)) - .addButton("Yes", dialog -> { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://osu.ppy.sh")); - GlobalManager.getInstance().getMainActivity().startActivity(browserIntent); - dialog.dismiss(); - return null; - }) - .addButton("No", dialog -> { - dialog.dismiss(); - return null; - }) - .show(); - - return true; - } - return false; + setSize(versionText.getWidth() + 20f, versionText.getHeight() + 4f); + setPosition(10f, Config.getRES_HEIGHT() - getHeight() - 10f); + setColor(0f, 0f, 0f, 0.5f); // Black + setCornerRadius(12f); } - }; - author.setPosition(10, Config.getRES_HEIGHT() - author.getHeight() - 10); - - final Text yasonline = new Text(720, 530, ResourceManager.getInstance().getFont("font"), " Global Ranking\n Provided by iBancho") { - - @Override - public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { - if (pSceneTouchEvent.isActionDown()) { + public boolean onAreaTouched(TouchEvent event, float localX, float localY) { + if (event.isActionUp()) { new MessageDialog() - .setMessage(context.getString(com.osudroid.resources.R.string.dialog_visit_osudroid_website)) - .addButton("Yes", dialog -> { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://" + OnlineManager.hostname)); - GlobalManager.getInstance().getMainActivity().startActivity(browserIntent); - dialog.dismiss(); - return null; - }) - .addButton("No", dialog -> { + .setTitle("About") + .setMessage( + "

osu!droid

\n" + + "
Version " + versionString + "
\n" + + "

Made by osu!droid team
osu! is © peppy 2007-2024

\n" + + "
\n" + + "Visit official osu! website ↗\n" + + "
\n" + + "
\n" + + "Visit official osu!droid website ↗\n" + + "
\n" + + "
\n" + + "Join the official Discord server ↗\n", + true + ) + .addButton("Close", dialog -> { dialog.dismiss(); return null; }) .show(); - - return true; } - return false; + return true; } }; - yasonline.setPosition(Config.getRES_WIDTH() - yasonline.getWidth() - 40, Config.getRES_HEIGHT() - yasonline.getHeight() - 10); + scene.attachChild(box); final Sprite music_prev = new Sprite(Config.getRES_WIDTH() - 50 * 6 + 35, 47, 40, 40, ResourceManager.getInstance().getTexture( @@ -362,14 +343,6 @@ public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final TextureRegion nptex = ResourceManager.getInstance().getTexture("music_np"); music_nowplay = new Sprite(Utils.toRes(Config.getRES_WIDTH() - 500), 0, (float) (40 * nptex.getWidth()) / nptex.getHeight(), 40, nptex); - final Rectangle bgTopRect = new Rectangle(0, 0, Config.getRES_WIDTH(), Utils.toRes(120)); - bgTopRect.setColor(0, 0, 0, 0.3f); - - final Rectangle bgbottomRect = new Rectangle(0, 0, Config.getRES_WIDTH(), - Math.max(author.getHeight(), yasonline.getHeight()) + Utils.toRes(15)); - bgbottomRect.setPosition(0, Config.getRES_HEIGHT() - bgbottomRect.getHeight()); - bgbottomRect.setColor(0, 0, 0, 0.3f); - for (int i = 0; i < 120; i++) { final float pX = (float) Config.getRES_WIDTH() / 2; final float pY = (float) Config.getRES_HEIGHT() / 2; @@ -456,10 +429,6 @@ public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX menuBarX = menu.getFirst().getX(); scene.attachChild(lastBackground, 0); - scene.attachChild(bgTopRect); - scene.attachChild(bgbottomRect); - scene.attachChild(author); - scene.attachChild(yasonline); menu.attachButtons(); @@ -475,9 +444,8 @@ public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX scene.attachChild(beatmapDownloader); scene.registerTouchArea(logo); - scene.registerTouchArea(author); + scene.registerTouchArea(box); scene.registerTouchArea(beatmapDownloader); - scene.registerTouchArea(yasonline); scene.registerTouchArea(music_prev); scene.registerTouchArea(music_play); scene.registerTouchArea(music_pause); From fefbdaaf758cfdf0c822cb570c40489b4c91a255 Mon Sep 17 00:00:00 2001 From: Geronimo Ferruccio Date: Sun, 15 Dec 2024 23:00:44 -0300 Subject: [PATCH 3/4] Add development build text --- src/ru/nsu/ccfit/zuev/osu/MainScene.java | 47 +++++++++++++++++------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/ru/nsu/ccfit/zuev/osu/MainScene.java b/src/ru/nsu/ccfit/zuev/osu/MainScene.java index 302b3bc82..6b780e520 100644 --- a/src/ru/nsu/ccfit/zuev/osu/MainScene.java +++ b/src/ru/nsu/ccfit/zuev/osu/MainScene.java @@ -5,7 +5,9 @@ import android.os.PowerManager; import android.util.Log; +import com.reco1l.andengine.Anchor; import com.reco1l.andengine.shape.RoundedBox; +import com.reco1l.andengine.sprite.ExtendedSprite; import com.reco1l.osu.data.BeatmapInfo; import com.reco1l.osu.Execution; import com.reco1l.osu.ui.entity.MainMenu; @@ -170,13 +172,30 @@ public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, menu = new MainMenu(this); - // Only show build type if it's not release - String versionString = BuildConfig.VERSION_NAME + String.format(" (%s)", BuildConfig.BUILD_TYPE).replace(" (release)", ""); + if (BuildConfig.DEBUG) { + ResourceManager.getInstance().loadHighQualityAsset("dev-build-overlay", "dev-build-overlay.png"); + + ExtendedSprite debugOverlay = new ExtendedSprite(ResourceManager.getInstance().getTexture("dev-build-overlay")); + debugOverlay.setPosition(Config.getRES_WIDTH() / 2f, Config.getRES_HEIGHT()); + debugOverlay.setOrigin(Anchor.BottomCenter); + scene.attachChild(debugOverlay); + + Text debugText = new Text(0, 0, ResourceManager.getInstance().getFont("smallFont"), "DEVELOPMENT BUILD"); + debugText.setColor(1f, 237f / 255f, 0f); + debugText.setPosition((Config.getRES_WIDTH() - debugText.getWidth()) / 2f, Config.getRES_HEIGHT() - debugOverlay.getHeight() - 1f - debugText.getHeight()); + + Text debugTextShadow = new Text(0, 0, ResourceManager.getInstance().getFont("smallFont"), "DEVELOPMENT BUILD"); + debugTextShadow.setColor(0f, 0f, 0f, 0.5f); + debugTextShadow.setPosition((Config.getRES_WIDTH() - debugText.getWidth()) / 2f + 2f, Config.getRES_HEIGHT() - debugOverlay.getHeight() - 1f - debugText.getHeight() + 2f); + + scene.attachChild(debugTextShadow); + scene.attachChild(debugText); + } RoundedBox box = new RoundedBox() { { - Text versionText = new Text(10f, 2f, ResourceManager.getInstance().getFont("font"), "osu!droid " + versionString); + Text versionText = new Text(10f, 2f, ResourceManager.getInstance().getFont("smallFont"), "osu!droid " + BuildConfig.VERSION_NAME); attachChild(versionText); setSize(versionText.getWidth() + 20f, versionText.getHeight() + 4f); @@ -190,17 +209,17 @@ public boolean onAreaTouched(TouchEvent event, float localX, float localY) { new MessageDialog() .setTitle("About") .setMessage( - "

osu!droid

\n" + - "
Version " + versionString + "
\n" + - "

Made by osu!droid team
osu! is © peppy 2007-2024

\n" + - "
\n" + - "Visit official osu! website ↗\n" + - "
\n" + - "
\n" + - "Visit official osu!droid website ↗\n" + - "
\n" + - "
\n" + - "Join the official Discord server ↗\n", + "

osu!droid

\n" + + "
Version " + BuildConfig.VERSION_NAME + "
\n" + + "

Made by osu!droid team
osu! is © peppy 2007-2024

\n" + + "
\n" + + "Visit official osu! website ↗\n" + + "
\n" + + "
\n" + + "Visit official osu!droid website ↗\n" + + "
\n" + + "
\n" + + "Join the official Discord server ↗\n", true ) .addButton("Close", dialog -> { From 75801ebbce57bf530f96d20bdf87c338c1364088 Mon Sep 17 00:00:00 2001 From: Geronimo Ferruccio Date: Sun, 15 Dec 2024 23:02:36 -0300 Subject: [PATCH 4/4] Add missing texture --- assets/dev-build-overlay.png | Bin 0 -> 937 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/dev-build-overlay.png diff --git a/assets/dev-build-overlay.png b/assets/dev-build-overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..652a1d3e5e8c4a89357e53bdfa055f8f83b13aa7 GIT binary patch literal 937 zcmeAS@N?(olHy`uVBq!ia0y~yU;;83m^s*h}FfdWk9d zNvV1jxdk9)3^w)^1&PVosU-?Ysp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^ z3rViZPPR-@vbW>1sjvbXkegbPs8ErclUHn2VXFi-*9yo63F|8hPmo~=?wNlAf~zJ7Umxn8-kUVc%!zM-Y1rM`iYzLAkGP=#)BWnM{Q zg>GK4GRO#s87`^C$wiq3C7Jno3LrBRlk!VTY?YMsL6+!4Z2@{uAMQUO2OdJHdB9*P z0{VZROu~C$I7@oEIEF;D-kt87Asi^ux_`QxtM5UFvr#c(OaDDsq_jw5S{F;R!n&aP zrWIStGB$KeP1q*VWpFSpS)i%6X~$$Qhqbd57Kwy6b!#}yn#wA=Yr};FGoA-|sLwUO zEGc)k@wDyxIoAD$c|NN@F=AlK`JEM$y7rak^%_&nzVEXZ1-UXX&aTvscjeyk;o2GX zO-@BVAHu^-pPp4c6H;$5DK(@z2~{6rHK=!dMzy!lis(8J+gnr_YWUFmOYy8bJx?xy_&;o^Yxqi%@VLUyptI-X@=ZroC(N59Z2-nNI4<&)>T^*G07HKfi7Cp30l& zA3FOtOselRN!mASiFwwir>ozo+)K(}2s$kA?!w$7>MX~8hFbd{J2Tm9sm<-OyR{5D zdQvev{!E#9i2H7!&GDlZ;*y^gqMg_N{4~8jIi)x^M%w3f-y`mM;yzV