Skip to content

Commit

Permalink
improve modconf
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Jan 27, 2024
1 parent d2d6db8 commit 7435889
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 23 deletions.
101 changes: 82 additions & 19 deletions Website/src/activitys/ModConfActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alert, Box, Divider, List, ListSubheader } from "@mui/material";
import { Alert, Box, Divider, List, ListSubheader, Stack, Typography } from "@mui/material";
import AvatarGroup from "@mui/material/AvatarGroup";
import Avatar from "@mui/material/Avatar";
import { Toolbar } from "@Components/onsenui/Toolbar";
Expand All @@ -9,6 +9,7 @@ import { StyledListItemText } from "@Components/StyledListItemText";
import { Shell } from "@Native/Shell";
import { DialogEditTextListItem } from "@Components/DialogEditTextListItem";
import React from "react";
import Anchor from "@Components/dapi/Anchor";

interface ModConfSections {
sectionText: string;
Expand All @@ -18,6 +19,7 @@ interface ModConfSections {
interface ModConfListItem<K extends keyof ModConf> {
confKey: K;
text: string;
dialogDesc?: React.ReactNode;
/**
* Used for the config requirement
*/
Expand Down Expand Up @@ -177,14 +179,68 @@ function ModConfActivity() {
},
],
},
{
sectionText: "Others",
items: [
{
text: "MMRL Install Tools",
confKey: "MMRLINI",
},
{
text: "Config working directory",
confKey: "CONFCWD",
},
{
text: "Config index file",
confKey: "CONFINDEX",
},
{
text: "Explore install script",
dialogDesc: (
<>
<Typography>
Check the{" "}
<Anchor href="https://github.com/DerGoogler/MMRL/tree/master/docs" noIcon>
documentations
</Anchor>{" "}
for possible workarounds!<br />{"<URL> and <MODID> can also be used, "} shell supported.
</Typography>
</>
),
confKey: "EXPLORE_INSTALL",
},
{
text: "Local install script",
dialogDesc: (
<>
<Typography>
Check the{" "}
<Anchor href="https://github.com/DerGoogler/MMRL/tree/master/docs" noIcon>
documentations
</Anchor>{" "}
for possible workarounds!<br />{"<ZIPFILE> can also be used, "} shell supported.
</Typography>
</>
),
confKey: "LOCAL_INSTALL",
},
],
},
],
[]
);

return (
<Page renderToolbar={renderToolbar}>
<Page.RelativeContent zeroMargin>
<Alert sx={{ m: { xs: 1, md: 1 } }} severity="error">
<Page.RelativeContent
zeroMargin
sx={{
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
}}
>
<Alert sx={{ m: { xs: 1, md: 1 }, whiteSpace: "normal" }} severity="error">
I am not responsible for anything that may happen to your phone by changing these informations. You do it at your own risk and
take the responsibility upon yourself and you are not to blame us or MMRL and its respected developers
</Alert>
Expand All @@ -202,6 +258,7 @@ function ModConfActivity() {
type="text"
title={item.text}
disabled={item.disabled}
description={item.dialogDesc}
initialValue={_modConf[item.confKey]}
onSuccess={(value) => {
if (value) {
Expand All @@ -211,22 +268,28 @@ function ModConfActivity() {
>
<StyledListItemText
primary={
<Box sx={{ display: "flex", alignItems: "center", justifyItems: "center" }}>
{item.logoText && Array.isArray(item.logoText) ? (
<>
<AvatarGroup sx={{ mr: 1 }}>
{item.logoText.map((logo) => (
<Avatar sx={{ borderRadius: "unset", width: "1rem", height: "1rem" }} src={logo} />
))}
</AvatarGroup>
</>
) : (
item.logoText && (
<Avatar sx={{ borderRadius: "unset", mr: 1, width: "1rem", height: "1rem" }} src={item.logoText} />
)
)}
[{item.confKey}]: {item.text}
</Box>
<Stack direction="column" justifyContent="center" alignItems="flex-start" spacing={0}>
<Typography variant="caption">{`<${item.confKey}>`}</Typography>
<Typography sx={{ fontSize: "unset" }}>
{" "}
<Box sx={{ display: "flex", alignItems: "center", justifyItems: "center", whiteSpace: "normal" }}>
{item.logoText && Array.isArray(item.logoText) ? (
<>
<AvatarGroup sx={{ mr: 1 }}>
{item.logoText.map((logo) => (
<Avatar sx={{ borderRadius: "unset", width: "1rem", height: "1rem" }} src={logo} />
))}
</AvatarGroup>
</>
) : (
item.logoText && (
<Avatar sx={{ borderRadius: "unset", mr: 1, width: "1rem", height: "1rem" }} src={item.logoText} />
)
)}
{item.text}
</Box>
</Typography>
</Stack>
}
secondary={_modConf[item.confKey]}
/>
Expand Down
9 changes: 7 additions & 2 deletions Website/src/activitys/TerminalActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const TerminalActivity = () => {
};

Terminal.exec({
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_explore_install_v4`,
command: modConf("EXPLORE_INSTALL", {
URL: path,
}),
env: envp_explore,
onLine: (line) => {
addLine(line);
Expand All @@ -101,7 +103,10 @@ const TerminalActivity = () => {
};

Terminal.exec({
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_local_install_v4`,
command: modConf("LOCAL_INSTALL", {
ZIPFILE: path,
MODID: id,
}),
env: envp_local,
onLine: (line) => {
addLine(line);
Expand Down
4 changes: 2 additions & 2 deletions Website/src/components/DialogEditTextListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface DialogEditTextListItemProps extends React.PropsWithChildren {
title: string;
disabled?: boolean;
initialValue: string;
description?: string;
description?: React.ReactNode;
type?: React.HTMLInputTypeAttribute;
onSuccess: (value: string) => void;
InputProps?: Partial<InputBaseProps>;
Expand Down Expand Up @@ -50,7 +50,7 @@ export const DialogEditTextListItem = (props: DialogEditTextListItemProps) => {
<ListItemButton disabled={props.disabled} onClick={handleClickOpen}>
{props.children}
</ListItemButton>
<Dialog open={open} onClose={handleClose}>
<Dialog open={open} maxWidth="md" fullWidth onClose={handleClose}>
<DialogTitle>{props.title}</DialogTitle>
<DialogContent>
{props.description && <DialogContentText>{props.description}</DialogContentText>}
Expand Down
4 changes: 4 additions & 0 deletions Website/src/hooks/useModConf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export interface ModConf {

// others
MMRLINI: string;
EXPLORE_INSTALL: string;
LOCAL_INSTALL: string;
CONFCWD: string;
CONFINDEX: string;
}
Expand Down Expand Up @@ -79,6 +81,8 @@ export const INITIAL_MOD_CONF: ModConf = {
// others
MMRLINI: "<MODULES>/mmrl_install_tools",
CONFCWD: "<MODULECWD>/system/usr/share/mmrl/config/<MODID>",
EXPLORE_INSTALL: "<MMRLINI>/system/usr/share/mmrl/bin/mmrl_explore_install_v5",
LOCAL_INSTALL: "<MMRLINI>/system/usr/share/mmrl/bin/mmrl_local_install_v5",
CONFINDEX: "<CONFCWD>/index.jsx",
};

Expand Down
33 changes: 33 additions & 0 deletions docs/ModConf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ModConf

TODO

## Workarounds

Here are some samples to avoid some configs

## Avoid MMRL Install Tools

This workaroud is for people who don't wanna install a extra module for installing other modules

Based on your selected root method

| Root method | CLI | Busybox |
| ----------- | ---------- | ---------- |
| Magisk | `<MSUCLI>` | `<MSUBSU>` |
| KernelSU | `<KSUCLI>` | `<KSUBSU>` |
| APatch | `<ASUCLI>` | `<ASUBSU>` |

### Local install script

```shell
<MSUCLI> --install-module "<ZIPFILE>"
```

> We use magisk as example. KernelSU or APatch is `<KSUCLI> module install "<ZIPFILE>"`
### Explore install script

```shell
FILE="/data/local/tmp/<MODID>.zip"; <MSUBSU> wget "<URL>" -O $FILE; <MSUCLI> --install-module $FILE;
```

0 comments on commit 7435889

Please sign in to comment.