mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -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 java.io.IOException;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.kiwix.kiwixmobile.KiwixApplication;
|
import org.kiwix.kiwixmobile.KiwixApplication;
|
||||||
import org.kiwix.kiwixmobile.core.BuildConfig;
|
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
import org.kiwix.kiwixmobile.core.R;
|
||||||
import org.kiwix.kiwixmobile.core.R2;
|
import org.kiwix.kiwixmobile.core.R2;
|
||||||
import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil;
|
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
|
// From Nougat 7 (API 24) access to files is shared temporarily with other apps
|
||||||
// Need to use FileProvider for the same
|
// Need to use FileProvider for the same
|
||||||
noteFileUri =
|
noteFileUri =
|
||||||
FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".fileprovider",
|
FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider",
|
||||||
noteFile);
|
noteFile);
|
||||||
} else {
|
} else {
|
||||||
noteFileUri = Uri.fromFile(noteFile);
|
noteFileUri = Uri.fromFile(noteFile);
|
||||||
|
@ -110,7 +110,7 @@ public class KiwixWebViewClient extends WebViewClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
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);
|
Log.d(TAG_KIWIX, "invalidUrl = " + invalidUrl);
|
||||||
|
|
||||||
if (invalidUrl) {
|
if (invalidUrl) {
|
||||||
|
@ -94,11 +94,12 @@ import javax.inject.Inject;
|
|||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.kiwix.kiwixmobile.core.BuildConfig;
|
import org.kiwix.kiwixmobile.KiwixApplication;
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
|
||||||
import org.kiwix.kiwixmobile.base.BaseActivity;
|
import org.kiwix.kiwixmobile.base.BaseActivity;
|
||||||
import org.kiwix.kiwixmobile.bookmark.BookmarkItem;
|
import org.kiwix.kiwixmobile.bookmark.BookmarkItem;
|
||||||
import org.kiwix.kiwixmobile.bookmark.BookmarksActivity;
|
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.core.R2;
|
||||||
import org.kiwix.kiwixmobile.help.HelpActivity;
|
import org.kiwix.kiwixmobile.help.HelpActivity;
|
||||||
import org.kiwix.kiwixmobile.history.HistoryActivity;
|
import org.kiwix.kiwixmobile.history.HistoryActivity;
|
||||||
@ -368,7 +369,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
setupDocumentParser();
|
setupDocumentParser();
|
||||||
|
|
||||||
if (BuildConfig.IS_CUSTOM_APP) {
|
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()) {
|
if (loadCustomAppContent()) {
|
||||||
Log.d(TAG_KIWIX, "Found custom content, continuing...");
|
Log.d(TAG_KIWIX, "Found custom content, continuing...");
|
||||||
// Continue
|
// Continue
|
||||||
@ -1827,7 +1828,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
filePath = libDir.listFiles()[0].getPath() + "/" + BuildConfig.ZIM_FILE_NAME;
|
filePath = libDir.listFiles()[0].getPath() + "/" + BuildConfig.ZIM_FILE_NAME;
|
||||||
}
|
}
|
||||||
if (filePath.isEmpty() || !new File(filePath).exists()) {
|
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);
|
BuildConfig.ZIM_FILE_NAME);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1846,7 +1847,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
|||||||
final Activity activity = this;
|
final Activity activity = this;
|
||||||
zimFileMissingBuilder.setPositiveButton(getString(R.string.go_to_play_store),
|
zimFileMissingBuilder.setPositiveButton(getString(R.string.go_to_play_store),
|
||||||
(dialog, which) -> {
|
(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 intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(market_uri));
|
intent.setData(Uri.parse(market_uri));
|
||||||
startActivity(intent);
|
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 ONGOING_DOWNLOAD_CHANNEL_ID = "ongoing_downloads_channel_id";
|
||||||
|
|
||||||
public static final String OLD_PROVIDER_DOMAIN = "org.kiwix.zim.base";
|
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;
|
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;
|
import static org.kiwix.kiwixmobile.utils.Constants.OLD_PROVIDER_DOMAIN;
|
||||||
|
|
||||||
public class UpdateUtils {
|
public class UpdateUtils {
|
||||||
public static String reformatProviderUrl(String url) {
|
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.os.Environment
|
||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import org.kiwix.kiwixmobile.KiwixApplication
|
||||||
import org.kiwix.kiwixmobile.core.BuildConfig
|
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||||
import org.kiwix.kiwixmobile.downloader.ChunkUtils
|
import org.kiwix.kiwixmobile.downloader.ChunkUtils
|
||||||
import org.kiwix.kiwixmobile.extensions.get
|
import org.kiwix.kiwixmobile.extensions.get
|
||||||
@ -37,7 +38,7 @@ object FileUtils {
|
|||||||
|
|
||||||
private val saveFilePath =
|
private val saveFilePath =
|
||||||
"${Environment.getExternalStorageDirectory()}${File.separator}Android" +
|
"${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 =
|
@JvmStatic fun getFileCacheDir(context: Context): File =
|
||||||
if (Environment.MEDIA_MOUNTED == Environment.getExternalStorageState()) {
|
if (Environment.MEDIA_MOUNTED == Environment.getExternalStorageState()) {
|
||||||
@ -101,7 +102,7 @@ object FileUtils {
|
|||||||
*/
|
*/
|
||||||
@JvmStatic fun getExpansionAPKFileName(mainFile: Boolean) =
|
@JvmStatic fun getExpansionAPKFileName(mainFile: Boolean) =
|
||||||
"${if (mainFile) "main." else "patch."}${BuildConfig.CONTENT_VERSION_CODE}" +
|
"${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
|
* Returns the filename (where the file should be saved) from info about a download
|
||||||
|
@ -220,7 +220,7 @@ class ZimFileReader(
|
|||||||
@JvmField
|
@JvmField
|
||||||
val UI_URI: Uri? = Uri.parse("content://org.kiwix.ui/")
|
val UI_URI: Uri? = Uri.parse("content://org.kiwix.ui/")
|
||||||
@JvmField
|
@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 =
|
private const val INVERT_IMAGES_VIDEO =
|
||||||
"img, video { \n -webkit-filter: invert(1); \n filter: invert(1); \n} \n"
|
"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))\$)")
|
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.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
|
import org.kiwix.kiwixmobile.KiwixApplication
|
||||||
import org.kiwix.kiwixmobile.core.BuildConfig
|
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
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) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
FileProvider.getUriForFile(
|
FileProvider.getUriForFile(
|
||||||
activity,
|
activity,
|
||||||
BuildConfig.APPLICATION_ID + ".fileprovider",
|
activity.packageName + ".fileprovider",
|
||||||
it.file
|
it.file
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user