mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-05-12 15:49:39 -06:00
android: Clean up flavor checking implementation
This commit is contained in:
parent
0ed010166d
commit
c2f4e06901
@ -147,8 +147,7 @@ class SetupFragment : Fragment() {
|
||||
false,
|
||||
0,
|
||||
pageButtons = mutableListOf<PageButton>().apply {
|
||||
@Suppress("KotlinConstantConditions", "SimplifyBooleanWithConstants")
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
add(
|
||||
PageButton(
|
||||
R.drawable.ic_folder,
|
||||
@ -284,8 +283,7 @@ class SetupFragment : Fragment() {
|
||||
NotificationManagerCompat.from(requireContext())
|
||||
.areNotificationsEnabled()
|
||||
// External Storage
|
||||
@Suppress("KotlinConstantConditions", "SimplifyBooleanWithConstants")
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
permissionsComplete =
|
||||
(permissionsComplete && Environment.isExternalStorageManager())
|
||||
@ -568,7 +566,7 @@ class SetupFragment : Fragment() {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
if (NativeLibrary.getUserDirectory(result) == "") {
|
||||
SelectUserDirectoryDialogFragment.newInstance(
|
||||
mainActivity,
|
||||
|
||||
@ -52,6 +52,7 @@ import org.citra.citra_emu.features.settings.utils.SettingsFile
|
||||
import org.citra.citra_emu.fragments.GrantMissingFilesystemPermissionFragment
|
||||
import org.citra.citra_emu.fragments.SelectUserDirectoryDialogFragment
|
||||
import org.citra.citra_emu.fragments.UpdateUserDirectoryDialogFragment
|
||||
import org.citra.citra_emu.utils.BuildUtil
|
||||
import org.citra.citra_emu.utils.CiaInstallWorker
|
||||
import org.citra.citra_emu.utils.CitraDirectoryHelper
|
||||
import org.citra.citra_emu.utils.CitraDirectoryUtils
|
||||
@ -199,8 +200,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
return
|
||||
}
|
||||
|
||||
@Suppress("KotlinConstantConditions", "SimplifyBooleanWithConstants")
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
fun requestMissingFilesystemPermission() =
|
||||
GrantMissingFilesystemPermissionFragment.newInstance()
|
||||
.show(supportFragmentManager, GrantMissingFilesystemPermissionFragment.TAG)
|
||||
@ -236,8 +236,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
return
|
||||
}
|
||||
|
||||
@Suppress("KotlinConstantConditions", "SimplifyBooleanWithConstants")
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
if (supportFragmentManager.findFragmentByTag(SelectUserDirectoryDialogFragment.TAG) == null) {
|
||||
if (NativeLibrary.getUserDirectory() == "") {
|
||||
SelectUserDirectoryDialogFragment.newInstance(this)
|
||||
@ -367,7 +366,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
if (BuildConfig.FLAVOR != "googlePlay") {
|
||||
if (!BuildUtil.isGooglePlayBuild) {
|
||||
if (NativeLibrary.getUserDirectory(result) == "") {
|
||||
SelectUserDirectoryDialogFragment.newInstance(
|
||||
this,
|
||||
|
||||
@ -7,11 +7,19 @@ package org.citra.citra_emu.utils
|
||||
import org.citra.citra_emu.BuildConfig
|
||||
|
||||
object BuildUtil {
|
||||
fun assertNotGooglePlay() {
|
||||
@Suppress("unused")
|
||||
object BuildFlavors {
|
||||
const val GOOGLEPLAY = "googlePlay"
|
||||
const val VANILLA = "vanilla"
|
||||
}
|
||||
|
||||
@Suppress("KotlinConstantConditions", "SimplifyBooleanWithConstants")
|
||||
if (BuildConfig.FLAVOR == "googlePlay") {
|
||||
fun assertNotGooglePlay() {
|
||||
if (isGooglePlayBuild) {
|
||||
error("Non-GooglePlay code being called in GooglePlay build")
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions")
|
||||
val isGooglePlayBuild =
|
||||
BuildConfig.FLAVOR == BuildFlavors.GOOGLEPLAY
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
V(DeleteDocument, bool, delete_document, CallStaticBooleanMethod, "deleteDocument", \
|
||||
"(Ljava/lang/String;)Z")
|
||||
namespace AndroidStorage {
|
||||
|
||||
static JavaVM* g_jvm = nullptr;
|
||||
static jclass native_library = nullptr;
|
||||
#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID)
|
||||
@ -69,6 +70,12 @@ enum class AndroidOpenMode {
|
||||
NEVER = EINVAL,
|
||||
};
|
||||
|
||||
class AndroidBuildFlavors {
|
||||
public:
|
||||
static constexpr std::string GOOGLEPLAY = "googlePlay";
|
||||
static constexpr std::string VANILLA = "vanilla";
|
||||
};
|
||||
|
||||
inline AndroidOpenMode operator|(AndroidOpenMode a, int b) {
|
||||
return static_cast<AndroidOpenMode>(static_cast<int>(a) | b);
|
||||
}
|
||||
@ -92,5 +99,6 @@ ANDROID_STORAGE_FUNCTIONS(FS)
|
||||
ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
|
||||
#undef F
|
||||
#undef FR
|
||||
|
||||
} // namespace AndroidStorage
|
||||
#endif
|
||||
|
||||
@ -312,7 +312,7 @@ bool Rename(const std::string& srcFullPath, const std::string& destFullPath) {
|
||||
return true;
|
||||
#elif ANDROID
|
||||
// srcFullPath and destFullPath are relative to the user directory
|
||||
if (AndroidStorage::GetBuildFlavor() == "googlePlay") {
|
||||
if (AndroidStorage::GetBuildFlavor() == AndroidStorage::AndroidBuildFlavors::GOOGLEPLAY) {
|
||||
if (AndroidStorage::MoveAndRenameFile(srcFullPath, destFullPath))
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user