capturePixels() {
- if (mDisplay == null) {
- return GeckoResult.fromException(new IllegalStateException("Display must be created before pixels can be captured"));
- }
-
- return mDisplay.capturePixels();
- }
- }
-
- @SuppressWarnings("checkstyle:javadocmethod")
- public extendedGeckoView(final Context context) {
- super(context);
- init();
- }
-
- @SuppressWarnings("checkstyle:javadocmethod")
- public extendedGeckoView(final Context context, final AttributeSet attrs) {
- super(context, attrs);
- init();
- }
-
- private void init() {
- setFocusable(true);
- setFocusableInTouchMode(true);
- setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
-
- // We are adding descendants to this LayerView, but we don't want the
- // descendants to affect the way LayerView retains its focus.
- setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
-
- // This will stop PropertyAnimator from creating a drawing cache (i.e. a
- // bitmap) from a SurfaceView, which is just not possible (the bitmap will be
- // transparent).
- setWillNotCacheDrawing(false);
-
- mSurfaceWrapper = new SurfaceViewWrapper(getContext());
- mSurfaceWrapper.setBackgroundColor(Color.WHITE);
- addView(mSurfaceWrapper.getView(),
- new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
-
- mSurfaceWrapper.setListener(mDisplay);
-
- //final Activity activity = ActivityUtils.getActivityFromContext(getContext());
- //if (activity != null) {
- //mSelectionActionDelegate = new BasicSelectionActionDelegate();
- //}
-
- mAutofillDelegate = new AndroidAutofillDelegate();
- }
-
- /**
- * Set a color to cover the display surface while a document is being shown. The color
- * is automatically cleared once the new document starts painting.
- *
- * @param color Cover color.
- */
- public void coverUntilFirstPaint(final int color) {
- mLastCoverColor = color;
- if (mSession != null) {
- mSession.getCompositorController().setClearColor(color);
- }
- coverUntilFirstPaintInternal(color);
- }
-
- private void uncover() {
- coverUntilFirstPaintInternal(Color.TRANSPARENT);
- }
-
- private void coverUntilFirstPaintInternal(final int color) {
- ThreadUtils.assertOnUiThread();
-
- if (mSurfaceWrapper != null) {
- mSurfaceWrapper.setBackgroundColor(color);
- }
- }
-
- /**
- * This extendedGeckoView instance will be backed by a {@link SurfaceView}.
- *
- * This option offers the best performance at the price of not being
- * able to animate extendedGeckoView.
- */
- public static final int BACKEND_SURFACE_VIEW = 1;
- /**
- * This extendedGeckoView instance will be backed by a {@link TextureView}.
- *
- * This option offers worse performance compared to {@link #BACKEND_SURFACE_VIEW}
- * but allows you to animate extendedGeckoView or to paint a extendedGeckoView on top of another extendedGeckoView.
- */
- public static final int BACKEND_TEXTURE_VIEW = 2;
-
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({BACKEND_SURFACE_VIEW, BACKEND_TEXTURE_VIEW})
- /* protected */ @interface ViewBackend {
- }
-
- /**
- * Set which view should be used by this extendedGeckoView instance to display content.
- *
- * By default, extendedGeckoView will use a {@link SurfaceView}.
- *
- * @param backend Any of {@link #BACKEND_SURFACE_VIEW BACKEND_*}.
- */
- public void setViewBackend(final @ViewBackend int backend) {
- removeView(mSurfaceWrapper.getView());
-
- if (backend == BACKEND_SURFACE_VIEW) {
- mSurfaceWrapper.useSurfaceView(getContext());
- } else if (backend == BACKEND_TEXTURE_VIEW) {
- mSurfaceWrapper.useTextureView(getContext());
- }
-
- addView(mSurfaceWrapper.getView());
- }
-
- /**
- * Return whether the view should be pinned on the screen. When pinned, the view
- * should not be moved on the screen due to animation, scrolling, etc. A common reason
- * for the view being pinned is when the user is dragging a selection caret inside
- * the view; normal user interaction would be disrupted in that case if the view
- * was moved on screen.
- *
- * @return True if view should be pinned on the screen.
- */
- public boolean shouldPinOnScreen() {
- ThreadUtils.assertOnUiThread();
-
- return mDisplay.shouldPinOnScreen();
- }
-
- /**
- * Update the amount of vertical space that is clipped or visibly obscured in the bottom portion
- * of the view. Tells gecko where to put bottom fixed elements so they are fully visible.
- *
- * Optional call. The display's visible vertical space has changed. Must be
- * called on the application main thread.
- *
- * @param clippingHeight The height of the bottom clipped space in screen pixels.
- */
- public void setVerticalClipping(final int clippingHeight) {
- ThreadUtils.assertOnUiThread();
-
- mDisplay.setVerticalClipping(clippingHeight);
- }
-
- /**
- * Set the maximum height of the dynamic toolbar(s).
- *
- * If there are two or more dynamic toolbars, the height value should be the total amount of
- * the height of each dynamic toolbar.
- *
- * @param height The the maximum height of the dynamic toolbar(s).
- */
- public void setDynamicToolbarMaxHeight(final int height) {
- mDisplay.setDynamicToolbarMaxHeight(height);
- }
-
- /* package */ void setActive(final boolean active) {
- if (mSession != null) {
- mSession.setActive(active);
- }
- }
-
- // TODO: Bug 1670805 this should really be configurable
- // Default dark color for about:blank, keep it in sync with PresShell.cpp
- final static int DEFAULT_DARK_COLOR = 0xFF2A2A2E;
-
-
- /**
- * Unsets the current session from this instance and returns it, if any. You must call
- * this before {@link #setSession(GeckoSession)} if there is already an open session
- * set for this instance.
- *
- * Note: this method does not close the session and the session remains active. The
- * caller is responsible for calling {@link GeckoSession#close()} when appropriate.
- *
- * @return The {@link GeckoSession} that was set for this instance. May be null.
- */
- @UiThread
- public @Nullable
- GeckoSession releaseSession() {
- ThreadUtils.assertOnUiThread();
-
- if (mSession == null) {
- return null;
- }
-
- GeckoSession session = mSession;
- mSession.releaseDisplay(mDisplay.release());
- mSession.getOverscrollEdgeEffect().setInvalidationCallback(null);
- mSession.getCompositorController().setFirstPaintCallback(null);
-
- if (mSession.getAccessibility().getView() == this) {
- mSession.getAccessibility().setView(null);
- }
-
- if (mSession.getTextInput().getView() == this) {
- mSession.getTextInput().setView(null);
- }
-
- if (mSession.getSelectionActionDelegate() == mSelectionActionDelegate) {
- mSession.setSelectionActionDelegate(null);
- }
-
- if (mSession.getAutofillDelegate() == mAutofillDelegate) {
- mSession.setAutofillDelegate(null);
- }
-
- if (isFocused()) {
- mSession.setFocused(false);
- }
- mSession = null;
- return session;
- }
-
- /**
- * Attach a session to this view. If this instance already has an open session, you must use
- * {@link #releaseSession()} first, otherwise {@link IllegalStateException}
- * will be thrown. This is to avoid potentially leaking the currently opened session.
- *
- * @param session The session to be attached.
- * @throws IllegalArgumentException if an existing open session is already set.
- */
- @UiThread
- public void setSession(@NonNull final GeckoSession session) {
- ThreadUtils.assertOnUiThread();
-
- if (mSession != null && mSession.isOpen()) {
- throw new IllegalStateException("Current session is open");
- }
-
- releaseSession();
-
- mSession = session;
-
- // Make sure the clear color is set to the default
-
- if (ViewCompat.isAttachedToWindow(this)) {
- mDisplay.acquire(session.acquireDisplay());
- }
-
- final Context context = getContext();
- session.getOverscrollEdgeEffect().setTheme(context);
- session.getOverscrollEdgeEffect().setInvalidationCallback(new Runnable() {
- @Override
- public void run() {
- if (Build.VERSION.SDK_INT >= 16) {
- extendedGeckoView.this.postInvalidateOnAnimation();
- } else {
- extendedGeckoView.this.postInvalidateDelayed(10);
- }
- }
- });
-
- final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- final TypedValue outValue = new TypedValue();
- if (context.getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight,
- outValue, true)) {
- session.getPanZoomController().setScrollFactor(outValue.getDimension(metrics));
- } else {
- session.getPanZoomController().setScrollFactor(0.075f * metrics.densityDpi);
- }
-
- session.getCompositorController().setFirstPaintCallback(this::uncover);
-
- if (session.getTextInput().getView() == null) {
- session.getTextInput().setView(this);
- }
-
- if (session.getAccessibility().getView() == null) {
- session.getAccessibility().setView(this);
- }
-
- if (session.getSelectionActionDelegate() == null && mSelectionActionDelegate != null) {
- session.setSelectionActionDelegate(mSelectionActionDelegate);
- }
-
- if (mAutofillEnabled) {
- session.setAutofillDelegate(mAutofillDelegate);
- }
-
- if (isFocused()) {
- session.setFocused(true);
- }
- }
-
- @AnyThread
- @SuppressWarnings("checkstyle:javadocmethod")
- public @Nullable
- GeckoSession getSession() {
- return mSession;
- }
-
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
-
- if (mSession == null) {
- return;
- }
-
- // Release the display before we detach from the window.
- mSession.releaseDisplay(mDisplay.release());
- }
-
-
- @Override
- public boolean gatherTransparentRegion(final Region region) {
- // For detecting changes in SurfaceView layout, we take a shortcut here and
- // override gatherTransparentRegion, instead of registering a layout listener,
- // which is more expensive.
- if (mSurfaceWrapper != null) {
- mDisplay.onGlobalLayout();
- }
- return super.gatherTransparentRegion(region);
- }
-
- @Override
- public void onWindowFocusChanged(final boolean hasWindowFocus) {
- super.onWindowFocusChanged(hasWindowFocus);
-
- // Only call setFocus(true) when the window gains focus. Any focus loss could be temporary
- // (e.g. due to auto-fill popups) and we don't want to call setFocus(false) in those cases.
- // Instead, we call setFocus(false) in onWindowVisibilityChanged.
- if (mSession != null && hasWindowFocus && isFocused()) {
- mSession.setFocused(true);
- }
- }
-
- @Override
- protected void onWindowVisibilityChanged(final int visibility) {
- super.onWindowVisibilityChanged(visibility);
-
- // We can be reasonably sure that the focus loss is not temporary, so call setFocus(false).
- if (mSession != null && visibility != View.VISIBLE && !hasWindowFocus()) {
- mSession.setFocused(false);
- }
- }
-
- @Override
- protected void onFocusChanged(final boolean gainFocus, final int direction,
- final Rect previouslyFocusedRect) {
- super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
-
- if (mIsResettingFocus) {
- return;
- }
-
- if (mSession != null) {
- mSession.setFocused(gainFocus);
- }
-
- if (!gainFocus) {
- return;
- }
-
- post(new Runnable() {
- @Override
- public void run() {
- if (!isFocused()) {
- return;
- }
-
- final InputMethodManager imm = InputMethods.getInputMethodManager(getContext());
- // Bug 1404111: Through View#onFocusChanged, the InputMethodManager queues
- // up a checkFocus call for the next spin of the message loop, so by
- // posting this Runnable after super#onFocusChanged, the IMM should have
- // completed its focus change handling at this point and we should be the
- // active view for input handling.
-
- // If however onViewDetachedFromWindow for the previously active view gets
- // called *after* onFocusChanged, but *before* the focus change has been
- // fully processed by the IMM with the help of checkFocus, the IMM will
- // lose track of the currently active view, which means that we can't
- // interact with the IME.
- if (!imm.isActive(extendedGeckoView.this)) {
- // If that happens, we bring the IMM's internal state back into sync
- // by clearing and resetting our focus.
- mIsResettingFocus = true;
- clearFocus();
- // After calling clearFocus we might regain focus automatically, but
- // we explicitly request it again in case this doesn't happen. If
- // we've already got the focus back, this will then be a no-op anyway.
- requestFocus();
- mIsResettingFocus = false;
- }
- }
- });
- }
-
- @Override
- public Handler getHandler() {
- if (Build.VERSION.SDK_INT >= 24 || mSession == null) {
- return super.getHandler();
- }
- return mSession.getTextInput().getHandler(super.getHandler());
- }
-
- @Override
- public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
- if (mSession == null) {
- return null;
- }
- return mSession.getTextInput().onCreateInputConnection(outAttrs);
- }
-
- @Override
- public boolean onKeyPreIme(final int keyCode, final KeyEvent event) {
- if (super.onKeyPreIme(keyCode, event)) {
- return true;
- }
- return mSession != null &&
- mSession.getTextInput().onKeyPreIme(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(final int keyCode, final KeyEvent event) {
- if (super.onKeyUp(keyCode, event)) {
- return true;
- }
- return mSession != null &&
- mSession.getTextInput().onKeyUp(keyCode, event);
- }
-
- @Override
- public boolean onKeyDown(final int keyCode, final KeyEvent event) {
- if (super.onKeyDown(keyCode, event)) {
- return true;
- }
- return mSession != null &&
- mSession.getTextInput().onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyLongPress(final int keyCode, final KeyEvent event) {
- if (super.onKeyLongPress(keyCode, event)) {
- return true;
- }
- return mSession != null &&
- mSession.getTextInput().onKeyLongPress(keyCode, event);
- }
-
- @Override
- public boolean onKeyMultiple(final int keyCode, final int repeatCount, final KeyEvent event) {
- if (super.onKeyMultiple(keyCode, repeatCount, event)) {
- return true;
- }
- return mSession != null &&
- mSession.getTextInput().onKeyMultiple(keyCode, repeatCount, event);
- }
-
- @Override
- public void dispatchDraw(final Canvas canvas) {
- super.dispatchDraw(canvas);
-
- if (mSession != null) {
- mSession.getOverscrollEdgeEffect().draw(canvas);
- }
- }
-
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public boolean onTouchEvent(final MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- requestFocus();
- }
-
- if (mSession == null) {
- return false;
- }
-
- mSession.getPanZoomController().onTouchEvent(event);
- return true;
- }
-
- /**
- * Dispatches a {@link MotionEvent} to the {@link PanZoomController}. This is the same as
- * indicating how the event was handled.
- *
- * NOTE: It is highly recommended to only call this with ACTION_DOWN or in otherwise
- * limited capacity. Returning a GeckoResult for every touch event will generate
- * a lot of allocations and unnecessary GC pressure.
- *
- * @param event A {@link MotionEvent}
- * @return One of the {@link PanZoomController#INPUT_RESULT_UNHANDLED INPUT_RESULT_*}) indicating how the event was handled.
- */
-
-
- @Override
- public boolean onGenericMotionEvent(final MotionEvent event) {
- if (AndroidGamepadManager.handleMotionEvent(event)) {
- return true;
- }
-
- if (mSession == null) {
- return true;
- }
-
- if (mSession.getAccessibility().onMotionEvent(event)) {
- return true;
- }
-
- mSession.getPanZoomController().onMotionEvent(event);
- return true;
- }
-
- @Override
- public void onProvideAutofillVirtualStructure(final ViewStructure structure,
- final int flags) {
- super.onProvideAutofillVirtualStructure(structure, flags);
-
- if (mSession == null) {
- return;
- }
-
- final Autofill.Session autofillSession = mSession.getAutofillSession();
- autofillSession.fillViewStructure(this, structure, flags);
- }
-
- @Override
- @TargetApi(26)
- public void autofill(@NonNull final SparseArray values) {
- super.autofill(values);
-
- if (mSession == null) {
- return;
- }
- final SparseArray strValues = new SparseArray<>(values.size());
- for (int i = 0; i < values.size(); i++) {
- final AutofillValue value = values.valueAt(i);
- if (value.isText()) {
- // Only text is currently supported.
- strValues.put(values.keyAt(i), value.getTextValue());
- }
- }
- mSession.getAutofillSession().autofill(strValues);
- }
-
- /**
- * Request a {@link Bitmap} of the visible portion of the web page currently being
- * rendered.
- *
- * See {@link GeckoDisplay#capturePixels} for more details.
- *
- * @return A {@link GeckoResult} that completes with a {@link Bitmap} containing
- * the pixels and size information of the currently visible rendered web page.
- */
- @UiThread
- public @NonNull
- GeckoResult capturePixels() {
- return mDisplay.capturePixels();
- }
-
- /**
- * Sets whether or not this View participates in Android autofill.
- *
- * When enabled, this will set an {@link Autofill.Delegate} on the
- * {@link GeckoSession} for this instance.
- *
- * @param enabled Whether or not Android autofill is enabled for this view.
- */
- @TargetApi(26)
- public void setAutofillEnabled(final boolean enabled) {
- mAutofillEnabled = enabled;
-
- if (mSession != null) {
- if (!enabled && mSession.getAutofillDelegate() == mAutofillDelegate) {
- mSession.setAutofillDelegate(null);
- } else if (enabled) {
- mSession.setAutofillDelegate(mAutofillDelegate);
- }
- }
- }
-
- /**
- * @return Whether or not Android autofill is enabled for this view.
- */
- @TargetApi(26)
- public boolean getAutofillEnabled() {
- return mAutofillEnabled;
- }
-
- private class AndroidAutofillDelegate implements Autofill.Delegate {
-
- private Rect displayRectForId(@NonNull final GeckoSession session,
- @NonNull final Autofill.Node node) {
- if (node == null) {
- return new Rect(0, 0, 0, 0);
- }
-
- final Matrix matrix = new Matrix();
- final RectF rectF = new RectF(node.getDimensions());
- session.getPageToScreenMatrix(matrix);
- matrix.mapRect(rectF);
-
- final Rect screenRect = new Rect();
- rectF.roundOut(screenRect);
- return screenRect;
- }
-
- @Override
- public void onNodeUpdate(
- @NonNull final GeckoSession session,
- @NonNull final Autofill.Node node,
- @NonNull final Autofill.NodeData data) {
-
- final AutofillManager manager;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
- manager = extendedGeckoView.this.getContext().getSystemService(AutofillManager.class);
- if (manager == null) {
- return;
- }
- manager.notifyViewEntered(extendedGeckoView.this, data.getId(),displayRectForId(session, node));
- }
-
- }
-
- @Override
- public void onNodeFocus(
- @NonNull final GeckoSession session,
- @NonNull final Autofill.Node node,
- @NonNull final Autofill.NodeData data) {
-
- final AutofillManager manager;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
- manager = extendedGeckoView.this.getContext().getSystemService(AutofillManager.class);
- if (manager == null) {
- return;
- }
- manager.notifyViewEntered(extendedGeckoView.this, data.getId(),displayRectForId(session, node));
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoClients.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoClients.java
index 26057b98..d2fb5fc9 100644
--- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoClients.java
+++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoClients.java
@@ -9,24 +9,25 @@ import android.util.Log;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import com.hiddenservices.onionservices.appManager.activityContextManager;
+import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.downloadManager.geckoDownloadManager;
+import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeEnums;
import com.hiddenservices.onionservices.appManager.kotlinHelperLibraries.BrowserIconManager;
import com.hiddenservices.onionservices.constants.*;
import com.hiddenservices.onionservices.dataManager.dataController;
import com.hiddenservices.onionservices.dataManager.dataEnums;
import com.hiddenservices.onionservices.eventObserver;
import com.hiddenservices.onionservices.helperManager.helperMethod;
-
+import com.hiddenservices.onionservices.pluginManager.pluginController;
import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
-
import static com.hiddenservices.onionservices.constants.constants.CONST_GENESIS_URL_CACHED;
import static com.hiddenservices.onionservices.constants.constants.CONST_GENESIS_URL_CACHED_DARK;
import static com.hiddenservices.onionservices.constants.constants.CONST_PRIVACY_POLICY_URL_NON_TOR;
import static com.hiddenservices.onionservices.constants.constants.CONST_REPORT_URL;
-import static com.hiddenservices.onionservices.constants.enums.etype.on_handle_external_intent;
+import static com.hiddenservices.onionservices.pluginManager.pluginEnums.eMessageManager.M_LOAD_NEW_TAB;
+import static com.hiddenservices.onionservices.pluginManager.pluginEnums.eMessageManager.M_MAX_TAB_REACHED;
import static org.mozilla.geckoview.GeckoSessionSettings.USER_AGENT_MODE_MOBILE;
import static org.mozilla.geckoview.StorageController.ClearFlags.AUTH_SESSIONS;
import static org.mozilla.geckoview.StorageController.ClearFlags.COOKIES;
@@ -36,185 +37,104 @@ import static org.mozilla.geckoview.StorageController.ClearFlags.NETWORK_CACHE;
import static org.mozilla.geckoview.StorageController.ClearFlags.PERMISSIONS;
import static org.mozilla.geckoview.StorageController.ClearFlags.SITE_DATA;
import static org.mozilla.geckoview.StorageController.ClearFlags.SITE_SETTINGS;
-
import org.mozilla.geckoview.ContentBlocking;
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoRuntimeSettings;
import org.mozilla.geckoview.GeckoView;
import org.mozilla.geckoview.WebResponse;
-import org.torproject.android.service.wrapper.orbotLocalConstants;
public class geckoClients {
+
/*Gecko Variables*/
+ private static GeckoRuntime mRuntime;
private geckoSession mSession = null;
-
- static GeckoRuntime mRuntime;
private BrowserIconManager mIconManager;
- private eventObserver.eventListener event;
-
- /*Local Variable*/
-
+ private eventObserver.eventListener mEvent;
private String mSessionID;
- public void initialize(GeckoView geckoView, eventObserver.eventListener event, AppCompatActivity context, boolean isForced) {
- this.event = event;
- mSessionID = helperMethod.createRandomID();
- //initRuntimeSettings(context);
+ /*Local Initiaizations*/
- if (!isForced && geckoView.getSession() != null && geckoView.getSession().isOpen()) {
- mSession = (geckoSession) geckoView.getSession();
- } else {
-
- mSession = new geckoSession(new geckoViewClientCallback(), mSessionID, context, geckoView);
- mSession.getSettings().setUseTrackingProtection(status.sStatusDoNotTrack);
- mSession.getSettings().setFullAccessibilityTree(true);
- mSession.getSettings().setUserAgentMode(USER_AGENT_MODE_MOBILE);
- mSession.getSettings().setAllowJavascript(status.sSettingJavaStatus);
- if (geckoView.getSession() != null) {
- geckoView.releaseSession();
- mSession.open(mRuntime);
- geckoView.setSession(mSession);
- onUpdateFont();
- } else if (status.sSettingIsAppStarted) {
- mSession.open(mRuntime);
- geckoView.setSession(mSession);
- onUpdateFont();
- }
+ public void initializeSession(GeckoView pGeckoView, eventObserver.eventListener pEvent, AppCompatActivity pContext) {
+ if (pGeckoView.getSession() != null) {
+ pGeckoView.releaseSession();
}
- mSession.onSetInitializeFromStartup();
- }
-
- public void postInitRuntime(GeckoView geckoView, AppCompatActivity context) {
- initRuntimeSettings(context);
+ mSession = initSettings(pGeckoView, pEvent, pContext);
+ initRuntimeSettings(pContext);
mSession.open(mRuntime);
- geckoView.setSession(mSession);
+ pGeckoView.setSession(mSession);
onUpdateFont();
}
- public geckoSession initializeBackground(GeckoView geckoView, eventObserver.eventListener event, AppCompatActivity context, boolean isForced) {
- geckoSession mSessionTemp;
- mSessionTemp = new geckoSession(new geckoViewClientCallback(), helperMethod.createRandomID(), context, geckoView);
- mSessionTemp.open(mRuntime);
- mSessionTemp.getSettings().setUseTrackingProtection(status.sStatusDoNotTrack);
- mSessionTemp.getSettings().setFullAccessibilityTree(true);
- mSessionTemp.getSettings().setUserAgentMode(USER_AGENT_MODE_MOBILE);
- mSessionTemp.getSettings().setAllowJavascript(status.sSettingJavaStatus);
- return mSessionTemp;
+ public geckoSession initializeSessionInBackground(GeckoView pGeckoView, eventObserver.eventListener pEvent, AppCompatActivity pContext, String pURL) {
+ geckoSession mSessionHidden = initSettings(pGeckoView, pEvent, pContext);
+ mSessionHidden.loadUri(pURL);
+
+ pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(pContext), M_LOAD_NEW_TAB);
+ dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_ADD_TAB, Arrays.asList(mSessionHidden, true));
+ return mSessionHidden;
}
- public void onValidateInitializeFromStartup(NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext) {
- boolean mStatus = mSession.onValidateInitializeFromStartup();
+ private geckoSession initSettings(GeckoView pGeckoView, eventObserver.eventListener pEvent, AppCompatActivity pContext){
+ this.mEvent = pEvent;
+ mSessionID = helperMethod.createRandomID();
+ mSession = new geckoSession(new geckoViewClientCallback(), mSessionID, pContext, pGeckoView);
- if (mStatus) {
- boolean mState = mSession.onRestoreState();
- if (!mState) {
- mSession.stop();
- loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
- } else {
- String mURL = mSession.getCurrentURL();
- if (mURL.equals("http://167.86.99.31") || mURL.startsWith(CONST_GENESIS_URL_CACHED) || mURL.startsWith(CONST_GENESIS_URL_CACHED_DARK)) {
- if (!mSession.canGoBack()) {
- mNestedGeckoView.releaseSession();
- mSession.close();
- mSession.open(mRuntime);
- mNestedGeckoView.setSession(mSession);
- } else {
- mSession.goBack();
- }
- loadURL("http://167.86.99.31", mNestedGeckoView, pcontext);
- }
- }
+ mSession.getSettings().setUseTrackingProtection(status.sStatusDoNotTrack);
+ mSession.getSettings().setFullAccessibilityTree(true);
+ mSession.getSettings().setUserAgentMode(USER_AGENT_MODE_MOBILE);
+ mSession.getSettings().setAllowJavascript(status.sSettingJavaStatus);
+ return mSession;
+ }
+
+ public void initializeIcon(Context pcontext) {
+ if (mIconManager == null) {
+ mIconManager = new BrowserIconManager();
+ mIconManager.init(pcontext, mRuntime);
}
}
- public geckoSession initFreeSession(GeckoView pGeckoView, AppCompatActivity pcontext, eventObserver.eventListener event) {
- this.event = event;
- initRuntimeSettings(pcontext);
- geckoSession mTempSession = new geckoSession(new geckoViewClientCallback(), mSessionID, pcontext, pGeckoView);
- mTempSession.open(mRuntime);
- mTempSession.getSettings().setUseTrackingProtection(status.sStatusDoNotTrack);
- mTempSession.getSettings().setFullAccessibilityTree(true);
- mTempSession.getSettings().setUserAgentMode(USER_AGENT_MODE_MOBILE);
- mTempSession.getSettings().setAllowJavascript(status.sSettingJavaStatus);
- return mTempSession;
- }
-
- public void onDestroy() {
- mSession.onDestroy();
- mSession = null;
- mIconManager = null;
- event = null;
- }
-
- public GeckoRuntime getmRuntime() {
- return mRuntime;
- }
-
- public void onSessionReinit() {
- mSession.onSessionReinit();
- }
-
- public void toogleUserAgent() {
- mSession.toogleUserAgent();
- }
-
- public int getUserAgent() {
- return mSession.getUserAgentMode();
- }
-
-
- public String getAssetsCacheFile(Context context, String fileName) {
- File cacheFile = new File(context.getCacheDir(), fileName);
- try {
- try (InputStream inputStream = context.getAssets().open(fileName)) {
- try (FileOutputStream outputStream = new FileOutputStream(cacheFile)) {
- byte[] buf = new byte[1024];
- int len;
- while ((len = inputStream.read(buf)) > 0) {
- outputStream.write(buf, 0, len);
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
+ public void onSaveCurrentTab(boolean isHardCopy) {
+ int mStatus = (Integer) dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_ADD_TAB, Arrays.asList(mSession, isHardCopy));
+ if (mStatus == enums.AddTabCallback.TAB_FULL) {
+ pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), M_MAX_TAB_REACHED);
}
+ }
- String mYAML = helperMethod.readFromFile(cacheFile.getPath());
- if (status.sTorBrowsing) {
- mYAML = mYAML.replace("# network.proxy.socks: \"127.0.0.1\"", "network.proxy.socks: \"127.0.0.1\"");
- mYAML = mYAML.replace("# network.proxy.socks_port: 9050", "network.proxy.socks_port: 9050");
- mYAML = mYAML.replace("browser.cache.memory.enable: true", "browser.cache.memory.enable: false");
-
- StringBuilder buf = new StringBuilder(mYAML);
- int portIndex = mYAML.indexOf("network.proxy.socks_port");
- int breakIndex = mYAML.indexOf("\n", portIndex);
- mYAML = buf.replace(portIndex, breakIndex, "network.proxy.socks_port: " + orbotLocalConstants.mSOCKSPort).toString();
- helperMethod.writeToFile(cacheFile.getPath(), mYAML);
+ public void initRestore(geckoView mNestedGeckoView, AppCompatActivity pcontext) {
+ boolean mState = mSession.onRestoreState();
+ if (!mState) {
+ mSession.stop();
+ loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
} else {
- mYAML = mYAML.replace("browser.cache.memory.enable: true", "browser.cache.memory.enable: false");
- helperMethod.writeToFile(cacheFile.getPath(), mYAML);
+ String mURL = mSession.getCurrentURL();
+ if (mURL.equals("http://167.86.99.31") || mURL.startsWith(CONST_GENESIS_URL_CACHED) || mURL.startsWith(CONST_GENESIS_URL_CACHED_DARK)) {
+ if (!mSession.getNavigationDelegate().canGoBack()) {
+ mNestedGeckoView.releaseSession();
+ mSession.close();
+ mSession.open(mRuntime);
+ mNestedGeckoView.setSession(mSession);
+ } else {
+ mSession.goBack();
+ }
+ loadURL("http://167.86.99.31", mNestedGeckoView, pcontext);
+ }
}
-
- return cacheFile.getAbsolutePath();
}
-
@SuppressLint("WrongConstant")
public void initRuntimeSettings(AppCompatActivity context) {
if (mRuntime == null) {
GeckoRuntimeSettings.Builder mSettings = new GeckoRuntimeSettings.Builder();
if (status.sShowImages == 2) {
- mSettings.configFilePath(getAssetsCacheFile(context, "geckoview-config-noimage.yaml"));
+ mSettings.configFilePath(helperMethod.getAssetsCacheFile(context, "geckoview-config-noimage.yaml"));
} else {
- mSettings.configFilePath(getAssetsCacheFile(context, "geckoview-config.yaml"));
+ mSettings.configFilePath(helperMethod.getAssetsCacheFile(context, "geckoview-config.yaml"));
}
mSettings.build();
+ onClearAll();
mRuntime = GeckoRuntime.create(context, mSettings.build());
-
- //mCreated = true;
- onClearAll();
mRuntime.getSettings().setAboutConfigEnabled(true);
mRuntime.getSettings().setAutomaticFontSizeAdjustment(false);
mRuntime.getSettings().setWebFontsEnabled(status.sShowWebFonts);
@@ -229,109 +149,36 @@ public class geckoClients {
}
dataController.getInstance().initializeListData();
- //installExtension();
}
- initBrowserManager(context);
+ initializeIcon(context);
}
- public void initBrowserManager(Context pcontext) {
- if (mIconManager == null) {
- mIconManager = new BrowserIconManager();
- mIconManager.init(pcontext, mRuntime);
+ public void onReload(geckoView mNestedGeckoView, AppCompatActivity pcontext, boolean isThemeCall, boolean isDelayed) {
+ int mDelay = 1000;
+ if(!isDelayed){
+ mDelay = 0;
}
- }
-
-
- public void onGetFavIcon(ImageView pImageView, String pURL, AppCompatActivity pcontext) {
- if(status.sLowMemory != enums.MemoryStatus.CRITICAL_MEMORY && status.sLowMemory != enums.MemoryStatus.LOW_MEMORY){
- initBrowserManager(pcontext);
- pURL = helperMethod.completeURL(helperMethod.getDomainName(pURL));
- Log.i("FUCKSSS1111","111");
- mIconManager.onLoadIconIntoView(pImageView, pURL);
- Log.i("FUCKSSS1111","222");
- }
- }
-
- public void onLoadFavIcon(AppCompatActivity pcontext) {
- if (mRuntime != null) {
- if(status.sLowMemory != enums.MemoryStatus.CRITICAL_MEMORY){
- //BrowserIconManager mIconManager = new BrowserIconManager();
- ///mIconManager.onLoadIcon(pcontext, mRuntime);
+ new Handler().postDelayed(() ->
+ { if(mSession != null){
+ mSession.stop();
+ String url = mSession.getCurrentURL();
+ if (url.startsWith("http://167.86.99.31/?pG") || url.startsWith("https://167.86.99.31?pG") || url.endsWith("167.86.99.31") || url.contains(constants.CONST_GENESIS_HELP_URL_SUB) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE_DARK)) {
+ loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
+ } else if (!isThemeCall) {
+ mSession.reload();
}
}
+ }, mDelay);
}
- private int getCookiesBehaviour() {
- return status.sSettingCookieStatus;
+ public void onLoadTab(geckoSession pSession, GeckoView geckoView) {
+ mSession = pSession;
+ geckoView.releaseSession();
+ geckoView.setSession(pSession);
+ mSessionID = pSession.getSessionID();
}
- @SuppressLint("WrongConstant")
- public void updateSetting(NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext) {
-
- }
-
- public void resetSession() {
- mSessionID = strings.GENERIC_EMPTY_STR;
- }
-
- public void onKillMedia(){
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.DESTROY);
- }
-
- public void onPlayMedia(){
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.PLAY);
- }
-
- public void onPauseMedia(){
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.PAUSE);
- }
-
- public void onSkipForwardMedia(){
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.SKIP_FORWARD);
- }
- public void onSkipBackwardMedia(){
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.SKIP_BACKWARD);
- }
-
-
- public String getTheme() {
- if (mSessionID.equals(strings.GENERIC_EMPTY_STR)) {
- return null;
- } else if (mSession != null && mSession.getTheme() != null) {
- return mSession.getTheme();
- } else {
- return null;
- }
- }
-
- public void initSession(geckoSession mSession) {
- mSessionID = mSession.getSessionID();
- this.mSession = mSession;
- }
-
- public geckoSession getSession() {
- return mSession;
- }
-
- public void onStopMedia() {
- mSession.getMediaSessionDelegate().onTrigger(enums.MediaController.STOP);
- }
-
- public void onUploadRequest(int resultCode, Intent data) {
- mSession.onFileUploadRequest(resultCode, data);
- }
-
- public void setLoading(boolean status) {
- mSession.setLoading(status);
- }
-
-
- public void initURL(String url) {
- mSession.initURL(url);
- }
-
- public void loadURL(String url, NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext) {
-
+ public void loadURL(String url, geckoView mNestedGeckoView, AppCompatActivity pcontext) {
if (url.startsWith("https://orion.onion/privacy")) {
url = CONST_PRIVACY_POLICY_URL_NON_TOR;
@@ -341,62 +188,124 @@ public class geckoClients {
}
url = helperMethod.completeURL(url);
- //geckoSession mSessionTemp = (geckoSession) mNestedGeckoView.getSession();
- //if (mSessionTemp != null) {
- // return;
- //}
-
Log.i("FERROR : ", "FERROR" + url);
- if (mSession.onGetInitializeFromStartup()) {
- mSession.initURL(url);
- if (!url.startsWith(CONST_REPORT_URL) && (url.startsWith("resource://android/assets/homepage/") || url.startsWith("http://167.86.99.31/?pG") || url.startsWith("https://167.86.99.31?pG") || url.endsWith("167.86.99.31") || url.endsWith(constants.CONST_GENESIS_DOMAIN_URL_SLASHED))) {
- try {
- mSession.initURL(constants.CONST_GENESIS_DOMAIN_URL);
- if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(pcontext)) {
- String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
- mSession.getSettings().setAllowJavascript(true);
- mSession.initURL(mURL);
+ mSession.initURL(url);
+ if (!url.startsWith(CONST_REPORT_URL) && (url.startsWith("resource://android/assets/homepage/") || url.startsWith("http://167.86.99.31/?pG") || url.startsWith("https://167.86.99.31?pG") || url.endsWith("167.86.99.31") || url.endsWith(constants.CONST_GENESIS_DOMAIN_URL_SLASHED))) {
+ try {
+ mSession.initURL(constants.CONST_GENESIS_DOMAIN_URL);
+ if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(pcontext)) {
+ String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.initURL(mURL);
- mSession.stop();
- mSession.loadUri(mURL);
- } else {
- String mURL = constants.CONST_GENESIS_URL_CACHED_DARK + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
- mSession.getSettings().setAllowJavascript(true);
- mSession.loadUri(mURL);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
+ mSession.stop();
+ mSession.loadUri(mURL);
+ } else {
+ String mURL = constants.CONST_GENESIS_URL_CACHED_DARK + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.loadUri(mURL);
}
- } else if (url.contains(constants.CONST_GENESIS_HELP_URL_SUB) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE_DARK)) {
- try {
- mSession.initURL(constants.CONST_GENESIS_HELP_URL);
-
- if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(pcontext)) {
- mSession.getSettings().setAllowJavascript(true);
- mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE);
- } else {
- mSession.getSettings().setAllowJavascript(true);
- mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE_DARK);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- } else {
- mSession.getSettings().setAllowJavascript(status.sSettingJavaStatus);
- mSession.loadUri(url);
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
+ } else if (url.contains(constants.CONST_GENESIS_HELP_URL_SUB) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE_DARK)) {
+ try {
+ mSession.initURL(constants.CONST_GENESIS_HELP_URL);
+
+ if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(pcontext)) {
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE);
+ } else {
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.loadUri(constants.CONST_GENESIS_HELP_URL_CACHE_DARK);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ mSession.getSettings().setAllowJavascript(status.sSettingJavaStatus);
+ mSession.loadUri(url);
}
}
- public void onRedrawPixel(AppCompatActivity pcontext) {
+ public void initHomeTheme() {
+ String mURLFinal;
+ mSession.initURL(constants.CONST_GENESIS_DOMAIN_URL);
+ if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(activityContextManager.getInstance().getHomeController())) {
+ String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.initURL(mURL);
+ mURLFinal = mURL;
+ } else {
+ String mURL = constants.CONST_GENESIS_URL_CACHED_DARK + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
+ mSession.getSettings().setAllowJavascript(true);
+ mSession.initURL(mURL);
+ mURLFinal = mURL;
+ }
+
+ if (!mSession.getNavigationDelegate().canGoBack()) {
+ activityContextManager.getInstance().getHomeController().getGeckoView().releaseSession();
+ mSession.close();
+ mSession.open(mRuntime);
+ activityContextManager.getInstance().getHomeController().getGeckoView().setSession(mSession);
+ } else {
+ mSession.goBack();
+ }
+
+ new Handler().postDelayed(() ->
+ {
+ if (!mSession.getNavigationDelegate().canGoBack()) {
+ mSession.close();
+ activityContextManager.getInstance().getHomeController().getGeckoView().releaseSession();
+ mSession.open(mRuntime);
+ activityContextManager.getInstance().getHomeController().getGeckoView().setSession(mSession);
+ }
+
+ mSession.loadUri(mURLFinal);
+
+ }, 10);
+
+ }
+
+ /*Helper Classes*/
+
+
+ public void toggleUserAgent() {
+ mSession.toggleUserAgent();
+ }
+
+ public int getUserAgent() {
+ return mSession.getUserAgentMode();
+ }
+
+ public void onGetFavIcon(ImageView pImageView, String pURL, AppCompatActivity pcontext) {
if(status.sLowMemory != enums.MemoryStatus.CRITICAL_MEMORY && status.sLowMemory != enums.MemoryStatus.LOW_MEMORY){
- mSession.onRedrawPixel();
- onLoadFavIcon(pcontext);
+ initializeIcon(pcontext);
+ pURL = helperMethod.completeURL(helperMethod.getDomainName(pURL));
+ mIconManager.onLoadIconIntoView(pImageView, pURL);
}
}
- public boolean isLoaded() {
- return mSession.isLoaded();
+ private int getCookiesBehaviour() {
+ return status.sSettingCookieStatus;
+ }
+
+ public void resetSession() {
+ mSessionID = strings.GENERIC_EMPTY_STR;
+ }
+
+ public void onMediaInvoke(enums.MediaController mController){
+ mSession.getMediaSessionDelegate().onTrigger(mController);
+ }
+
+ public String getTheme() {
+ if (mSessionID.equals(strings.GENERIC_EMPTY_STR)) {
+ return null;
+ } else if (mSession != null && mSession.getTheme() != null) {
+ return mSession.getTheme();
+ } else {
+ return null;
+ }
}
public void onClearAll() {
@@ -440,93 +349,83 @@ public class geckoClients {
}
}
- public void onBackPressed(boolean isFinishAllowed, int mTabSize, NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext) {
- if (mSession.canGoBack()) {
+ public void onBackPressed(boolean isFinishAllowed, int mTabSize, geckoView mNestedGeckoView, AppCompatActivity pcontext) {
+ if (mSession.getNavigationDelegate().canGoBack()) {
mSession.goBackSession();
} else if (isFinishAllowed) {
- if (mSession.getRemovableFromBackPressed() && mTabSize > 1) {
- event.invokeObserver(null, enums.etype.M_CLOSE_TAB_BACK);
+ if (mSession.isRemovableFromBackPressed() && mTabSize > 1) {
+ mEvent.invokeObserver(null, homeEnums.eGeckoCallback.M_CLOSE_TAB_BACK);
} else {
- event.invokeObserver(null, enums.etype.back_list_empty);
+ mEvent.invokeObserver(null, homeEnums.eGeckoCallback.BACK_LIST_EMPTY);
}
}
}
public String getSecurityInfo() {
- return mSession.getSecurityInfo();
+ return mSession.getProgressDelegate().getSecurityInfo();
}
- public boolean wasPreviousErrorPage() {
- return mSession.wasPreviousErrorPage();
+ public void onUploadRequest(int resultCode, Intent data) {
+ mSession.getDownloadHandler().onFileUploadRequest(resultCode, data, mSession.getPromptDelegate());
}
public boolean canGoForward() {
- return mSession.canGoForward();
- }
-
- public boolean isLoading() {
- return mSession.isLoading();
+ return mSession.getNavigationDelegate().canGoForward();
}
public Uri getUriPermission() {
- return mSession.getUriPermission();
+ return mSession.getDownloadHandler().getUriPermission();
}
public boolean getFullScreenStatus() {
+ if(mSession==null){
+ return false;
+ }
return mSession.getContentDelegate().getFullScreenStatus();
}
public void onExitFullScreen() {
- mSession.exitScreen();
+ //mSession.exitScreen();
}
public void onForwardPressed() {
- if (mSession.canGoForward()) {
+ if (mSession.getNavigationDelegate().canGoForward()) {
mSession.goForwardSession();
}
}
- public void onClose() {
- onKillMedia();
- mSession.onClose();
- }
-
public void setRemovableFromBackPressed(boolean pStatus) {
mSession.setRemovableFromBackPressed(pStatus);
}
-
- public void onStop() {
- mSession.stop();
+ public void onUpdateFont() {
+ float font = (status.sSettingFontSize - 100) / 3 + 100;
+ mRuntime.getSettings().setFontSizeFactor(font / 117);
}
- public void onReload(NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext, boolean isThemeCall) {
- mSession.stop();
- String url = mSession.getCurrentURL();
- if (url.startsWith("http://167.86.99.31/?pG") || url.startsWith("https://167.86.99.31?pG") || url.endsWith("167.86.99.31") || url.contains(constants.CONST_GENESIS_HELP_URL_SUB) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE_DARK)) {
- loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
- } else if (!isThemeCall) {
- mSession.reload();
+ public int getScrollOffset() {
+ return mSession.getmScrollDelegate().getScrollOffset();
+ }
+
+ public void manualDownloadWithName(String url, String file, AppCompatActivity context) {
+ Uri downloadURL = Uri.parse(url);
+ if (helperMethod.checkPermissions(context)) {
+ mSession.getDownloadHandler().downloadRequestedFile(downloadURL, file);
}
}
- public void onReloadDelay(NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext, boolean isThemeCall) {
- new Handler().postDelayed(() ->
- { if(mSession != null){
- mSession.stop();
- String url = mSession.getCurrentURL();
- if (url.startsWith("http://167.86.99.31/?pG") || url.startsWith("https://167.86.99.31?pG") || url.endsWith("167.86.99.31") || url.contains(constants.CONST_GENESIS_HELP_URL_SUB) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE) || url.contains(constants.CONST_GENESIS_HELP_URL_CACHE_DARK)) {
- loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
- } else if (!isThemeCall) {
- mSession.reload();
- }
- }
- }, 1000);
+ public void downloadFile(AppCompatActivity pcontext) {
+ if (helperMethod.checkPermissions(pcontext)) {
+ geckoDownloadManager mDownloadManager = mSession.getContentDelegate().getDownloadManager();
+ mSession.getDownloadHandler().downloadRequestedFile(mDownloadManager);
+ }
}
- public void onReloadStatic(NestedGeckoView mNestedGeckoView, AppCompatActivity pcontext) {
- ///mSession.stop();
- loadURL(mSession.getCurrentURL(), mNestedGeckoView, pcontext);
+ public void downloadFile(String mURL, AppCompatActivity pcontext) {
+ if (helperMethod.checkPermissions(pcontext)) {
+ geckoDownloadManager mDownloadManager = mSession.getContentDelegate().getDownloadManager();
+ mSession.getDownloadHandler().downloadRequestedFile(mDownloadManager);
+ }
}
public void manual_download(String url, AppCompatActivity context) {
@@ -535,112 +434,58 @@ public class geckoClients {
f.getName();
String downloadFile = f.getName();
- /*EXTERNAL STORAGE REQUEST*/
if (helperMethod.checkPermissions(context)) {
- mSession.downloadRequestedFile(downloadURL, downloadFile);
+ mSession.getDownloadHandler().downloadRequestedFile(downloadURL, downloadFile);
}
}
- public void manualDownloadWithName(String url, String file, AppCompatActivity context) {
- Uri downloadURL = Uri.parse(url);
- /*EXTERNAL STORAGE REQUEST*/
- if (helperMethod.checkPermissions(context)) {
- mSession.downloadRequestedFile(downloadURL, file);
- }
+ public void onClose() {
+ onMediaInvoke(enums.MediaController.DESTROY);
+ mSession.onClose();
}
- public void downloadFile(AppCompatActivity pcontext) {
- if (helperMethod.checkPermissions(pcontext)) {
- mSession.downloadRequestedFile();
- }
+ /*Private Rrturn*/
+
+ public GeckoRuntime getmRuntime() {
+ return mRuntime;
}
- public void downloadFile(String mURL, AppCompatActivity pcontext) {
- if (helperMethod.checkPermissions(pcontext)) {
- mSession.downloadRequestedFile();
- }
+ public geckoSession getSession() {
+ return mSession;
}
/*Session Updates*/
- public void onUpdateFont() {
- float font = (status.sSettingFontSize - 100) / 3 + 100;
- mRuntime.getSettings().setFontSizeFactor(font / 117);
- }
-
- public void reinitHomeTheme() {
- String mURLFinal;
- mSession.initURL(constants.CONST_GENESIS_DOMAIN_URL);
- if (status.sTheme == enums.Theme.THEME_LIGHT || helperMethod.isDayMode(activityContextManager.getInstance().getHomeController())) {
- String mURL = constants.CONST_GENESIS_URL_CACHED + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
- mSession.getSettings().setAllowJavascript(true);
- mSession.initURL(mURL);
- mURLFinal = mURL;
- } else {
- String mURL = constants.CONST_GENESIS_URL_CACHED_DARK + "?pData=" + dataController.getInstance().invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands.M_FETCH, null);
- mSession.getSettings().setAllowJavascript(true);
- mSession.initURL(mURL);
- mURLFinal = mURL;
- }
-
- if (!mSession.canGoBack()) {
- activityContextManager.getInstance().getHomeController().getGeckoView().releaseSession();
- mSession.close();
- mSession.open(mRuntime);
- activityContextManager.getInstance().getHomeController().getGeckoView().setSession(mSession);
- } else {
- mSession.goBack();
- }
-
- new Handler().postDelayed(() ->
- {
- if (!mSession.canGoBack()) {
- mSession.close();
- activityContextManager.getInstance().getHomeController().getGeckoView().releaseSession();
- mSession.open(mRuntime);
- activityContextManager.getInstance().getHomeController().getGeckoView().setSession(mSession);
- }
-
- mSession.loadUri(mURLFinal);
-
- }, 10);
-
- }
-
- public int getScrollOffset() {
- return mSession.getmScrollDelegate().getScrollOffset();
- }
-
public class geckoViewClientCallback implements eventObserver.eventListener {
@Override
public Object invokeObserver(List