Display a warning about storage on the first launch

This commit is contained in:
artdeell 2021-08-26 14:09:24 +03:00
parent 7aadde90c7
commit 28fa92f1cb
2 changed files with 20 additions and 2 deletions

View File

@ -17,7 +17,9 @@ import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.util.Base64;
import android.util.Log;
@ -327,7 +329,7 @@ public class PojavLoginActivity extends BaseActivity
}
mkdirs(Tools.CTRLMAP_PATH);
try {
new CustomControls(this).save(Tools.CTRLDEF_FILE);
@ -347,13 +349,27 @@ public class PojavLoginActivity extends BaseActivity
mLockSelectJRE.wait();
}
}
if(Build.VERSION.SDK_INT > 28) runOnUiThread(this::showStorageDialog);
LauncherPreferences.loadPreferences(getApplicationContext());
}
catch(Throwable e){
Tools.showError(this, e);
}
}
private void showStorageDialog() {
if(!firstLaunchPrefs.getBoolean("storageDialogShown",false)) {
AlertDialog.Builder bldr = new AlertDialog.Builder(this);
bldr.setTitle(R.string.storage_warning_title);
Spanned sp = Html.fromHtml(getString(R.string.storage_warning_text,BuildConfig.APPLICATION_ID));
bldr.setMessage(sp);
bldr.setCancelable(false);
bldr.setPositiveButton(android.R.string.ok, (dialog, which)->{
firstLaunchPrefs.edit().putBoolean("storageDialogShown",true).apply();
dialog.dismiss();
});
bldr.show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

View File

@ -241,4 +241,6 @@
<string name="pvc_gameDirectory">Game directory</string>
<string name="pvc_jvmArgs">JVM arguments</string>
<string name="pvc_title">Per-version settings</string>
<string name="storage_warning_title">Storage changes</string>
<string name="storage_warning_text"> <![CDATA[Due to Google\'s new scoped storage enforcements added in Android 10 and higher, we are required to move the game directory into an app-private folder.<br /> The new folder for Pojav files is <b>Android/data/%s/files/</b> (also accessible using a storage provider in your file explorer).<br /> If you need to copy your game files, please copy everything from the original folder at <b>games/PojavLauncher</b> manually.]]></string>
</resources>