Skip to content

Commit abc7a5d

Browse files
committed
see 07/11 log
1 parent 3dfa55e commit abc7a5d

File tree

12 files changed

+369
-16
lines changed

12 files changed

+369
-16
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.2-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.3-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/java/com/blankj/androidutilcode/feature/core/keyboard/KeyboardActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import android.widget.TextView;
1111

1212
import com.blankj.androidutilcode.R;
13-
import com.blankj.androidutilcode.base.BaseBackActivity;
13+
import com.blankj.androidutilcode.base.BaseActivity;
1414
import com.blankj.androidutilcode.helper.DialogHelper;
1515
import com.blankj.utilcode.util.KeyboardUtils;
1616
import com.blankj.utilcode.util.SpanUtils;
@@ -23,7 +23,7 @@
2323
* desc : demo about KeyboardUtils
2424
* </pre>
2525
*/
26-
public class KeyboardActivity extends BaseBackActivity {
26+
public class KeyboardActivity extends BaseActivity{
2727

2828
public static void start(Context context) {
2929
Intent starter = new Intent(context, KeyboardActivity.class);
@@ -41,13 +41,13 @@ public void initData(@Nullable Bundle bundle) {
4141

4242
@Override
4343
public int bindLayout() {
44-
return R.layout.activity_keyboard;
44+
return R.layout.activity_keyboard1;
4545
}
4646

4747
@Override
4848
public void initView(Bundle savedInstanceState, View contentView) {
4949
KeyboardUtils.fixAndroidBug5497(this);
50-
getToolBar().setTitle(getString(R.string.demo_keyboard));
50+
// getToolBar().setTitle(getString(R.string.demo_keyboard));
5151
etInput = findViewById(R.id.et_input);
5252
findViewById(R.id.btn_hide_soft_input).setOnClickListener(this);
5353
findViewById(R.id.btn_show_soft_input).setOnClickListener(this);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="@color/white"
6+
android:gravity="center_horizontal"
7+
android:orientation="vertical">
8+
9+
<TextView
10+
android:id="@+id/tv_about_keyboard"
11+
style="@style/TextStyle"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content" />
14+
15+
<Button
16+
android:id="@+id/btn_hide_soft_input"
17+
style="@style/WideBtnStyle"
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:text="@string/keyboard_hide_soft_input" />
21+
22+
<Button
23+
android:id="@+id/btn_show_soft_input"
24+
style="@style/WideBtnStyle"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:text="@string/keyboard_show_soft_input" />
28+
29+
<Button
30+
android:id="@+id/btn_toggle_soft_input"
31+
style="@style/WideBtnStyle"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:text="@string/keyboard_toggle_soft_input" />
35+
36+
<Button
37+
android:id="@+id/btn_keyboard_in_fragment"
38+
style="@style/WideBtnStyle"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:text="@string/keyboard_show_dialog" />
42+
43+
<EditText
44+
android:id="@+id/et_input"
45+
android:layout_width="match_parent"
46+
android:layout_height="wrap_content"
47+
android:layout_gravity="bottom"
48+
android:inputType="text" />
49+
50+
</LinearLayout>
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
package com.blankj.subutil.util;
2+
3+
import android.annotation.SuppressLint;
4+
import android.os.Build;
5+
import android.os.Environment;
6+
import android.text.TextUtils;
7+
8+
import java.io.BufferedReader;
9+
import java.io.File;
10+
import java.io.FileInputStream;
11+
import java.io.IOException;
12+
import java.io.InputStreamReader;
13+
import java.lang.reflect.Method;
14+
import java.util.Properties;
15+
16+
/**
17+
* <pre>
18+
* author: Blankj
19+
* blog : http://blankj.com
20+
* time : 2018/07/04
21+
* desc : utils about rom
22+
* </pre>
23+
*/
24+
public final class RomUtils {
25+
26+
public static final String SYS_EMUI = "emui";
27+
public static final String SYS_MIUI = "miui";
28+
public static final String SYS_FLYME = "flyme";
29+
public static final String SYS_COLOROS = "colorOs";
30+
public static final String SYS_FUNTOUCH = "Funtouch";
31+
public static final String SYS_SAMSUNG = "samsung";
32+
33+
///////////////////////////////////////////////////////////////////////////
34+
// MIUI
35+
///////////////////////////////////////////////////////////////////////////
36+
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
37+
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
38+
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
39+
private static final String KEY_MIUI_VERSION_INCREMENTAL = "ro.build.version.incremental";
40+
41+
///////////////////////////////////////////////////////////////////////////
42+
// EMUI
43+
///////////////////////////////////////////////////////////////////////////
44+
private static final String KEY_EMUI_API_LEVEL = "ro.build.hw_emui_api_level";
45+
private static final String KEY_EMUI_VERSION = "ro.build.version.emui";
46+
private static final String KEY_EMUI_CONFIG_HW_SYS_VERSION = "ro.confg.hw_systemversion";
47+
48+
///////////////////////////////////////////////////////////////////////////
49+
// OPPO
50+
///////////////////////////////////////////////////////////////////////////
51+
private static final String KEY_OPPO_NAME = "ro.rom.different.version";
52+
private static final String KEY_OPPO_VERSION = "ro.build.version.opporom";
53+
54+
///////////////////////////////////////////////////////////////////////////
55+
// VIVO
56+
///////////////////////////////////////////////////////////////////////////
57+
private static final String KEY_VIVO_NAME = "ro.vivo.os.name";
58+
private static final String KEY_VIVO_VERSION = "ro.vivo.os.version";
59+
60+
private static RomBean bean = null;
61+
62+
/**
63+
* Return the name of rom.
64+
*
65+
* @return the name of rom
66+
*/
67+
public static RomBean getRom() {
68+
if (bean != null) return bean;
69+
bean = new RomBean();
70+
// 小米
71+
if (!TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_CODE))
72+
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_NAME))
73+
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_INTERNAL_STORAGE))) {
74+
bean.setRomName(SYS_MIUI);
75+
bean.setRomVersion(getSystemProperty(KEY_MIUI_VERSION_INCREMENTAL));
76+
}
77+
// 华为
78+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_EMUI_API_LEVEL))
79+
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_VERSION))
80+
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION))) {
81+
bean.setRomName(SYS_EMUI);
82+
String version = getSystemProperty(KEY_EMUI_VERSION);// EmotionUI_2.0
83+
String[] temp = version.split("_");
84+
if (temp.length > 1) {
85+
bean.setRomVersion(temp[1]);
86+
} else {
87+
bean.setRomVersion(version);
88+
}
89+
}
90+
// 魅族
91+
else if (Build.DISPLAY.toLowerCase().contains("flyme")) {
92+
bean.setRomName(SYS_FLYME);
93+
bean.setRomVersion(Build.DISPLAY);
94+
return bean;
95+
}
96+
// OPPO
97+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_OPPO_NAME)) &&
98+
getSystemProperty(KEY_OPPO_NAME).toLowerCase().contains("coloros")) {
99+
bean.setRomName(SYS_COLOROS);
100+
bean.setRomVersion(getSystemProperty(KEY_OPPO_VERSION));
101+
}
102+
// VIVO
103+
else if (!TextUtils.isEmpty(getSystemProperty(KEY_VIVO_NAME))) {
104+
bean.setRomName(SYS_FUNTOUCH);
105+
bean.setRomVersion(getSystemProperty(KEY_VIVO_VERSION));
106+
}
107+
// 其他手机
108+
else {
109+
String brand = Build.BRAND;
110+
bean.setRomName(Build.BRAND);
111+
if (SYS_SAMSUNG.equalsIgnoreCase(brand)) {
112+
bean.setRomVersion(getSystemProperty("ro.build.changelist"));
113+
}
114+
}
115+
return bean;
116+
}
117+
118+
private static String getSystemProperty(final String name) {
119+
String prop = getSystemPropertyByShell(name);
120+
if (!TextUtils.isEmpty(prop)) return prop;
121+
prop = getSystemPropertyByStream(name);
122+
if (!TextUtils.isEmpty(prop)) return prop;
123+
if (Build.VERSION.SDK_INT < 28) {
124+
return getSystemPropertyByReflect(name);
125+
}
126+
return prop;
127+
}
128+
129+
private static String getSystemPropertyByShell(final String propName) {
130+
String line;
131+
BufferedReader input = null;
132+
try {
133+
Process p = Runtime.getRuntime().exec("getprop " + propName);
134+
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
135+
return input.readLine();
136+
} catch (IOException e) {
137+
return "";
138+
} finally {
139+
if (input != null) {
140+
try {
141+
input.close();
142+
} catch (IOException ignore) {
143+
144+
}
145+
}
146+
}
147+
}
148+
149+
private static String getSystemPropertyByStream(final String key) {
150+
try {
151+
Properties prop = new Properties();
152+
FileInputStream is = new FileInputStream(
153+
new File(Environment.getRootDirectory(), "build.prop")
154+
);
155+
prop.load(is);
156+
return prop.getProperty(key, "");
157+
} catch (Exception e) {
158+
e.printStackTrace();
159+
return "";
160+
}
161+
}
162+
163+
private static String getSystemPropertyByReflect(String key) {
164+
try {
165+
@SuppressLint("PrivateApi")
166+
Class<?> clz = Class.forName("android.os.SystemProperties");
167+
Method get = clz.getMethod("get", String.class, String.class);
168+
return (String) get.invoke(clz, key, "");
169+
} catch (Exception e) {
170+
return "";
171+
}
172+
}
173+
174+
public static class RomBean {
175+
private String romName;
176+
private String romVersion;
177+
178+
public String getRomName() {
179+
if (romName == null) return "";
180+
return romName;
181+
}
182+
183+
private void setRomName(String romName) {
184+
this.romName = romName;
185+
}
186+
187+
public String getRomVersion() {
188+
if (romVersion == null) return "";
189+
return romVersion;
190+
}
191+
192+
private void setRomVersion(String romVersion) {
193+
this.romVersion = romVersion;
194+
}
195+
196+
@Override
197+
public String toString() {
198+
return "romName: " + romName +
199+
"\nromVersion: " + romVersion;
200+
}
201+
}
202+
}

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/06/29 修复 IntentUtils 分享图片判断逻辑,CacheDiskUtils 可放入 byte[0],发布 1.17.3
12
* 18/06/29 修复 FragmentUtils 中 getFragmentManager 空指针错误,发布 1.17.2
23
* 18/06/27 新增 UriUtils#uri2File
34
* 18/06/25 新增 KeyboardUtils#fixAndroidBug5497,发布 1.17.1 版本

utilcode/README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.17.2'
5+
implementation 'com.blankj:utilcode:1.17.3'
66
```
77

88

utilcode/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.17.2'
5+
implementation 'com.blankj:utilcode:1.17.3'
66
```
77

88

utilcode/src/main/java/com/blankj/utilcode/util/CacheDiskUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public void put(@NonNull final String key, final byte[] value) {
172172
* @param saveTime The save time of cache, in seconds.
173173
*/
174174
public void put(@NonNull final String key, byte[] value, final int saveTime) {
175-
if (value == null || value.length <= 0) return;
175+
if (value == null) return;
176176
if (saveTime >= 0) value = DiskCacheHelper.newByteArrayWithTime(saveTime, value);
177177
File file = mDiskCacheManager.getFileBeforePut(key);
178178
DiskCacheHelper.writeFileFromBytes(file, value);

utilcode/src/main/java/com/blankj/utilcode/util/CacheMemoryUtils.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import com.blankj.utilcode.constant.CacheConstants;
88

9-
import java.lang.reflect.Array;
10-
119
/**
1210
* <pre>
1311
* author: Blankj
@@ -79,7 +77,6 @@ public void put(@NonNull final String key, final Object value) {
7977
*/
8078
public void put(@NonNull final String key, final Object value, int saveTime) {
8179
if (value == null) return;
82-
if (value.getClass().isArray() && Array.getLength(value) <= 0) return;
8380
long dueTime = saveTime < 0 ? -1 : System.currentTimeMillis() + saveTime * 1000;
8481
mMemoryCache.put(key, new CacheValue(dueTime, value));
8582
}

utilcode/src/main/java/com/blankj/utilcode/util/CacheUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void put(@NonNull final String key, final byte[] value) {
175175
* @param saveTime The save time of cache, in seconds.
176176
*/
177177
public void put(@NonNull final String key, byte[] value, final int saveTime) {
178-
if (value == null || value.length <= 0) return;
178+
if (value == null) return;
179179
if (saveTime >= 0) value = DiskCacheHelper.newByteArrayWithTime(saveTime, value);
180180
File file = mDiskCacheManager.getFileBeforePut(key);
181181
DiskCacheHelper.writeFileFromBytes(file, value);

0 commit comments

Comments
 (0)