use of me.devsaki.hentoid.activities.bundles.BaseWebActivityBundle in project Hentoid by avluis.
the class BaseWebActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// NB : This doesn't restore the browsing history, but WebView.saveState/restoreState
// doesn't work that well (bugged when using back/forward commands). A valid solution still has to be found
BaseWebActivityBundle bundle = new BaseWebActivityBundle();
bundle.setUrl(webView.getUrl());
outState.putAll(bundle.toBundle());
}
use of me.devsaki.hentoid.activities.bundles.BaseWebActivityBundle in project Hentoid by avluis.
the class BaseWebActivity method onRestoreInstanceState.
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// NB : This doesn't restore the browsing history, but WebView.saveState/restoreState
// doesn't work that well (bugged when using back/forward commands). A valid solution still has to be found
String url = new BaseWebActivityBundle(savedInstanceState).getUrl();
if (url != null && !url.isEmpty())
webView.loadUrl(url);
}
use of me.devsaki.hentoid.activities.bundles.BaseWebActivityBundle in project Hentoid by avluis.
the class BaseWebActivity method getStartUrl.
/**
* Determine the URL the browser will load at startup
* - Either an URL specifically given to the activity (e.g. "view source" action)
* - Or the last viewed page, if the option is enabled
* - If neither of the previous cases, the default URL of the site
*
* @return URL to load at startup
*/
private String getStartUrl() {
// Priority 1 : URL specifically given to the activity (e.g. "view source" action)
if (getIntent().getExtras() != null) {
BaseWebActivityBundle bundle = new BaseWebActivityBundle(getIntent().getExtras());
String intentUrl = StringHelper.protect(bundle.getUrl());
if (!intentUrl.isEmpty())
return intentUrl;
}
// Priority 2 : Last viewed position, if option enabled
if (Preferences.isBrowserResumeLast()) {
SiteHistory siteHistory = dao.selectHistory(getStartSite());
if (siteHistory != null && !siteHistory.getUrl().isEmpty())
return siteHistory.getUrl();
}
// Priority 3 : Homepage, if manually set through bookmarks
SiteBookmark welcomePage = dao.selectHomepage(getStartSite());
if (welcomePage != null)
return welcomePage.getUrl();
// Default site URL
return getStartSite().getUrl();
}
use of me.devsaki.hentoid.activities.bundles.BaseWebActivityBundle in project Hentoid by avluis.
the class ContentHelper method launchBrowserFor.
/**
* Launch the web browser for the given site and URL
*
* @param context COntext to be used
* @param targetUrl Url to navigate to
*/
public static void launchBrowserFor(@NonNull final Context context, @NonNull final String targetUrl) {
Site targetSite = Site.searchByUrl(targetUrl);
if (null == targetSite || targetSite.equals(Site.NONE))
return;
Intent intent = new Intent(context, Content.getWebActivityClass(targetSite));
BaseWebActivityBundle bundle = new BaseWebActivityBundle();
bundle.setUrl(targetUrl);
intent.putExtras(bundle.toBundle());
context.startActivity(intent);
}
use of me.devsaki.hentoid.activities.bundles.BaseWebActivityBundle in project Hentoid by avluis.
the class ContentHelper method viewContentGalleryPage.
/**
* Open the app's web browser to view the given Content's gallery page
*
* @param context Context to use for the action
* @param content Content to view
* @param wrapPin True if the intent should be wrapped with PIN protection
*/
public static void viewContentGalleryPage(@NonNull final Context context, @NonNull Content content, boolean wrapPin) {
if (content.getSite().equals(Site.NONE))
return;
Intent intent = new Intent(context, Content.getWebActivityClass(content.getSite()));
BaseWebActivityBundle bundle = new BaseWebActivityBundle();
bundle.setUrl(content.getGalleryUrl());
intent.putExtras(bundle.toBundle());
if (wrapPin)
intent = UnlockActivity.wrapIntent(context, intent);
context.startActivity(intent);
}
Aggregations