playstore compilation flag

This commit is contained in:
MohitMaliFtechiz 2022-06-13 18:41:11 +05:30 committed by Kelson
parent 9defd1eba8
commit ad16e81d5d
8 changed files with 79 additions and 37 deletions

View File

@ -61,4 +61,4 @@ jobs:
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
run: ./gradlew publishReleaseBundle run: ./gradlew publishPlayStoreBundle

View File

@ -44,6 +44,7 @@ android {
resValue("string", "app_search_string", "Search Kiwix") resValue("string", "app_search_string", "Search Kiwix")
versionCode = generateVersionCode() versionCode = generateVersionCode()
versionName = generateVersionName() versionName = generateVersionName()
manifestPlaceholders["permission"] = "android.permission.MANAGE_EXTERNAL_STORAGE"
} }
lintOptions { lintOptions {
isCheckDependencies = true isCheckDependencies = true
@ -53,14 +54,22 @@ android {
getByName("debug") { getByName("debug") {
multiDexKeepProguard = file("multidex-instrumentation-config.pro") multiDexKeepProguard = file("multidex-instrumentation-config.pro")
buildConfigField("boolean", "KIWIX_ERROR_ACTIVITY", "false") buildConfigField("boolean", "KIWIX_ERROR_ACTIVITY", "false")
buildConfigField("boolean", "IS_PLAYSTORE", "false")
} }
getByName("release") { getByName("release") {
buildConfigField("boolean", "KIWIX_ERROR_ACTIVITY", "true") buildConfigField("boolean", "KIWIX_ERROR_ACTIVITY", "true")
buildConfigField("boolean", "IS_PLAYSTORE", "false")
if (properties.containsKey("disableSigning")) { if (properties.containsKey("disableSigning")) {
signingConfig = null signingConfig = null
} }
} }
create("playStore") {
initWith(getByName("release"))
matchingFallbacks = listOf("release")
buildConfigField("boolean", "IS_PLAYSTORE", "true")
manifestPlaceholders["permission"] = "android.permission.placeholder"
}
} }
bundle { bundle {
language { language {

View File

@ -6,8 +6,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" <uses-permission android:name="${permission}" />
tools:ignore="ScopedStorage" />
<queries> <queries>
<intent> <intent>

View File

@ -33,6 +33,7 @@ import kotlinx.android.synthetic.main.activity_kiwix_main.bottom_nav_view
import kotlinx.android.synthetic.main.activity_kiwix_main.drawer_nav_view import kotlinx.android.synthetic.main.activity_kiwix_main.drawer_nav_view
import kotlinx.android.synthetic.main.activity_kiwix_main.navigation_container import kotlinx.android.synthetic.main.activity_kiwix_main.navigation_container
import kotlinx.android.synthetic.main.activity_kiwix_main.reader_drawer_nav_view import kotlinx.android.synthetic.main.activity_kiwix_main.reader_drawer_nav_view
import org.kiwix.kiwixmobile.BuildConfig
import org.kiwix.kiwixmobile.R import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent import org.kiwix.kiwixmobile.core.di.components.CoreComponent
@ -100,6 +101,7 @@ class KiwixMainActivity : CoreMainActivity() {
if (sharedPreferenceUtil.showIntro()) { if (sharedPreferenceUtil.showIntro()) {
navigate(KiwixReaderFragmentDirections.actionReaderFragmentToIntroFragment()) navigate(KiwixReaderFragmentDirections.actionReaderFragmentToIntroFragment())
} }
sharedPreferenceUtil.setIsPlayStoreBuildType(BuildConfig.IS_PLAYSTORE)
} }
override fun onSupportActionModeStarted(mode: ActionMode) { override fun onSupportActionModeStarted(mode: ActionMode) {

View File

@ -284,26 +284,30 @@ class LocalLibraryFragment : BaseFragment() {
REQUEST_STORAGE_PERMISSION REQUEST_STORAGE_PERMISSION
) )
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (sharedPreferenceUtil.isPlayStoreBuild) {
if (Environment.isExternalStorageManager()) {
// We already have permission!!
requestFileSystemCheck()
} else {
if (sharedPreferenceUtil.manageExternalFilesPermissionDialog) {
// We should only ask for first time, If the users wants to revoke settings
// then they can directly toggle this feature from settings screen
sharedPreferenceUtil.manageExternalFilesPermissionDialog = false
// Show Dialog and Go to settings to give permission
dialogShower.show(
KiwixDialog.ManageExternalFilesPermissionDialog,
{
this.activity?.let(FragmentActivity::navigateToSettings)
}
)
}
}
} else {
requestFileSystemCheck() requestFileSystemCheck()
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Environment.isExternalStorageManager()) {
// We already have permission!!
requestFileSystemCheck()
} else {
if (sharedPreferenceUtil.manageExternalFilesPermissionDialog) {
// We should only ask for first time, If the users wants to revoke settings
// then they can directly toggle this feature from settings screen
sharedPreferenceUtil.manageExternalFilesPermissionDialog = false
// Show Dialog and Go to settings to give permission
dialogShower.show(
KiwixDialog.ManageExternalFilesPermissionDialog,
{
this.activity?.let(FragmentActivity::navigateToSettings)
}
)
}
}
} else {
requestFileSystemCheck()
}
} }
} }
} }

View File

@ -300,16 +300,24 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
) )
sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION) sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION)
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (sharedPreferenceUtil.isPlayStoreBuild) {
val view = LayoutInflater.from(activity).inflate(R.layout.select_folder_dialog, null) setExternalStoragePath(storageDevice)
dialogShower.show(SelectFolder { view }, ::selectFolder)
} else { } else {
sharedPreferenceUtil.putPrefStorage(storageDevice.name) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION) val view = LayoutInflater.from(activity).inflate(R.layout.select_folder_dialog, null)
dialogShower.show(SelectFolder { view }, ::selectFolder)
} else {
setExternalStoragePath(storageDevice)
}
} }
} }
} }
private fun setExternalStoragePath(storageDevice: StorageDevice) {
sharedPreferenceUtil.putPrefStorage(storageDevice.name)
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
}
private fun selectFolder() { private fun selectFolder() {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
intent.addFlags( intent.addFlags(

View File

@ -292,21 +292,30 @@ public abstract class CorePrefsFragment extends PreferenceFragmentCompat impleme
findPreference(PREF_STORAGE).setTitle(getString(R.string.internal_storage)); findPreference(PREF_STORAGE).setTitle(getString(R.string.internal_storage));
sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION); sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION);
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (sharedPreferenceUtil.isPlayStoreBuild()) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.select_folder_dialog, null); setExternalStoragePath(storageDevice);
alertDialogShower.show(new KiwixDialog.SelectFolder(() -> view), () -> {
selectFolder();
return Unit.INSTANCE;
});
} else { } else {
sharedPreferenceUtil.putPrefStorage(storageDevice.getName()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
findPreference(PREF_STORAGE).setTitle(getString(R.string.external_storage)); @SuppressLint("InflateParams") View view =
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION); LayoutInflater.from(getActivity()).inflate(R.layout.select_folder_dialog, null);
alertDialogShower.show(new KiwixDialog.SelectFolder(() -> view), () -> {
selectFolder();
return Unit.INSTANCE;
});
} else {
setExternalStoragePath(storageDevice);
}
} }
} }
return Unit.INSTANCE; return Unit.INSTANCE;
} }
private void setExternalStoragePath(StorageDevice storageDevice) {
sharedPreferenceUtil.putPrefStorage(storageDevice.getName());
findPreference(PREF_STORAGE).setTitle(getString(R.string.external_storage));
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION);
}
private void selectFolder() { private void selectFolder() {
Intent intent = new Intent(ACTION_OPEN_DOCUMENT_TREE); Intent intent = new Intent(ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags( intent.addFlags(

View File

@ -70,6 +70,9 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
val prefExternalLinkPopup: Boolean val prefExternalLinkPopup: Boolean
get() = sharedPreferences.getBoolean(PREF_EXTERNAL_LINK_POPUP, true) get() = sharedPreferences.getBoolean(PREF_EXTERNAL_LINK_POPUP, true)
val isPlayStoreBuild: Boolean
get() = sharedPreferences.getBoolean(IS_PLAY_STORE_BUILD, false)
val prefLanguage: String val prefLanguage: String
get() = sharedPreferences.getString(PREF_LANG, "") ?: Locale.ROOT.toString() get() = sharedPreferences.getString(PREF_LANG, "") ?: Locale.ROOT.toString()
@ -121,6 +124,10 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
sharedPreferences.edit { putInt(STORAGE_POSITION, pos) } sharedPreferences.edit { putInt(STORAGE_POSITION, pos) }
} }
fun setIsPlayStoreBuildType(isPlayStoreBuildType: Boolean) {
sharedPreferences.edit { putBoolean(IS_PLAY_STORE_BUILD, isPlayStoreBuildType) }
}
fun putPrefFullScreen(fullScreen: Boolean) = fun putPrefFullScreen(fullScreen: Boolean) =
sharedPreferences.edit { putBoolean(PREF_FULLSCREEN, fullScreen) } sharedPreferences.edit { putBoolean(PREF_FULLSCREEN, fullScreen) }
@ -174,7 +181,10 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
} }
fun getPublicDirectoryPath(path: String): String = fun getPublicDirectoryPath(path: String): String =
path.substringBefore(context.getString(R.string.android_directory_seperator)) if (isPlayStoreBuild)
path
else
path.substringBefore(context.getString(R.string.android_directory_seperator))
companion object { companion object {
// Prefs // Prefs
@ -197,5 +207,6 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
private const val TEXT_ZOOM = "true_text_zoom" private const val TEXT_ZOOM = "true_text_zoom"
private const val DEFAULT_ZOOM = 100 private const val DEFAULT_ZOOM = 100
private const val PREF_MANAGE_EXTERNAL_FILES = "pref_manage_external_files" private const val PREF_MANAGE_EXTERNAL_FILES = "pref_manage_external_files"
private const val IS_PLAY_STORE_BUILD = "is_play_store_build"
} }
} }