Skip to content

Commit

Permalink
Some works
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Feb 22, 2024
1 parent d1fc711 commit 1571dda
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 104 deletions.
12 changes: 4 additions & 8 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<queries>
<package android:name="com.topjohnwu.magisk" />
Expand All @@ -24,14 +19,15 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme.SplashScreen"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="q">
<activity
android:name="com.dergoogler.mmrl.MainActivity"
android:configChanges="orientation|screenSize"
android:exported="true">
android:windowSoftInputMode="adjustResize"
android:exported="true"
tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
4 changes: 2 additions & 2 deletions Android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources>
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen.IconBackground">
<style name="AppTheme.SplashScreen" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_cdv_splashscreen</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
Expand Down
4 changes: 3 additions & 1 deletion Website/src/activitys/MainApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const MainApplication = () => {
}
}, [modules]);

const hasInstallTools = SuFile.exist(`${modFS("MMRLINI")}/module.prop`);

const renderTabs = (): TabbarRenderTab[] => {
return [
{
Expand All @@ -72,7 +74,7 @@ const MainApplication = () => {
modules={localModules}
renderItem={(module, key) => <DeviceModule key={key} module={module} />}
renderFixed={() => {
if (os.isAndroid && (Shell.isMagiskSU() || Shell.isKernelSU() || Shell.isAPatchSU())) {
if (os.isAndroid && (Shell.isMagiskSU() || Shell.isKernelSU() || Shell.isAPatchSU()) && hasInstallTools) {
return (
<Fab
sx={{
Expand Down
27 changes: 6 additions & 21 deletions Website/src/activitys/ModuleViewActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import Tooltip from "@mui/material/Tooltip";
import { view } from "@Native/View";
import AntiFeatureListItem from "@Components/AntiFeatureListItem";
import FetchTextActivity from "./FetchTextActivity";
import { Image } from "@Components/dapi/Image";
import { useModFS } from "@Hooks/useModFS";

function a11yProps(index: number) {
return {
Expand Down Expand Up @@ -156,8 +158,10 @@ const ModuleViewActivity = () => {
);
};

const { modFS } = useModFS();
const [value, setValue] = React.useState(0);
const [isNameVisible, setIsNameVisible] = React.useState(true);
const hasInstallTools = SuFile.exist(`${modFS("MMRLINI")}/module.prop`);

const handleChange = (event: React.SyntheticEvent, newValue: number) => {
setValue(newValue);
Expand Down Expand Up @@ -287,7 +291,7 @@ const ModuleViewActivity = () => {
</Typography>

<Stack direction="row" justifyContent="center" alignItems="center" spacing={1}>
{os.isAndroid && (Shell.isMagiskSU() || Shell.isKernelSU() || Shell.isAPatchSU()) && (
{os.isAndroid && (Shell.isMagiskSU() || Shell.isKernelSU() || Shell.isAPatchSU()) && hasInstallTools && (
<Button
color="secondary"
sx={{
Expand Down Expand Up @@ -538,26 +542,7 @@ const ModuleViewActivity = () => {
mr: 1,
})}
>
<Box
component="img"
src={image}
sx={(theme) => ({
":hover": {
cursor: "pointer",
},
border: `1px solid ${theme.palette.divider} !important`,
borderRadius: theme.shape.borderRadius / theme.shape.borderRadius,
})}
onClick={() => {
context.pushPage({
component: PicturePreviewActivity,
key: "PicturePreviewActivity",
extra: {
picture: image,
},
});
}}
/>
<Box component={Image} src={image} />
</ImageListItem>
))}
</ImageList>
Expand Down
20 changes: 18 additions & 2 deletions Website/src/activitys/fragments/ModuleFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Button from "@mui/material/Button";
import Menu, { MenuProps } from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
import VolunteerActivismIcon from "@mui/icons-material/VolunteerActivism";
import { os } from "@Native/Os";

const RenderWhenEmpty = React.memo(() => {
const { theme } = useTheme();
Expand Down Expand Up @@ -80,7 +82,7 @@ const StyledMenu = styled((props: MenuProps) => (

const ModuleFragment = React.memo<ModuleFragmentProps>((props) => {
const { isNetworkAvailable } = useNetwork();

const { theme } = useTheme();
const renderItem = React.useCallback<renderFunc<Module>>((m, k) => props.renderItem(m, k), []);
const [filter, _filter, setFilter] = useModuleFilter(`${props.id}_filter`);

Expand All @@ -105,7 +107,21 @@ const ModuleFragment = React.memo<ModuleFragmentProps>((props) => {
return (
<Page renderFixed={props.renderFixed}>
<Page.RelativeContent>
<Stack direction="row" justifyContent="flex-end" alignItems="center" spacing={1}>
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={1}>
<Button
onClick={() => {
os.open("https://github.com/sponsors/DerGoogler", {
target: "_blank",
features: {
color: theme.palette.background.default,
},
});
}}
variant="outlined"
endIcon={<VolunteerActivismIcon />}
>
Sponsor
</Button>
<Button
id="demo-customized-button"
aria-controls={open ? "demo-customized-menu" : undefined}
Expand Down
60 changes: 1 addition & 59 deletions Website/src/components/ConfigureView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ModFS, useModFS } from "@Hooks/useModFS";
import ini from "ini";
import yaml from "yaml";
import { useLog } from "@Hooks/native/useLog";
import { extname } from "@Util/extname";

function plugin({ types: t }): PluginObj {
return {
Expand Down Expand Up @@ -161,62 +162,3 @@ export const ConfigureView = React.forwardRef<any, { children: string; modid: st
);
}
});

const CHAR_FORWARD_SLASH = 47; /* / */
const CHAR_DOT = 46; /* . */

function extname(path: string) {
if (typeof path !== "string") {
throw new TypeError(`The "path" argument must be of type string. Received type ${typeof path}`);
}

let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
let preDotState = 0;
for (let i = path.length - 1; i >= 0; --i) {
let code = path.charCodeAt(i);
if (code === CHAR_FORWARD_SLASH) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash = false;
end = i + 1;
}
if (code === CHAR_DOT) {
// If this is our first dot, mark it as the start of our extension
if (startDot === -1) {
startDot = i;
} else if (preDotState !== 1) {
preDotState = 1;
}
} else if (startDot !== -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState = -1;
}
}

if (
startDot === -1 ||
end === -1 ||
// We saw a non-dot character immediately before the dot
preDotState === 0 ||
// The (right-most) trimmed path component is exactly '..'
(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
) {
return "";
}
return path.slice(startDot, end);
}
2 changes: 2 additions & 0 deletions Website/src/components/ConfigureView/libs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Video from "@Components/dapi/Video";
import { Image } from "@Components/dapi/Image";
import Anchor from "@Components/dapi/Anchor";
import { DiscordWidget } from "@Components/dapi/DiscordWidget";
import { BottomToolbar } from "@Components/onsenui/BottomToolbar";
Expand Down Expand Up @@ -64,6 +65,7 @@ export const libraries = [
Video: Video,
DiscordWidget: DiscordWidget,
Markdown: Markdown,
Image: Image,
Ansi: Ansi,
},
},
Expand Down
6 changes: 3 additions & 3 deletions Website/src/hooks/useModFS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const INITIAL_MOD_CONF: ModFS = {
// others
MMRLINI: "<MODULES>/mmrl_install_tools",
CONFCWD: "<MODULECWD>/system/usr/share/mmrl/config/<MODID>",
EXPLORE_INSTALL: "<INCLUDECORE>; bb wget -O $NAME.zip $URL -nc && install_cli \"$NAME.zip\"",
LOCAL_INSTALL: "<INCLUDECORE>; install_cli \"$ZIPFILE\";",
EXPLORE_INSTALL: "<MMRLINI>/system/usr/share/mmrl/bin/mmrl_explore_install_v6",
LOCAL_INSTALL: "<MMRLINI>/system/usr/share/mmrl/bin/mmrl_local_install_v6",
CONFINDEX: "<CONFCWD>/index.jsx",
};

Expand All @@ -108,7 +108,7 @@ export const useModFS = () => {
};

export const ModFSProvider = (props: React.PropsWithChildren) => {
const [modFS, setModFS] = useNativeFileStorage("/data/adb/mmrl/modfs.v1.json", INITIAL_MOD_CONF);
const [modFS, setModFS] = useNativeFileStorage("/data/adb/mmrl/modfs.v6.json", INITIAL_MOD_CONF);

const contextValue = React.useMemo(
() => ({
Expand Down
23 changes: 15 additions & 8 deletions Website/src/hooks/useTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,22 @@ const THIS_IS_THE_THEME_OBJECT_OF_THIS_F_APP = createTheme({
},
MuiButton: {
styleOverrides: {
root: {
color: "black",
":disabled": {
cursor: "not-allowed",
root: ({ theme, ownerState }) => ({
...(ownerState.variant === "outlined" && {
color: "white",
border: `1px solid ${theme.palette.divider}`,
boxShadow: "none",
}),
...(ownerState.variant === "contained" && {
color: "black",
opacity: ".3",
backgroundColor: "#ffffff",
},
},
":disabled": {
cursor: "not-allowed",
color: "black",
opacity: ".3",
backgroundColor: "#ffffff",
},
}),
}),
},
defaultProps: {
disableElevation: true,
Expand Down
58 changes: 58 additions & 0 deletions Website/src/util/extname.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const CHAR_FORWARD_SLASH = 47; /* / */
const CHAR_DOT = 46; /* . */

export function extname(path: string) {
if (typeof path !== "string") {
throw new TypeError(`The "path" argument must be of type string. Received type ${typeof path}`);
}

let startDot = -1;
let startPart = 0;
let end = -1;
let matchedSlash = true;
// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
let preDotState = 0;
for (let i = path.length - 1; i >= 0; --i) {
let code = path.charCodeAt(i);
if (code === CHAR_FORWARD_SLASH) {
// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if (!matchedSlash) {
startPart = i + 1;
break;
}
continue;
}
if (end === -1) {
// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash = false;
end = i + 1;
}
if (code === CHAR_DOT) {
// If this is our first dot, mark it as the start of our extension
if (startDot === -1) {
startDot = i;
} else if (preDotState !== 1) {
preDotState = 1;
}
} else if (startDot !== -1) {
// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState = -1;
}
}

if (
startDot === -1 ||
end === -1 ||
// We saw a non-dot character immediately before the dot
preDotState === 0 ||
// The (right-most) trimmed path component is exactly '..'
(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
) {
return "";
}
return path.slice(startDot, end);
}

0 comments on commit 1571dda

Please sign in to comment.