ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.6k stars 365 forks source link

Android release preparations #6008

Closed ihhub closed 1 year ago

ihhub commented 1 year ago

Preliminary checks

Describe the problem requiring a solution

Even having a very basic Android build we are far away from a proper release for this platform. We need to make multiple changes and adjustments in order to make it user-friendly and ready to be published in App Store.

Describe the possible solution

Additional info

No response

oleg-derevenetz commented 1 year ago

Android filesystem is case-sensitive. Right now the code does not handle it properly. The logic present for case-sensitive filesystems is not applicable for Android due to a fact that an Android application has access (even for reading) only to certain directories.

If we are going to distribute APK via direct download, we can just use the MANAGE_EXTERNAL_STORAGE permission and screw the Google "best practices".

Android has native support of it.

I'm not sure about that. SDL_Mixer has support for native MIDI on MacOS X and Windows, but not on Android. It can be built with TiMidity though (just like I did for our Android package), but in this case it requires additional files (GUS patches, i.e. soundfonts).

ihhub commented 1 year ago

Hi @oleg-derevenetz , I see no issues not to follow "best practices" but make the application more user-friendly in general.

oleg-derevenetz commented 1 year ago

I see no issues not to follow "best practices" but make the application more user-friendly in general.

The problem is that in this case app becomes less suitable for Google Play :) So we have to choose between Google Play and ease of use ("just copy the data files to your SD card") in this case. Also people are often scared by permission requests.

ihhub commented 1 year ago

Let's come to this issue at the very last moment once we fix other 12+ issues. Once the time comes we can decide which approach is the best to move forward.

ihhub commented 1 year ago

We should enable software cursor rendering but we need to fix #5778 in order to make it work.

oleg-derevenetz commented 1 year ago

@ihhub

We should enable software cursor rendering

Why? What's the purpose of the mouse cursor on the touchscreen?

ihhub commented 1 year ago

@oleg-derevenetz , we need to choose one of the way to control the game on Android devices:

I was thinking to try the second approach but looks like we have no choice but to stick to the first one. We can add some touch actions to avoid difficulties of controlling the game.

oleg-derevenetz commented 1 year ago

@ihhub

emulation of cursor and clicks in the game. Showing a visible cursor to have high precision clicks.

Never seen this :) How does this work? Does it emulate "right mouse button" on the touch screen? If this works fine, then maybe we should try this.

ihhub commented 1 year ago

My artistic skills are not up to date but: image

ihhub commented 1 year ago

I've seen such games being played by other people. Of course it doesn't need to be black background and etc. but many games use this concept. If we stick to it we don't need to change much code in the game regarding controls.

oleg-derevenetz commented 1 year ago

@ihhub Well, looks promising. Does SDL have some built-in support for this mode?

ihhub commented 1 year ago

@oleg-derevenetz , I do not know. We need to investigate this🙂

oleg-derevenetz commented 1 year ago

@ihhub

left click simulation

I suppose you mean RIGHT click simulation :) Left click is simulated just fine using the single touch.

ihhub commented 1 year ago

@oleg-derevenetz , yes! I need more sleep :)

poVoq commented 1 year ago

Any idea why copying the map files fails? I got the game up and running, but android refuses to copy the map files and shows some strange java error and the .MP2 files end up as 0 byte .MP2.mpeg files in the folder I need to copy them to.

oleg-derevenetz commented 1 year ago

Hi @poVoq how exactly are you trying to copy them? I usually use either Total Commander on the Android device itself or Windows Explorer when the device is attached to Windows machine using USB cable. It seems that the program you are using perceives the map files as multimedia files because of their MP2 extension. You can try to pack them into the ZIP archive, copy this ZIP archive to the device and then extract these files to the MAPS directory using Total Commander.

poVoq commented 1 year ago

I tried using the SimpleFiles app from f-droid. Other Apps do not seem to allow accessing the /android/data/ folder at all. I will try over a usb connection, but I think that system folder is not easily accessible that way either? Edit: seems to be possible to access via USB.

oleg-derevenetz commented 1 year ago

@poVoq this is Android/data/.. on the shared storage, i.e. full path from the phone filesystem root is /sdcard/Android/data/.... This is not a system folder at all, any file manager, including the Android preinstalled "Files" app is able to access it and write to it:

Files

poVoq commented 1 year ago

In the standard files app from LinageOS it is totally inaccessible and the SimpleFiles app needs to ask special permission to access it. Copying via usb seems to work, but it is super slow and breaks down every new few minutes. Normally that does not happen when copying files to normal directories like the /downloads folder.

zenseii commented 1 year ago

Copying via usb seems to work, but it is super slow and breaks down every new few minutes. Normally that does not happen when copying files to normal directories like the /downloads folder.

This probably happens because the device has been inactive for a moment and therefore goes into somekind of a rest mode. I transferred each directory separately.

oleg-derevenetz commented 1 year ago

@poVoq It's strange that interaction with this folder is broken on the LineageOS , because the main purpose of this folder is to allow user to exchange files with the installed apps.

poVoq commented 1 year ago

My impression is that this folder is meant for storing app specific configuration files etc. and is not mean to be accessed manually at all.

oleg-derevenetz commented 1 year ago

@poVoq Nope, there is separate folder for this - /data/data/org.fheroes2, so-called "private app folder". This folder is not accessible from outside (if phone is not in developer mode).

Laserlicht commented 1 year ago

@poVoq Maybe this problem? https://www.reddit.com/r/Android/comments/j3zgmm/managing_files_in_the_androiddata_folder_on/

@oleg-derevenetz Is it possible to run the app in immersive mode?

oleg-derevenetz commented 1 year ago

@Laserlicht

Is it possible to run the app in immersive mode?

Yes, of course. Just replace fullscreen = off by fullscreen = on in fheroes2.cfg.

P.S. Hi @ihhub maybe there is some way to integrate this setting into the GUI in addition to using hotkeys? It is unlikely that users on mobile systems will bother with manually editing the configuration file.

ihhub commented 1 year ago

Hi @oleg-derevenetz , I am thinking we need to make full screen for Android devices by default. However, having a special option for this is in my to-do list.

I also found a crash: use drag and drop to split a stack and when you press okay, the application crashes.

oleg-derevenetz commented 1 year ago

Hi @ihhub

I also found a crash: use drag and drop to split a stack and when you press okay, the application crashes.

This crash is not related to Android, it is due to an assertion failure:

Assertion failed: (0), function addNewTroopsToFreeSlots, file army.cpp, line 813.
oleg-derevenetz commented 1 year ago

I am thinking we need to make full screen for Android devices by default

As for me personally, I'd like to have a choice, because I'm used to seeing the clock in the top bar to keep track of time. But this is a matter of taste.

oleg-derevenetz commented 1 year ago

https://www.reddit.com/r/Android/comments/j3zgmm/managing_files_in_the_androiddata_folder_on/

OMG, WTF. Another shitty design decision from Google under the sauce of "security". It looks like that they want to have only messengers, Facebook and Instagram on the platform. Apps that work with files? Meh.

ihhub commented 1 year ago

Let's stick for Android 10-12 for now. All fancy Android 13 devices won't come up so quickly.

ihhub commented 1 year ago

I suggest for right click (I am almost falling asleep again) we can use multi-touch event handled by SDL2. This is either SDL_DollarGestureEvent or SDL_MultiGestureEvent.

This is an easy workaround to make some sort of workable touchscreen version of the game. What do you think?

ihhub commented 1 year ago

Actually we can modify this method void LocalEvent::HandleTouchEvent( const SDL_TouchFingerEvent & event ) to handle multi-finger gestures.

zenseii commented 1 year ago

A simple way to perform a right click could be to hold one finger, for instance the thumb, on the object of interest and then press another finger, ex. the other thumb, anywhere else on the screen. When the second finger is released the right click stops.

The typical touch device way of doing it would be to press on one object for x amount of time to get the right click info, but having to wait that time does not work well with Heroes 2 where you often need to right click objects. It needs to be quick to perform.

oleg-derevenetz commented 1 year ago

Let's stick for Android 10-12 for now. All fancy Android 13 devices won't come up so quickly.

In principle, this could be solved by an additional "toolset" Activity from the same package org.fheroes2 with some GUI that will be able to, say, open ZIP file with OG data files and maps from the SD card using the system file picker with ACTION_OPEN_DOCUMENT, and extract this ZIP file to the ExternalFilesDir. It may look like additional icon on the Android's Launchpad. This additional Activity can also be used to download and extract the demo version assets if user doesn't have a purchased copy of the original game. Maybe someone with experience in developing GUI applications for Android could do it.

oleg-derevenetz commented 1 year ago

connect system audio level to game's level of music or audio or both

I'm not sure that we need to do something in this regard. Currently the system audio volume is a "master volume" and can be adjusted in the usual way by the volume buttons on the side face of the device. Music and effects volume are adjusted in the game itself relative to this master volume. I believe that everything already works as it should.

zenseii commented 1 year ago

BTW I just noticed this very old issue which should be closed together with this issue once complete: https://github.com/ihhub/fheroes2/issues/665

ihhub commented 1 year ago

connect system audio level to game's level of music or audio or both

I'm not sure that we need to do something in this regard. Currently the system audio volume is a "master volume" and can be adjusted in the usual way by the volume buttons on the side face of the device. Music and effects volume are adjusted in the game itself relative to this master volume. I believe that everything already works as it should.

It's a fair point. I will mark it as completed.

ihhub commented 1 year ago

Regarding minimum Android version: I saw that players were capable to play the game on Android 8 but it doesn't work on Android 7. At least we should highlight recommended Android version to avoid any complains from users.

oleg-derevenetz commented 1 year ago

@ihhub I have the Android 6 tablet and was able to run & play the fheroes2 just fine (that was some time ago, I'll try this again tomorrow, but I suppose it should still work). In fact, the minimum supported Android API version now is 19, which means Android 4.4 KitKat - and that's only because this is the minimum version supported by the latest NDK, the SDL itself should work even on API 16 (Android 4.1). But I don't have devices that old.

ihhub commented 1 year ago

Wow, @Branikolog wasn't able to run fheroes2 on his device which is Android 7 based.

oleg-derevenetz commented 1 year ago

@ihhub Yes, I just tried it and it won't work on Android 6. The reason is Apache commons-io library, which modern version uses Java language features that Android 6 didn't support yet, for example, lambdas. If I use an older version 2.8.0, fheroes2 runs on Android 6 just fine. I can switch to commons-io 2.8.0 and set Android 6 as the minimum supported version. What do you think?

ihhub commented 1 year ago

Hi @oleg-derevenetz , lets downgrade it since we don't have much code in Java.

oleg-derevenetz commented 1 year ago

Hi @ihhub I implemented the proper desugaring of advanced Java language features instead.

BTW please note that only 64-bit platforms are currently supported (arm64-v8a and x86_64). 32-bit platforms would just uselessly take up the build time and space in the APK, because all 32-bit devices should be at the landfill by now :)

oleg-derevenetz commented 1 year ago

Tablet experience is very nice BTW. On 6'' phone everything is too small, even if 640x480 is selected.

ihhub commented 1 year ago

Tablet experience is very nice BTW. On 6'' phone everything is too small, even if 640x480 is selected.

Now imagine people trying to set 2000x1000 resolution on their phones....

zenseii commented 1 year ago

I just realised that even if we add keyboard support we will not be able to delete save games from the app, which we currently do by pressing the DEL key. No one has complained on devices like Switch and Vita so it's probably not critical.

ihhub commented 1 year ago

Since we locked the screen position into landscape mode resolution detection works fine.

zenseii commented 1 year ago

@ihhub I have the Android 6 tablet and was able to run & play the fheroes2 just fine (that was some time ago, I'll try this again tomorrow, but I suppose it should still work). In fact, the minimum supported Android API version now is 19, which means Android 4.4 KitKat - and that's only because this is the minimum version supported by the latest NDK, the SDL itself should work even on API 16 (Android 4.1). But I don't have devices that old.

Hi, @oleg-derevenetz.

We have a user who's willing to test on Android 5.1: https://heroes2.forumactif.com/t1013-android-build-quick-install-guide-for-noobs#9203 They say that their Android device has an Intel architecture CPU, but I'm not sure if this is relevant. I've never heard of any Android apps that were specifically catered to Intel CPUs. It would be weird if this device is locked out of probably 99% of Android apps if such a thing is necessary, disregarding the age of the device.

oleg-derevenetz commented 1 year ago

Hi @zenseii

We have a user who's willing to test on Android 5.1: https://heroes2.forumactif.com/t1013-android-build-quick-install-guide-for-noobs#9203

There are most likely two issues:

  1. Currently Android APK has the "hard limit" for the lowest Android version, which is currently 6.0. So this user will not be able to install fheroes2.apk on 5.x anyway.
  2. His INSTALL_FAILED_NO_MATCHING_ABIS error may be because he has 32-bit Android, while fheroes2.apk is currently built only for 64-bit architectures (arm64-v8a and x86_64).

I can later create a separate PR with support for the lower minimal Android version (5.1) and 32-bit architectures for ancient devices.

zenseii commented 1 year ago
  1. His INSTALL_FAILED_NO_MATCHING_ABIS error may be because he has 32-bit Android, while fheroes2.apk is currently built only for 64-bit architectures (arm64-v8a and x86_64).

Hi, @oleg-derevenetz. I looked up what I believe is the CPU from reference sites and it says 64-bit on Intel's own page (just scroll to the bottom of the page): https://www.intel.com/content/www/us/en/products/sku/87461/intel-atom-x3c3230rk-processor-1m-cache-up-to-1-10-ghz/specifications.html

Unless this device supports 64-bit but has a 32-bit Android installed? Not sure that's a thing. Hopefully not. Considering it was released in 2015 that shouldn't be the case.