diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..51c63e29 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +*.tgz filter=lfs diff=lfs merge=lfs -text +*.trp filter=lfs diff=lfs merge=lfs -text +*.apk filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.asm filter=lfs diff=lfs merge=lfs -text +*.8svn filter=lfs diff=lfs merge=lfs -text +*.9svn filter=lfs diff=lfs merge=lfs -text +*.dylib filter=lfs diff=lfs merge=lfs -text +*.exe filter=lfs diff=lfs merge=lfs -text +*.a filter=lfs diff=lfs merge=lfs -text +*.so filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.dll filter=lfs diff=lfs merge=lfs -text diff --git a/LICENSE b/LICENSE new file mode 100755 index 00000000..d0381d6d --- /dev/null +++ b/LICENSE @@ -0,0 +1,176 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/README.en.md b/README.en.md deleted file mode 100644 index e9f82bc0..00000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# applications_launcher - -#### Description -Launcher system app | 系统桌面 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md old mode 100644 new mode 100755 index b23495f9..b0fce4a9 --- a/README.md +++ b/README.md @@ -1,37 +1,43 @@ -# applications_launcher +# Launcher -#### 介绍 -Launcher system app | 系统桌面 +- [Introduction](#section11660541593) + - [Architecture](#section78574815486) -#### 软件架构 -软件架构说明 +- [Directory Structure](#section161941989596) +- [Repositories Involved](#section1371113476307) +## Introduction -#### 安装教程 +The home screen launcher provides a main entry to human-machine interactions. It displays app icons for users to start or uninstall the apps, and allows users to set the home screen layout and manage recent tasks. -1. xxxx -2. xxxx -3. xxxx +### Architecture -#### 使用说明 +![](figures/launcherl2-en.png) -1. xxxx -2. xxxx -3. xxxx +## Directory Structure -#### 参与贡献 +``` +/applications/standard/launcher/ +├── figures # Architecture figures +├── launcher # Main ability of the home screen, which provides the functions of displaying app icons, starting and uninstalling apps, and setting the home screen layout. +│ └── src +│ └── main +│ ├── config.json # Global configuration files +│ ├── js # JavaScript code +│ └── resources # Resource configuration files +├── recents # Ability for managing recent tasks +│ └── src +│ └── main +│ ├── config.json # Global configuration files +│ ├── js # JavaScript code +│ └── resources # Resource configuration files +├── signature # Certificate files +├── LICENSE # License files +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +## Repositories Involved +System apps -#### 特技 +**applications\_standard\_launcher** -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README_zh.md b/README_zh.md new file mode 100755 index 00000000..8ab6c759 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,42 @@ +# 桌面 + +- [简介](#section11660541593) + - [架构图](#section78574815486) + +- [目录](#section161941989596) +- [相关仓](#section1371113476307) + +## 简介 + +桌面作为系统人机交互的首要入口,提供应用图标的显示、点击启动、卸载应用,以及桌面布局设置、最近任务管理等功能。 + +### 架构图 + +![](figures/launcherl2-en.png) + +## 目录 + +``` +/applications/standard/launcher/ +├── figures # 架构图目录 +├── launcher # 桌面主Ability,提供应用图标的显示、点击启动、卸载应用、桌面布局设置 +│ └── src +│ └── main +│ ├── config.json # 全局配置文件 +│ ├── js # js代码目录 +│ └── resources # 资源配置文件存放目录 +├── recents # 最近任务Ability,提供最近任务管理 +│ └── src +│ └── main +│ ├── config.json # 全局配置文件 +│ ├── js # js代码目录 +│ └── resources # 资源配置文件存放目录 +├── signature # 证书文件目录 +├── LICENSE # 许可文件 +``` + +## 相关仓 + +系统应用 + +**applications\_standard\_launcher** diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..88edf766 --- /dev/null +++ b/build.gradle @@ -0,0 +1,39 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } +} + +buildscript { + repositories { + maven { + url 'https://mirrors.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + maven { + url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/' + } + jcenter() + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.4.3-RC' + } +} + +allprojects { + repositories { + maven { + url 'https://mirrors.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } +} diff --git a/figures/launcherl2-en.png b/figures/launcherl2-en.png new file mode 100755 index 00000000..ee58b9c6 Binary files /dev/null and b/figures/launcherl2-en.png differ diff --git a/gradle.properties b/gradle.properties new file mode 100755 index 00000000..b8c947d3 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +# Project-wide Gradle settings. +# IDE (e.g. DevEco Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# If the Chinese output is garbled, please configure the following parameter. +# org.gradle.jvmargs=-Dfile.encoding=GBK diff --git a/gradlew b/gradlew new file mode 100644 index 00000000..2fe81a7d --- /dev/null +++ b/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..62bd9b9c --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,103 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/launcher/.gitignore b/launcher/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/launcher/.gitignore @@ -0,0 +1 @@ +/build diff --git a/launcher/build.gradle b/launcher/build.gradle new file mode 100644 index 00000000..9f834c28 --- /dev/null +++ b/launcher/build.gradle @@ -0,0 +1,11 @@ +apply plugin: 'com.huawei.ohos.hap' +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + supportSystem "standard" +} + +dependencies { +} diff --git a/launcher/package.json b/launcher/package.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/launcher/package.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/launcher/src/main/config.json b/launcher/src/main/config.json new file mode 100644 index 00000000..fb38740b --- /dev/null +++ b/launcher/src/main/config.json @@ -0,0 +1,71 @@ +{ + "app": { + "bundleName": "com.ohos.launcher", + "vendor": "ohos", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.launcher", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "launcher", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home", + "flag.home.intent.from.system" + ], + "actions": [ + "action.system.home", + "com.ohos.action.main" + ] + } + ], + "name": "com.ohos.launcher.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "metaData": { + "customizeData": [ + { + "name": "hwc-theme" + } + ] + } + } + ], + "js": [ + { + "pages": [ + "pages/EntryView/EntryView", + "pages/AppGridView/AppGridView", + "pages/AppListView/AppListView", + "pages/SettingsView/SettingsView" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/app.js b/launcher/src/main/js/default/app.js new file mode 100644 index 00000000..d2f36d8f --- /dev/null +++ b/launcher/src/main/js/default/app.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AppModel from './common/model/AppModel.js' +import SettingsModel from './common/model/SettingsModel.js' + +export default { + data: { + appModel: new AppModel(), + settingsModel: new SettingsModel() + }, + + onCreate() { + console.info("Application onCreate"); + }, + + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/launcher/src/main/js/default/common/colors/Colors.js b/launcher/src/main/js/default/common/colors/Colors.js new file mode 100644 index 00000000..ec86b9d8 --- /dev/null +++ b/launcher/src/main/js/default/common/colors/Colors.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var Colors = { + bgSelectedColor: "#FF008000", + bgUnselectedColor: "white", + fontSelectedColor: "white", + fontUnselectedColor: "black" +} + +export default Colors; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/component/AppIcon/AppIcon.css b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.css new file mode 100644 index 00000000..bdda70d4 --- /dev/null +++ b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.css @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../css/CommonPageStyle.css'; +.image-box{ + height: 110px; + width: 110px; + display: flex; + align-items: center; + justify-content: center; +} + + diff --git a/launcher/src/main/js/default/common/component/AppIcon/AppIcon.hml b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.hml new file mode 100644 index 00000000..ee550af1 --- /dev/null +++ b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.hml @@ -0,0 +1,20 @@ + + +
+ +
\ No newline at end of file diff --git a/launcher/src/main/js/default/common/component/AppIcon/AppIcon.js b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.js new file mode 100644 index 00000000..f9db09e2 --- /dev/null +++ b/launcher/src/main/js/default/common/component/AppIcon/AppIcon.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ResourceManager from '../../model/ResourceManager.js'; + +var mResourceManager; + +export default { + props: ['itemAppId', 'itemAppIcon', 'itemBundleName'], + + data() { + return { + bundleName: this.itemBundleName, + appId: this.itemAppId, + appIcon: "" + }; + }, + + onInit() { + this.$watch('itemBundleName','appIconWatcher'); + mResourceManager = new ResourceManager(); + mResourceManager.getAppIcon(this.itemAppIcon, this.itemBundleName, this.iconLoadCallback); + }, + + onShow() { + }, + + appIconWatcher(newV, oldV) { + if (newV != null && newV != undefined) { + mResourceManager.getAppIcon(this.itemAppIcon, this.itemBundleName, this.iconLoadCallback); + } + }, + + iconLoadCallback(image) { + this.appIcon = image; + }, + + updateIcon() { + console.info("Launcher AppIcon updateIcon in bundleName = " + this.itemBundleName); + mResourceManager.getAppIcon(this.itemAppIcon, this.itemBundleName, this.iconLoadCallback); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/component/GridName/GridName.css b/launcher/src/main/js/default/common/component/GridName/GridName.css new file mode 100644 index 00000000..2d150204 --- /dev/null +++ b/launcher/src/main/js/default/common/component/GridName/GridName.css @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../css/CommonPageStyle.css'; + +.app-name { + text-align: center; + width: 110px; + height: 60px; + color: white; + font-size: 27px; +} diff --git a/launcher/src/main/js/default/common/component/GridName/GridName.hml b/launcher/src/main/js/default/common/component/GridName/GridName.hml new file mode 100644 index 00000000..3c368a78 --- /dev/null +++ b/launcher/src/main/js/default/common/component/GridName/GridName.hml @@ -0,0 +1,20 @@ + + + + {{appName}} + diff --git a/launcher/src/main/js/default/common/component/GridName/GridName.js b/launcher/src/main/js/default/common/component/GridName/GridName.js new file mode 100644 index 00000000..6dbb4bfb --- /dev/null +++ b/launcher/src/main/js/default/common/component/GridName/GridName.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ResourceManager from '../../model/ResourceManager.js'; + +var mResourceManager; + +export default { + props: ['itemAppId', 'itemLabelId', 'itemBundleName', 'itemAppName'], + + data() { + return { + labelId: this.itemLabelId, + bundleName: this.itemBundleName, + appId: this.itemAppId, + appName: "" + }; + }, + + onInit() { + this.$watch('itemBundleName','appIconWatcher'); + mResourceManager = new ResourceManager(); + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + }, + + onShow() { + }, + + appIconWatcher(newV, oldV) { + if (newV != null && newV != undefined) { + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + } + }, + + iconLoadCallback(name) { + this.appName = name; + }, + + updateName() { + console.info("Launcher AppIcon updateIcon in bundleName = " + this.itemBundleName); + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/component/ListName/AppName.css b/launcher/src/main/js/default/common/component/ListName/AppName.css new file mode 100644 index 00000000..11077790 --- /dev/null +++ b/launcher/src/main/js/default/common/component/ListName/AppName.css @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../css/CommonPageStyle.css'; +.appitem { + height: 110px; + width: 90%; + display: flex; + flex-direction: row; + align-items: center; +} + +.app-name { + margin-left: 30px; + width: 300px; + color: white; +} diff --git a/launcher/src/main/js/default/common/component/ListName/AppName.hml b/launcher/src/main/js/default/common/component/ListName/AppName.hml new file mode 100644 index 00000000..3c368a78 --- /dev/null +++ b/launcher/src/main/js/default/common/component/ListName/AppName.hml @@ -0,0 +1,20 @@ + + + + {{appName}} + diff --git a/launcher/src/main/js/default/common/component/ListName/AppName.js b/launcher/src/main/js/default/common/component/ListName/AppName.js new file mode 100644 index 00000000..6dbb4bfb --- /dev/null +++ b/launcher/src/main/js/default/common/component/ListName/AppName.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ResourceManager from '../../model/ResourceManager.js'; + +var mResourceManager; + +export default { + props: ['itemAppId', 'itemLabelId', 'itemBundleName', 'itemAppName'], + + data() { + return { + labelId: this.itemLabelId, + bundleName: this.itemBundleName, + appId: this.itemAppId, + appName: "" + }; + }, + + onInit() { + this.$watch('itemBundleName','appIconWatcher'); + mResourceManager = new ResourceManager(); + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + }, + + onShow() { + }, + + appIconWatcher(newV, oldV) { + if (newV != null && newV != undefined) { + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + } + }, + + iconLoadCallback(name) { + this.appName = name; + }, + + updateName() { + console.info("Launcher AppIcon updateIcon in bundleName = " + this.itemBundleName); + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/configs/DefaultLayoutConfig.js b/launcher/src/main/js/default/common/configs/DefaultLayoutConfig.js new file mode 100644 index 00000000..8ea39543 --- /dev/null +++ b/launcher/src/main/js/default/common/configs/DefaultLayoutConfig.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var DefaultLayoutConfig = { + DefaultAppPageStartConfig: 'Grid', + DefaultGridConfig: 0, + DefaultRecentProcessLimit: 6 +} + +export default DefaultLayoutConfig; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/configs/GridLayoutConfigs.js b/launcher/src/main/js/default/common/configs/GridLayoutConfigs.js new file mode 100644 index 00000000..c69d5cc2 --- /dev/null +++ b/launcher/src/main/js/default/common/configs/GridLayoutConfigs.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var GridLayoutConfigs = { + GridLayoutTable: [ + {id:0, layout:'5X4', row:5, column:4}, + {id:1, layout:'4X4', row:4, column:4}, + {id:2, layout:'6X4', row:6, column:4}, + ] +} + +export default GridLayoutConfigs; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/configs/SystemApplication.js b/launcher/src/main/js/default/common/configs/SystemApplication.js new file mode 100644 index 00000000..01435a08 --- /dev/null +++ b/launcher/src/main/js/default/common/configs/SystemApplication.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var SystemApplication = { + SystemApplicationName: 'com.ohos.launcher,com.ohos.systemui' +} + +export default SystemApplication; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/constants/LayoutConstants.js b/launcher/src/main/js/default/common/constants/LayoutConstants.js new file mode 100644 index 00000000..dcf94f39 --- /dev/null +++ b/launcher/src/main/js/default/common/constants/LayoutConstants.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var LayoutContants = { + Grid: "Grid", + List: "List" +} + +export default LayoutContants; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/constants/PageData.js b/launcher/src/main/js/default/common/constants/PageData.js new file mode 100644 index 00000000..8c6664a7 --- /dev/null +++ b/launcher/src/main/js/default/common/constants/PageData.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var PageData = { + GRID_APP_PAGE: 'pages/AppGridView/AppGridView', + LIST_APP_PAGE: 'pages/AppListView/AppListView' +} + +export default PageData; \ No newline at end of file diff --git a/launcher/src/main/js/default/common/css/CommonPageStyle.css b/launcher/src/main/js/default/common/css/CommonPageStyle.css new file mode 100644 index 00000000..72045c17 --- /dev/null +++ b/launcher/src/main/js/default/common/css/CommonPageStyle.css @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.app-icon-img{ + border-radius: 20px; + width: 110px; + height: 110px; +} + +.app-icon-img:active{ + width: 105px; + height: 105px; +} + +.app-name{ + color: black; +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/model/AppModel.js b/launcher/src/main/js/default/common/model/AppModel.js new file mode 100644 index 00000000..749f6a53 --- /dev/null +++ b/launcher/src/main/js/default/common/model/AppModel.js @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle_mgr from '@ohos.bundle_mgr'; +import feature_ability from '@ohos.feature_ability'; +import Subscriber from '@ohos.commonevent'; +import SystemApplication from '../../common/configs/SystemApplication.js'; + +var mBundleInfoList = []; +var mGridBootAppList = []; +const DEFAULT_ICON_URL = 'common/pics/icon_default.png'; +var mAppUninstallListener = null; +var mAppInstallListeners = []; +var gridListCallback; +var systemApplicationName = SystemApplication.SystemApplicationName; +var mCommonEventSubscriber = null; +var mCommonEventSubscribeInfo = { + events: ["usual.event.PACKAGE_ADDED", "usual.event.PACKAGE_CHANGED", "usual.event.PACKAGE_REMOVED"] +}; + +export default class AppModel { + getAppList(callback) { + mBundleInfoList = []; + console.info('Launcher getAppIcon getAppList'); + bundle_mgr.getApplicationInfos().then((data) => { + console.info('Launcher getApplicationInfos >' + JSON.stringify(data)); + for (var i = 0; i < data.length; i++) { + if (systemApplicationName.indexOf(data[i].bundleName) > -1) { + } else { + mBundleInfoList.push( + { + System: data[i].isSystemApp, + AppName: data[i].label, + AppId: data[i].name, + AppIcon: data[i].iconId, + bundleName: data[i].bundleName, + labelId: data[i].labelId, + } + ) + } + } + let appArrayLength = mBundleInfoList.length; + for (let i = 0; i < appArrayLength; i++) { + var iconUrl = mBundleInfoList[i].AppIcon; + if (iconUrl == null || iconUrl == "" || iconUrl == "undefined") { + mBundleInfoList[i].AppIcon = DEFAULT_ICON_URL; + } + } + console.info('Launcher mBundleInfoList' + JSON.stringify(mBundleInfoList)); + callback(mBundleInfoList); + }); + } + + installApp() { + } + + uninstallApp(appId, callback) { + console.info('Launcher uninstallApp appId' + appId); + var result = bundle_mgr.uninstall(appId).then((data) => { + console.info("Launcher uninstall data [" + data + "]"); + callback(true); + }).catch(error => + console.info("Launcher uninstall err " + error)); + } + + getGridBootAppList() { + return mGridBootAppList; + } + + getGridPagesAppList(callback) { + gridListCallback = callback; + this.getAppList(this.getGridlist.bind(this)); + } + + getGridlist(list) { + gridListCallback(this.dealList(list)); + } + + dealList(appList) { + var gridPagesList = []; + var bootListLength = mGridBootAppList.length; + var appArrayLength = appList.length; + for (var i = 0; i < appArrayLength; i++) { + gridPagesList.push(appList[i]); + for (var j = 0; j < bootListLength; j++) { + if (appList[i].AppName === mGridBootAppList[j].AppName) { + gridPagesList.pop(); + } + } + } + return gridPagesList; + } + + openApplication(bundleName) { + this.getAbilityName(bundleName, this.startApplication) + } + + getAbilityName(bundleName, callback) { + console.info('Launcher getAbilityName bundleName' + bundleName); + bundle_mgr.getBundleInfo(bundleName).then(data => { + console.info('Launcher getBundleInfo ' + data); + callback(data.abilityInfos[0].name, bundleName); + }); + } + + startApplication(abilityname, bundleName) { + let paramBundleName = bundleName; + let paramAbilityname = abilityname; + // promise + console.info('Launcher startApplication abilityname' + abilityname); + var result = feature_ability.startAbility({ + bundleName: paramBundleName, + abilityName: paramAbilityname, + requestCode: 1, + abilityType: "PageAbility", + want: { + action: "action1", + entities: ["entity1"], + type: "PageAbility", + flags: 2, + elementName: { + deviceId: "deviceId", + bundleName: paramBundleName, + abilityName: paramAbilityname, + }, + }, + syncOption: 1, + }).then(data => + console.info("Launcher promise::then : " + JSON.stringify(data)) + ).catch(error => + console.info("Launcher promise::catch : " + JSON.stringify(error)) + ); + console.info("Launcher AceApplication : startAbility : " + result); + } + + reportAppInstallEvent() { + console.info("Launcher AppModel reportAppInstallEvent"); + for (let i = 0; i < mAppInstallListeners.length; i++) { + let listener = mAppInstallListeners[i]; + if (listener != undefined && listener != null) { + listener(); + } + } + } + + reportAppUninstallEvent(appId) { + if (mAppUninstallListener != null) { + mAppUninstallListener(appId); + } + } + + registerAppUninstallListener(listener) { + mAppUninstallListener = listener; + } + + registerAppInstallListener(listener) { + console.info("Launcher AppModel registerAppInstallListener"); + if (mAppInstallListeners.indexOf(listener) == -1) { + mAppInstallListeners.push(listener); + } + Subscriber.createSubscriber( + mCommonEventSubscribeInfo, + this.createInstallationSubscriberCallBack.bind(this) + ); + } + + unregisterAppInstallListener(listener) { + Subscriber.unsubscribe(mCommonEventSubscriber, () => { + console.info("Launcher AppModel unsubscribe app install listener"); + let index = mAppInstallListeners.indexOf(listener); + if (index != -1) { + mAppInstallListeners.splice(index, 1); + } + }); + } + + createInstallationSubscriberCallBack(err, data) { + console.info("Launcher AppModel createInstallationSubscriberCallBack"); + mCommonEventSubscriber = data; + Subscriber.subscribe(mCommonEventSubscriber, this.installationSubscriberCallBack.bind(this)); + } + + installationSubscriberCallBack(err, data) { + console.info("Launcher AppModel installationSubscriberCallBack"); + this.reportAppInstallEvent(); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/model/ILayoutConfig.js b/launcher/src/main/js/default/common/model/ILayoutConfig.js new file mode 100644 index 00000000..ccac07fb --- /dev/null +++ b/launcher/src/main/js/default/common/model/ILayoutConfig.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class ILayoutConfig { + constructor() { + } + + getAppPageStartConfig() { + return this.loadAppPageStartConfig(); + } + + setAppPageStartConfig(type) { + this.saveAppPageStartConfig(type); + } + + getGridConfig() { + return this.loadGridConfig(); + } + + setGridConfig(id) { + this.saveGridConfig(id); + } + + getRecentProcessLimit() { + return this.loadRecentProcessLimit(); + } + + setRecentProcessLimit(num) { + this.saveRecentProcessLimit(num); + } + + loadAppPageStartConfig() { + } + + saveAppPageStartConfig(type) { + } + + loadGridConfig() { + } + + saveGridConfig(id) { + } + + loadRecentProcessLimit() { + } + + saveRecentProcessLimit(num) { + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/model/LayoutConfigManager.js b/launcher/src/main/js/default/common/model/LayoutConfigManager.js new file mode 100644 index 00000000..35b0003e --- /dev/null +++ b/launcher/src/main/js/default/common/model/LayoutConfigManager.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import StorageLayoutConfig from './StorageLayoutConfig.js' + +export function getLayoutConfig() { + return new StorageLayoutConfig(); +} diff --git a/launcher/src/main/js/default/common/model/ResourceManager.js b/launcher/src/main/js/default/common/model/ResourceManager.js new file mode 100644 index 00000000..8e8a2548 --- /dev/null +++ b/launcher/src/main/js/default/common/model/ResourceManager.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import resmgr from '@ohos.resmgr'; + +const DEFAULT_ICON_URL = 'common/pics/icon_default.png'; + +export default class ResourceManager { + ResourceManager() { + } + + getAppIcon(path, bundleName, callback) { + if (path == null || path == undefined || path == "" || path <= 0) { + console.info('Launcher getAppIcon iconid > ' + DEFAULT_ICON_URL); + callback(DEFAULT_ICON_URL); + } else { + resmgr.getResourceManager(bundleName).then(item => { + console.info('Launcher getResourceManager data>' + item); + item.getMediaBase64(path, (error, value) => { + console.info('Launcher getMediaBase64 value>' + value); + if (value != null) { + callback(value); + } + }); + }); + } + } + + getAppName(labelId, bundleName, appName, callback) { + if (labelId == null || labelId == undefined || labelId == "" || labelId <= 0) { + console.info('Launcher getAppName callback ' + appName); + callback(appName); + } else { + resmgr.getResourceManager(bundleName).then(item => { + console.info('Launcher getResourceManager labelId' + labelId); + item.getString(labelId, (error, value) => { + console.info('Launcher getString value>' + value); + if (value != null) { + callback(value); + } + }); + }); + } + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/model/SettingsModel.js b/launcher/src/main/js/default/common/model/SettingsModel.js new file mode 100644 index 00000000..264221e4 --- /dev/null +++ b/launcher/src/main/js/default/common/model/SettingsModel.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import GridLayoutConfigs from '../../common/configs/GridLayoutConfigs.js'; +import {getLayoutConfig} from './LayoutConfigManager.js'; + +var mLayoutConfig = getLayoutConfig(); +var mGridConfig = 0; +var gridLayoutTable = GridLayoutConfigs.GridLayoutTable; + +export default class SettingsModel { + getGridLayoutTable() { + return gridLayoutTable; + } + + getGridConfig() { + mGridConfig = mLayoutConfig.getGridConfig(); + return gridLayoutTable[mGridConfig]; + } + + setGridConfig(id) { + mLayoutConfig.setGridConfig(id); + } + + getRecentProcessLimit() { + return mLayoutConfig.getRecentProcessLimit(); + } + + setRecentProcessLimit(num) { + mLayoutConfig.setRecentProcessLimit(num); + } + + getAppPageStartConfig() { + return mLayoutConfig.getAppPageStartConfig(); + } + + setAppPageStartConfig(type) { + mLayoutConfig.setAppPageStartConfig(type); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/model/StorageLayoutConfig.js b/launcher/src/main/js/default/common/model/StorageLayoutConfig.js new file mode 100755 index 00000000..63f6dc3b --- /dev/null +++ b/launcher/src/main/js/default/common/model/StorageLayoutConfig.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ILayoutConfig from './ILayoutConfig.js'; +import DefaultLayoutConfig from '../../common/configs/DefaultLayoutConfig.js'; +import storage from '@ohos.data.storage'; + +const APP_PAGE_START_CONFIG = 'AppStartPageType'; +const GRID_CONFIG = "GridConfig"; +const RECENT_PROCESS_LIMIT = "RecentProcessLimit"; +const PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.launcher/sharedPreference/LauncherPreference'; +var mPreferences = storage.getStorageSync(PREFERENCES_PATH); + +export default class StorageLayoutConfig extends ILayoutConfig { + constructor() { + super(); + } + + loadAppPageStartConfig() { + console.info('Launcher mPreferences get APP_PAGE_START_CONFIG'); + var data = mPreferences.getSync(APP_PAGE_START_CONFIG, DefaultLayoutConfig.DefaultAppPageStartConfig); + console.info('Launcher mPreferences get' + data); + return data; + } + + saveAppPageStartConfig(type) { + console.info('Launcher mPreferences put type' + type); + mPreferences.putSync(APP_PAGE_START_CONFIG, type); + mPreferences.flushSync(); + console.info('Launcher mPreferences put type flush'); + } + + loadGridConfig() { + console.info('Launcher mPreferences get GRID_CONFIG'); + var data = mPreferences.getSync(GRID_CONFIG, DefaultLayoutConfig.DefaultGridConfig); + console.info('Launcher mPreferences get' + data); + return data; + } + + saveGridConfig(id) { + console.info('Launcher mPreferences put id' + id); + mPreferences.putSync(GRID_CONFIG, id); + mPreferences.flushSync(); + console.info('Launcher mPreferences put id flush'); + } + + loadRecentProcessLimit() { + console.info('Launcher mPreferences get'); + var data = mPreferences.getSync(RECENT_PROCESS_LIMIT, DefaultLayoutConfig.DefaultRecentProcessLimit); + console.info('Launcher mPreferences get' + data); + return data; + } + + saveRecentProcessLimit(num) { + console.info('Launcher mPreferences put num' + num); + mPreferences.putSync(RECENT_PROCESS_LIMIT, num); + mPreferences.flushSync(); + console.info('Launcher mPreferences put num flush'); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/common/pics/icon_default.png b/launcher/src/main/js/default/common/pics/icon_default.png new file mode 100644 index 00000000..f72f0a34 Binary files /dev/null and b/launcher/src/main/js/default/common/pics/icon_default.png differ diff --git a/launcher/src/main/js/default/common/pics/img_wallpaper_default.jpg b/launcher/src/main/js/default/common/pics/img_wallpaper_default.jpg new file mode 100644 index 00000000..46c32d7a Binary files /dev/null and b/launcher/src/main/js/default/common/pics/img_wallpaper_default.jpg differ diff --git a/launcher/src/main/js/default/common/utils/RouterUtil.js b/launcher/src/main/js/default/common/utils/RouterUtil.js new file mode 100644 index 00000000..bf620f3e --- /dev/null +++ b/launcher/src/main/js/default/common/utils/RouterUtil.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; + +var Router = function () { + return { + push: function (uri, papams) { + router.push({ + uri: uri, + params: papams + }) + }, replace: function (uri, papams) { + router.replace({ + uri: uri, + params: papams + }) + }, back: function () { + router.back(); + }, clear: function () { + router.clear(); + } + } +}(); + +export default Router; \ No newline at end of file diff --git a/launcher/src/main/js/default/i18n/en-US.json b/launcher/src/main/js/default/i18n/en-US.json new file mode 100644 index 00000000..4a116bc5 --- /dev/null +++ b/launcher/src/main/js/default/i18n/en-US.json @@ -0,0 +1,18 @@ +{ + "strings": { + "loading": "Loading...", + "cancelled": "Cancelled", + "uninstall_succeeded": "Successfully uninstalled", + "uninstall": "Uninstall", + "cancel": "Cancel", + "prohibited": "Uninstall prohibited ", + "settings": "Settings", + "carry_out": "Finish", + "do_you_want_to_uninstall_start": "Are you sure uninstall", + "do_you_want_to_uninstall_end": "?", + "launcher_settings": "Launcher settings", + "uninstall_app": "Uninstall App", + "layout": "Layout", + "recent_tasks_settings": "Recent tasks settings" + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/i18n/zh-CN.json b/launcher/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 00000000..aa832cfc --- /dev/null +++ b/launcher/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,18 @@ +{ + "strings": { + "loading": "加载中...", + "cancelled": "已取消", + "uninstall_succeeded": "卸载成功", + "uninstall": "卸载", + "cancel": "取消", + "prohibited": "禁止卸载", + "settings": "设置", + "carry_out": "完成", + "do_you_want_to_uninstall_start": "确定卸载", + "do_you_want_to_uninstall_end": "吗?", + "launcher_settings": "桌面设置", + "uninstall_app": "应用卸载", + "layout": "布局", + "recent_tasks_settings": "最近任务设置" + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/pages/AppGridView/AppGridView.css b/launcher/src/main/js/default/pages/AppGridView/AppGridView.css new file mode 100644 index 00000000..7eb25de8 --- /dev/null +++ b/launcher/src/main/js/default/pages/AppGridView/AppGridView.css @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../common/css/CommonPageStyle.css'; + +.container { + background-image: url("common/pics/img_wallpaper_default.jpg"); + background-size: cover; +} + +.body { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-around; +} + +.row { + justify-content: space-around; + height: 180px; + width: 920px; +} + +.app-box { + display: flex; + flex-direction: column; + align-items: center; + height: 170px; + width: 110px; + margin-top: 10px; + border-radius: 20px; +} + +.image-box { + height: 110px; + width: 110px; + display: flex; + align-items: center; + justify-content: center; +} + +.app-name { + text-align: center; + width: 110px; + height: 60px; + color: white; + font-size: 27px; +} + +.pageView { + height: 85%; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.systemApp { + height: 15%; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; +} + +.txt { + color: #000000; + font-weight: bold; + font-size: 39px; +} + +.dialog-main { + width: 500px; +} + +.dialog-div { + flex-direction: column; + align-items: center; +} + +.inner-txt { + width: 400px; + height: 160px; + flex-direction: column; + align-items: center; + justify-content: space-around; +} + +.inner-btn { + width: 400px; + height: 120px; + justify-content: space-around; + align-items: center; +} + +.btn-txt { + height: 50px; +} + + + + diff --git a/launcher/src/main/js/default/pages/AppGridView/AppGridView.hml b/launcher/src/main/js/default/pages/AppGridView/AppGridView.hml new file mode 100644 index 00000000..259d332e --- /dev/null +++ b/launcher/src/main/js/default/pages/AppGridView/AppGridView.hml @@ -0,0 +1,65 @@ + + + + + +
+ +
+
+
+ + + + +
+
+
+
+
+
+
+
+ +
+ + {{ $item.AppName }} + +
+
+ +
+
+ {{ $t('strings.do_you_want_to_uninstall_start') }}{{ uninstallAppName }}{{ + $t('strings.do_you_want_to_uninstall_end') }} + +
+
+ + +
+
+
+
\ No newline at end of file diff --git a/launcher/src/main/js/default/pages/AppGridView/AppGridView.js b/launcher/src/main/js/default/pages/AppGridView/AppGridView.js new file mode 100644 index 00000000..ca2b970a --- /dev/null +++ b/launcher/src/main/js/default/pages/AppGridView/AppGridView.js @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AppGridPresenter from '../../presenter/app/AppGridPresenter.js'; +import prompt from '@system.prompt'; + +var mAppGridPresenter; +const APP_INFO_REFRESH_DELAY = 500; + +export default { + data: { + index: 0, + uninstallAppName: "", + uninstallAppId: "", + uninstallSystem: "", + appArray: [[[]]], + bottomBar: [], + }, + + onInit() { + console.info("Launcher AppGridView onInit"); + mAppGridPresenter = new AppGridPresenter(this.$app.$def.data.appModel, this.$app.$def.data.settingsModel); + mAppGridPresenter.registerAppUninstallListener(this.onAppUninstallCallback.bind(this)); + mAppGridPresenter.registerAppInstallListener(this.onAppInstallCallback.bind(this)); + }, + + onShow() { + console.info("Launcher AppGridView onShow"); + mAppGridPresenter.clearRouter(); + this.index = mAppGridPresenter.getGridIndex(); + mAppGridPresenter.getGridList(this.getGridListCallback.bind(this)); + this.bottomBar = mAppGridPresenter.getBootAppList(); + }, + + onDestory() { + mAppGridPresenter.unregisterAppInstallListener(this.onAppInstallCallback.bind(this)); + }, + + openApplication(bundleName) { + mAppGridPresenter.jumpTo(bundleName); + }, + + longPress(appId, appName, system) { + this.uninstallAppName = appName; + this.uninstallAppId = appId; + this.uninstallSystem = system; + if (system == 0) { + this.$element('simpleDialog').show() + } else{ + prompt.showToast({ + message: this.$t('strings.prohibited') + }) + } + }, + + intoSetting() { + mAppGridPresenter.jumpToSetting(); + }, + + cancelDialog(e) { + prompt.showToast({ + message: 'Dialog cancelled' + }) + }, + + cancelSchedule(e) { + this.$element('simpleDialog').close(); + prompt.showToast({ + message: this.$t('strings.cancelled') + }) + }, + + uninstallApplication(e) { + this.$element('simpleDialog').close() + mAppGridPresenter.uninstallApp(this.uninstallAppId); + prompt.showToast({ + message: this.$t('strings.uninstall_succeeded') + }) + }, + + pageChange(e) { + this.index = e.index; + mAppGridPresenter.setGridIndex(e.index); + }, + + getGridListCallback(callbackDate) { + this.appArray = callbackDate; + console.info("Launcher AppGridView getGridListCallback this.appList.length = " + this.appArray.length); + }, + + onAppUninstallCallback(appId) { + mAppGridPresenter.getGridList(this.getGridListCallback.bind(this)); + }, + + onAppInstallCallback(appId) { + console.info("Launcher AppGridView onAppInstallCallback start"); + mAppGridPresenter.getGridList(this.applicationInstallCallback.bind(this)); + }, + + updateAppInfos() { + setTimeout(() => { + console.info("Launcher AppGridView getGridListCallback setTimeout this.appList.length = " + this.appArray.length); + for (let i = 0; i < this.appArray.length; i++) { + let page = this.appArray[i]; + console.info("Launcher AppGridView getGridListCallback setTimeout page = " + i); + for (let j = 0; j < page.length; j++) { + let row = page[j]; + console.info("Launcher AppGridView getGridListCallback setTimeout row = " + j); + for (let k = 0; k < row.length; k++) { + let element = row[k]; + console.info("Launcher AppGridView getGridListCallback setTimeout in page = " + i + " row = " + j + " column = " + k); + this.$child('icon-' + element.bundleName).updateIcon(); + this.$child('name-' + element.bundleName).updateName(); + } + } + } + }, APP_INFO_REFRESH_DELAY); + }, + + applicationInstallCallback(callbackData) { + this.appArray = callbackData; + console.info("Launcher AppGridView applicationIntallCallback this.appList.length = " + this.appArray.length); + this.updateAppInfos(); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/pages/AppListView/AppListView.css b/launcher/src/main/js/default/pages/AppListView/AppListView.css new file mode 100644 index 00000000..b380aa6e --- /dev/null +++ b/launcher/src/main/js/default/pages/AppListView/AppListView.css @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../common/css/CommonPageStyle.css'; + +.container { + background-image: url("common/pics/img_wallpaper_default.jpg"); + background-size: cover; +} + +.list { + width: 100%; + height: 100%; +} + +.list-item { + width: 100%; + height: 130px; + display: flex; + align-items: center; + justify-content: center; +} + +.appitem { + height: 110px; + width: 90%; + display: flex; + flex-direction: row; + align-items: center; +} + +.app-name { + margin-left: 30px; + width: 300px; + color: white; +} + +.txt { + color: #000000; + font-weight: bold; + font-size: 39px; +} + +.dialog-main { + width: 500px; +} + +.dialog-div { + flex-direction: column; + align-items: center; +} + +.inner-txt { + width: 400px; + height: 160px; + flex-direction: column; + align-items: center; + justify-content: space-around; +} + +.inner-btn { + width: 400px; + height: 120px; + justify-content: space-around; + align-items: center; +} + +.btn-txt { + height: 50px; +} \ No newline at end of file diff --git a/launcher/src/main/js/default/pages/AppListView/AppListView.hml b/launcher/src/main/js/default/pages/AppListView/AppListView.hml new file mode 100644 index 00000000..fe7dc17e --- /dev/null +++ b/launcher/src/main/js/default/pages/AppListView/AppListView.hml @@ -0,0 +1,61 @@ + + + + + +
+ + +
+ + + + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ {{ $t('strings.do_you_want_to_uninstall_start') }}{{ uninstallAppName }}{{ + $t('strings.do_you_want_to_uninstall_end') }} + +
+
+ + +
+
+
+
\ No newline at end of file diff --git a/launcher/src/main/js/default/pages/AppListView/AppListView.js b/launcher/src/main/js/default/pages/AppListView/AppListView.js new file mode 100644 index 00000000..9afeaa9b --- /dev/null +++ b/launcher/src/main/js/default/pages/AppListView/AppListView.js @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AppListPresenter from '../../presenter/app/AppListPresenter.js'; +import prompt from '@system.prompt'; + +var mAppListPresenter; + +const APP_INFO_REFRESH_DELAY = 500; + +export default { + data: { + appList: [], + uninstallAppId: null, + uninstallAppName: null, + ifSystem: true, + }, + + onInit() { + mAppListPresenter = new AppListPresenter(this.$app.$def.data.appModel); + mAppListPresenter.registerAppUninstallListener(this.onAppUninstallCallback); + mAppListPresenter.registerAppInstallListener(this.onAppInstallCallback); + }, + + onShow() { + mAppListPresenter.clearRouter(); + mAppListPresenter.getAppList(this.getListCallback.bind(this)); + }, + + onDestory() { + mAppListPresenter.unregisterAppInstallListener(this.onAppInstallCallback.bind(this)); + }, + + getListCallback(list) { + if (list == undefined || list == null) { + this.appList = []; + return; + } + this.appList = list; + }, + + openApplication(bundleName) { + mAppListPresenter.jumpTo(bundleName); + }, + + longPress(appId, bundleName, System) { + this.uninstallAppId = appId; + this.uninstallAppName = bundleName; + this.ifSystem = System; + this.$element('chooseDialog').show(); + }, + + toSetting() { + mAppListPresenter.jumpToSetting(); + }, + + chooseUninstall() { + this.$element('simpleDialog').show(); + }, + + chooseSettings() { + this.$element('chooseDialog').close(); + mAppListPresenter.jumpToSetting(); + }, + + cancelDialog(e) { + this.$element('chooseDialog').close(); + prompt.showToast({ + message: 'Dialog cancelled' + }) + }, + + cancelSchedule(e) { + this.$element('chooseDialog').close(); + this.$element('simpleDialog').close(); + prompt.showToast({ + message: this.$t('strings.cancelled') + }) + }, + + uninstallApplication(e) { + this.$element('chooseDialog').close(); + this.$element('simpleDialog').close(); + if (this.uninstallAppName != null) { + mAppListPresenter.uninstallApp(this.uninstallAppName,this.ifSystem,this.getUninstallApp.bind(this)); + } + }, + + getUninstallApp(callback) { + var success = callback; + if (!success) { + prompt.showToast({ + message: this.$t('strings.prohibited') + }) + } else if (success) { + prompt.showToast({ + message: this.$t('strings.uninstall_succeeded') + }) + } + }, + + onAppUninstallCallback(appId) { + }, + + onAppInstallCallback(appId) { + console.info("Launcher AppListView onAppInstallCallback start"); + mAppListPresenter.getAppList(this.applicationInstallCallback.bind(this)); + console.info("Launcher AppListView onAppInstallCallback end"); + }, + + updateAppInfos() { + console.info("Launcher AppListView getListCallback setTimeout this.appList.length = " + this.appList.length); + setTimeout(() => { + for (let i = 0; i < this.appList.length; i++) { + console.info("Launcher AppListView getListCallback setTimeout in i = " + i); + this.$child('icon' + i).updateIcon(); + this.$child('name' + i).updateName(); + } + }, APP_INFO_REFRESH_DELAY); + }, + + applicationInstallCallback(list) { + console.info("Launcher AppListView applicationInstallCallback in "); + if (list == undefined || list == null) { + this.appList = []; + return; + } + this.appList = list; + this.initListFocus(); + this.updateAppInfos(); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/pages/EntryView/EntryView.css b/launcher/src/main/js/default/pages/EntryView/EntryView.css new file mode 100644 index 00000000..624f3dd7 --- /dev/null +++ b/launcher/src/main/js/default/pages/EntryView/EntryView.css @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + background-image: url("common/pics/img_wallpaper_default.jpg"); + background-size: cover; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +text { + color: white; + font-size: 30px; +} diff --git a/launcher/src/main/js/default/pages/EntryView/EntryView.hml b/launcher/src/main/js/default/pages/EntryView/EntryView.hml new file mode 100644 index 00000000..3e887d82 --- /dev/null +++ b/launcher/src/main/js/default/pages/EntryView/EntryView.hml @@ -0,0 +1,20 @@ + + +
+ {{$t('strings.loading')}} +
diff --git a/launcher/src/main/js/default/pages/EntryView/EntryView.js b/launcher/src/main/js/default/pages/EntryView/EntryView.js new file mode 100644 index 00000000..ac5937cd --- /dev/null +++ b/launcher/src/main/js/default/pages/EntryView/EntryView.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import EntryPresenter from '../../presenter/entry/EntryPresenter.js' + +var mEntryPresenter; +const timeout = 1000; + +export default { + onInit() { + console.info("Launcher EntryView onInit start"); + mEntryPresenter = new EntryPresenter(this.$app.$def.data.settingsModel); + console.info("Launcher EntryView onInit end"); + }, + + onShow() { + setTimeout(() => { + console.info("Launcher EntryView onShow start"); + mEntryPresenter.startAppListView(); + console.info("Launcher EntryView onShow end"); + }, timeout); + + }, + + fun(){} +} diff --git a/launcher/src/main/js/default/pages/SettingsView/SettingsView.css b/launcher/src/main/js/default/pages/SettingsView/SettingsView.css new file mode 100755 index 00000000..553f9421 --- /dev/null +++ b/launcher/src/main/js/default/pages/SettingsView/SettingsView.css @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + display: flex; + flex-direction: column; + align-items: center; + width: 100%; + height: 100%; + background-color: white; +} + +.top-bar { + top:0; + height: 100px; + width: 100%; + display: flex; + justify-content: center; + align-items: center; + background-color: #F0EEEE; +} + +.settings-box { + height: 100%; + width: 90%; +} + +text { + font-size: 40px; +} + +list { + height: 100%; + width: 100%; + background-color: white; +} + +.list-bar { + background-color: white; + border-bottom-width: 3px; + border-color: black; +} + +list-item { + height: 100px; + width: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.item-box { + width: 95%; + height: 100%; + border-bottom-width: 3px; + border-color: #ACABAB; + display: flex; + flex-direction: row; + align-items: center; + justify-content:space-around; +} + +.layout, .recentProcessLimit { + width: 70%; + height: 100%; + display: flex; + flex-direction: row; + align-items: center; +} + +.switch, .select { + width: 30%; + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; +} + +.over { + height: 100px; + width: 70%; + background-color: #BE008000; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + border-radius: 20px; +} + +.over:active { + background-color: green; +} + +.layoutButton { + background-color: green; + height: 50%; + width: 15%; + border-radius: 30px; + border-color: #A0A0A0; + border-width: 2px; + margin:3px ; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/launcher/src/main/js/default/pages/SettingsView/SettingsView.hml b/launcher/src/main/js/default/pages/SettingsView/SettingsView.hml new file mode 100644 index 00000000..7285adcb --- /dev/null +++ b/launcher/src/main/js/default/pages/SettingsView/SettingsView.hml @@ -0,0 +1,88 @@ + + +
+
+ + {{$t('strings.settings')}} + +
+
+ + + + + {{$t('strings.layout')}} + + + +
+
+ + {{layout}} + +
+
+ +
+
+
+ +
+
+ {{$item.layout}} +
+
+
+
+ + + + {{$t('strings.recent_tasks_settings')}} + + + +
+
+ + {{recentProcessLimit}} + +
+
+ +
+
+
+
+
+
+
+ + {{$t('strings.carry_out')}} + +
+
diff --git a/launcher/src/main/js/default/pages/SettingsView/SettingsView.js b/launcher/src/main/js/default/pages/SettingsView/SettingsView.js new file mode 100644 index 00000000..47fe4dc2 --- /dev/null +++ b/launcher/src/main/js/default/pages/SettingsView/SettingsView.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import SettingsPresenter from '../../presenter/settings/SettingsPresenter.js'; +import Colors from '../../common/colors/Colors.js' +import LayoutConstants from '../../common/constants/LayoutConstants.js' + +var mSettingsPresenter; +var mGridConfig; + +export default { + data: { + layout: "", + checked: false, + layoutButtonStyle: [], + gridLayoutTable: [], + recentProcessLimit: '' + }, + + onInit() { + mSettingsPresenter = new SettingsPresenter(this.$app.$def.data.settingsModel); + mGridConfig = mSettingsPresenter.getGridConfig(); + this.gridLayoutTable = mSettingsPresenter.getGridLayoutTable() + this.recentProcessLimit = mSettingsPresenter.getRecentProcessLimit(); + for (let i = 0; i < this.gridLayoutTable.length; i++) { + this.layoutButtonStyle.push({ + color: "", + fontColor: "" + }); + } + }, + + onShow() { + this.layout = mSettingsPresenter.getAppPageStartConfig(); + if (this.layout == LayoutConstants.Grid) { + this.checked = false; + this.layout = LayoutConstants.Grid; + } else { + this.checked = true; + this.layout = LayoutConstants.List; + } + for (let i = 0; i < this.gridLayoutTable.length; i++) { + if (i == mGridConfig.id) { + this.layoutButtonStyle[i].color = Colors.bgSelectedColor; + this.layoutButtonStyle[i].fontColor = Colors.fontSelectedColor; + } else { + this.layoutButtonStyle[i].color = Colors.bgUnselectedColor; + this.layoutButtonStyle[i].fontColor = Colors.fontUnselectedColor; + } + } + }, + + changeSwitch() { + if (this.checked) { + this.checked = false; + this.layout = LayoutConstants.Grid; + } else { + this.checked = true; + this.layout = LayoutConstants.List; + } + }, + + changeSelect(selected) { + this.recentProcessLimit = Number(selected.newValue) + mSettingsPresenter.setRecentProcessLimit(this.recentProcessLimit); + }, + + submit() { + mSettingsPresenter.setAppPageStartConfig(this.layout); + mSettingsPresenter.settingUpdate(); + mSettingsPresenter.setRecentProcessLimit(this.recentProcessLimit); + }, + + changeLayout(id) { + for (let i = 0; i < this.gridLayoutTable.length; i++) { + if (i == id) { + this.layoutButtonStyle[i].color = Colors.bgSelectedColor; + this.layoutButtonStyle[i].fontColor = Colors.fontSelectedColor; + } else { + this.layoutButtonStyle[i].color = Colors.bgUnselectedColor; + this.layoutButtonStyle[i].fontColor = Colors.fontUnselectedColor; + } + } + mSettingsPresenter.setGridConfig(id); + } +} diff --git a/launcher/src/main/js/default/presenter/app/AppGridPresenter.js b/launcher/src/main/js/default/presenter/app/AppGridPresenter.js new file mode 100644 index 00000000..ca3c8b9c --- /dev/null +++ b/launcher/src/main/js/default/presenter/app/AppGridPresenter.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import BaseAppPresenter from './base/BaseAppPresenter.js'; + +var mSettingsModel; +var mGridConfig; +var mAppGridList = []; +var viewCallback; +var mIndex = 0; + +export default class AppGridPresenter extends BaseAppPresenter { + constructor(AppModel, SettingsModel) { + super(AppModel); + this.appModel = AppModel; + mSettingsModel = SettingsModel; + mGridConfig = mSettingsModel.getGridConfig(); + } + + pagingFiltering(mblist) { + mAppGridList = []; + var listLength = mblist.length; + var column = mGridConfig.column; + var row = mGridConfig.row; + var page = Math.ceil(listLength / column / row); + for (var k = 0; k < page; k++) { + var appPageList = []; + for (var i = 0; i < row; i++) { + var appRowList = []; + for (var j = 0; j < column; j++) { + if ((i * column) + j + k * column * row >= listLength) { + var appInfo = { + System: false, + AppName: '', + AppId: '', + AppIcon: '', + bundleName: '', + labelId: '', + visibility: 'hidden' + }; + appRowList.push(appInfo); + } else { + var tmp ={ + System: mblist[(i * column) + j + k * column * row].System, + AppName: mblist[(i * column) + j + k * column * row].AppName, + AppId: mblist[(i * column) + j + k * column * row].AppId, + AppIcon: mblist[(i * column) + j + k * column * row].AppIcon, + bundleName: mblist[(i * column) + j + k * column * row].bundleName, + labelId: mblist[(i * column) + j + k * column * row].labelId, + visibility:'visible' + }; + appRowList.push(tmp); + } + } + appPageList.push(appRowList); + } + mAppGridList.push(appPageList); + } + return mAppGridList; + } + + getGridList(callback) { + viewCallback = callback; + this.appModel.getGridPagesAppList(this.getGridListCallback.bind(this)); + } + + getGridListCallback(list) { + let callbackList = this.pagingFiltering(list); + viewCallback(callbackList); + } + + getGridIndex() { + return mIndex; + } + + setGridIndex(index) { + mIndex = index + } + + getBootAppList() { + return this.appModel.getGridBootAppList(); + } + +} \ No newline at end of file diff --git a/launcher/src/main/js/default/presenter/app/AppListPresenter.js b/launcher/src/main/js/default/presenter/app/AppListPresenter.js new file mode 100644 index 00000000..a9c2e277 --- /dev/null +++ b/launcher/src/main/js/default/presenter/app/AppListPresenter.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import BaseAppPresenter from './base/BaseAppPresenter.js'; + +export default class AppListPresenter extends BaseAppPresenter { + constructor(AppModel) { + super(AppModel); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/presenter/app/base/BaseAppPresenter.js b/launcher/src/main/js/default/presenter/app/base/BaseAppPresenter.js new file mode 100644 index 00000000..96b455a3 --- /dev/null +++ b/launcher/src/main/js/default/presenter/app/base/BaseAppPresenter.js @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import RouterUtil from '../../../common/utils/RouterUtil.js'; + +const JUMPSETTING='pages/SettingsView/SettingsView'; +var viewCallback; +var uninstallCallback; + +export default class BaseAppPresenter { + constructor(AppModel) { + this.appModel = AppModel; + } + + getAppList(callback) { + viewCallback = callback; + this.appModel.getAppList(this.getListCallback.bind(this)); + } + + getListCallback(list) { + let callbacklist = list.sort( + function compareFunction(param1, param2) { + return param1.AppName.localeCompare(param2.AppName, "zh"); + } + ); + + viewCallback(callbacklist); + } + + uninstallApp(uninstallAppName, ifSystem, callback) { + uninstallCallback = callback; + if (ifSystem == true) { + callback(false); + } else { + this.appModel.uninstallApp(uninstallAppName, this.uninstallAppCallback.bind(this)); + } + } + + uninstallAppCallback(callback) { + uninstallCallback(callback); + } + + jumpTo(bundleName) { + this.appModel.openApplication(bundleName); + } + + jumpToSetting() { + RouterUtil.push(JUMPSETTING); + } + + back() { + RouterUtil.back(); + } + + clearRouter() { + RouterUtil.clear(); + } + + registerAppUninstallListener(listener) { + this.appModel.registerAppUninstallListener(listener); + } + + registerAppInstallListener(listener) { + console.info("Launcher BaseAppPresenter registerAppInstallListener start"); + this.appModel.registerAppInstallListener(listener); + } + + unregisterAppInstallListener(listener) { + this.appModel.unregisterAppInstallListener(listener); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/presenter/entry/EntryPresenter.js b/launcher/src/main/js/default/presenter/entry/EntryPresenter.js new file mode 100644 index 00000000..f0ceb61a --- /dev/null +++ b/launcher/src/main/js/default/presenter/entry/EntryPresenter.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import RouterUtil from '../../common/utils/RouterUtil.js'; +import LayoutConstants from '../../common/constants/LayoutConstants.js' +import PageData from '../../common/constants/PageData.js'; + +const GRID = LayoutConstants.Grid; +const GRID_APP_VIEW = PageData.GRID_APP_PAGE; +const LIST_APP_VIEW = PageData.LIST_APP_PAGE; +var mSettingsModel; + +export default class EntryPresenter { + constructor(settingsModel) { + mSettingsModel = settingsModel; + } + + startAppListView() { + console.info("Launcher EntryPresenter startAppListView start"); + let data = mSettingsModel.getAppPageStartConfig(); + if (data == GRID) { + RouterUtil.replace(GRID_APP_VIEW); + } else { + RouterUtil.replace(LIST_APP_VIEW); + } + console.info("Launcher EntryPresenter startAppListView end"); + } +} \ No newline at end of file diff --git a/launcher/src/main/js/default/presenter/settings/SettingsPresenter.js b/launcher/src/main/js/default/presenter/settings/SettingsPresenter.js new file mode 100644 index 00000000..f57819a8 --- /dev/null +++ b/launcher/src/main/js/default/presenter/settings/SettingsPresenter.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import RouterUtil from '../../common/utils/RouterUtil.js'; +import LayoutConstants from '../../common/constants/LayoutConstants.js' +import PageData from '../../common/constants/PageData.js'; + +const GRID = LayoutConstants.Grid; +const GRID_APP_VIEW = PageData.GRID_APP_PAGE; +const LIST_APP_VIEW = PageData.LIST_APP_PAGE; +var mSettingsModel; + +export default class SettingsPresenter { + constructor(settingsModel) { + mSettingsModel = settingsModel; + } + + getAppPageStartConfig() { + return mSettingsModel.getAppPageStartConfig(); + } + + setAppPageStartConfig(type) { + mSettingsModel.setAppPageStartConfig(type); + } + + settingUpdate() { + if (mSettingsModel.getAppPageStartConfig() == GRID) { + RouterUtil.replace(GRID_APP_VIEW); + } else { + RouterUtil.replace(LIST_APP_VIEW); + } + } + + getGridConfig() { + return mSettingsModel.getGridConfig(); + } + + setGridConfig(id) { + mSettingsModel.setGridConfig(id); + } + + getGridLayoutTable() { + return mSettingsModel.getGridLayoutTable(); + } + + getRecentProcessLimit() { + return mSettingsModel.getRecentProcessLimit(); + } + + setRecentProcessLimit(num) { + mSettingsModel.setRecentProcessLimit(num) + } + + /** + * Back to the desktop interface + */ + backToTheDesktop() { + this.settingUpdate(); + } +} \ No newline at end of file diff --git a/launcher/src/main/resources/base/element/string.json b/launcher/src/main/resources/base/element/string.json new file mode 100644 index 00000000..3a1e3ea1 --- /dev/null +++ b/launcher/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Launcher" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/launcher/src/main/resources/base/media/icon.png b/launcher/src/main/resources/base/media/icon.png new file mode 100644 index 00000000..ce307a88 Binary files /dev/null and b/launcher/src/main/resources/base/media/icon.png differ diff --git a/launcher/src/main/resources/base/media/icon_small.png b/launcher/src/main/resources/base/media/icon_small.png new file mode 100644 index 00000000..0ed5fea2 Binary files /dev/null and b/launcher/src/main/resources/base/media/icon_small.png differ diff --git a/local.properties b/local.properties new file mode 100755 index 00000000..5ce895d2 --- /dev/null +++ b/local.properties @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Thu Mar 18 17:01:34 CST 2021 +hwsdk.dir=XXX +native.dir=XXX +nodejs.dir=XXX diff --git a/recents/build.gradle b/recents/build.gradle new file mode 100644 index 00000000..5c6256e9 --- /dev/null +++ b/recents/build.gradle @@ -0,0 +1,22 @@ +apply plugin: 'com.huawei.ohos.hap' +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + supportSystem "standard" + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + entryModules "launcher" +} + +dependencies { + entryImplementation project(':launcher') +} + diff --git a/recents/package.json b/recents/package.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/recents/package.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/recents/src/main/config.json b/recents/src/main/config.json new file mode 100644 index 00000000..8f7c2571 --- /dev/null +++ b/recents/src/main/config.json @@ -0,0 +1,59 @@ +{ + "app": { + "bundleName": "com.ohos.launcher", + "vendor": "ohos", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.launcher.recents", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "recents", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "visible": true, + "name": "com.ohos.launcher.recents.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "metaData": { + "customizeData": [ + { + "name": "hwc-theme" + } + ] + } + } + ], + "js": [ + { + "pages": [ + "pages/recent/recent" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/app.js b/recents/src/main/js/default/app.js new file mode 100644 index 00000000..dfb8ca10 --- /dev/null +++ b/recents/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import RecentsModel from './common/model/RecentsModel.js' + +export default { + data: { + recentsModel: new RecentsModel(), + }, + onCreate() { + console.info('Launcher recents AceApplication onCreate'); + }, + onDestroy() { + console.info('Launcher recents AceApplication onDestroy'); + } +}; diff --git a/recents/src/main/js/default/common/component/AppIcon/AppIcon.css b/recents/src/main/js/default/common/component/AppIcon/AppIcon.css new file mode 100644 index 00000000..00c9529c --- /dev/null +++ b/recents/src/main/js/default/common/component/AppIcon/AppIcon.css @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../css/CommonPageStyle.css'; + +.image-box { + height: 80px; + width: 80px; + display: flex; + align-items: center; + justify-content: center; +} + + diff --git a/recents/src/main/js/default/common/component/AppIcon/AppIcon.hml b/recents/src/main/js/default/common/component/AppIcon/AppIcon.hml new file mode 100644 index 00000000..70f0c093 --- /dev/null +++ b/recents/src/main/js/default/common/component/AppIcon/AppIcon.hml @@ -0,0 +1,20 @@ + + +
+ +
\ No newline at end of file diff --git a/recents/src/main/js/default/common/component/AppIcon/AppIcon.js b/recents/src/main/js/default/common/component/AppIcon/AppIcon.js new file mode 100644 index 00000000..cbb56de8 --- /dev/null +++ b/recents/src/main/js/default/common/component/AppIcon/AppIcon.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ResourceManager from '../../model/ResourceManager.js'; + +var mResourceManager; + +export default { + props: ['itemAppId', 'itemAppIcon', 'itemBundleName'], + data() { + return { + bundleName: this.itemBundleName, + appId: this.itemAppId, + appIcon: "" + }; + }, + onInit() { + console.info("Launcher recents AppIcon onInit start") + this.$watch('itemAppIcon', 'appIconWatcher'); + mResourceManager = new ResourceManager(); + mResourceManager.getAppIcon(this.itemAppIcon, this.itemBundleName, this.iconLoadCallback); + console.info("Launcher recents AppIcon onInit end") + }, + onShow() { + + }, + appIconWatcher(newV, oldV) { + if (newV != null && newV != undefined) { + mResourceManager.getAppIcon(this.itemAppIcon, this.itemBundleName, this.iconLoadCallback); + } + }, + iconLoadCallback(image) { + this.appIcon = image; + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/common/component/AppName/AppName.css b/recents/src/main/js/default/common/component/AppName/AppName.css new file mode 100644 index 00000000..235e1703 --- /dev/null +++ b/recents/src/main/js/default/common/component/AppName/AppName.css @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../css/CommonPageStyle.css'; + +.app-name { + color: black; +} diff --git a/recents/src/main/js/default/common/component/AppName/AppName.hml b/recents/src/main/js/default/common/component/AppName/AppName.hml new file mode 100644 index 00000000..3dd26835 --- /dev/null +++ b/recents/src/main/js/default/common/component/AppName/AppName.hml @@ -0,0 +1,20 @@ + + + + {{ appName }} + diff --git a/recents/src/main/js/default/common/component/AppName/AppName.js b/recents/src/main/js/default/common/component/AppName/AppName.js new file mode 100644 index 00000000..64c103c2 --- /dev/null +++ b/recents/src/main/js/default/common/component/AppName/AppName.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ResourceManager from '../../model/ResourceManager.js'; + +var mResourceManager; + +export default { + props: ['itemAppId', 'itemLabelId', 'itemBundleName', 'itemAppName'], + data() { + return { + labelId: this.itemLabelId, + bundleName: this.itemBundleName, + appId: this.itemAppId, + appName: "" + }; + }, + onInit() { + this.$watch('itemLabelId', 'appIconWatcher'); + mResourceManager = new ResourceManager(); + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + }, + onShow() { + + }, + appIconWatcher(newV, oldV) { + if (newV != null && newV != undefined) { + mResourceManager.getAppName(this.itemLabelId, this.itemBundleName, this.itemAppName, this.iconLoadCallback); + } + }, + iconLoadCallback(name) { + this.appName = name; + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/common/css/CommonPageStyle.css b/recents/src/main/js/default/common/css/CommonPageStyle.css new file mode 100644 index 00000000..f74b1375 --- /dev/null +++ b/recents/src/main/js/default/common/css/CommonPageStyle.css @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.app-icon-img { + border-radius: 20px; + width: 80px; + height: 80px; +} + +.app-icon-img:active { + width: 75px; + height: 75px; +} + +.app-name { + color: black; +} \ No newline at end of file diff --git a/recents/src/main/js/default/common/model/RecentsModel.js b/recents/src/main/js/default/common/model/RecentsModel.js new file mode 100644 index 00000000..9eac335b --- /dev/null +++ b/recents/src/main/js/default/common/model/RecentsModel.js @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import napiAbilityManager from '@ohos.napi_ability_manager'; +import featureAbility from '@ohos.feature_ability'; +import storage from '@ohos.data.storage'; +import bundle_mgr from '@ohos.bundle_mgr'; +import feature_ability from '@ohos.feature_ability'; + +var RECENT_PROCESS_LIMIT_KEY = 'RecentProcessLimit'; +const PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.launcher/sharedPreference/LauncherPreference'; +var mRecentList = []; +var DEFAULT_RECENT_PROCESS_LIMIT = 10; +var INCLUDE_SYSTEM_APP = 0; +var EXCLUDE_SYSTEM_APP = 1; +var mIconResultCount = 0; +var mPreferences = storage.getStorageSync(PREFERENCES_PATH); + +export default class RecentsModel { + getRecentProcessList(callback) { + console.info("Launcher recents RecentsModel getRecentProcessList start") + mRecentList = []; + mIconResultCount = 0; + console.info("Launcher recents RecentsModel napiAbilityManager.queryRecentAbilityMissionInfos start") + napiAbilityManager.queryRecentAbilityMissionInfos().then((data) => { + console.info("Launcher recents RecentsModel napiAbilityManager.queryRecentAbilityMissionInfos() callback") + console.info('Launcher recents queryRecentAbilityMissionInfos data length [' + data.length + ']'); + console.info('Launcher recents queryRecentAbilityMissionInfos data = ' + JSON.stringify(data)); + for (var i = 0; i < data.length; i++) { + let recentTaskInfo = { + AppName: data[i].missionDescription.label, + AppId: data[i].topAbility.bundleName, + bundleName: data[i].topAbility.bundleName, + abilityName: data[i].topAbility.abilityName, + iconId: '', + labelId: '', + missionId: data[i].id + } + mRecentList.push(recentTaskInfo); + } + console.info('Launcher recents RecentsModel queryRecentAbilityMissionInfos mRecentList = ' + JSON.stringify(mRecentList)); + for (let element of mRecentList) { + console.info('Launcher recents RecentsModel bundle_mgr.getApplicationInfo element of mRecentList = ' + JSON.stringify(element)); + bundle_mgr.getApplicationInfo(element.AppId).then(data => { + console.info('Launcher recents bundle_mgr.getApplicationInfo data = ' + JSON.stringify(data)); + let recentTaskInfo = mRecentList.find((recentItem) => { + if (recentItem.AppId == data.bundleName) return recentItem; + }); + recentTaskInfo.iconId = data.iconId; + recentTaskInfo.labelId = data.labelId; + mIconResultCount++; + console.info('Launcher recents getApplicationInfo mIconResultCount = ' + mIconResultCount); + console.info('Launcher recents getApplicationInfo mRecentList.length = ' + mRecentList.length); + if (mIconResultCount == mRecentList.length) { + callback(mRecentList); + } + }); + } + }); + console.info("Launcher recents RecentsModel getRecentProcessList end") + } + + clearRecentProcess() { + console.info("Launcher recents RecentsModel clearRecentProcess start") + while (mRecentList.length > 0) { + mRecentList.pop(); + } + console.info("Launcher recents RecentsModel napiAbilityManager.removeStack start") + napiAbilityManager.removeStack(EXCLUDE_SYSTEM_APP).then((data) => { + console.info('Launcher recents removeStack data [' + data + ']'); + }); + + setTimeout(() => { + console.info("Launcher recents RecentsModel feature_ability.terminateAbility start") + feature_ability.terminateAbility() + .then(data => console.info("Launcher recents terminateAbility promise::then : " + data)) + .catch(error => console.info("Launcher recents terminateAbility promise::catch : " + error)); + }, 1000); + + console.info("Launcher recents RecentsModel clearRecentProcess end") + } + + removeRecentProcess(missionId) { + console.info("Launcher recents RecentsModel removeRecentProcess start") + for (var idx = 0; idx < mRecentList.length; idx++) { + if (mRecentList[idx].missionId == missionId) { + mRecentList.splice(idx, 1); + break; + } + } + console.info("Launcher recents RecentsModel napiAbilityManager.removeMission start") + napiAbilityManager.removeMission(missionId).then((data) => { + console.info('removeMission data [' + data + ']'); + }); + + if (mRecentList.length == 0) { + setTimeout(() => { + console.info("Launcher recents RecentsModel feature_ability.terminateAbility start") + feature_ability.terminateAbility() + .then(data => console.info("Launcher recents terminateAbility promise::then : " + data)) + .catch(error => console.info("Launcher recents terminateAbility promise::catch : " + error)); + }, 1000); + } + console.info("Launcher recents RecentsModel removeRecentProcess end") + } + + getRecentProcessLimit() { + console.info("Launcher recents RecentsModel getRecentProcessLimit start"); + let limit = DEFAULT_RECENT_PROCESS_LIMIT; + if (mPreferences != null && mPreferences != undefined) { + limit = mPreferences.getSync(RECENT_PROCESS_LIMIT_KEY, DEFAULT_RECENT_PROCESS_LIMIT); + } + console.info("Launcher recents RecentsModel getRecentProcessLimit end limit = " + limit); + return limit; + } + + hotStartUpApp(appInfo) { + console.info('Launcher recents hotStartUpApp start'); + this.startAbility(appInfo); + console.info('Launcher recents hotStartUpApp end'); + } + + startAbility(appInfo) { + console.info("Launcher recents startAbility start"); + console.info("Launcher recents featureAbility.startAbility appId = " + JSON.stringify(appInfo)); + featureAbility.startAbility({ + bundleName: appInfo.AppId, + abilityName: appInfo.abilityName, + requestCode: 1, + abilityType: "PageAbility", + want: { + action: "action1", + entities: ["entity1"], + type: "PageAbility", + flags: 2, + elementName: { + deviceId: "deviceId", + bundleName: appInfo.AppId, + abilityName: appInfo.abilityName, + }, + }, + syncOption: 1 + }).then(data => + console.info("Launcher recents promise::then : " + data)).catch(error => + console.info("Launcher recents promise::catch : " + error)); + console.info("Launcher recents startAbility end"); + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/common/model/ResourceManager.js b/recents/src/main/js/default/common/model/ResourceManager.js new file mode 100644 index 00000000..518d90f6 --- /dev/null +++ b/recents/src/main/js/default/common/model/ResourceManager.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import resmgr from '@ohos.resmgr'; + +const DEFAULT_ICON_URL = 'common/pics/icon_default.png'; + +export default class ResourceManager { + ResourceManager() { + } + + getAppIcon(path, bundleName, callback) { + console.info("Launcher recents ResourceManager getAppIcon start path = " + path + " bundleName = " + bundleName); + if (path == null || path == undefined || path == "") { + console.info("Launcher recents ResourceManager defaultIcon callback "); + callback(DEFAULT_ICON_URL) + } else { + console.info("Launcher recents ResourceManager resmgr.getResourceManager called"); + resmgr.getResourceManager(bundleName).then(item => { + console.info("Launcher recents ResourceManager item.getMediaBase64 called"); + item.getMediaBase64(path, (error, value) => { + console.info("Launcher recents ResourceManager item.getMediaBase64 callback value = " + value); + if (value != null) { + callback(value); + } + }); + }); + } + console.info("Launcher recents ResourceManager getAppIcon end"); + } + + getAppName(labelId, bundleName, appName, callback) { + console.info("Launcher recents ResourceManager getAppName start labelId = " + labelId + + " bundleName = " + bundleName + " appName = " + appName); + if (labelId <= 0) { + callback(appName); + } else { + console.info("Launcher recents ResourceManager resmgr.getResourceManager "); + resmgr.getResourceManager(bundleName).then(item => { + console.info("Launcher recents ResourceManager item.getString " + JSON.stringify(item)); + item.getString(labelId, (error, value) => { + if (value != null) { + console.info("Launcher recents ResourceManager item.getString callback value = " + value); + callback(value); + } + }); + }); + } + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/common/pics/ic_recent_delete.png b/recents/src/main/js/default/common/pics/ic_recent_delete.png new file mode 100644 index 00000000..14346375 Binary files /dev/null and b/recents/src/main/js/default/common/pics/ic_recent_delete.png differ diff --git a/recents/src/main/js/default/common/pics/ic_wallpaper_recent.jpg b/recents/src/main/js/default/common/pics/ic_wallpaper_recent.jpg new file mode 100644 index 00000000..e655997f Binary files /dev/null and b/recents/src/main/js/default/common/pics/ic_wallpaper_recent.jpg differ diff --git a/recents/src/main/js/default/common/pics/img_app_default.png b/recents/src/main/js/default/common/pics/img_app_default.png new file mode 100644 index 00000000..a6f4a7fa Binary files /dev/null and b/recents/src/main/js/default/common/pics/img_app_default.png differ diff --git a/recents/src/main/js/default/i18n/en-US.json b/recents/src/main/js/default/i18n/en-US.json new file mode 100644 index 00000000..9e520910 --- /dev/null +++ b/recents/src/main/js/default/i18n/en-US.json @@ -0,0 +1,4 @@ +{ + "strings": { + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/i18n/zh-CN.json b/recents/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 00000000..9e520910 --- /dev/null +++ b/recents/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,4 @@ +{ + "strings": { + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/pages/recent/recent.css b/recents/src/main/js/default/pages/recent/recent.css new file mode 100644 index 00000000..d9a54f25 --- /dev/null +++ b/recents/src/main/js/default/pages/recent/recent.css @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import '../../common/css/CommonPageStyle.css'; + +.container { + background-image: url("common/pics/ic_wallpaper_recent.jpg"); + background-size: cover; +} + +.body { + height: 80%; + width: 100%; +} + +.list { + display: flex; + flex-direction: row; +} + +.list-item { + height: 100%; + width: 50%; +} + +.app-item { + margin-right: 10px; + margin-left: 10px; + height: 100%; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.app-icon { + width: 100%; + height: 20%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.app-img { + background-size: auto; + width: 100%; + height: 60%; + border-radius: 25px; +} + +.piece { + height: 20%; + width: 100%; + display: flex; + align-items: center; + justify-content: center; +} + +.clear { + background-color: black; + opacity: 0.4; + border-radius: 40px; + height: 80px; + width: 80px; +} + +.clear:active { + opacity: 0.8; +} + +.clear-img { + border-radius: 40px; +} + +.message { + width: 90%; + height: 60px; + background-color: black; + opacity: 0.4; + border-radius: 20px; +} \ No newline at end of file diff --git a/recents/src/main/js/default/pages/recent/recent.hml b/recents/src/main/js/default/pages/recent/recent.hml new file mode 100644 index 00000000..6161ce99 --- /dev/null +++ b/recents/src/main/js/default/pages/recent/recent.hml @@ -0,0 +1,47 @@ + + + + +
+
+ + +
+
+ + + + +
+ + +
+
+
+
+
+
+ + +
+
+ +
\ No newline at end of file diff --git a/recents/src/main/js/default/pages/recent/recent.js b/recents/src/main/js/default/pages/recent/recent.js new file mode 100644 index 00000000..950c65e8 --- /dev/null +++ b/recents/src/main/js/default/pages/recent/recent.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import RecentsPresenter from '../../presenter/recent/RecentsPresenter.js'; + +var mRecentsPresenter; + +export default { + data: { + recentProcessList: [] + }, + onInit() { + console.info("Launcher recents onInit start"); + console.info("Launcher recents onInit end"); + }, + + onShow() { + console.info("Launcher recents onShow start"); + mRecentsPresenter = new RecentsPresenter(this.$app.$def.data.recentsModel); + mRecentsPresenter.getRecentProcessList((data) => { + this.recentProcessList = data; + console.info("Launcher recents onShow getRecentProcessList this.recentProcessList = " + JSON.stringify(this.recentProcessList)); + }); + console.info("Launcher recents onShow end"); + }, + + onHide() { + console.info("Launcher recents onHide start"); + this.recentProcessList = []; + console.info("Launcher recents onHide end"); + }, + + clearAll() { + console.info("Launcher recents clearAll start"); + mRecentsPresenter.clearRecentProcess(); + setTimeout(() => { + console.info("Launcher recents clearAll mRecentsPresenter.back()"); + mRecentsPresenter.back(); + }, 1500); + console.info("Launcher recents clearAll end"); + }, + + clearApp(missionId, e) { + console.info("Launcher recents clearApp start missionId = " + missionId + " e.direction = " + e.direction); + if (e.direction == "up") { + console.info(" mRecentsPresenter.removeRecentProcess missionId = " + missionId); + mRecentsPresenter.removeRecentProcess(missionId); + } + console.info("Launcher recents clearApp end"); + }, + + startUp(appInfo) { + console.info("Launcher recents startUp start appInfo = " + JSON.stringify(appInfo)); + mRecentsPresenter.startUpApp(appInfo); + console.info("Launcher recents startUp end"); + } +} \ No newline at end of file diff --git a/recents/src/main/js/default/presenter/recent/RecentsPresenter.js b/recents/src/main/js/default/presenter/recent/RecentsPresenter.js new file mode 100644 index 00000000..dcd2b9c4 --- /dev/null +++ b/recents/src/main/js/default/presenter/recent/RecentsPresenter.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; + +var mRecentsModel; +var mRecentsLimit; + +export default class RecentsPresenter { + constructor(recentsModel) { + console.info("Launcher recents RecentsPresenter constructor start"); + mRecentsModel = recentsModel; + mRecentsLimit = mRecentsModel.getRecentProcessLimit(); + console.info("Launcher recents RecentsPresenter constructor end"); + } + + getRecentProcessList(callback) { + console.info("Launcher recents RecentsPresenter getRecentProcessList start") + mRecentsModel.getRecentProcessList((data) => { + console.info("Launcher recents RecentsPresenter mRecentsModel.getRecentProcessList data = " + JSON.stringify(data)); + let recentProcessList = data; + if (recentProcessList.length > mRecentsLimit) { + recentProcessList.splice(0, recentProcessList.length - mRecentsLimit); + } + console.info("Launcher recents RecentsPresenter mRecentsModel.getRecentProcessList getRecentProcessList recentProcessList = " + JSON.stringify(recentProcessList)); + callback(recentProcessList); + }); + console.info("Launcher recents RecentsPresenter getRecentProcessList end") + } + + clearRecentProcess() { + console.info("Launcher recents RecentsPresenter clearRecentProcess start"); + mRecentsModel.clearRecentProcess(); + console.info("Launcher recents RecentsPresenter clearRecentProcess end"); + } + + removeRecentProcess(missionId) { + console.info("Launcher recents RecentsPresenter removeRecentProcess start missionId = " + missionId); + mRecentsModel.removeRecentProcess(missionId); + console.info("Launcher recents RecentsPresenter removeRecentProcess end"); + } + + back() { + console.info("Launcher recents RecentsPresenter back start"); + router.back(); + console.info("Launcher recents RecentsPresenter back end"); + } + + startUpApp(appInfo) { + console.info("Launcher recents RecentsPresenter startUpApp start appInfo = " + JSON.stringify(appInfo)); + mRecentsModel.hotStartUpApp(appInfo); + console.info("Launcher recents RecentsPresenter startUpApp end "); + } +} \ No newline at end of file diff --git a/recents/src/main/resources/base/element/string.json b/recents/src/main/resources/base/element/string.json new file mode 100644 index 00000000..614d217c --- /dev/null +++ b/recents/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Recents" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/recents/src/main/resources/base/media/icon.png b/recents/src/main/resources/base/media/icon.png new file mode 100644 index 00000000..ce307a88 Binary files /dev/null and b/recents/src/main/resources/base/media/icon.png differ diff --git a/settings.gradle b/settings.gradle new file mode 100755 index 00000000..b28c933e --- /dev/null +++ b/settings.gradle @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +include ':launcher', ':recents' + diff --git a/signature/launcher.p7b b/signature/launcher.p7b new file mode 100644 index 00000000..f64890d8 Binary files /dev/null and b/signature/launcher.p7b differ