move to Android/data (#63)

This commit is contained in:
notify 2023-03-05 06:39:03 +08:00 committed by GitHub
parent 79389d9444
commit def3344a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 2 deletions

2
.gitignore vendored
View File

@ -14,7 +14,7 @@ zh_CN.qm
tags
# file produced by game
FreeKill
/FreeKill
FreeKill.exe
freekill-wrap.cxx
server/users.db

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.notify.FreeKill"
android:installLocation="auto"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />

View File

@ -0,0 +1,37 @@
package org.notify.FreeKill;
import android.app.Activity;
import android.view.View;
import org.qtproject.qt.android.QtNative;
public class Helper {
public static void InitView() {
Activity activity = QtNative.activity();
// create app-specific dir on external storage
activity.getExternalFilesDir("");
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
View decorView = activity.getWindow().getDecorView();
int uiOpt = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOpt);
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
// Hide navigation bar when enter fullscreen again
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(uiOpt);
}
}
});
}
});
}
}

View File

@ -160,6 +160,9 @@ int main(int argc, char *argv[])
splash.showMessage(msg, Qt::AlignHCenter | Qt::AlignBottom);
#ifdef Q_OS_ANDROID
QJniObject::callStaticMethod <void>("org/notify/FreeKill/Helper", "InitView", "()V");
QDir::setCurrent("/storage/emulated/0/Android/data/org.notify.FreeKill/files");
QScreen *screen = qobject_cast<QApplication *>(app)->primaryScreen();
QRect screenGeometry = screen->geometry();
int screenWidth = screenGeometry.width();