提交 2d09b624 编写于 作者: B Blankj

see 12/30 log

上级 5444390e
......@@ -11,4 +11,5 @@ local.properties
/apk
*.phrof
/maven
/reports
\ No newline at end of file
/reports
*/reports
\ No newline at end of file
* `19/12/08` [add] Publish bus plugin v2.5.
* `19/12/06` [add] Publish api plugin v1.3.
* `19/11/30` [add] Publish bus plugin v2.4. Publish api plugin v1.2.
* `19/11/28` [add] Publish v1.26.0.
......
......@@ -15,7 +15,7 @@ class Config {
static minSdkVersion = 14
static targetSdkVersion = 28
static versionCode = 1_026_001
static versionName = '1.26.1'// E.g. 1.9.72 => 1,009,072
static versionName = '1.26.1-alpha1'// E.g. 1.9.72 => 1,009,072
// lib version
static gradlePluginVersion = '3.5.2'
......@@ -26,8 +26,8 @@ class Config {
static depConfig = [
/*Never delete this line*/
/*Generated by "config.json"*/
plugin_api_gradle_plugin : new DepConfig(false, true, ":plugin:api-gradle-plugin"),
plugin_bus_gradle_plugin : new DepConfig(false, true, ":plugin:bus-gradle-plugin"),
plugin_api_gradle_plugin : new DepConfig(true, true, ":plugin:api-gradle-plugin"),
plugin_bus_gradle_plugin : new DepConfig(true, true, ":plugin:bus-gradle-plugin"),
feature_mock : new DepConfig(false, true, ":feature:mock"),
feature_launcher_app : new DepConfig(true, true, ":feature:launcher:app"),
feature_main_app : new DepConfig(false, true, ":feature:main:app"),
......@@ -55,7 +55,7 @@ class Config {
// 本地上传成功之后 isApply = true 即可应用插件来调试,后续版本更新无需设置 isApply = false
// 发布版本的话把 isApply = false, useLocal = false,更新版本号,发布成功后 isApply = true 即可使用远程库版本
plugin_api : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:api-gradle-plugin:1.3", pluginId: "com.blankj.api"),
plugin_bus : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:bus-gradle-plugin:2.4", pluginId: "com.blankj.bus"),
plugin_bus : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:bus-gradle-plugin:2.5", pluginId: "com.blankj.bus"),
support_appcompat_v7 : new DepConfig("com.android.support:appcompat-v7:$supportVersion"),
support_design : new DepConfig("com.android.support:design:$supportVersion"),
......
......@@ -5,8 +5,8 @@
"pkgConfig": [],
"proConfigDesc": "proConfig 配置的是使用本地还是仓库,优先级低于 appConfig 和 pkgConfig",
"proConfig": [
{"isApply": false, "useLocal": true, "localPath": ":plugin:api-gradle-plugin"},
{"isApply": false, "useLocal": true, "localPath": ":plugin:bus-gradle-plugin"},
{"isApply": true, "useLocal": true, "localPath": ":plugin:api-gradle-plugin"},
{"isApply": true, "useLocal": true, "localPath": ":plugin:bus-gradle-plugin"},
{"isApply": true, "useLocal": true, "localPath": ":feature:mock"},
{"isApply": true, "useLocal": true, "localPath": ":feature:launcher:app"},
{"isApply": true, "useLocal": true, "localPath": ":feature:main:app"},
......
......@@ -9,10 +9,7 @@ import com.blankj.common.item.CommonItem
import com.blankj.common.item.CommonItemClick
import com.blankj.subutil.export.api.SubUtilApi
import com.blankj.utilcode.export.api.UtilCodeApi
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.ApiUtils
import com.blankj.utilcode.util.BarUtils
import com.blankj.utilcode.util.CollectionUtils
import com.blankj.utilcode.util.*
import kotlinx.android.synthetic.main.activity_main.*
......
......@@ -41,7 +41,7 @@ class ShadowActivity : CommonActivity() {
super.initView(savedInstanceState, contentView)
ShadowUtils.apply(shadowRectView, Config().setShadowRadius(0.01f).setShadowColor(Color.BLUE, Color.GREEN))
ShadowUtils.apply(shadowRoundRectView, Config().setShadowRadius(
SizeUtils.dp2px(16f).toFloat()).setShadowColor(Color.RED, Color.BLUE))
SizeUtils.dp2px(16f).toFloat()))
ShadowUtils.apply(shadowCircleView, Config().setCircle().setShadowColor(Color.GREEN, Color.BLUE))
}
}
......@@ -578,8 +578,11 @@ clickBlankArea2HideSoftInput : 点击屏幕空白区域隐藏软键盘
* ### 语言相关 -> [LanguageUtils.java][language.java] -> [Demo][language.demo]
```
applySystemLanguage: 应用系统语言
applyLanguage : 应用语言
applySystemLanguage : 应用系统语言
applyLanguage : 应用语言
isAppliedSystemLanguage: 判断是否使用系统语言
isAppliedLanguage : 判断是否使用某语言
getCurrentLocale : 获取当前语言
```
* ### 日志相关 -> [LogUtils.java][log.java] -> [Demo][log.demo]
......@@ -1010,6 +1013,8 @@ toSBC : 转化为全角字符
* ### 线程相关 -> [ThreadUtils.java][thread.java] -> [Test][thread.test]
```
isMainThread : 判断当前是否主线程
runOnUiThread : 运行在主线程
runOnUiThreadDelayed : 延时运行在主线程
getFixedPool : 获取固定线程池
getSinglePool : 获取单线程池
getCachedPool : 获取缓冲线程池
......
......@@ -580,6 +580,9 @@ clickBlankArea2HideSoftInput
```
applySystemLanguage
applyLanguage
isAppliedSystemLanguage
isAppliedLanguage
getCurrentLocale
```
* ### About Log -> [LogUtils.java][log.java] -> [Demo][log.demo]
......@@ -1010,6 +1013,8 @@ toSBC
* ### About Thread -> [ThreadUtils.java][thread.java] -> [Test][thread.test]
```
isMainThread
runOnUiThread
runOnUiThreadDelayed
getFixedPool
getSinglePool
getCachedPool
......
......@@ -11,6 +11,28 @@ readme {
readmeCnFile file('./README-CN.md')
}
android {
compileSdkVersion Config.compileSdkVersion
defaultConfig {
minSdkVersion Config.minSdkVersion
versionCode Config.versionCode
versionName Config.versionName
consumerProguardFiles 'proguard-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation Config.depConfig.gson.dep
......
......@@ -20,6 +20,8 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
......@@ -55,6 +57,16 @@ public final class ActivityUtils {
*/
public static Activity getActivityByContext(Context context) {
if (context instanceof Activity) return (Activity) context;
if (context != null && context.getClass().getName().equals("com.android.internal.policy.DecorContext")) {
try {
Field mActivityContextField = context.getClass().getDeclaredField("mActivityContext");
mActivityContextField.setAccessible(true);
//noinspection unchecked
return ((WeakReference<Activity>) mActivityContextField.get(context)).get();
} catch (Exception e) {
e.printStackTrace();
}
}
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity) context;
......
......@@ -33,15 +33,15 @@ public final class ApiUtils {
private ApiUtils() {
}
private void registerImpl(Class implClass) {
private void registerApiInner(Class implClass) {
if (implClass == null) return;
Class superclass = implClass.getSuperclass();
if (superclass == null) return;
mInjectApiImplMap.put(superclass, implClass);
}
public static void register(Class implClass) {
getInstance().registerImpl(implClass);
public static void registerApi(Class implClass) {
getInstance().registerApiInner(implClass);
}
/**
......
package com.blankj.utilcode.util;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2019/01/07
* desc : utils about json
* </pre>
*/
public final class JsonUtils {
private static final byte TYPE_BOOLEAN = 0x00;
......
package com.blankj.utilcode.util;
import android.app.Activity;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
......@@ -10,6 +9,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.DisplayMetrics;
......@@ -36,23 +36,14 @@ public class LanguageUtils {
}
/**
* Apply the system language in the {@link Application#onCreate()}.
* Apply the system language.
* It will not restart Activity. u can put it in ur {@link Activity#onCreate(Bundle)}.
*/
public static void applySystemLanguageInAppOnCreate() {
public static void applySystemLanguage() {
if (isAppliedSystemLanguage()) return;
applyLanguage(Resources.getSystem().getConfiguration().locale, "", true, false);
}
/**
* Apply the language in the {@link Application#onCreate()}.
*
* @param locale The language of locale.
*/
public static void applyLanguageInAppOnCreate(@NonNull final Locale locale) {
if (isAppliedLanguage()) return;
applyLanguage(locale, "", false, false);
}
/**
* Apply the system language.
*
......@@ -71,6 +62,17 @@ public class LanguageUtils {
applyLanguage(Resources.getSystem().getConfiguration().locale, activityClassName, true, true);
}
/**
* Apply the language.
* It will not restart Activity. u can put it in ur {@link Activity#onCreate(Bundle)}.
*
* @param locale The language of locale.
*/
public static void applyLanguage(@NonNull final Locale locale) {
if (isAppliedLanguage()) return;
applyLanguage(locale, "", false, false);
}
/**
* Apply the language.
*
......
......@@ -191,25 +191,24 @@ public final class ResourceUtils {
* @return the content of assets
*/
public static String readAssets2String(final String assetsFilePath, final String charsetName) {
InputStream is;
try {
is = Utils.getApp().getAssets().open(assetsFilePath);
InputStream is = Utils.getApp().getAssets().open(assetsFilePath);
byte[] bytes = is2Bytes(is);// close stream in it
if (bytes == null) return null;
if (isSpace(charsetName)) {
return new String(bytes);
} else {
try {
return new String(bytes, charsetName);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
byte[] bytes = is2Bytes(is);
if (bytes == null) return null;
if (isSpace(charsetName)) {
return new String(bytes);
} else {
try {
return new String(bytes, charsetName);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
}
}
/**
......@@ -274,7 +273,7 @@ public final class ResourceUtils {
*/
public static String readRaw2String(@RawRes final int resId, final String charsetName) {
InputStream is = Utils.getApp().getResources().openRawResource(resId);
byte[] bytes = is2Bytes(is);
byte[] bytes = is2Bytes(is);// close stream in it
if (bytes == null) return null;
if (isSpace(charsetName)) {
return new String(bytes);
......
......@@ -1009,7 +1009,7 @@ public final class SpanUtils {
@Override
public void chooseHeight(final CharSequence text, final int start, final int end,
final int spanstartv, final int v, final Paint.FontMetricsInt fm) {
LogUtils.e(fm, sfm);
// LogUtils.e(fm, sfm);
if (sfm == null) {
sfm = new Paint.FontMetricsInt();
sfm.top = fm.top;
......@@ -1049,7 +1049,7 @@ public final class SpanUtils {
if (end == ((Spanned) text).getSpanEnd(this)) {
sfm = null;
}
LogUtils.e(fm, sfm);
// LogUtils.e(fm, sfm);
}
}
......
......@@ -56,6 +56,14 @@ public final class ThreadUtils {
return Looper.myLooper() == Looper.getMainLooper();
}
public static void runOnUiThread(final Runnable runnable) {
Utils.runOnUiThread(runnable);
}
public static void runOnUiThreadDelayed(final Runnable runnable, long delayMillis) {
Utils.runOnUiThreadDelayed(runnable, delayMillis);
}
/**
* Return a thread pool that reuses a fixed number of threads
* operating off a shared unbounded queue, using the provided
......
/build
ApiUtils2333.class
\ No newline at end of file
/build
\ No newline at end of file
......@@ -18,6 +18,10 @@ public class ApiInfo {
this.isMock = isMock;
}
public String getFileDesc() {
return implApiClass + "-" + isMock;
}
@Override
public String toString() {
return "{ implApiClass: " + implApiClass +
......
......@@ -116,31 +116,14 @@ class ApiTransform extends Transform {
if (javaResJar == null) {
LogUtils.w("javaResJar didn't existed.")
} else {
injectApis2Assets(javaResJar, apiScan)
print2__api__(apiScan, ext, jsonFile)
injectApis2Assets(javaResJar, apiScan)
}
}
LogUtils.l(getName() + " finished: " + (System.currentTimeMillis() - stTime) + "ms")
}
private static void injectApis2Assets(File javaResJar, ApiScan apiScan) {
String javaResPath = javaResJar.getAbsolutePath()
File unzipJavaResDir = new File(javaResPath.substring(0, javaResPath.lastIndexOf(".")))
unzipJavaResDir.mkdirs()
ZipUtils.unzipFile(javaResJar, unzipJavaResDir)
File apiDir = new File(unzipJavaResDir, Config.API_PATH)
apiDir.mkdirs()
apiScan.apiImplMap.each { key, value ->
File apiClassDir = new File(apiDir, key)
apiClassDir.mkdir()
File apiClassImplDir = new File(apiClassDir, value.implApiClass + "-" + value.isMock)
apiClassImplDir.createNewFile()
}
javaResJar.delete()
ZipUtils.zipFiles(Arrays.asList(unzipJavaResDir.listFiles()), javaResJar)
}
private static void print2__api__(ApiScan apiScan, ApiExtension ext, File jsonFile) {
Map implApis = [:]
List<String> noImplApis = []
......@@ -166,6 +149,23 @@ class ApiTransform extends Transform {
}
}
private static void injectApis2Assets(File javaResJar, ApiScan apiScan) {
String javaResPath = javaResJar.getAbsolutePath()
File unzipJavaResDir = new File(javaResPath.substring(0, javaResPath.lastIndexOf(".")))
unzipJavaResDir.mkdirs()
ZipUtils.unzipFile(javaResJar, unzipJavaResDir)
File apiDir = new File(unzipJavaResDir, Config.API_PATH)
apiDir.mkdirs()
apiScan.apiImplMap.each { key, value ->
File apiClassDir = new File(apiDir, key)
apiClassDir.mkdir()
File apiClassImplFile = new File(apiClassDir, value.getFileDesc())
apiClassImplFile.createNewFile()
}
javaResJar.delete()
ZipUtils.zipFiles(Arrays.asList(unzipJavaResDir.listFiles()), javaResJar)
}
private static jumpScan(String jarName, ApiExtension ext) {
if (ext.onlyScanLibRegex != null && ext.onlyScanLibRegex.trim().length() > 0) {
return !Pattern.matches(ext.onlyScanLibRegex, jarName)
......
......@@ -26,17 +26,6 @@ public class ApiUtils {
private Map<Class, Class> mInjectApiImplMap = new HashMap<>();
private ApiUtils() {
init();
}
/**
* It'll be injected the implClasses who have {@link ApiUtils.Api} annotation
* by function of {@link ApiUtils#registerImpl} when execute transform task.
*/
private void init() {/*inject*/}
private void registerImpl(Class implClass) {
mInjectApiImplMap.put(implClass.getSuperclass(), implClass);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册