From 84b3c33b8372e89d9c8d44a6e33aee024d64f192 Mon Sep 17 00:00:00 2001
From: Der_Googler <54764558+DerGoogler@users.noreply.github.com>
Date: Sun, 1 Sep 2024 20:08:09 +0200
Subject: [PATCH] add landing page for browser
---
package.json | 2 +-
src/activitys/LandingActivity.tsx | 349 ++++++++++++++++++++
src/activitys/MainActivity.tsx | 58 +++-
src/activitys/ModConfPlaygroundActivity.tsx | 4 +-
src/components/onsenui/RouterNavigator.tsx | 9 +-
src/hooks/useActivity.ts | 1 +
src/hooks/useSettings.tsx | 2 +
src/util/RouterUtil.js | 10 +-
8 files changed, 415 insertions(+), 20 deletions(-)
create mode 100644 src/activitys/LandingActivity.tsx
diff --git a/package.json b/package.json
index ddc736e6..56813630 100644
--- a/package.json
+++ b/package.json
@@ -87,7 +87,7 @@
"localforage": "^1.10.0",
"markdown-to-jsx": "^7.4.0",
"material-icons": "^1.10.8",
- "material-ui-confirm": "^3.0.11",
+ "material-ui-confirm": "^3.0.16",
"modfs": "^1.3.2",
"monaco-editor": "^0.48.0",
"monaco-editor-core": "^0.50.0",
diff --git a/src/activitys/LandingActivity.tsx b/src/activitys/LandingActivity.tsx
new file mode 100644
index 00000000..f6c6be91
--- /dev/null
+++ b/src/activitys/LandingActivity.tsx
@@ -0,0 +1,349 @@
+import { alpha, Box, Grid, Button, Divider, Typography, Stack, Card } from "@mui/material";
+import { Google, GitHub } from "@mui/icons-material";
+import { useTheme } from "@Hooks/useTheme";
+import { Image } from "@Components/dapi/Image";
+import { Anchor } from "@Components/dapi/Anchor";
+import React from "react";
+import { useConfirm } from "material-ui-confirm";
+import { Page } from "@Components/onsenui/Page";
+import { os } from "@Native/Os";
+import { useSettings } from "@Hooks/useSettings";
+import { useActivity } from "@Hooks/useActivity";
+import MainApplication from "./MainApplication";
+
+interface GridCardProps {
+ title?: string;
+ description?: string;
+}
+
+const GridCard = (props: GridCardProps) => {
+ const { theme } = useTheme();
+
+ return (
+
+
+ {props.title}
+ {props.description}
+
+
+ );
+};
+
+interface GridImageProps {
+ src?: string;
+}
+
+const GridImage = (props: GridImageProps) => {
+ const { theme } = useTheme();
+
+ return (
+
+
+
+
+
+ );
+};
+
+export const LandingActivity = () => {
+ const { theme } = useTheme();
+ const confirm = useConfirm();
+ const [landing, setLanding] = useSettings("landingEnabled");
+ const { context } = useActivity();
+
+ const acceptCallback = React.useCallback((callback) => {
+ confirm({
+ title: "Your privacy is more worth!",
+ description: (
+ <>
+ Please make sure to read our{" "}
+
+ Privacy Policy
+ {" "}
+ and{" "}
+
+ Terms of Service
+ {" "}
+ before you continue.
+ >
+ ),
+ acknowledgement: "Accept",
+ })
+ .then(callback)
+ .catch(() => {});
+ }, []);
+
+ return (
+
+
+
+
+ Magisk Module Repo Loader
+
+
+
+ Your highly customizable module manager
+
+
+
+
+
+
+ or
+
+ }
+ onClick={() => {
+ acceptCallback(() => {
+ os.openURL("https://play.google.com/store/apps/details?id=com.dergoogler.mmrl", "_mmrlOwn");
+ });
+ }}
+ >
+ GET IT ON GOOGLE PLAY
+
+ }
+ onClick={() => {
+ acceptCallback(() => {
+ os.openURL("https://github.com/DerGoogler/MMRL/releases", "_mmrlOwn");
+ });
+ }}
+ >
+ GET IT ON GITHUB
+
+
+
+
+
+ Screenshots
+
+
+
+
+ {Array.from(Array(7), (_, i) => i + 1).map((num) => (
+
+ ))}
+
+
+
+
+ Key Features
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ © {new Date().getUTCFullYear()} Der_Googler & Googlers Repo. All rights reserved.
+
+
+
+
+
+ Privacy Policy
+
+
+
+
+ Terms of Service
+
+
+
+
+
+ );
+};
diff --git a/src/activitys/MainActivity.tsx b/src/activitys/MainActivity.tsx
index 552b531a..1b8536d1 100644
--- a/src/activitys/MainActivity.tsx
+++ b/src/activitys/MainActivity.tsx
@@ -28,6 +28,7 @@ import { SuFile } from "@Native/SuFile";
import pkg from "@Package";
import { LogcatActivity } from "./LogcatActivity";
import UnverifiedHostActivity from "./UnverifiedHostActivity";
+import { LandingActivity } from "./LandingActivity";
const getLocation = () => {
if (window.location !== window.parent.location) {
@@ -39,27 +40,36 @@ const getLocation = () => {
}
};
-const CheckRoot = () => {
- if (pkg.config.verified_hosts.some((e) => new RegExp(e[0], e[1]).test(getLocation().hostname))) {
- if (os.isAndroid) {
- // Shell.isAppGrantedRoot() doesn't work on KSU
- if (Shell.isSuAvailable()) {
- return React.memo(MainApplication);
+const useCheckRoot = () => {
+ const [landing] = useSettings("landingEnabled");
+
+ return React.useMemo(() => {
+ if (pkg.config.verified_hosts.some((e) => new RegExp(e[0], e[1]).test(getLocation().hostname))) {
+ if (os.isAndroid) {
+ // Shell.isAppGrantedRoot() doesn't work on KSU
+ if (Shell.isSuAvailable()) {
+ return React.memo(MainApplication);
+ } else {
+ return React.memo(NoRootActivity);
+ }
} else {
- return React.memo(NoRootActivity);
+ if (landing) {
+ return React.memo(LandingActivity);
+ } else {
+ return React.memo(MainApplication);
+ }
}
} else {
- return React.memo(MainApplication);
+ return React.memo(UnverifiedHostActivity);
}
- } else {
- return React.memo(UnverifiedHostActivity);
- }
+ }, []);
};
const MainActivity = (): JSX.Element => {
const { strings } = useStrings();
const { theme } = useTheme();
const { modFS } = useModFS();
+ const InitialActivity = useCheckRoot();
const [isSplitterOpen, setIsSplitterOpen] = useState(false);
@@ -93,6 +103,7 @@ const MainActivity = (): JSX.Element => {
const pushContext = {
pushPage: (props: IntentPusher) => pushPage(props),
popPage: (options?: any) => popPage(options),
+ replacePage: (props: IntentPusher) => replacePage(props),
splitter: {
show: () => showSplitter(),
hide: () => hideSplitter(),
@@ -103,7 +114,7 @@ const MainActivity = (): JSX.Element => {
const ignoreThat = RouterUtil.init([
{
route: {
- component: CheckRoot(),
+ component: InitialActivity,
props: {
key: "main",
},
@@ -158,6 +169,29 @@ const MainActivity = (): JSX.Element => {
);
};
+ const replacePage = (props: IntentPusher): void => {
+ const route = {
+ component: !props.noMemo ? React.memo(props.component) : props.component,
+ props: {
+ key: props.key,
+ },
+ };
+
+ const options = {};
+
+ setRouteConfig((prev: any) =>
+ RouterUtil.replace({
+ routeConfig: prev,
+ route: route,
+ options: options,
+ key: props.key,
+ props: props.props,
+ context: pushContext,
+ extra: props.extra ? props.extra : {},
+ })
+ );
+ };
+
const onPostPush = () => {
setRouteConfig((prev: any) => RouterUtil.postPush(prev));
};
diff --git a/src/activitys/ModConfPlaygroundActivity.tsx b/src/activitys/ModConfPlaygroundActivity.tsx
index 4eb07e15..8c285f1b 100644
--- a/src/activitys/ModConfPlaygroundActivity.tsx
+++ b/src/activitys/ModConfPlaygroundActivity.tsx
@@ -171,7 +171,9 @@ const ModConfPlaygroundActivity = () => {
{strings("modconf_playground")}
- {!isLargeScreen && }
+
+
+
);
};
diff --git a/src/components/onsenui/RouterNavigator.tsx b/src/components/onsenui/RouterNavigator.tsx
index bedc57a8..f3199ad1 100644
--- a/src/components/onsenui/RouterNavigator.tsx
+++ b/src/components/onsenui/RouterNavigator.tsx
@@ -112,7 +112,7 @@ class RouterNavigatorClass extends React.Component {
return this.ref.current._isRunning;
}
- private replacePage(route: object, options = {}) {
+ private replacePage(route: object, options = {}, props = {}, context = {}, extra = {}) {
if (this.isRunning()) {
return;
}
@@ -120,14 +120,14 @@ class RouterNavigatorClass extends React.Component {
const update = () => {
return new Promise((resolve) => {
this.setState((prevState) => {
- return { internalStack: [...prevState.internalStack, { route: route }] };
+ return { internalStack: [...prevState.internalStack, { route: route, props: props, context: context, extra: extra }] };
}, resolve as Noop);
});
};
return this.ref.current._pushPage(options, update).then(() => {
this.setState((prevState) => {
- return { internalStack: [...prevState.internalStack.slice(0, -2), { route: route }] };
+ return { internalStack: [...prevState.internalStack.slice(0, -2), { route: route, props: props, context: context, extra: extra }] };
});
});
}
@@ -222,7 +222,7 @@ class RouterNavigatorClass extends React.Component {
}
break;
case "replace":
- this.replacePage(route, options);
+ this.replacePage(route, options, props, context, extra);
break;
default:
throw new Error(`Unknown type ${type} in processStack`);
@@ -247,6 +247,7 @@ class RouterNavigatorClass extends React.Component {
} = this.props;
const pagesToRender = this.state.internalStack.map((item) => {
+ console.log(item);
return (
diff --git a/src/hooks/useActivity.ts b/src/hooks/useActivity.ts
index b01ab2d4..47d1b8b5 100644
--- a/src/hooks/useActivity.ts
+++ b/src/hooks/useActivity.ts
@@ -18,6 +18,7 @@ export interface IntentPusher {
export interface ActivityContext {
readonly popPage: (options?: any) => void;
readonly pushPage: (props: IntentPusher) => void;
+ readonly replacePage: (props: IntentPusher) => void;
readonly splitter: {
readonly show: () => void;
readonly hide: () => void;
diff --git a/src/hooks/useSettings.tsx b/src/hooks/useSettings.tsx
index 379e2c0d..22edc9b5 100644
--- a/src/hooks/useSettings.tsx
+++ b/src/hooks/useSettings.tsx
@@ -8,6 +8,7 @@ export interface Picker {
}
export interface StorageDeclaration {
+ landingEnabled: boolean;
language: Picker;
eruda_console_enabled: boolean;
disabled_repos: string[];
@@ -39,6 +40,7 @@ export const useSettings = (key: K): [Storag
const INITIAL_SETTINGS = React.useMemo(
() => ({
+ landingEnabled: true,
language: availableLangs[0],
eruda_console_enabled: false,
disabled_repos: [],
diff --git a/src/util/RouterUtil.js b/src/util/RouterUtil.js
index 152d8940..3cc94e7e 100644
--- a/src/util/RouterUtil.js
+++ b/src/util/RouterUtil.js
@@ -15,7 +15,7 @@ export const RouterUtil = {
};
},
- replace: ({ routeConfig, route, options, key }) => {
+ replace: ({ routeConfig, route, options, key, props, context, extra }) => {
const config = { ...routeConfig };
const routeStack = [...config.routeStack];
let processStack = [...config.processStack];
@@ -26,6 +26,9 @@ export const RouterUtil = {
route,
options,
key,
+ props,
+ context,
+ extra,
};
processStack = [...processStack, process];
}
@@ -36,7 +39,7 @@ export const RouterUtil = {
};
},
- reset: ({ routeConfig, route, options, key }) => {
+ reset: ({ routeConfig, route, options, key, props, context, extra }) => {
const config = { ...routeConfig };
const routeStack = [...config.routeStack];
let processStack = [...config.processStack];
@@ -47,6 +50,9 @@ export const RouterUtil = {
route,
options,
key,
+ props,
+ context,
+ extra,
};
processStack = [...processStack, process];