mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
#1577 Custom Apps try to open Home - move HomeUrl related code to app
This commit is contained in:
parent
0c99a17b5b
commit
fed540a390
@ -11,6 +11,7 @@
|
||||
<inspection_tool class="AndroidLintAnimatorKeep" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintAppCompatMethod" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintAppIndexingService" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintAppLinkUrlError" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintAppLinksAutoVerifyError" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintAppLinksAutoVerifyWarning" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintApplySharedPref" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
@ -57,8 +58,8 @@
|
||||
<inspection_tool class="AndroidLintFontValidationWarning" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGetInstance" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGifUsage" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGoogleAppIndexingApiWarning" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGoogleAppIndexingApiWarning" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||
<inspection_tool class="AndroidLintGradleDependency" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGradleDeprecated" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="AndroidLintGradleDynamicVersion" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
|
@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile.main
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
@ -30,6 +31,7 @@ import org.kiwix.kiwixmobile.core.extensions.start
|
||||
import org.kiwix.kiwixmobile.core.extensions.toast
|
||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||
import org.kiwix.kiwixmobile.core.main.WebViewCallback
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||
import org.kiwix.kiwixmobile.core.utils.Constants.EXTRA_ZIM_FILE
|
||||
import org.kiwix.kiwixmobile.core.utils.Constants.TAG_CURRENT_ARTICLES
|
||||
@ -45,6 +47,7 @@ import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||
import java.io.File
|
||||
|
||||
class KiwixMainActivity : CoreMainActivity() {
|
||||
private val homeUrl = "file:///android_asset/home.html"
|
||||
|
||||
override fun injection() {
|
||||
kiwixActivityComponent.inject(this)
|
||||
@ -55,6 +58,21 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
manageExternalLaunchAndRestoringViewState()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (zimReaderContainer.zimFile == null && homeUrl != currentWebView.url) {
|
||||
showHomePage()
|
||||
}
|
||||
|
||||
if (webViewList.isNotEmpty() && currentWebViewIndex < webViewList.size &&
|
||||
webViewList[currentWebViewIndex].url != null &&
|
||||
webViewList[currentWebViewIndex].url == homeUrl &&
|
||||
webViewList[currentWebViewIndex].findViewById<View>(R.id.get_content_card) != null
|
||||
) {
|
||||
webViewList[currentWebViewIndex].findViewById<View>(R.id.get_content_card).isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun createWebClient(
|
||||
webViewCallback: WebViewCallback,
|
||||
zimReaderContainer: ZimReaderContainer
|
||||
@ -95,6 +113,24 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun hasValidFileAndUrl(url: String?, zimFileReader: ZimFileReader?) =
|
||||
super.hasValidFileAndUrl(url, zimFileReader) && url != homeUrl
|
||||
|
||||
override fun urlIsInvalid() =
|
||||
super.urlIsInvalid() || currentWebView.url == homeUrl
|
||||
|
||||
override fun showHomePage() {
|
||||
currentWebView.removeAllViews()
|
||||
currentWebView.loadUrl(homeUrl)
|
||||
}
|
||||
|
||||
override fun createNewTab() {
|
||||
newTab(homeUrl)
|
||||
}
|
||||
|
||||
override fun isInvalidTitle(zimFileTitle: String?) =
|
||||
super.isInvalidTitle(zimFileTitle) || homeUrl == currentWebView.url
|
||||
|
||||
private fun uriFromIntent() =
|
||||
intent.data ?: intent.getStringExtra(EXTRA_ZIM_FILE)?.let {
|
||||
File(FileUtils.getFileName(it)).toUri()
|
||||
@ -133,9 +169,7 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
}
|
||||
|
||||
override fun manageZimFiles(tab: Int) {
|
||||
start<ZimManageActivity> {
|
||||
putExtra(ZimManageActivity.TAB_EXTRA, tab)
|
||||
}
|
||||
start<ZimManageActivity> { putExtra(ZimManageActivity.TAB_EXTRA, tab) }
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
|
@ -155,8 +155,6 @@ import static org.kiwix.kiwixmobile.core.utils.StyleUtils.dialogStyle;
|
||||
public abstract class CoreMainActivity extends BaseActivity implements WebViewCallback,
|
||||
MainContract.View {
|
||||
|
||||
private static final String NEW_TAB = "NEW_TAB";
|
||||
private static final String HOME_URL = "file:///android_asset/home.html";
|
||||
public static boolean isFullscreenOpened;
|
||||
public static boolean refresh;
|
||||
public static boolean wifiOnly;
|
||||
@ -186,9 +184,9 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
@BindView(R2.id.activity_main_nav_view)
|
||||
NavigationView tableDrawerRightContainer;
|
||||
@BindView(R2.id.activity_main_content_frame)
|
||||
FrameLayout contentFrame;
|
||||
protected FrameLayout contentFrame;
|
||||
@BindView(R2.id.bottom_toolbar)
|
||||
LinearLayout bottomToolbar;
|
||||
protected LinearLayout bottomToolbar;
|
||||
@BindView(R2.id.bottom_toolbar_bookmark)
|
||||
ImageView bottomToolbarBookmark;
|
||||
@BindView(R2.id.bottom_toolbar_arrow_back)
|
||||
@ -198,7 +196,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
@BindView(R2.id.tab_switcher_recycler_view)
|
||||
RecyclerView tabRecyclerView;
|
||||
@BindView(R2.id.activity_main_tab_switcher)
|
||||
View tabSwitcherRoot;
|
||||
protected View tabSwitcherRoot;
|
||||
@BindView(R2.id.tab_switcher_close_all_tabs)
|
||||
FloatingActionButton closeAllTabsButton;
|
||||
@BindView(R2.id.snackbar_root)
|
||||
@ -211,7 +209,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
@Inject
|
||||
StorageObserver storageObserver;
|
||||
@Inject
|
||||
ZimReaderContainer zimReaderContainer;
|
||||
protected ZimReaderContainer zimReaderContainer;
|
||||
|
||||
private CountDownTimer hideBackToTopTimer = new CountDownTimer(1200, 1200) {
|
||||
@Override
|
||||
@ -238,7 +236,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
private KiwixTextToSpeech tts;
|
||||
private CompatFindActionModeCallback compatCallback;
|
||||
private TabsAdapter tabsAdapter;
|
||||
private int currentWebViewIndex = 0;
|
||||
protected int currentWebViewIndex = 0;
|
||||
private File file;
|
||||
private ActionMode actionMode = null;
|
||||
private KiwixWebView tempForUndo;
|
||||
@ -392,11 +390,11 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
selectTab(webViewList.size() - 1);
|
||||
}
|
||||
if (intent.hasExtra(EXTRA_CHOSE_X_URL)) {
|
||||
newTab();
|
||||
newMainPageTab();
|
||||
getCurrentWebView().loadUrl(intent.getStringExtra(EXTRA_CHOSE_X_URL));
|
||||
}
|
||||
if (intent.hasExtra(EXTRA_CHOSE_X_TITLE)) {
|
||||
newTab();
|
||||
newMainPageTab();
|
||||
getCurrentWebView().loadUrl(intent.getStringExtra(EXTRA_CHOSE_X_TITLE));
|
||||
}
|
||||
}
|
||||
@ -507,7 +505,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
}
|
||||
}
|
||||
|
||||
private void hideTabSwitcher() {
|
||||
protected void hideTabSwitcher() {
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
|
||||
@ -644,15 +642,15 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
}
|
||||
|
||||
private void updateTitle() {
|
||||
String zimFileTitle = zimReaderContainer.getZimFileTitle();
|
||||
if (zimFileTitle == null) {
|
||||
zimFileTitle = getString(R.string.app_name);
|
||||
}
|
||||
if (zimFileTitle.trim().isEmpty() || HOME_URL.equals(getCurrentWebView().getUrl())) {
|
||||
actionBar.setTitle(createMenuText(getString(R.string.app_name)));
|
||||
} else {
|
||||
actionBar.setTitle(createMenuText(zimFileTitle));
|
||||
}
|
||||
actionBar.setTitle(createMenuText(getValidTitle(zimReaderContainer.getZimFileTitle())));
|
||||
}
|
||||
|
||||
private String getValidTitle(String zimFileTitle) {
|
||||
return isInvalidTitle(zimFileTitle) ? getString(R.string.app_name) : zimFileTitle;
|
||||
}
|
||||
|
||||
protected boolean isInvalidTitle(String zimFileTitle) {
|
||||
return zimFileTitle == null || zimFileTitle.trim().isEmpty();
|
||||
}
|
||||
|
||||
private void setUpTTS() {
|
||||
@ -768,7 +766,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
WebViewCallback webViewCallback,
|
||||
ZimReaderContainer zimReaderContainer);
|
||||
|
||||
private KiwixWebView newTab() {
|
||||
protected KiwixWebView newMainPageTab() {
|
||||
return newTab(contentUrl(zimReaderContainer.getMainPage()));
|
||||
}
|
||||
|
||||
@ -830,7 +828,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
}
|
||||
|
||||
protected KiwixWebView getCurrentWebView() {
|
||||
if (webViewList.size() == 0) return newTab();
|
||||
if (webViewList.size() == 0) return newMainPageTab();
|
||||
if (currentWebViewIndex < webViewList.size()) {
|
||||
return webViewList.get(currentWebViewIndex);
|
||||
} else {
|
||||
@ -845,7 +843,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
if (tabSwitcherRoot.getVisibility() == View.VISIBLE) {
|
||||
hideTabSwitcher();
|
||||
}
|
||||
newTab(HOME_URL);
|
||||
createNewTab();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_add_note) {
|
||||
if (requestExternalStorageWritePermissionForNotes()) {
|
||||
@ -898,6 +896,8 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
protected abstract void createNewTab();
|
||||
|
||||
/** Creates the full screen AddNoteDialog, which is a DialogFragment */
|
||||
private void showAddNoteDialog() {
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
@ -986,12 +986,6 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showHomePage() {
|
||||
getCurrentWebView().removeAllViews();
|
||||
getCurrentWebView().loadUrl(HOME_URL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openExternalUrl(Intent intent) {
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
@ -1222,12 +1216,13 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
private void openHomeScreen() {
|
||||
new Handler().postDelayed(() -> {
|
||||
if (webViewList.size() == 0) {
|
||||
newTab(HOME_URL);
|
||||
createNewTab();
|
||||
hideTabSwitcher();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R2.id.bottom_toolbar_bookmark)
|
||||
public void toggleBookmark() {
|
||||
//Check maybe need refresh
|
||||
@ -1280,17 +1275,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
recreate();
|
||||
}
|
||||
presenter.loadCurrentZimBookmarksUrl();
|
||||
if (zimReaderContainer.getZimFile() == null &&
|
||||
!HOME_URL.equals(getCurrentWebView().getUrl())) {
|
||||
showHomePage();
|
||||
}
|
||||
|
||||
if (!webViewList.isEmpty() && currentWebViewIndex < webViewList.size() &&
|
||||
webViewList.get(currentWebViewIndex).getUrl() != null &&
|
||||
webViewList.get(currentWebViewIndex).getUrl().equals(HOME_URL) &&
|
||||
webViewList.get(currentWebViewIndex).findViewById(R.id.get_content_card) != null) {
|
||||
webViewList.get(currentWebViewIndex).findViewById(R.id.get_content_card).setEnabled(true);
|
||||
}
|
||||
updateBottomToolbarVisibility();
|
||||
presenter.loadBooks();
|
||||
|
||||
@ -1327,9 +1312,6 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
startActivityForResult(i, REQUEST_FILE_SEARCH);
|
||||
}
|
||||
break;
|
||||
case NEW_TAB:
|
||||
newTab(HOME_URL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateWidgets(this);
|
||||
@ -1337,8 +1319,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
|
||||
private void updateBottomToolbarVisibility() {
|
||||
if (checkNull(bottomToolbar)) {
|
||||
if (!HOME_URL.equals(
|
||||
getCurrentWebView().getUrl())
|
||||
if (!urlIsInvalid()
|
||||
&& tabSwitcherRoot.getVisibility() != View.VISIBLE) {
|
||||
bottomToolbar.setVisibility(View.VISIBLE);
|
||||
if (getCurrentWebView() instanceof ToolbarStaticKiwixWebView) {
|
||||
@ -1510,7 +1491,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
}
|
||||
if (resultCode == RESULT_HISTORY_CLEARED) {
|
||||
webViewList.clear();
|
||||
newTab();
|
||||
newMainPageTab();
|
||||
tabsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
loadPrefs();
|
||||
@ -1525,7 +1506,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
kiwixWebView.clearHistory();
|
||||
}
|
||||
webViewList.clear();
|
||||
newTab(HOME_URL);
|
||||
createNewTab();
|
||||
} else {
|
||||
String title = data.getStringExtra(EXTRA_CHOSE_X_TITLE);
|
||||
String url = data.getStringExtra(EXTRA_CHOSE_X_URL);
|
||||
@ -1553,7 +1534,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
newTab();
|
||||
newMainPageTab();
|
||||
if (url != null) {
|
||||
getCurrentWebView().loadUrl(url);
|
||||
} else if (title != null) {
|
||||
@ -1611,7 +1592,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
menu.findItem(R.id.menu_read_aloud).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.menu_fullscreen).setVisible(true);
|
||||
if (urlIsHomeOrNull()) {
|
||||
if (urlIsInvalid()) {
|
||||
menu.findItem(R.id.menu_search).setVisible(false);
|
||||
menu.findItem(R.id.menu_read_aloud).setVisible(false);
|
||||
menu.findItem(R.id.menu_random_article).setVisible(false);
|
||||
@ -1624,9 +1605,8 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean urlIsHomeOrNull() {
|
||||
return getCurrentWebView().getUrl() == null ||
|
||||
getCurrentWebView().getUrl().equals(HOME_URL);
|
||||
protected boolean urlIsInvalid(){
|
||||
return getCurrentWebView().getUrl() == null;
|
||||
}
|
||||
|
||||
private void updateTabSwitcherIcon() {
|
||||
@ -1641,15 +1621,10 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
|
||||
private void refreshBookmarkSymbol() {
|
||||
if (checkNull(bottomToolbarBookmark)) {
|
||||
if (getCurrentWebView().getUrl() != null &&
|
||||
zimReaderContainer.getId() != null &&
|
||||
!getCurrentWebView().getUrl().equals(HOME_URL)) {
|
||||
int icon = bookmarks.contains(getCurrentWebView().getUrl()) ? R.drawable.ic_bookmark_24dp
|
||||
: R.drawable.ic_bookmark_border_24dp;
|
||||
bottomToolbarBookmark.setImageResource(icon);
|
||||
} else {
|
||||
bottomToolbarBookmark.setImageResource(R.drawable.ic_bookmark_border_24dp);
|
||||
}
|
||||
bottomToolbarBookmark.setImageResource(
|
||||
bookmarks.contains(getCurrentWebView().getUrl()) ? R.drawable.ic_bookmark_24dp
|
||||
: R.drawable.ic_bookmark_border_24dp
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1737,7 +1712,7 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
updateBottomToolbarArrowsAlpha();
|
||||
String url = getCurrentWebView().getUrl();
|
||||
final ZimFileReader zimFileReader = zimReaderContainer.getZimFileReader();
|
||||
if (url != null && !url.equals(HOME_URL) && zimFileReader != null) {
|
||||
if (hasValidFileAndUrl(url, zimFileReader)) {
|
||||
final long timeStamp = System.currentTimeMillis();
|
||||
SimpleDateFormat sdf =
|
||||
new SimpleDateFormat("d MMM yyyy", LanguageUtils.getCurrentLocale(this));
|
||||
@ -1753,6 +1728,10 @@ public abstract class CoreMainActivity extends BaseActivity implements WebViewCa
|
||||
updateBottomToolbarVisibility();
|
||||
}
|
||||
|
||||
protected boolean hasValidFileAndUrl(String url, ZimFileReader zimFileReader) {
|
||||
return url != null && zimFileReader != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void webViewFailedLoading(String url) {
|
||||
String error = String.format(getString(R.string.error_article_url_not_found), url);
|
||||
|
@ -26,7 +26,6 @@ import android.os.Build.VERSION_CODES
|
||||
import android.os.Environment
|
||||
import android.provider.DocumentsContract
|
||||
import android.util.Log
|
||||
import org.kiwix.kiwixmobile.core.CoreApp
|
||||
import org.kiwix.kiwixmobile.core.downloader.ChunkUtils
|
||||
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
|
||||
import org.kiwix.kiwixmobile.core.extensions.get
|
||||
@ -37,10 +36,6 @@ import java.util.ArrayList
|
||||
|
||||
object FileUtils {
|
||||
|
||||
private val saveFilePath =
|
||||
"${Environment.getExternalStorageDirectory()}${File.separator}Android" +
|
||||
"${File.separator}obb${File.separator}${CoreApp.getInstance().packageName}"
|
||||
|
||||
@JvmStatic fun getFileCacheDir(context: Context): File? =
|
||||
if (Environment.MEDIA_MOUNTED == Environment.getExternalStorageState()) {
|
||||
context.externalCacheDir
|
||||
@ -95,11 +90,6 @@ object FileUtils {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the filename (where the file should be saved) from info about a download
|
||||
*/
|
||||
@JvmStatic fun generateSaveFileName(fileName: String) = "$saveFilePath${File.separator}$fileName"
|
||||
|
||||
/**
|
||||
* Helper function to ascertain the existence of a file and return true/false appropriately
|
||||
*
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version_name": "2017-07",
|
||||
"version_code": "1",
|
||||
"zim_file": "wikipedia_fr_test_2017-07.zim",
|
||||
"embed_zim": true,
|
||||
"embed_zim": false,
|
||||
"ic_launcher": "icon.png",
|
||||
"enforced_lang": "en"
|
||||
}
|
||||
}
|
||||
|
BIN
custom/src/customexample/main.1.org.kiwix.kiwixcustomexample.obb
Normal file
BIN
custom/src/customexample/main.1.org.kiwix.kiwixcustomexample.obb
Normal file
Binary file not shown.
@ -39,6 +39,15 @@ import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
class CustomMainActivity : CoreMainActivity() {
|
||||
|
||||
override fun showHomePage() {
|
||||
Log.e("CustomMain", "tried to show home page")
|
||||
}
|
||||
|
||||
override fun createNewTab() {
|
||||
newMainPageTab()
|
||||
}
|
||||
|
||||
override fun injection() {
|
||||
customActivityComponent.inject(this)
|
||||
}
|
||||
@ -111,8 +120,7 @@ class CustomMainActivity : CoreMainActivity() {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
val fileName = getExpansionAPKFileName()
|
||||
filePath = FileUtils.generateSaveFileName(fileName)
|
||||
filePath = generateExpansionFilePath()
|
||||
}
|
||||
|
||||
Log.d(TAG_KIWIX, "BuildConfig.ZIM_FILE_SIZE = " + BuildConfig.ZIM_FILE_SIZE)
|
||||
@ -146,12 +154,10 @@ class CustomMainActivity : CoreMainActivity() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Returns the file name (without full path) for an Expansion APK file from the given context.
|
||||
*
|
||||
* @return String the file name of the expansion file
|
||||
*/
|
||||
@JvmStatic fun getExpansionAPKFileName() =
|
||||
"patch.${BuildConfig.CONTENT_VERSION_CODE}.${CoreApp.getInstance().packageName}.obb"
|
||||
private fun getExpansionAPKFileName() =
|
||||
"main.${BuildConfig.CONTENT_VERSION_CODE}.${CoreApp.getInstance().packageName}.obb"
|
||||
|
||||
fun generateExpansionFilePath(fileName: String = getExpansionAPKFileName()) =
|
||||
"${CoreApp.getInstance().obbDir}${File.separator}$fileName"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user