Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移植 澪Ultimate 隐藏主题 #811

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Make sure that the shell files use LF
FCL/src/main/assets/fcl_shell/** text=auto eol=lf
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions FCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ android {
versionName "1.2.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions{
ignoreAssets "!.svn:!.git:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
}
}

buildTypes {
Expand Down
6 changes: 6 additions & 0 deletions FCL/src/main/assets/fcl_shell/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/system/bin/sh
export FCL_PATH_SHELL="$(dirname "$(readlink -f "${0}")")/cmd_tools"
export FCL_PATH_INTERNAL="${HOME}"
chmod +x "${FCL_PATH_SHELL}/bin/"*
export PATH="${FCL_PATH_SHELL}/bin":${PATH}
. ${FCL_PATH_SHELL}/init.sh
7 changes: 7 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/bin/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/system/bin/sh
${fclshell_load_lang} hello
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "${lang_hello_help}"
else
echo "${lang_hello_welcome}"
fi
5 changes: 5 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/system/bin/sh
. "${FCL_PATH_SHELL}/lib/lang/init.sh"
export fclshell_load_lang=". ${FCL_PATH_SHELL}/lib/lang/load.sh"
. "${FCL_PATH_SHELL}/lib/hidden_theme/init.sh"
sh "${FCL_PATH_SHELL}/bin/hello"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/system/bin/sh
alias EnableHiddenTheme="sh \"${FCL_PATH_SHELL}/lib/hidden_theme/set.sh\""
23 changes: 23 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/lib/hidden_theme/set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/system/bin/sh
${fclshell_load_lang} hidden_theme

. "${FCL_PATH_SHELL}/lib/launcher_theme/load.sh"
export FCL_CONF_THEME_THEME_COLOR="2136981471"
export FCL_CONF_THEME_THEME_COLOR2="-32897"
export FCL_CONF_THEME_ANIMATION_SPEED="8"
export FCL_CONF_THEME_CLOSE_SKIN_MODEL="true"
export FCL_CONF_THEME_MODIFIED="true"
. "${FCL_PATH_SHELL}/lib/launcher_theme/set.sh"
. "${FCL_PATH_SHELL}/lib/launcher_theme/unload.sh"

rm -rf "${FCL_PATH_INTERNAL}/files/background" >"/dev/null" 2>&1
rm -rf "${FCL_PATH_INTERNAL}/files/cursor.png" >"/dev/null" 2>&1
rm -rf "${FCL_PATH_INTERNAL}/files/menu_icon.png" >"/dev/null" 2>&1
rm -rf "${FCL_PATH_INTERNAL}/files/menu_icon.gif" >"/dev/null" 2>&1
mkdir -p "${FCL_PATH_INTERNAL}/files/background"
cp -f "${FCL_PATH_SHELL}/res/hidden_theme/background.png" "${FCL_PATH_INTERNAL}/files/background/lt.png"
cp -f "${FCL_PATH_SHELL}/res/hidden_theme/background.png" "${FCL_PATH_INTERNAL}/files/background/dk.png"
cp -f "${FCL_PATH_SHELL}/res/hidden_theme/cursor.png" "${FCL_PATH_INTERNAL}/files/cursor.png"
cp -f "${FCL_PATH_SHELL}/res/hidden_theme/menu_icon.gif" "${FCL_PATH_INTERNAL}/files/menu_icon.gif"

echo "${lang_hidden_theme_enabled}"
26 changes: 26 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/lib/lang/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/system/bin/sh
if [[ -f "${FCL_PATH_INTERNAL}/shared_prefs/launcher.xml" ]]; then
fclLang="$(cat "${FCL_PATH_INTERNAL}/shared_prefs/launcher.xml" | grep "name=\"lang\"")"
fi
if [[ "${fclLang}" != "" ]]; then
fclLang=${fclLang/# <int name=\"lang\" value=\"/}
fclLang=${fclLang/%\" \/>/}
if [[ "${fclLang}" == "0" ]]; then
FCL_CONF_LANG="$(getprop persist.sys.locale )"
FCL_CONF_LANG="${FCL_CONF_LANG:0:2}"
elif [[ "${fclLang}" == "1" ]]; then
FCL_CONF_LANG="en"
elif [[ "${fclLang}" == "2" ]]; then
FCL_CONF_LANG="zh"
elif [[ "${fclLang}" == "3" ]]; then
FCL_CONF_LANG="ru"
elif [[ "${fclLang}" == "4" ]]; then
FCL_CONF_LANG="pt"
elif [[ "${fclLang}" == "3" ]]; then
FCL_CONF_LANG="fa"
fi
else
FCL_CONF_LANG="$(getprop persist.sys.locale )"
FCL_CONF_LANG="${FCL_CONF_LANG:0:2}"
fi
export FCL_CONF_LANG="${FCL_CONF_LANG}"
30 changes: 30 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/lib/lang/load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/system/bin/sh
target="$1"
fallback="$2"
lang="${FCL_CONF_LANG}"
lang_res="${FCL_PATH_SHELL}/res/lang"

if [[ "${fallback}" == "" ]]; then
fallback="en"
fi

if [[ $1 == "" ]]; then
if [[ -f "${lang_res}/${lang}.sh" ]]; then
. "${lang_res}/${lang}.sh"
else
. "${lang_res}/${fallback}.sh"
fi
elif [[ -d "${lang_res}/${target}" ]]; then
if [[ -f "${lang_res}/${target}/${lang}.sh" ]]; then
. "${lang_res}/${target}/${lang}.sh"
else
. "${lang_res}/${target}/${fallback}.sh"
fi
else
echo "error: invalid argument"
fi

unset target
unset fallback
unset lang
unset lang_res
67 changes: 67 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/lib/launcher_theme/load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/system/bin/sh
if [[ -f "${FCL_PATH_INTERNAL}/shared_prefs/theme.xml" ]]; then
theme_data="$(cat "${FCL_PATH_INTERNAL}/shared_prefs/theme.xml")"
fi

theme_color="$(echo -n "${theme_data}" | grep "<int name=\"theme_color\"")"
if [[ "${theme_color}" != "" ]]; then
theme_color=${theme_color/# <int name=\"theme_color\" value=\"/}
theme_color=${theme_color/%\" \/>/}
else
theme_color=""
fi

theme_color2="$(echo -n "${theme_data}" | grep "<int name=\"theme_color2\"")"
if [[ "${theme_color2}" != "" ]]; then
theme_color2=${theme_color2/# <int name=\"theme_color2\" value=\"/}
theme_color2=${theme_color2/%\" \/>/}
else
theme_color2=""
fi

animation_speed="$(echo -n "${theme_data}" | grep "<int name=\"animation_speed\"")"
if [[ "${animation_speed}" != "" ]]; then
animation_speed=${animation_speed/# <int name=\"animation_speed\" value=\"/}
animation_speed=${animation_speed/%\" \/>/}
else
animation_speed=""
fi

close_skin_model="$(echo -n "${theme_data}" | grep "<boolean name=\"close_skin_model\"")"
if [[ "${close_skin_model}" != "" ]]; then
close_skin_model=${close_skin_model/# <boolean name=\"close_skin_model\" value=\"/}
close_skin_model=${close_skin_model/%\" \/>/}
else
close_skin_model=""
fi

fullscreen="$(echo -n "${theme_data}" | grep "<boolean name=\"fullscreen\"")"
if [[ "${fullscreen}" != "" ]]; then
fullscreen=${fullscreen/# <boolean name=\"fullscreen\" value=\"/}
fullscreen=${fullscreen/%\" \/>/}
else
fullscreen=""
fi

modified="$(echo -n "${theme_data}" | grep "<boolean name=\"modified\"")"
if [[ "${modified}" != "" ]]; then
modified=${modified/# <boolean name=\"modified\" value=\"/}
modified=${modified/%\" \/>/}
else
modified=""
fi

export FCL_CONF_THEME_THEME_COLOR="${theme_color}"
export FCL_CONF_THEME_THEME_COLOR2="${theme_color2}"
export FCL_CONF_THEME_ANIMATION_SPEED="${animation_speed}"
export FCL_CONF_THEME_CLOSE_SKIN_MODEL="${close_skin_model}"
export FCL_CONF_THEME_FULLSCREEN="${fullscreen}"
export FCL_CONF_THEME_MODIFIED="${modified}"

unset theme_data
unset theme_color
unset theme_color2
unset animation_speed
unset close_skin_model
unset fullscreen
unset modified
69 changes: 69 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/lib/launcher_theme/set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/system/bin/sh
theme_file="${FCL_PATH_INTERNAL}/shared_prefs/theme.xml"

theme_begin="<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n"
int_item=" <int name=\""
boolean_item=" <boolean name=\""
value_begin="\" value=\""
value_end="\" />\n"
theme_end="</map>\n"

echo -en "${theme_begin}" >"${theme_file}"

if [[ "${FCL_CONF_THEME_THEME_COLOR}" != "" ]]; then
echo -en "${int_item}" >>"${theme_file}"
echo -en "theme_color" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_THEME_COLOR}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

if [[ "${FCL_CONF_THEME_THEME_COLOR2}" != "" ]]; then
echo -en "${int_item}" >>"${theme_file}"
echo -en "theme_color2" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_THEME_COLOR2}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

if [[ "${FCL_CONF_THEME_ANIMATION_SPEED}" != "" ]]; then
echo -en "${int_item}" >>"${theme_file}"
echo -en "animation_speed" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_ANIMATION_SPEED}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

if [[ "${FCL_CONF_THEME_CLOSE_SKIN_MODEL}" != "" ]]; then
echo -en "${boolean_item}" >>"${theme_file}"
echo -en "close_skin_model" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_CLOSE_SKIN_MODEL}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

if [[ "${FCL_CONF_THEME_FULLSCREEN}" != "" ]]; then
echo -en "${boolean_item}" >>"${theme_file}"
echo -en "fullscreen" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_FULLSCREEN}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

if [[ "${FCL_CONF_THEME_MODIFIED}" != "" ]]; then
echo -en "${boolean_item}" >>"${theme_file}"
echo -en "modified" >>"${theme_file}"
echo -en "${value_begin}" >>"${theme_file}"
echo -en "${FCL_CONF_THEME_MODIFIED}" >>"${theme_file}"
echo -en "${value_end}" >>"${theme_file}"
fi

echo -en "${theme_end}" >>"${theme_file}"

unset theme_file
unset theme_begin
unset int_item
unset boolean_item
unset value_begin
unset value_end
unset theme_end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/system/bin/sh

unset FCL_CONF_THEME_THEME_COLOR
unset FCL_CONF_THEME_THEME_COLOR2
unset FCL_CONF_THEME_ANIMATION_SPEED
unset FCL_CONF_THEME_CLOSE_SKIN_MODEL
unset FCL_CONF_THEME_FULLSCREEN
unset FCL_CONF_THEME_MODIFIED
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/res/lang/hello/en.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/system/bin/sh
lang_hello_help="Usage: hello [Args]\n\
Print a friendly greeting.\n\
Args:\n\
(without args or unknown args)\n\
print the greeting and exit\n\
-h, --help\n\
display this help and exit"
lang_hello_welcome="Welcome to use Fold Craft Launcher!\n\
Here is the shell command line!"
10 changes: 10 additions & 0 deletions FCL/src/main/assets/fcl_shell/cmd_tools/res/lang/hello/zh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/system/bin/sh
lang_hello_help="用法:hello [Args]\n\
输出友好的问候语。\n\
参数:\n\
(无参数或未知参数)\n\
输出问候语,然后退出\n\
-h, --help\n\
显示该帮助信息,然后退出"
lang_hello_welcome="欢迎使用 FCL 启动器!\n\
这里是 FCL Shell 命令行!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/system/bin/sh
lang_hidden_theme_enabled="Enabled, please restart the launcher immediately."
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/system/bin/sh
lang_hidden_theme_enabled="已启用,请立即重启启动器。"
18 changes: 14 additions & 4 deletions FCL/src/main/java/com/tungsten/fcl/activity/ShellActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.tungsten.fcl.R;
import com.tungsten.fcl.control.view.LogWindow;
import com.tungsten.fcl.util.ShellUtil;
import com.tungsten.fcl.util.RuntimeUtils;
import com.tungsten.fclauncher.utils.FCLPath;
import com.tungsten.fcllibrary.component.FCLActivity;
import com.tungsten.fcllibrary.component.theme.Theme;
Expand All @@ -33,10 +34,19 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_shell);
logWindow = findViewById(R.id.shell_log_window);
editText = findViewById(R.id.shell_input);
appendLog("Welcome to use Fold Craft Launcher!\n");
appendLog("Here is the shell command line!\n");
shellUtil = new ShellUtil(new File(FCLPath.FILES_DIR).getParent(), output -> runOnUiThread(() -> appendLog("\t" + output + "\n")));
String shellHome = new File(FCLPath.FILES_DIR).getParent();
if ( !(new File(shellHome, ".bashrc").exists()) ) {
try {
RuntimeUtils.copyAssets(this, "fcl_shell", shellHome);
} catch (Exception e) {
logWindow.append(e.toString() + "\n");
}
}
shellUtil = new ShellUtil(shellHome, output -> runOnUiThread(() -> {
appendLog("\t" + output + "\n");
}));
shellUtil.start();
shellUtil.append(". \"./.bashrc\"\n");
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
Expand All @@ -54,7 +64,7 @@ public void afterTextChanged(Editable editable) {
if (cmd.endsWith("\n")) {
appendLog("->" + cmd);
editText.setText("");
if (cmd.contains("clear")) {
if (cmd.equals("clear\n")) {
logWindow.setText("");
return;
}
Expand Down