mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
fix Build.ApplicationId issue
This commit is contained in:
parent
09449c4238
commit
73595a2a11
@ -36,7 +36,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.inject.Inject;
|
||||
import org.kiwix.kiwixmobile.KiwixApplication;
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.R2;
|
||||
import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil;
|
||||
@ -390,7 +389,7 @@ public class AddNoteDialog extends DialogFragment
|
||||
// From Nougat 7 (API 24) access to files is shared temporarily with other apps
|
||||
// Need to use FileProvider for the same
|
||||
noteFileUri =
|
||||
FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".fileprovider",
|
||||
FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider",
|
||||
noteFile);
|
||||
} else {
|
||||
noteFileUri = Uri.fromFile(noteFile);
|
||||
|
@ -110,7 +110,7 @@ public class KiwixWebViewClient extends WebViewClient {
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
boolean invalidUrl = url.equals("content://" + BuildConfig.APPLICATION_ID + ".zim.base/null");
|
||||
boolean invalidUrl = url.equals("content://" + KiwixApplication.getInstance().getPackageName() + ".zim.base/null");
|
||||
Log.d(TAG_KIWIX, "invalidUrl = " + invalidUrl);
|
||||
|
||||
if (invalidUrl) {
|
||||
|
@ -94,11 +94,12 @@ import javax.inject.Inject;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONArray;
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.KiwixApplication;
|
||||
import org.kiwix.kiwixmobile.base.BaseActivity;
|
||||
import org.kiwix.kiwixmobile.bookmark.BookmarkItem;
|
||||
import org.kiwix.kiwixmobile.bookmark.BookmarksActivity;
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.R2;
|
||||
import org.kiwix.kiwixmobile.help.HelpActivity;
|
||||
import org.kiwix.kiwixmobile.history.HistoryActivity;
|
||||
@ -368,7 +369,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
||||
setupDocumentParser();
|
||||
|
||||
if (BuildConfig.IS_CUSTOM_APP) {
|
||||
Log.d(TAG_KIWIX, "This is a custom app:" + BuildConfig.APPLICATION_ID);
|
||||
Log.d(TAG_KIWIX, "This is a custom app:" + getPackageName());
|
||||
if (loadCustomAppContent()) {
|
||||
Log.d(TAG_KIWIX, "Found custom content, continuing...");
|
||||
// Continue
|
||||
@ -1827,7 +1828,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
||||
filePath = libDir.listFiles()[0].getPath() + "/" + BuildConfig.ZIM_FILE_NAME;
|
||||
}
|
||||
if (filePath.isEmpty() || !new File(filePath).exists()) {
|
||||
filePath = String.format("/data/data/%s/lib/%s", BuildConfig.APPLICATION_ID,
|
||||
filePath = String.format("/data/data/%s/lib/%s", getPackageName(),
|
||||
BuildConfig.ZIM_FILE_NAME);
|
||||
}
|
||||
} else {
|
||||
@ -1846,7 +1847,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
||||
final Activity activity = this;
|
||||
zimFileMissingBuilder.setPositiveButton(getString(R.string.go_to_play_store),
|
||||
(dialog, which) -> {
|
||||
String market_uri = "market://details?id=" + BuildConfig.APPLICATION_ID;
|
||||
String market_uri = "market://details?id=" + getPackageName();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(market_uri));
|
||||
startActivity(intent);
|
||||
|
@ -93,6 +93,4 @@ public final class Constants {
|
||||
public static final String ONGOING_DOWNLOAD_CHANNEL_ID = "ongoing_downloads_channel_id";
|
||||
|
||||
public static final String OLD_PROVIDER_DOMAIN = "org.kiwix.zim.base";
|
||||
|
||||
public static final String NEW_PROVIDER_DOMAIN = BuildConfig.APPLICATION_ID + ".zim.base";
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package org.kiwix.kiwixmobile.utils;
|
||||
|
||||
import static org.kiwix.kiwixmobile.utils.Constants.NEW_PROVIDER_DOMAIN;
|
||||
import org.kiwix.kiwixmobile.KiwixApplication;
|
||||
|
||||
import static org.kiwix.kiwixmobile.utils.Constants.OLD_PROVIDER_DOMAIN;
|
||||
|
||||
public class UpdateUtils {
|
||||
public static String reformatProviderUrl(String url) {
|
||||
return url.replace(OLD_PROVIDER_DOMAIN, NEW_PROVIDER_DOMAIN);
|
||||
return url.replace(OLD_PROVIDER_DOMAIN,
|
||||
KiwixApplication.getInstance().getPackageName() + ".zim.base");
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.DocumentsContract
|
||||
import android.util.Log
|
||||
import org.kiwix.kiwixmobile.KiwixApplication
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||
import org.kiwix.kiwixmobile.downloader.ChunkUtils
|
||||
import org.kiwix.kiwixmobile.extensions.get
|
||||
@ -37,7 +38,7 @@ object FileUtils {
|
||||
|
||||
private val saveFilePath =
|
||||
"${Environment.getExternalStorageDirectory()}${File.separator}Android" +
|
||||
"${File.separator}obb${File.separator}${BuildConfig.APPLICATION_ID}"
|
||||
"${File.separator}obb${File.separator}${KiwixApplication.getInstance().packageName}"
|
||||
|
||||
@JvmStatic fun getFileCacheDir(context: Context): File =
|
||||
if (Environment.MEDIA_MOUNTED == Environment.getExternalStorageState()) {
|
||||
@ -101,7 +102,7 @@ object FileUtils {
|
||||
*/
|
||||
@JvmStatic fun getExpansionAPKFileName(mainFile: Boolean) =
|
||||
"${if (mainFile) "main." else "patch."}${BuildConfig.CONTENT_VERSION_CODE}" +
|
||||
".${BuildConfig.APPLICATION_ID}.obb"
|
||||
".${KiwixApplication.getInstance().packageName}.obb"
|
||||
|
||||
/**
|
||||
* Returns the filename (where the file should be saved) from info about a download
|
||||
|
@ -220,7 +220,7 @@ class ZimFileReader(
|
||||
@JvmField
|
||||
val UI_URI: Uri? = Uri.parse("content://org.kiwix.ui/")
|
||||
@JvmField
|
||||
val CONTENT_URI: Uri? = Uri.parse("content://${BuildConfig.APPLICATION_ID}.zim.base/")
|
||||
val CONTENT_URI: Uri? = Uri.parse("content://${KiwixApplication.getInstance().packageName}.zim.base/")
|
||||
private const val INVERT_IMAGES_VIDEO =
|
||||
"img, video { \n -webkit-filter: invert(1); \n filter: invert(1); \n} \n"
|
||||
private val VIDEO_REGEX = Regex("([^\\s]+(\\.(?i)(3gp|mp4|m4a|webm|mkv|ogg|ogv))\$)")
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.core.content.FileProvider
|
||||
import org.kiwix.kiwixmobile.KiwixApplication
|
||||
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
||||
@ -18,7 +19,7 @@ class ShareFiles(private val selectedBooks: List<BookOnDisk>) : SideEffect<Unit>
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
FileProvider.getUriForFile(
|
||||
activity,
|
||||
BuildConfig.APPLICATION_ID + ".fileprovider",
|
||||
activity.packageName + ".fileprovider",
|
||||
it.file
|
||||
)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user