names = UriCompact.getQueryParameterNames(uri);
+
+ IntentParams intentParams = new IntentParams();
for (String name : names) {
- String value = uri.getQueryParameter(name);
+ String value = uri.getFirstQueryParamByKey(name);
+ intentParams.setParam(name,bundle);
put(bundle, name, value);
}
return bundle;
}
- private void put(Bundle bundle, String name, String value) {
+ private void put(IntentParams bundle, String name, String value) {
int type = extraTypes.getType(name);
name = extraTypes.transfer(name);
if (type == ExtraTypes.STRING) {
@@ -108,31 +129,31 @@ public class Mapping {
}
switch (type) {
case ExtraTypes.INT:
- bundle.putInt(name, Integer.parseInt(value));
+ bundle.setParam(name, Integer.parseInt(value));
break;
case ExtraTypes.LONG:
- bundle.putLong(name, Long.parseLong(value));
+ bundle.setParam(name, Long.parseLong(value));
break;
case ExtraTypes.BOOL:
- bundle.putBoolean(name, Boolean.parseBoolean(value));
+ bundle.setParam(name, Boolean.parseBoolean(value));
break;
case ExtraTypes.SHORT:
- bundle.putShort(name, Short.parseShort(value));
+ bundle.setParam(name, Short.parseShort(value));
break;
case ExtraTypes.FLOAT:
- bundle.putFloat(name, Float.parseFloat(value));
+ bundle.setParam(name, Float.parseFloat(value));
break;
case ExtraTypes.DOUBLE:
- bundle.putDouble(name, Double.parseDouble(value));
+ bundle.setParam(name, Double.parseDouble(value));
break;
case ExtraTypes.BYTE:
- bundle.putByte(name, Byte.parseByte(value));
+ bundle.setParam(name, Byte.parseByte(value));
break;
case ExtraTypes.CHAR:
- bundle.putChar(name, value.charAt(0));
+ bundle.setParam(name, value.charAt(0));
break;
default:
- bundle.putString(name, value);
+ bundle.setParam(name, value);
break;
}
}
diff --git a/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/MethodInvoker.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/MethodInvoker.java
new file mode 100644
index 0000000000000000000000000000000000000000..c7ef31390337e618cf90cc08e1e16dc00438d5c7
--- /dev/null
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/MethodInvoker.java
@@ -0,0 +1,16 @@
+package com.github.mzule.abilityrouter.router;
+
+import ohos.aafwk.content.IntentParams;
+import ohos.app.Context;
+/**
+ * Created by CaoDongping on 04/11/2016.
+ */
+public interface MethodInvoker {
+ /**
+ * 调用
+ *
+ * @param context 上下文
+ * @param bundle 存取内容
+ */
+ void invoke(Context context, IntentParams bundle);
+}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/Path.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Path.java
similarity index 63%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/Path.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Path.java
index 43502a6605916f5e71f36d540eca6922bf7f9c86..28ec45476c153d6c1deaa980e770214b8daf4af4 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/Path.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Path.java
@@ -1,7 +1,6 @@
-package com.github.mzule.activityrouter.router;
-
-import android.net.Uri;
+package com.github.mzule.abilityrouter.router;
+import ohos.utils.net.Uri;
/**
* Created by CaoDongping on 4/7/16.
*/
@@ -12,7 +11,13 @@ public class Path {
private Path(String value) {
this.value = value;
}
-
+ /**
+ * 路径匹配方法
+ *
+ * @param format 格式
+ * @param link 链接
+ * @return match 匹配
+ */
public static boolean match(final Path format, final Path link) {
if (format == null || link == null) {
return false;
@@ -20,28 +25,33 @@ public class Path {
if (format.length() != link.length()) {
return false;
}
- Path x = format;
- Path y = link;
- while (x != null) {
- if (!x.match(y)) {
+ Path xt = format;
+ Path ya = link;
+ while (xt != null) {
+ if (!xt.match(ya)) {
return false;
}
- x = x.next;
- y = y.next;
+ xt = xt.next;
+ ya = ya.next;
}
return true;
}
-
+ /**
+ * 创建
+ *
+ * @param uri URI地址
+ * @return create 创建
+ */
public static Path create(Uri uri) {
Path path = new Path(uri.getScheme().concat("://"));
- String urlPath = uri.getPath();
+ String urlPath = uri.getDecodedPath();
if (urlPath == null) {
urlPath = "";
}
if (urlPath.endsWith("/")) {
urlPath = urlPath.substring(0, urlPath.length() - 1);
}
- parse(path, uri.getHost() + urlPath);
+ parse(path, uri.getDecodedHost() + urlPath);
return path;
}
@@ -54,11 +64,19 @@ public class Path {
curPath = temp;
}
}
-
+ /**
+ * 定义一个获取下一个内容的方法
+ *
+ * @return next 下一个
+ */
public Path next() {
return next;
}
-
+ /**
+ * 定义一个长度的方法
+ *
+ * @return length 长度
+ **/
public int length() {
Path path = this;
int len = 1;
@@ -76,17 +94,30 @@ public class Path {
public boolean isArgument() {
return value.startsWith(":");
}
-
+ /**
+ * 论据的方法
+ *
+ * @return argument 论据
+ */
public String argument() {
return value.substring(1);
}
-
+ /**
+ * 定义一个获取value的方法
+ *
+ * @return value 类型
+ */
public String value() {
return value;
}
-
+ /**
+ * 定义一个判断是否是http的方法
+ *
+ * @return isHttp 是http
+ */
public boolean isHttp() {
String low = value.toLowerCase();
return low.startsWith("http://") || low.startsWith("https://");
}
+
}
diff --git a/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterAbility.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..01a1f3c0502d7aa8812b6997571285255a51423b
--- /dev/null
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterAbility.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.router;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.utils.net.Uri;
+/**
+ * Created by CaoDongping on 4/6/16.
+ */
+public class RouterAbility extends Ability {
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ RouterCallback callback = getRouterCallback();
+ Uri uri = getIntent().getUri();
+ if (uri != null) {
+ Routers.open(this, uri, callback);
+ }
+
+ terminateAbility();
+ }
+
+ private RouterCallback getRouterCallback() {
+ if (getAbilityPackage() instanceof RouterCallbackProvider) {
+ return ((RouterCallbackProvider) getAbilityPackage()).provideRouterCallback();
+ }
+ return null;
+ }
+}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallback.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallback.java
similarity index 30%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallback.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallback.java
index e7981f978189594ca78001911ffd287c9ed58143..d046a957570716b59e0c1007d5bfa561a8effb73 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallback.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallback.java
@@ -1,17 +1,39 @@
-package com.github.mzule.activityrouter.router;
-
-import android.content.Context;
-import android.net.Uri;
+package com.github.mzule.abilityrouter.router;
+import ohos.app.Context;
+import ohos.utils.net.Uri;
/**
* Created by CaoDongping on 4/8/16.
*/
public interface RouterCallback {
+ /**
+ * 定义一个未找到的方法
+ *
+ * @param context 上下文
+ * @param uri URI地址
+ */
void notFound(Context context, Uri uri);
-
+ /**
+ * 定义一个打开前的方法
+ *
+ * @param context 上下文
+ * @param uri URI地址
+ * @return beforOpen 打开前
+ */
boolean beforeOpen(Context context, Uri uri);
-
+ /**
+ * 定义一个打开后的方法
+ *
+ * @param context 上下文
+ * @param uri URI地址
+ */
void afterOpen(Context context, Uri uri);
-
+ /**
+ * 定义一个错误的方法
+ *
+ * @param context 上下文
+ * @param uri URI地址
+ * @param e 错误
+ */
void error(Context context, Uri uri, Throwable e);
}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallbackProvider.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallbackProvider.java
similarity index 49%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallbackProvider.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallbackProvider.java
index 1cbb0efa76a877e7fb8fa5c8245e014040f41512..ba7614d2600d2aa3543d6e83c5ea1141645950fc 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterCallbackProvider.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/RouterCallbackProvider.java
@@ -1,8 +1,13 @@
-package com.github.mzule.activityrouter.router;
+package com.github.mzule.abilityrouter.router;
/**
* Created by CaoDongping on 4/8/16.
*/
public interface RouterCallbackProvider {
+ /**
+ * 提供路由器回调
+ *
+ * @return RouterCallback 回调
+ * */
RouterCallback provideRouterCallback();
}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/Routers.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Routers.java
similarity index 38%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/Routers.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Routers.java
index 114e409684af69b4bc5eb16d45b5fb517f8026f5..95a2bffb9015477a2665e67c62376e1f1f15ef4a 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/Routers.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/Routers.java
@@ -1,24 +1,22 @@
-package com.github.mzule.activityrouter.router;
+package com.github.mzule.abilityrouter.router;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.app.Context;
+import ohos.utils.net.Uri;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
/**
* Created by CaoDongping on 4/6/16.
*/
public class Routers {
-
- public static String KEY_RAW_URL = "com.github.mzule.activityrouter.router.KeyRawUrl";
-
- private static List mappings = new ArrayList<>();
-
+ private static final String KEY_RAW_URL = "com.github.mzule.abilityrouter.router.KeyRawUrl";
+ private static final List mappings = new ArrayList<>();
+ private static final int MARK = 15;
private static void initIfNeed() {
if (!mappings.isEmpty()) {
return;
@@ -26,9 +24,17 @@ public class Routers {
RouterInit.init();
sort();
}
-
- static void map(String format, Class extends Activity> activity, MethodInvoker method, ExtraTypes extraTypes) {
- mappings.add(new Mapping(format, activity, method, extraTypes));
+ /**
+ * 调用
+ *
+ * @param format 格式
+ * @param ability 目标ability类
+ * @param method 方法
+ * @param extraTypes 额外类型
+ * */
+ public static void map(String format,Class extends Ability> ability,
+ MethodInvoker method,ExtraTypes extraTypes) {
+ mappings.add(new Mapping(format, ability, method, extraTypes));
}
private static void sort() {
@@ -41,41 +47,101 @@ public class Routers {
}
});
}
-
+ /**
+ * 通过url打开匹配页面
+ *
+ * @param context 上下文
+ * @param url string类型的地址
+ * @return open 通过url打开匹配页面
+ * */
public static boolean open(Context context, String url) {
return open(context, Uri.parse(url));
}
-
+ /**
+ * 通过路由器回调的方法进行打开匹配页面
+ *
+ * @param context 上下文
+ * @param url string类型的地址
+ * @param callback 回调
+ * @return open 通过路由器回调的方法进行打开匹配页面
+ * */
public static boolean open(Context context, String url, RouterCallback callback) {
return open(context, Uri.parse(url), callback);
}
-
+ /**
+ * 打开匹配的uri页面
+ *
+ * @param context 上下文
+ * @param uri 地址
+ * @return open 打开匹配的uri页面
+ * */
public static boolean open(Context context, Uri uri) {
return open(context, uri, getGlobalCallback(context));
}
-
+ /**
+ * 打开匹配Uri的页面并回调
+ *
+ * @param context 上下文
+ * @param uri 地址
+ * @param callback 回调
+ * @return open 打开匹配Uri的页面并回调
+ * */
public static boolean open(Context context, Uri uri, RouterCallback callback) {
return open(context, uri, -1, callback);
}
-
- public static boolean openForResult(Activity activity, String url, int requestCode) {
- return openForResult(activity, Uri.parse(url), requestCode);
- }
-
- public static boolean openForResult(Activity activity, String url, int requestCode, RouterCallback callback) {
- return openForResult(activity, Uri.parse(url), requestCode, callback);
- }
-
- public static boolean openForResult(Activity activity, Uri uri, int requestCode) {
- return openForResult(activity, uri, requestCode, getGlobalCallback(activity));
- }
-
- public static boolean openForResult(Activity activity, Uri uri, int requestCode, RouterCallback callback) {
- return open(activity, uri, requestCode, callback);
+ /**
+ * 通过目标url打开指定ability并回调
+ *
+ * @param ability 目标ability
+ * @param url 地址
+ * @param requestCode 请求代码的参数
+ * @return openForResult 通过目标url打开指定ability并回调
+ * */
+ public static boolean openForResult(Ability ability, String url, int requestCode) {
+ return openForResult(ability, Uri.parse(url), requestCode);
+ }
+ /**
+ * 通过url打开匹配的页面并回调
+ *
+ * @param ability 目标ability
+ * @param url string类型的url
+ * @param requestCode 请求代码的参数
+ * @param callback 路由器回调
+ * @return openForResult 通过url打开匹配的页面并回调
+ * */
+ public static boolean openForResult(Ability ability, String url, int requestCode, RouterCallback callback) {
+ return openForResult(ability, Uri.parse(url), requestCode, callback);
+ }
+ /**
+ * 打开匹配uri页面并回调结果
+ *
+ * @param ability 目标ability
+ * @param uri 地址
+ * @param requestCode 请求代码的参数
+ * @return openForResult 打开匹配uri页面并回调结果
+ * */
+ public static boolean openForResult(Ability ability, Uri uri, int requestCode) {
+
+ return openForResult(ability, uri, requestCode, getGlobalCallback(ability));
+
+ }
+ /**
+ * 打开匹配的url页面并回调结果
+ *
+ * @param ability 目标ability
+ * @param requestCode 请求代码的参数
+ * @param uri 地址
+ * @param callback 路由器回调
+ * @return openForResult 打开匹配的url页面并回调结果
+ * */
+ public static boolean openForResult(Ability ability, Uri uri, int requestCode, RouterCallback callback) {
+
+ return open(ability, uri, requestCode, callback);
}
private static boolean open(Context context, Uri uri, int requestCode, RouterCallback callback) {
boolean success = false;
+
if (callback != null) {
if (callback.beforeOpen(context, uri)) {
return false;
@@ -100,20 +166,37 @@ public class Routers {
}
return success;
}
-
+ /**
+ * resolve
+ *
+ * @param context 上下文
+ * @param url 地址
+ * @return intent 返回解决的方法
+ * */
public static Intent resolve(Context context, String url) {
return resolve(context, Uri.parse(url));
}
-
+ /**
+ * resolve
+ *
+ * @param context 上下文
+ * @param uri 地址
+ * @return intent 返回null的方法
+ * */
public static Intent resolve(Context context, Uri uri) {
initIfNeed();
Path path = Path.create(uri);
for (Mapping mapping : mappings) {
if (mapping.match(path)) {
- Intent intent = new Intent(context, mapping.getActivity());
- intent.putExtras(mapping.parseExtras(uri));
- intent.putExtra(KEY_RAW_URL, uri.toString());
- return intent;
+ Intent intent2 = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withBundleName(context.getBundleName())
+ .withAbilityName(mapping.getAbility())
+ .build();
+ intent2.setParams(mapping.parseExtras(uri));
+ intent2.setParam(KEY_RAW_URL,uri.toString());
+ intent2.setOperation(operation);
+ return intent2;
}
}
return null;
@@ -124,24 +207,30 @@ public class Routers {
Path path = Path.create(uri);
for (Mapping mapping : mappings) {
if (mapping.match(path)) {
- if (mapping.getActivity() == null) {
+ if (mapping.getAbility() == null) {
mapping.getMethod().invoke(context, mapping.parseExtras(uri));
return true;
}
- Intent intent = new Intent(context, mapping.getActivity());
- intent.putExtras(mapping.parseExtras(uri));
- intent.putExtra(KEY_RAW_URL, uri.toString());
- if (!(context instanceof Activity)) {
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ Intent intent1 = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withBundleName(context.getBundleName())
+ .withAbilityName(mapping.getAbility())
+ .build();
+ intent1.setParams(mapping.parseExtras(uri));
+ intent1.setParam(KEY_RAW_URL,uri.toString());
+ intent1.setOperation(operation);
+
+ if (!(context instanceof Ability)) {
+ intent1.addFlags(Intent.FLAG_ABILITY_NEW_MISSION);
}
if (requestCode >= 0) {
- if (context instanceof Activity) {
- ((Activity) context).startActivityForResult(intent, requestCode);
+ if (context instanceof Ability) {
+ ((Ability)context).startAbilityForResult(intent1,requestCode);
} else {
- throw new RuntimeException("can not startActivityForResult context " + context);
+ throw new RuntimeException("can not startAbilityForResult context " + context);
}
} else {
- context.startActivity(intent);
+ context.startAbility(intent1,MARK);
}
return true;
}
@@ -150,8 +239,8 @@ public class Routers {
}
private static RouterCallback getGlobalCallback(Context context) {
- if (context.getApplicationContext() instanceof RouterCallbackProvider) {
- return ((RouterCallbackProvider) context.getApplicationContext()).provideRouterCallback();
+ if (((Ability)context).getAbilityPackage() instanceof RouterCallbackProvider) {
+ return ((RouterCallbackProvider) ((Ability)context).getAbilityPackage()).provideRouterCallback();
}
return null;
}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/SimpleRouterCallback.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/SimpleRouterCallback.java
similarity index 80%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/SimpleRouterCallback.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/SimpleRouterCallback.java
index 29d44dcf4f4aa21afdcb454eb86e097f13b072a3..2613126975975f5879a37998f9bc1bcb6b48307c 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/SimpleRouterCallback.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/SimpleRouterCallback.java
@@ -1,8 +1,7 @@
-package com.github.mzule.activityrouter.router;
-
-import android.content.Context;
-import android.net.Uri;
+package com.github.mzule.abilityrouter.router;
+import ohos.app.Context;
+import ohos.utils.net.Uri;
/**
* Created by CaoDongping on 4/8/16.
*/
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/UriCompact.java b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/UriCompact.java
similarity index 93%
rename from activityrouter/src/main/java/com/github/mzule/activityrouter/router/UriCompact.java
rename to activityrouter/src/main/java/com/github/mzule/abilityrouter/router/UriCompact.java
index 9030736559a33a7d5dc316b4c16762ed57182d5d..b39d79301d00683e5cb80778147170ce837d2994 100644
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/UriCompact.java
+++ b/activityrouter/src/main/java/com/github/mzule/abilityrouter/router/UriCompact.java
@@ -1,11 +1,9 @@
-package com.github.mzule.activityrouter.router;
-
-import android.net.Uri;
+package com.github.mzule.abilityrouter.router;
+import ohos.utils.net.Uri;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
-
/**
* Created by CaoDongping on 6/1/16.
*/
@@ -36,6 +34,7 @@ public class UriCompact {
String name = query.substring(start, separator);
names.add(Uri.decode(name));
+
// Move start to end of name.
start = end + 1;
} while (start < query.length());
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/MethodInvoker.java b/activityrouter/src/main/java/com/github/mzule/activityrouter/router/MethodInvoker.java
deleted file mode 100644
index 6516713b3135b49a69bbedfaa177732e2947867d..0000000000000000000000000000000000000000
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/MethodInvoker.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.github.mzule.activityrouter.router;
-
-import android.content.Context;
-import android.os.Bundle;
-
-/**
- * Created by CaoDongping on 04/11/2016.
- */
-
-public interface MethodInvoker {
- void invoke(Context context, Bundle bundle);
-}
diff --git a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterActivity.java b/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterActivity.java
deleted file mode 100644
index 0e10e9244d786dcd2874119bc1464a9c270eb279..0000000000000000000000000000000000000000
--- a/activityrouter/src/main/java/com/github/mzule/activityrouter/router/RouterActivity.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.github.mzule.activityrouter.router;
-
-import android.app.Activity;
-import android.net.Uri;
-import android.os.Bundle;
-
-/**
- * Created by CaoDongping on 4/6/16.
- */
-public class RouterActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- RouterCallback callback = getRouterCallback();
-
- Uri uri = getIntent().getData();
- if (uri != null) {
- Routers.open(this, uri, callback);
- }
- finish();
- }
-
- private RouterCallback getRouterCallback() {
- if (getApplication() instanceof RouterCallbackProvider) {
- return ((RouterCallbackProvider) getApplication()).provideRouterCallback();
- }
- return null;
- }
-}
diff --git a/activityrouter/src/main/res/values/strings.xml b/activityrouter/src/main/res/values/strings.xml
deleted file mode 100644
index f9d172dc9d2fb97c7bcf232942a20644d99e64ea..0000000000000000000000000000000000000000
--- a/activityrouter/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- ActivityRouter
-
diff --git a/activityrouter/src/main/resources/base/element/string.json b/activityrouter/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..977dd6bd58cac1f6766ab884475999ecd432867a
--- /dev/null
+++ b/activityrouter/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "abilityrouter"
+ }
+ ]
+}
diff --git a/annotation/build.gradle b/annotation/build.gradle
index ab1b7b8236ade1e052b28cfc621805b67e34d06b..cd1aba7ec07218eb51a9204dbf28ac0aaa576469 100644
--- a/annotation/build.gradle
+++ b/annotation/build.gradle
@@ -1,35 +1,9 @@
-apply plugin: 'java'
+apply plugin: 'java-library'
-sourceCompatibility = 1.7
-targetCompatibility = 1.7
-
-ext {
- bintrayRepo = 'maven'
- bintrayName = 'activity-router-annotation'
-
- publishedGroupId = 'com.github.mzule.activityrouter'
- libraryName = 'Annotation'
- artifact = 'annotation'
-
- libraryDescription = 'Router activities'
-
- siteUrl = 'https://github.com/mzule/ActivityRouter/'
- gitUrl = 'https://github.com/mzule/ActivityRouter.git'
-
- libraryVersion = '1.1.5'
-
- developerId = 'mzule'
- developerName = 'Cao Dongping'
- developerEmail = 'mzule4j@gmail.com'
-
- licenseName = 'The Apache Software License, Version 2.0'
- licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- allLicenses = ["Apache-2.0"]
-}
+sourceCompatibility = "1.8"
+targetCompatibility = "1.8"
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
}
-
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
diff --git a/annotation/src/main/config.json b/annotation/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..025ded63fe3181e379823b266e37ac7f2486354e
--- /dev/null
+++ b/annotation/src/main/config.json
@@ -0,0 +1,27 @@
+{
+ "app": {
+ "bundleName": "com.github.mzule.abilityrouter",
+ "vendor": "github",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.github.mzule.abilityrouter.annotation",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "annotation",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Module.java b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Module.java
similarity index 64%
rename from annotation/src/main/java/com/github/mzule/activityrouter/annotation/Module.java
rename to annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Module.java
index da39df9820d429374f33b7f1539a1edd2eef34ee..559a2053b7c0fde5368e521ae69589b44c07fbee 100644
--- a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Module.java
+++ b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Module.java
@@ -1,4 +1,4 @@
-package com.github.mzule.activityrouter.annotation;
+package com.github.mzule.abilityrouter.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -8,5 +8,10 @@ import java.lang.annotation.RetentionPolicy;
*/
@Retention(RetentionPolicy.CLASS)
public @interface Module {
+ /**
+ * 类型
+ *
+ * @return value 类型
+ * */
String value();
}
diff --git a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Modules.java b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Modules.java
similarity index 65%
rename from annotation/src/main/java/com/github/mzule/activityrouter/annotation/Modules.java
rename to annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Modules.java
index 84aa153dbb26fff26ccdbd87d8a2815c83dbc502..59f302cb12b3837285b07d5f984008f24f1bb3b3 100644
--- a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Modules.java
+++ b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Modules.java
@@ -1,4 +1,4 @@
-package com.github.mzule.activityrouter.annotation;
+package com.github.mzule.abilityrouter.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -8,5 +8,10 @@ import java.lang.annotation.RetentionPolicy;
*/
@Retention(RetentionPolicy.CLASS)
public @interface Modules {
+ /**
+ * 类型
+ *
+ * @return value 类型
+ * */
String[] value();
}
diff --git a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Router.java b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Router.java
similarity index 40%
rename from annotation/src/main/java/com/github/mzule/activityrouter/annotation/Router.java
rename to annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Router.java
index f78fdeab390789c3bf72aedf44d59d1dd397492d..c8437b3c1392be22969d83e56cc0c832ce0adcfa 100644
--- a/annotation/src/main/java/com/github/mzule/activityrouter/annotation/Router.java
+++ b/annotation/src/main/java/com/github/mzule/abilityrouter/annotation/Router.java
@@ -1,33 +1,82 @@
-package com.github.mzule.activityrouter.annotation;
+package com.github.mzule.abilityrouter.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * Router
+ *
+ * @since 2021-04-16
+ * */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface Router {
-
+ /**
+ * 类型
+ *
+ * @return value 类型
+ * */
String[] value();
-
+ /**
+ * 字符串参数
+ *
+ * @return stringParams 字符串
+ * */
String[] stringParams() default "";
-
+ /**
+ * 整形参数
+ *
+ * @return intParams 整形
+ * */
String[] intParams() default "";
-
+ /**
+ * 长参数
+ *
+ * @return longParams long类型
+ * */
String[] longParams() default "";
-
+ /**
+ * boolean类型参数
+ *
+ * @return booleanParams 布尔
+ * */
String[] booleanParams() default "";
-
+ /**
+ * short类型参数
+ *
+ * @return shortParams short类型
+ * */
String[] shortParams() default "";
-
+ /**
+ * float类型参数
+ *
+ * @return floatParams float类型
+ * */
String[] floatParams() default "";
-
+ /**
+ * double类型参数
+ *
+ * @return doubleParams double类型
+ * */
String[] doubleParams() default "";
-
+ /**
+ * byte类型参数
+ *
+ * @return byteParams byte类型
+ * */
String[] byteParams() default "";
-
+ /**
+ * char类型参数
+ *
+ * @return charParams char类型
+ * */
String[] charParams() default "";
-
+ /**
+ * 转移
+ *
+ * @return transfer 转移
+ * */
String[] transfer() default "";
}
diff --git a/annotation/src/main/resources/base/element/string.json b/annotation/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d1b3f2d2bf9ce24dc3f4e5e772be4960d911f0c9
--- /dev/null
+++ b/annotation/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "annotation"
+ }
+ ]
+}
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index 725d2351cca1d7a98948ad9798d31bcf2ecc4fc2..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-apply plugin: 'com.android.application'
-
-sourceCompatibility = 1.7
-targetCompatibility = 1.7
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
-
- defaultConfig {
- applicationId "com.github.mzule.activityrouter"
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- debug {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- release {
- minifyEnabled true
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.2.1'
- compile project(':app_module')
- annotationProcessor project(':compiler')
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index c17b6d1b5a6bbd8deda3a3dcdff5172b8c448581..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/baidu/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
--keep class com.github.mzule.activityrouter.router.** { *; }
diff --git a/app/src/androidTest/java/com/github/mzule/activityrouter/ApplicationTest.java b/app/src/androidTest/java/com/github/mzule/activityrouter/ApplicationTest.java
deleted file mode 100644
index bef2dd12e6153b8653f22ea57a371408cb0cc152..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/com/github/mzule/activityrouter/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index c6a24d5acdb4decf35237c27142b401ede7f2315..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/com/github/mzule/activityrouter/App.java b/app/src/main/java/com/github/mzule/activityrouter/App.java
deleted file mode 100644
index 9707981b2ccbe6d02113aa3fa43e86a51f492f84..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/App.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Modules;
-import com.github.mzule.activityrouter.router.RouterCallback;
-import com.github.mzule.activityrouter.router.RouterCallbackProvider;
-import com.github.mzule.activityrouter.router.SimpleRouterCallback;
-
-import android.app.Application;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
-/**
- * Created by CaoDongping on 4/6/16.
- */
-@Modules({"app", "sdk"})
-public class App extends Application implements RouterCallbackProvider {
- @Override
- public RouterCallback provideRouterCallback() {
- return new SimpleRouterCallback() {
- @Override
- public boolean beforeOpen(Context context, Uri uri) {
- if (uri.toString().startsWith("mzule://")) {
- context.startActivity(new Intent(context, LaunchActivity.class));
- return true;
- }
- return false;
- }
-
- @Override
- public void notFound(Context context, Uri uri) {
- context.startActivity(new Intent(context, NotFoundActivity.class));
- }
-
- @Override
- public void error(Context context, Uri uri, Throwable e) {
- context.startActivity(ErrorStackActivity.makeIntent(context, uri, e));
- }
- };
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/DumpExtrasActivity.java b/app/src/main/java/com/github/mzule/activityrouter/DumpExtrasActivity.java
deleted file mode 100644
index 4621e02e73a3b501ea98af4594eab31e118d24e0..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/DumpExtrasActivity.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.TextView;
-
-import java.util.Set;
-
-/**
- * Created by CaoDongping on 4/7/16.
- */
-public abstract class DumpExtrasActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Bundle extras = getIntent().getExtras();
- if (extras != null) {
- Set keys = extras.keySet();
-
- TextView textView = new TextView(this);
- int padding = getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
- textView.setPadding(padding, padding, padding, padding);
- textView.setText(getClass().getSimpleName());
- textView.append("\n\n");
-
- for (String key : keys) {
- textView.append(key + "=>");
- Object v = extras.get(key);
- if (v != null) {
- textView.append(v + "=>" + v.getClass().getSimpleName());
- } else {
- textView.append("null");
- }
- textView.append("\n\n");
- }
-
- setContentView(textView);
- }
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/ErrorStackActivity.java b/app/src/main/java/com/github/mzule/activityrouter/ErrorStackActivity.java
deleted file mode 100644
index de33f32cbc9de8025ee642407b7ff1c4e433e5b4..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/ErrorStackActivity.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-/**
- * Created by CaoDongping on 8/9/16.
- */
-public class ErrorStackActivity extends Activity {
- public static Intent makeIntent(Context context, Uri uri, Throwable e) {
- Intent intent = new Intent(context, ErrorStackActivity.class);
- intent.putExtra("uri", uri);
- intent.putExtra("error", e);
- return intent;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Throwable e = (Throwable) getIntent().getSerializableExtra("error");
- Uri uri = getIntent().getParcelableExtra("uri");
-
- TextView textView = new TextView(this);
- textView.setText(String.format("Error on open uri %s\n", uri));
- textView.append(Log.getStackTraceString(e));
- textView.setGravity(Gravity.START);
- setContentView(textView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/HomeActivity.java b/app/src/main/java/com/github/mzule/activityrouter/HomeActivity.java
deleted file mode 100644
index f74c0fdc5fb1fdbcfa069103fd7dda95812e85e7..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/HomeActivity.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-import android.content.Intent;
-
-/**
- * Created by CaoDongping on 4/7/16.
- */
-@Router(value = "home/:homeName", stringParams = "o")
-public class HomeActivity extends DumpExtrasActivity {
-
- @Override
- public void finish() {
- Intent intent = new Intent();
- intent.putExtra("msg", "goodbye");
- setResult(RESULT_OK, intent);
- super.finish();
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/HostActivity.java b/app/src/main/java/com/github/mzule/activityrouter/HostActivity.java
deleted file mode 100644
index f408fac7f1a4387c2ca3c5d92b38122a01ec1102..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/HostActivity.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-/**
- * @author Kale
- * @date 2016/8/9
- */
-@Router("with_host")
-public class HostActivity extends DumpExtrasActivity{
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/mzule/activityrouter/LaunchActivity.java b/app/src/main/java/com/github/mzule/activityrouter/LaunchActivity.java
deleted file mode 100644
index 6dc8d4db22be409e1259d84aa5de8b40bd80367c..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/LaunchActivity.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.router.Routers;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import android.widget.Toast;
-
-/**
- * Created by CaoDongping on 4/7/16.
- */
-public class LaunchActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_launch);
- ViewGroup container = (ViewGroup) findViewById(R.id.container);
- for (int i = 0; i < container.getChildCount(); i++) {
- final View view = container.getChildAt(i);
- if (view instanceof TextView) {
- view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- /*
- // 第三方app通过url打开本app的activity时,通过ACTION_VIEW的方式
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(((TextView) view).getText().toString()));
- startActivity(intent);
- */
- // app内打开页面可以使用Routers.open(Context, Uri)
- // Routers.open(LaunchActivity.this, Uri.parse(((TextView) view).getText().toString()), ((RouterCallbackProvider) getApplication()).provideRouterCallback());
- Routers.openForResult(LaunchActivity.this, ((TextView) view).getText().toString(), Constant.REQUEST_CODE_DEMO);
- }
- });
- }
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK && requestCode == Constant.REQUEST_CODE_DEMO) {
- String msg;
- if (data == null) {
- msg = "success";
- } else {
- msg = data.getStringExtra("msg");
- msg = TextUtils.isEmpty(msg) ? "success" : msg;
- }
- Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
- }
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/MainActivity.java b/app/src/main/java/com/github/mzule/activityrouter/MainActivity.java
deleted file mode 100644
index a13d5a2604c84e13e2e92e48f33aa1b509fcaca2..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/MainActivity.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-@Router(value = {"http://mzule.com/main", "main", "home"},
- longParams = {"id", "updateTime"},
- booleanParams = "web",
- transfer = "web=>fromWeb")
-public class MainActivity extends DumpExtrasActivity {
-
- @Override
- public void finish() {
- setResult(RESULT_OK);
- super.finish();
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/NonUIActions.java b/app/src/main/java/com/github/mzule/activityrouter/NonUIActions.java
deleted file mode 100644
index f778a8810525930ca760da1ca53a37ca2b5fd746..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/NonUIActions.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.widget.Toast;
-
-/**
- * Created by CaoDongping on 04/11/2016.
- */
-
-public class NonUIActions {
-
- @Router("logout")
- public static void logout(Context context, Bundle bundle) {
- Toast.makeText(context, "logout", Toast.LENGTH_SHORT).show();
- }
-
- @Router("upload")
- public static void uploadLog(Context context, Bundle bundle) {
- Toast.makeText(context, "upload", Toast.LENGTH_SHORT).show();
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/NotFoundActivity.java b/app/src/main/java/com/github/mzule/activityrouter/NotFoundActivity.java
deleted file mode 100644
index 984ae19ce678e3820e834936e226560e3032e0e1..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/NotFoundActivity.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.Gravity;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-/**
- * Created by CaoDongping on 4/8/16.
- */
-public class NotFoundActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- TextView textView = new TextView(this);
- textView.setText("404");
- textView.setGravity(Gravity.CENTER);
- setContentView(textView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- }
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/UserActivity.java b/app/src/main/java/com/github/mzule/activityrouter/UserActivity.java
deleted file mode 100644
index f260f086d11a01faa61326fbfc17df81768c729d..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/UserActivity.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-/**
- * Created by CaoDongping on 4/7/16.
- */
-@Router({"user/:userId", "user/:nickname/city/:city/gender/:gender/age/:age"})
-public class UserActivity extends DumpExtrasActivity {
-}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/UserCollectionActivity.java b/app/src/main/java/com/github/mzule/activityrouter/UserCollectionActivity.java
deleted file mode 100644
index fb6e89f9f3408613fec76f792683d7f64d55fd4b..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/github/mzule/activityrouter/UserCollectionActivity.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-/**
- * Created by CaoDongping on 4/7/16.
- */
-@Router("user/collection")
-public class UserCollectionActivity extends DumpExtrasActivity {
-}
diff --git a/app/src/main/res/layout/activity_launch.xml b/app/src/main/res/layout/activity_launch.xml
deleted file mode 100644
index a1e75e0838c32f28e139398d02ffd43328cb3827..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_launch.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index f9d172dc9d2fb97c7bcf232942a20644d99e64ea..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- ActivityRouter
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 48e48a6d043458d99955161c9d8151f394c8501a..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/app/src/test/java/com/github/mzule/activityrouter/ExampleUnitTest.java b/app/src/test/java/com/github/mzule/activityrouter/ExampleUnitTest.java
deleted file mode 100644
index a4fd99d308422abf871c9b0ee9ae7abc1c8b4a16..0000000000000000000000000000000000000000
--- a/app/src/test/java/com/github/mzule/activityrouter/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.github.mzule.activityrouter;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/app_module/build.gradle b/app_module/build.gradle
index 2c2ce055bc635061203470b9c462fd3428028c49..76346276b4ba965468281c030836ba979d4aa59f 100644
--- a/app_module/build.gradle
+++ b/app_module/build.gradle
@@ -1,32 +1,15 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 24
- buildToolsVersion "24.0.2"
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 24
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
+ compatibleSdkVersion 4
}
+
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:24.2.1'
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':activityrouter')
annotationProcessor project(':compiler')
diff --git a/app_module/proguard-rules.pro b/app_module/proguard-rules.pro
deleted file mode 100644
index 8e1553780652b555b085fe953ad9fa9d75eeda95..0000000000000000000000000000000000000000
--- a/app_module/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/baidu/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/app_module/src/androidTest/java/com/github/mzule/activityrouter/module/ExampleInstrumentedTest.java b/app_module/src/androidTest/java/com/github/mzule/activityrouter/module/ExampleInstrumentedTest.java
deleted file mode 100644
index 4b2fdd4bbf5a2daa6741676bf928ac117b995eb3..0000000000000000000000000000000000000000
--- a/app_module/src/androidTest/java/com/github/mzule/activityrouter/module/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.github.mzule.activityrouter.module;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.github.mzule.activityrouter.module.test", appContext.getPackageName());
- }
-}
diff --git a/app_module/src/main/AndroidManifest.xml b/app_module/src/main/AndroidManifest.xml
deleted file mode 100644
index 69686e47e8c64abdaf223e4839b5564fd5e105f0..0000000000000000000000000000000000000000
--- a/app_module/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app_module/src/main/config.json b/app_module/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..e61cee23384282c5959c4b7ff8f7c2b3e61781e5
--- /dev/null
+++ b/app_module/src/main/config.json
@@ -0,0 +1,36 @@
+{
+ "app": {
+ "bundleName": "com.github.mzule.abilityrouter",
+ "vendor": "github",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.github.mzule.abilityrouter.module",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "app_module",
+ "moduleType": "har"
+ },
+ "abilities": [
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.module.ModuleAbility",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app_module/src/main/java/com/github/mzule/abilityrouter/module/ModuleAbility.java b/app_module/src/main/java/com/github/mzule/abilityrouter/module/ModuleAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..2396efc6738d818472b6574731b0ee517c557cf9
--- /dev/null
+++ b/app_module/src/main/java/com/github/mzule/abilityrouter/module/ModuleAbility.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.module;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Text;
+
+/**
+ * Created by CaoDongping on 30/10/2016.
+ */
+@Router(value = "module")
+public class ModuleAbility extends Ability {
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_module_layout);
+ Text text = (Text) findComponentById(ResourceTable.Id_module);
+ text.setText("this is ModuleAbility");
+ }
+}
diff --git a/app_module/src/main/java/com/github/mzule/activityrouter/module/SdkModule.java b/app_module/src/main/java/com/github/mzule/abilityrouter/module/SdkModule.java
similarity index 46%
rename from app_module/src/main/java/com/github/mzule/activityrouter/module/SdkModule.java
rename to app_module/src/main/java/com/github/mzule/abilityrouter/module/SdkModule.java
index b326272555e3b864df35ef42aa55953a4366ef02..f2cdba4bb1e5e2be34b01372e706e648e3db05f4 100644
--- a/app_module/src/main/java/com/github/mzule/activityrouter/module/SdkModule.java
+++ b/app_module/src/main/java/com/github/mzule/abilityrouter/module/SdkModule.java
@@ -1,6 +1,6 @@
-package com.github.mzule.activityrouter.module;
+package com.github.mzule.abilityrouter.module;
-import com.github.mzule.activityrouter.annotation.Module;
+import com.github.mzule.abilityrouter.annotation.Module;
/**
* Created by CaoDongping on 30/10/2016.
diff --git a/app_module/src/main/java/com/github/mzule/activityrouter/module/ModuleActivity.java b/app_module/src/main/java/com/github/mzule/activityrouter/module/ModuleActivity.java
deleted file mode 100644
index 3ae347e1f6df137860dd575f07a234d0d4f4db02..0000000000000000000000000000000000000000
--- a/app_module/src/main/java/com/github/mzule/activityrouter/module/ModuleActivity.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.github.mzule.activityrouter.module;
-
-import com.github.mzule.activityrouter.annotation.Router;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.TextView;
-
-/**
- * Created by CaoDongping on 30/10/2016.
- */
-
-@Router("module")
-public class ModuleActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- TextView textView = new TextView(this);
- textView.setText("this is ModuleActivity");
- setContentView(textView);
- }
-}
diff --git a/app_module/src/main/res/values/strings.xml b/app_module/src/main/res/values/strings.xml
deleted file mode 100644
index d1651872b1439e6ea6ce64dec4ffa8ded5559258..0000000000000000000000000000000000000000
--- a/app_module/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Module
-
diff --git a/app_module/src/main/resources/base/element/string.json b/app_module/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..3a3110597f1f0b3f1cdf1a56f3005e64822c0002
--- /dev/null
+++ b/app_module/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "app_module"
+ }
+ ]
+}
diff --git a/app_module/src/main/resources/base/layout/module_layout.xml b/app_module/src/main/resources/base/layout/module_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3fc3121b01533618b71ef0c00413904999304858
--- /dev/null
+++ b/app_module/src/main/resources/base/layout/module_layout.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app_module/src/test/java/com/github/mzule/activityrouter/module/ExampleUnitTest.java b/app_module/src/test/java/com/github/mzule/activityrouter/module/ExampleUnitTest.java
deleted file mode 100644
index 75c8686d29a0c093f49a04fa3d5dcc0128fc53ed..0000000000000000000000000000000000000000
--- a/app_module/src/test/java/com/github/mzule/activityrouter/module/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.github.mzule.activityrouter.module;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 03aec8e4d0ff54d37bd1ca5f985029eada63e457..8cdd760a21b2f97193ac7968854468f4fc746de6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,25 +1,51 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
buildscript {
repositories {
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ maven {
+ url 'https://maven.aliyun.com/nexus/content/groups/public/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.3'
+ classpath 'com.huawei.ohos:hap:2.4.4.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ maven {
+ url 'https://maven.aliyun.com/nexus/content/groups/public/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/compiler/build.gradle b/compiler/build.gradle
index 2e9ed2d309f9654067da8f4d097ce77ba5ea41d8..ef4633b9087403066443c0373392b04d4facc138 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -1,38 +1,13 @@
-apply plugin: 'java'
-
-sourceCompatibility = 1.7
-targetCompatibility = 1.7
-
-ext {
- bintrayRepo = 'maven'
- bintrayName = 'activity-router-compiler'
-
- publishedGroupId = 'com.github.mzule.activityrouter'
- libraryName = 'Compiler'
- artifact = 'compiler'
-
- libraryDescription = 'Router activities'
-
- siteUrl = 'https://github.com/mzule/ActivityRouter/'
- gitUrl = 'https://github.com/mzule/ActivityRouter.git'
-
- libraryVersion = '1.1.7'
-
- developerId = 'mzule'
- developerName = 'Cao Dongping'
- developerEmail = 'mzule4j@gmail.com'
-
- licenseName = 'The Apache Software License, Version 2.0'
- licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- allLicenses = ["Apache-2.0"]
-}
+apply plugin: 'java-library'
dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+ compile project(':annotation')
compile 'com.squareup:javapoet:1.8.0'
compile 'com.google.auto.service:auto-service:1.0-rc3'
- compile 'com.github.mzule.activityrouter:annotation:1.1.5'
+ annotationProcessor 'com.google.auto.service:auto-service:1.0-rc3'
}
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
-
+sourceCompatibility = "1.8"
+targetCompatibility = "1.8"
diff --git a/compiler/src/main/java/com/github/mzule/activityrouter/compiler/RouterProcessor.java b/compiler/src/main/java/com/github/mzule/abilityrouter/compiler/RouterProcessor.java
similarity index 80%
rename from compiler/src/main/java/com/github/mzule/activityrouter/compiler/RouterProcessor.java
rename to compiler/src/main/java/com/github/mzule/abilityrouter/compiler/RouterProcessor.java
index d16a66f75cfce85ea0360199ac5f63b38127e2c0..815d95371affa6310930b9a43a79c40797809acb 100644
--- a/compiler/src/main/java/com/github/mzule/activityrouter/compiler/RouterProcessor.java
+++ b/compiler/src/main/java/com/github/mzule/abilityrouter/compiler/RouterProcessor.java
@@ -1,29 +1,25 @@
-package com.github.mzule.activityrouter.compiler;
+package com.github.mzule.abilityrouter.compiler;
-import java.util.HashSet;
-import java.util.Set;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.Processor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import com.github.mzule.activityrouter.annotation.Module;
-import com.github.mzule.activityrouter.annotation.Modules;
-import com.github.mzule.activityrouter.annotation.Router;
+import com.github.mzule.abilityrouter.annotation.Module;
+import com.github.mzule.abilityrouter.annotation.Modules;
+import com.github.mzule.abilityrouter.annotation.Router;
import com.google.auto.service.AutoService;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
+import java.util.HashSet;
+import java.util.Set;
+/**
+ * RouterProcessor
+ *
+ * @since 2021-04-16
+ * */
@AutoService(Processor.class)
public class RouterProcessor extends AbstractProcessor {
private static final boolean DEBUG = false;
@@ -59,6 +55,7 @@ public class RouterProcessor extends AbstractProcessor {
}
boolean hasModule = false;
boolean hasModules = false;
+
// module
String moduleName = "RouterMapping";
Set extends Element> moduleList = roundEnv.getElementsAnnotatedWith(Module.class);
@@ -67,6 +64,7 @@ public class RouterProcessor extends AbstractProcessor {
moduleName = moduleName + "_" + annotation.value();
hasModule = true;
}
+
// modules
String[] moduleNames = null;
Set extends Element> modulesList = roundEnv.getElementsAnnotatedWith(Modules.class);
@@ -75,6 +73,7 @@ public class RouterProcessor extends AbstractProcessor {
moduleNames = modules.getAnnotation(Modules.class).value();
hasModules = true;
}
+
// RouterInit
if (hasModules) {
debug("generate modules RouterInit");
@@ -83,6 +82,7 @@ public class RouterProcessor extends AbstractProcessor {
debug("generate default RouterInit");
generateDefaultRouterInit();
}
+
// RouterMapping
return handleRouter(moduleName, roundEnv);
}
@@ -96,10 +96,11 @@ public class RouterProcessor extends AbstractProcessor {
.addMethod(initMethod.build())
.build();
try {
- JavaFile.builder("com.github.mzule.activityrouter.router", routerInit)
+ JavaFile.builder("com.github.mzule.abilityrouter.router", routerInit)
.build()
.writeTo(filer);
} catch (Exception e) {
+
e.printStackTrace();
}
}
@@ -115,7 +116,7 @@ public class RouterProcessor extends AbstractProcessor {
.addMethod(initMethod.build())
.build();
try {
- JavaFile.builder("com.github.mzule.activityrouter.router", routerInit)
+ JavaFile.builder("com.github.mzule.abilityrouter.router", routerInit)
.build()
.writeTo(filer);
} catch (Exception e) {
@@ -129,7 +130,7 @@ public class RouterProcessor extends AbstractProcessor {
MethodSpec.Builder mapMethod = MethodSpec.methodBuilder("map")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL, Modifier.STATIC)
.addStatement("java.util.Map transfer = null")
- .addStatement("com.github.mzule.activityrouter.router.ExtraTypes extraTypes")
+ .addStatement("com.github.mzule.abilityrouter.router.ExtraTypes extraTypes")
.addCode("\n");
for (Element element : elements) {
@@ -137,10 +138,10 @@ public class RouterProcessor extends AbstractProcessor {
String[] transfer = router.transfer();
if (transfer.length > 0 && !"".equals(transfer[0])) {
mapMethod.addStatement("transfer = new java.util.HashMap()");
- for (String s : transfer) {
- String[] components = s.split("=>");
+ for (String s1 : transfer) {
+ String[] components = s1.split("=>");
if (components.length != 2) {
- error("transfer `" + s + "` not match a=>b format");
+ error("transfer `" + s1 + "` not match a=>b format");
break;
}
mapMethod.addStatement("transfer.put($S, $S)", components[0], components[1]);
@@ -149,7 +150,7 @@ public class RouterProcessor extends AbstractProcessor {
mapMethod.addStatement("transfer = null");
}
- mapMethod.addStatement("extraTypes = new com.github.mzule.activityrouter.router.ExtraTypes()");
+ mapMethod.addStatement("extraTypes = new com.github.mzule.abilityrouter.router.ExtraTypes()");
mapMethod.addStatement("extraTypes.setTransfer(transfer)");
addStatement(mapMethod, int.class, router.intParams());
@@ -181,14 +182,20 @@ public class RouterProcessor extends AbstractProcessor {
return false;
}
if (element.getKind() == ElementKind.CLASS) {
- mapMethod.addStatement("com.github.mzule.activityrouter.router.Routers.map($S, $T.class, null, extraTypes)", format, className);
+ mapMethod.addStatement("com.github.mzule.abilityrouter.router.Routers.map($S, $T.class, null, extraTypes)", format, className);
} else {
- mapMethod.addStatement("com.github.mzule.activityrouter.router.Routers.map($S, null, " +
- "new MethodInvoker() {\n" +
- " public void invoke(android.content.Context context, android.os.Bundle bundle) {\n" +
- " $T.$N(context, bundle);\n" +
- " }\n" +
- "}, " +
+ mapMethod.addStatement("com.github.mzule.abilityrouter.router.Routers.map($S, null, "
+ +
+ "new MethodInvoker() {\n"
+ +
+ " public void invoke(ohos.app.Context context, ohos.aafwk.content.IntentParams bundle) {\n"
+ +
+ " $T.$N(context, bundle);\n"
+ +
+ " }\n"
+ +
+ "}, "
+ +
"extraTypes)", format, className, methodName);
}
}
@@ -199,7 +206,7 @@ public class RouterProcessor extends AbstractProcessor {
.addMethod(mapMethod.build())
.build();
try {
- JavaFile.builder("com.github.mzule.activityrouter.router", routerMapping)
+ JavaFile.builder("com.github.mzule.abilityrouter.router", routerMapping)
.build()
.writeTo(filer);
} catch (Throwable e) {
@@ -212,9 +219,9 @@ public class RouterProcessor extends AbstractProcessor {
String extras = join(args);
if (extras.length() > 0) {
String typeName = typeClz.getSimpleName();
- String s = typeName.substring(0, 1).toUpperCase() + typeName.replaceFirst("\\w", "");
+ String s1 = typeName.substring(0, 1).toUpperCase() + typeName.replaceFirst("\\w", "");
- mapMethod.addStatement("extraTypes.set" + s + "Extra($S.split(\",\"))", extras);
+ mapMethod.addStatement("extraTypes.set" + s1 + "Extra($S.split(\",\"))", extras);
}
}
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 100%
rename from app/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..47d07c5d6f4490433a97c0e2ceeb63f324785719
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+ compileOptions {
+ annotationEnabled true
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+
+dependencies {
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testCompile 'junit:junit:4.12'
+ compile project(':app_module')
+ annotationProcessor project(':compiler')
+}
+decc {
+ supportType = ['html', 'xml']
+}
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..01d38a259f3ed253b3c9a4666e041459bd51b693
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,126 @@
+{
+ "app": {
+ "bundleName": "com.github.mzule.abilityrouter",
+ "vendor": "github",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.github.mzule.abilityrouter",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.LaunchAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.ErrorStackAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.HomeAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.HostAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.NotFoundAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.UserAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.slice.UserCollectionAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.github.mzule.abilityrouter.router.RouterAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": ".MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "icon": "$media:icon",
+ "name": "com.github.mzule.abilityrouter.slice.DumpExtrasAbility",
+ "description": "",
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/github/mzule/activityrouter/AppModule.java b/entry/src/main/java/com/github/mzule/abilityrouter/AppModule.java
similarity index 48%
rename from app/src/main/java/com/github/mzule/activityrouter/AppModule.java
rename to entry/src/main/java/com/github/mzule/abilityrouter/AppModule.java
index 9aee9bb0bc9d5b53fa88c27c97c1d393aeac4e1a..f48dab3a7d89449ef923867865c75129e362ea17 100644
--- a/app/src/main/java/com/github/mzule/activityrouter/AppModule.java
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/AppModule.java
@@ -1,11 +1,10 @@
-package com.github.mzule.activityrouter;
+package com.github.mzule.abilityrouter;
-import com.github.mzule.activityrouter.annotation.Module;
+import com.github.mzule.abilityrouter.annotation.Module;
/**
* Created by CaoDongping on 30/10/2016.
*/
-
@Module("app")
public class AppModule {
}
diff --git a/app/src/main/java/com/github/mzule/activityrouter/Constant.java b/entry/src/main/java/com/github/mzule/abilityrouter/Constant.java
similarity index 54%
rename from app/src/main/java/com/github/mzule/activityrouter/Constant.java
rename to entry/src/main/java/com/github/mzule/abilityrouter/Constant.java
index 73aa3e4c250296f3693a995d4e6221c1ae34d40f..d764bf0b68832a468dd1ecdc73f880096cb96480 100644
--- a/app/src/main/java/com/github/mzule/activityrouter/Constant.java
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/Constant.java
@@ -1,9 +1,11 @@
-package com.github.mzule.activityrouter;
+package com.github.mzule.abilityrouter;
/**
* Created by CaoDongping on 14/10/2016.
*/
-
public interface Constant {
+ /**
+ * 定义一个用于请求的变量
+ */
int REQUEST_CODE_DEMO = 1001;
}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/MainAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..37bd24a4dcd97442badc935386b7b6b540b3b832
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/MainAbility.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+import com.github.mzule.abilityrouter.slice.DumpExtrasAbility;
+import ohos.aafwk.content.Intent;
+/**
+ * MainAbility
+ *
+ * @since 2021-04-26
+ **/
+@Router(value = {"http://mzule.com/main", "main", "home"},
+ longParams = {"id", "updateTime"},
+ booleanParams = "web",
+ transfer = "web=>fromWeb")
+public class MainAbility extends DumpExtrasAbility {
+ /**
+ * 定义一个 用于接收的变量
+ */
+ public static final int RESULT_OK = -1;
+
+ @Override
+ protected void onActive() {
+ super.onActive();
+ Intent resultIntent = new Intent();
+ setResult(RESULT_OK,resultIntent);
+ }
+
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/MyApplication.java b/entry/src/main/java/com/github/mzule/abilityrouter/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0fa5454cc004b5f03e6980ab203da8b99a6a4a5
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/MyApplication.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter;
+
+import com.github.mzule.abilityrouter.annotation.Modules;
+import com.github.mzule.abilityrouter.router.RouterCallback;
+import com.github.mzule.abilityrouter.router.RouterCallbackProvider;
+import com.github.mzule.abilityrouter.router.SimpleRouterCallback;
+import com.github.mzule.abilityrouter.slice.ErrorStackAbility;
+import com.github.mzule.abilityrouter.slice.LaunchAbility;
+import com.github.mzule.abilityrouter.slice.NotFoundAbility;
+import ohos.aafwk.ability.AbilityPackage;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.app.Context;
+import ohos.utils.net.Uri;
+/**
+ * MyApplication
+ *
+ * @since 2021-04-26
+ **/
+@Modules({"app", "sdk"})
+public class MyApplication extends AbilityPackage implements RouterCallbackProvider {
+ private final int beforopenmark = 11;
+ private final int notFound = 2;
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+
+ @Override
+ public RouterCallback provideRouterCallback() {
+ return new SimpleRouterCallback() {
+
+ @Override
+ public boolean beforeOpen(Context context, Uri uri) {
+ if (uri.toString().startsWith("mzule://")) {
+ Intent intent = new Intent();
+ Operation operationBuilder = new Intent.OperationBuilder()
+ .withBundleName(context.getBundleName())
+ .withAbilityName(LaunchAbility.class.getName())
+ .build();
+ intent.setOperation(operationBuilder);
+ context.startAbility(intent,beforopenmark);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void notFound(Context context, Uri uri) {
+ Intent intent = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withBundleName(context.getBundleName())
+ .withFlags(Intent.FLAG_ABILITY_NEW_MISSION)
+ .withAbilityName(NotFoundAbility.class.getName())
+ .build();
+ intent.setOperation(operation);
+ context.startAbility(intent,notFound);
+ }
+
+ @Override
+ public void error(Context context, Uri uri, Throwable e) {
+ context.startAbility(ErrorStackAbility.makeIntent(context,uri,e),1);
+ }
+ };
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/DumpExtrasAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/DumpExtrasAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..c4929225729f577ad973f5ca7879de5d746555a1
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/DumpExtrasAbility.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.ResourceTable;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.IntentParams;
+import ohos.agp.components.Text;
+import java.util.Set;
+
+/**
+ * Created by CaoDongping on 4/7/16.
+ */
+public abstract class DumpExtrasAbility extends Ability {
+ private static final int PADDINGS = 16;
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_dump);
+
+ Text text = (Text) findComponentById(ResourceTable.Id_dump);
+ Intent bundle = getIntent();
+ IntentParams params = bundle.getParams();
+
+ if (params != null) {
+
+ Set strings = params.keySet();
+
+ int padding = PADDINGS;
+ text.setPadding(padding,padding,padding,padding);
+ text.setText(getClass().getSimpleName());
+ text.append("\n\n");
+
+ for (String key : strings) {
+ if ("callerBundleName".equals(key)) {
+ continue;
+ }
+ text.append(key + "=>");
+
+ Object v1 = params.getParam(key);
+
+ if (null != v1) {
+ text.append(v1 + "=>" + v1.getClass().getSimpleName());
+ } else {
+ text.append("null");
+ }
+
+ text.append("\n\n");
+ }
+
+ }
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/ErrorStackAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/ErrorStackAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..21bd045098ae079d6eee2fce7c70927a2624dee5
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/ErrorStackAbility.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.ResourceTable;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.agp.components.Text;
+import ohos.agp.utils.TextAlignment;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+import ohos.utils.net.Uri;
+/**
+ * Created by CaoDongping on 8/9/16.
+ */
+public class ErrorStackAbility extends Ability {
+ /**
+ * 跳转
+ *
+ * @param context 上下文
+ * @param uri 地址
+ * @param e1 错误日志
+ * @return makeIntent 跳转的方法
+ */
+ public static Intent makeIntent(Context context, Uri uri, Throwable e1) {
+ Intent intent1 = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withBundleName(context.getBundleName())
+ .withFlags(Intent.FLAG_ABILITY_NEW_MISSION)
+ .withAbilityName(ErrorStackAbility.class.getName())
+ .build();
+ intent1.setParam("uri",uri);
+ intent1.setParam("error",e1);
+ intent1.setOperation(operation);
+ return intent1;
+ }
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_error);
+ Text error = (Text) findComponentById(ResourceTable.Id_error_text);
+ Throwable e1 = (Throwable)getIntent().getSerializableParam("error");
+ Uri uri = getIntent().getParcelableParam("uri");
+ error.setText(String.format("Error on open uri %s\n", uri));
+ error.append(HiLog.getStackTrace(e1));
+ error.setTextAlignment(TextAlignment.START);
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/HomeAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/HomeAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..e599b5f3e5e3318e4c2a7113939bbac93f2178c1
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/HomeAbility.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+import ohos.aafwk.content.Intent;
+/**
+ * Created by CaoDongping on 4/7/16.
+ */
+@Router(value = "home/:homeName", stringParams = "o")
+public class HomeAbility extends DumpExtrasAbility {
+ /**
+ * 定义一个 用于接收的变量
+ */
+ public static final int RESULT_OK = -1;
+
+ @Override
+ protected void onActive() {
+ super.onActive();
+ Intent intent = new Intent();
+ intent.setParam("msg","goodbye");
+ setResult(RESULT_OK, intent);
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/HostAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/HostAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..7def4c839b31d3dc5b539affbcbbce89fb783eb9
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/HostAbility.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+
+/**
+ * @author Kale
+ * @date 2016/8/9
+ */
+@Router("with_host")
+public class HostAbility extends DumpExtrasAbility {
+
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/LaunchAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/LaunchAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..9421bc55a792245f02683e326f6a5af7243a0790
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/LaunchAbility.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.Constant;
+import com.github.mzule.abilityrouter.ResourceTable;
+import com.github.mzule.abilityrouter.router.Routers;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.ScrollView;
+import ohos.agp.components.Text;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.TextTool;
+import ohos.agp.window.dialog.ToastDialog;
+/**
+ * Created by CaoDongping on 4/7/16.
+ */
+public class LaunchAbility extends Ability {
+ /**
+ * 定义一个 用于接收的变量
+ */
+ public static final int RESULT_OK = -1;
+ private final int direction = 1;
+ private final int scrollbarthickness = 12;
+ private static final int MIN_DELAY_TIME = 1000;
+ private static long lastClickTime;
+ /**
+ * 限制按钮多次点击一秒之内不能重复点击
+ *
+ * @return 是否快速点击
+ **/
+ public static boolean isFastClick() {
+ boolean flag = true;
+ long currentClickTime = System.currentTimeMillis();
+ if ((currentClickTime - lastClickTime) >= MIN_DELAY_TIME) {
+ flag = false;
+ }
+ lastClickTime = currentClickTime;
+ return flag;
+ }
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_launch);
+
+ ComponentContainer container = (ComponentContainer) findComponentById(ResourceTable.Id_container);
+ ScrollView scrollView = (ScrollView) findComponentById(ResourceTable.Id_scroll);
+ scrollView.enableScrollBar(direction,true);
+ scrollView.setScrollbarColor(Color.GRAY);
+ scrollView.setScrollbarThickness(scrollbarthickness);
+ for (int i = 0; i < container.getChildCount(); i++) {
+ final Component view = container.getComponentAt(i);
+ if (view instanceof Text) {
+ view.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ if (isFastClick()) {
+ return;
+ }
+ Routers.openForResult(LaunchAbility.this,((Text)view).getText(), Constant.REQUEST_CODE_DEMO);
+ }
+ });
+ }
+ }
+ }
+
+
+ @Override
+ protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
+ super.onAbilityResult(requestCode, resultCode, resultData);
+ if (resultCode == RESULT_OK && requestCode == Constant.REQUEST_CODE_DEMO) {
+ String msg;
+ if (resultData == null) {
+ msg = "success";
+ } else {
+ msg = resultData.getStringParam("msg");
+ msg = TextTool.isNullOrEmpty(msg) ? "success" : msg;
+ }
+ ToastDialog toastDialog = new ToastDialog(this);
+ toastDialog.setText(msg).show();
+ }
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/MainAbilitySlice.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff4181e6da31bc6ae5445b2cb668c61e34feab3c
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/MainAbilitySlice.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+/**
+ * MainAbilitySlice
+ *
+ * @since 2021-04-16
+ * */
+public class MainAbilitySlice extends AbilitySlice {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/NonUIActions.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/NonUIActions.java
new file mode 100644
index 0000000000000000000000000000000000000000..ac7a31473c233cbae4df2f7f051cf523b401bb9f
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/NonUIActions.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+import ohos.aafwk.content.IntentParams;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.app.Context;
+/**
+ * Created by CaoDongping on 04/11/2016.
+ */
+public class NonUIActions {
+ /**
+ * 定义一个登出的方法
+ *
+ * @param context 上下文
+ * @param bundle 接收的值
+ */
+ @Router("logout")
+ public static void logout(Context context, IntentParams bundle) {
+ ToastDialog toastDialog = new ToastDialog(context);
+ toastDialog.setText("logout").show();
+ }
+ /**
+ * 定义一个上传的方法
+ *
+ * @param context 上下文
+ * @param bundle 接收的值
+ */
+ @Router("upload")
+ public static void uploadLog(Context context, IntentParams bundle) {
+ ToastDialog toastDialog = new ToastDialog(context);
+ toastDialog.setText("upload").show();
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/NotFoundAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/NotFoundAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..572e26a47d10b3f709f37042d0b344f8dcc656db
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/NotFoundAbility.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.ResourceTable;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Text;
+import ohos.agp.utils.TextAlignment;
+/**
+ * Created by CaoDongping on 4/8/16.
+ */
+public class NotFoundAbility extends Ability {
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ Text componentById = (Text) findComponentById(ResourceTable.Id_text_helloworld);
+ componentById.setText("404");
+ componentById.setTextAlignment(TextAlignment.CENTER);
+ }
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..7fb5967da1d8079be9358857fec3c1d0c1607851
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserAbility.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+/**
+ * Created by CaoDongping on 4/7/16.
+ */
+@Router({"user/:userId", "user/:nickname/city/:city/gender/:gender/age/:age"})
+public class UserAbility extends DumpExtrasAbility {
+}
diff --git a/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserCollectionAbility.java b/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserCollectionAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..b74ee85b4520289453676f7620e3d4f4d9518f50
--- /dev/null
+++ b/entry/src/main/java/com/github/mzule/abilityrouter/slice/UserCollectionAbility.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
+ *
+ * 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.
+ */
+package com.github.mzule.abilityrouter.slice;
+
+import com.github.mzule.abilityrouter.annotation.Router;
+/**
+ * Created by CaoDongping on 4/7/16.
+ */
+@Router("user/collection")
+public class UserCollectionAbility extends DumpExtrasAbility {
+}
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..5d501a6b7cd8b920948bc2f0afb9ab28d9a7f8be
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AbilityRouter"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_button.xml b/entry/src/main/resources/base/graphic/background_ability_button.xml
new file mode 100644
index 0000000000000000000000000000000000000000..23647cee0077654bba462308923ec2ac54a07dec
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_button.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_dump.xml b/entry/src/main/resources/base/layout/ability_dump.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a8cb32dfb2c241bb267e3b1cf3ba2049104c9ad2
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_dump.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
diff --git a/entry/src/main/resources/base/layout/ability_error.xml b/entry/src/main/resources/base/layout/ability_error.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9a9dfeda24c5a7dede3e2b4a23b1a8c910117d36
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_error.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/entry/src/main/resources/base/layout/ability_launch.xml b/entry/src/main/resources/base/layout/ability_launch.xml
new file mode 100644
index 0000000000000000000000000000000000000000..13f27ee6bb1bc563bde304ec089ab7b9daa9fc25
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_launch.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e80802e007fd2ac0b43c0aac8068534bf4798f65
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..fd1f06f1775435805eea8878dd1cf73d2788d39c
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "com.github.mzule.abilityrouter",
+ "vendor": "github",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.github.mzule.abilityrouter",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/github/mzule/abilityrouter/ExampleOhosTest.java b/entry/src/ohosTest/java/com/github/mzule/abilityrouter/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c36e73d9185dd7e15e9813a6343f823267ea686c
--- /dev/null
+++ b/entry/src/ohosTest/java/com/github/mzule/abilityrouter/ExampleOhosTest.java
@@ -0,0 +1,18 @@
+package com.github.mzule.abilityrouter;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class ExampleOhosTest {
+
+ // 纯UI组件,无法提供详细单元测试
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.github.mzule.abilityrouter", actualBundleName);
+ }
+
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/github/mzule/abilityrouter/ExampleTest.java b/entry/src/test/java/com/github/mzule/abilityrouter/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..fece7bce64948ce1ec8cbfc306f317827892bbf5
--- /dev/null
+++ b/entry/src/test/java/com/github/mzule/abilityrouter/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.github.mzule.abilityrouter;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gif/http.gif b/gif/http.gif
deleted file mode 100644
index 49d06f4ab2bcb1da12c036c54b14020d6cbceffc..0000000000000000000000000000000000000000
Binary files a/gif/http.gif and /dev/null differ
diff --git a/gif/router.gif b/gif/router.gif
deleted file mode 100644
index 1d849d0e434e0e003b3cb31f7b1727bb09c1d221..0000000000000000000000000000000000000000
Binary files a/gif/router.gif and /dev/null differ
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# 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.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 05ef575b0cd0173fc735f2857ce4bd594ce4f6bd..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9372d65f33aff8ba77cc050551a631585a18be3c..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Fri Oct 14 10:40:18 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/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.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# 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 ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# 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
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+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
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# 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"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 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
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+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" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@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
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@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=
-
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
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/img/demo1.gif b/img/demo1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..fce29590cb3d32dfabf77cdba98b0cdfa19dca87
Binary files /dev/null and b/img/demo1.gif differ
diff --git a/settings.gradle b/settings.gradle
index b53145510a2e851e255b2b4dd474139da17371c7..4ac1943c6e1a5a7e5f9ab8bc3ef10c275d902bd4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':compiler', ':annotation', ':activityrouter', ':stub', ':app_module'
+include ':entry', ':activityrouter', ':annotation', ':app_module', ':stub', ':compiler'
diff --git a/stub/build.gradle b/stub/build.gradle
index c152b193116317833c5bdcc678c11207d4d2f26a..2ba93635a17f051785c1e73ac0b4591aa6b09cc4 100644
--- a/stub/build.gradle
+++ b/stub/build.gradle
@@ -1,5 +1,9 @@
-apply plugin: 'java'
+apply plugin: 'java-library'
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
-}
\ No newline at end of file
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
+}
+
+sourceCompatibility = "1.8"
+targetCompatibility = "1.8"
\ No newline at end of file
diff --git a/stub/src/main/config.json b/stub/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..01f296a3447b686b79f4c91c0fc003bc6715073f
--- /dev/null
+++ b/stub/src/main/config.json
@@ -0,0 +1,27 @@
+{
+ "app": {
+ "bundleName": "com.github.mzule.abilityrouter",
+ "vendor": "github",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.github.mzule.abilityrouter.router",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "stub",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/stub/src/main/java/com/github/mzule/activityrouter/router/RouterInit.java b/stub/src/main/java/com/github/mzule/abilityrouter/router/RouterInit.java
similarity index 54%
rename from stub/src/main/java/com/github/mzule/activityrouter/router/RouterInit.java
rename to stub/src/main/java/com/github/mzule/abilityrouter/router/RouterInit.java
index eb9ebb94b28993faea8fe121a8cfdfcb8c17d575..cbdbd4e15b7815564380438745038df21d23c530 100644
--- a/stub/src/main/java/com/github/mzule/activityrouter/router/RouterInit.java
+++ b/stub/src/main/java/com/github/mzule/abilityrouter/router/RouterInit.java
@@ -1,10 +1,12 @@
-package com.github.mzule.activityrouter.router;
+package com.github.mzule.abilityrouter.router;
/**
* Created by CaoDongping on 30/10/2016.
*/
-
public class RouterInit {
+ /**
+ * 一个初始化的方法
+ * */
public static void init() {
}
}
diff --git a/stub/src/main/java/com/github/mzule/activityrouter/router/RouterMapping.java b/stub/src/main/java/com/github/mzule/abilityrouter/router/RouterMapping.java
similarity index 35%
rename from stub/src/main/java/com/github/mzule/activityrouter/router/RouterMapping.java
rename to stub/src/main/java/com/github/mzule/abilityrouter/router/RouterMapping.java
index 0d20fdc060cf0ec49d8291b0fad1d0fb7c9b43ff..3fae11c579b5eb4aa10a54f1406c26c2f42b2c51 100644
--- a/stub/src/main/java/com/github/mzule/activityrouter/router/RouterMapping.java
+++ b/stub/src/main/java/com/github/mzule/abilityrouter/router/RouterMapping.java
@@ -1,8 +1,14 @@
-package com.github.mzule.activityrouter.router;
+package com.github.mzule.abilityrouter.router;
+/**
+ * RouterMapping
+ *
+ * @since 2021-04-16
+ * */
public final class RouterMapping {
-
+ /**
+ * 一个映射的方法
+ * */
public static final void map() {
-
}
}
diff --git a/stub/src/main/resources/base/element/string.json b/stub/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f4c7c1aa9474f2e4bcd559aa920de463e9874fca
--- /dev/null
+++ b/stub/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "stub"
+ }
+ ]
+}