提交 711d1ce4 编写于 作者: B Blankj

see 06/25 log

上级 542ea59f
......@@ -41,7 +41,7 @@
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.0-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.1-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.0-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.17.1-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
......
......@@ -57,5 +57,5 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
// implementation 'com.blankj:utilcode:1.16.4'
// implementation 'com.blankj:utilcode:1.17.1'
}
......@@ -120,8 +120,7 @@
android:launchMode="singleTop" />
<activity
android:name=".feature.core.keyboard.KeyboardActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="stateHidden|adjustPan" />
android:launchMode="singleTop" />
<activity
android:name=".feature.core.log.LogActivity"
android:launchMode="singleTop" />
......
......@@ -5,9 +5,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
......@@ -15,7 +13,6 @@ import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.base.BaseBackActivity;
import com.blankj.androidutilcode.helper.DialogHelper;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.SpanUtils;
/**
......@@ -49,8 +46,8 @@ public class KeyboardActivity extends BaseBackActivity {
@Override
public void initView(Bundle savedInstanceState, View contentView) {
KeyboardUtils.fixAndroidBug5497(this);
getToolBar().setTitle(getString(R.string.demo_keyboard));
ScreenUtils.setFullScreen(this);
etInput = findViewById(R.id.et_input);
findViewById(R.id.btn_hide_soft_input).setOnClickListener(this);
findViewById(R.id.btn_show_soft_input).setOnClickListener(this);
......@@ -95,34 +92,34 @@ public class KeyboardActivity extends BaseBackActivity {
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (isShouldHideKeyboard(v, ev)) {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) return super.dispatchTouchEvent(ev);
imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
return super.dispatchTouchEvent(ev);
}
// 根据 EditText 所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] l = {0, 0};
v.getLocationInWindow(l);
int left = l[0],
top = l[1],
bottom = top + v.getHeight(),
right = left + v.getWidth();
return !(event.getX() > left && event.getX() < right
&& event.getY() > top && event.getY() < bottom);
}
return false;
}
// @Override
// public boolean dispatchTouchEvent(MotionEvent ev) {
// if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// View v = getCurrentFocus();
// if (isShouldHideKeyboard(v, ev)) {
// InputMethodManager imm =
// (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// if (imm == null) return super.dispatchTouchEvent(ev);
// imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
// }
// }
// return super.dispatchTouchEvent(ev);
// }
//
// // 根据 EditText 所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
// private boolean isShouldHideKeyboard(View v, MotionEvent event) {
// if (v != null && (v instanceof EditText)) {
// int[] l = {0, 0};
// v.getLocationInWindow(l);
// int left = l[0],
// top = l[1],
// bottom = top + v.getHeight(),
// right = left + v.getWidth();
// return !(event.getX() > left && event.getX() < right
// && event.getY() > top && event.getY() < bottom);
// }
// return false;
// }
@Override
protected void onDestroy() {
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_layout"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/spacing_16">
<TextView
android:id="@+id/tv_about_keyboard"
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent">
<Button
android:id="@+id/btn_hide_soft_input"
style="@style/WideBtnStyle"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_hide_soft_input" />
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/spacing_16">
<Button
android:id="@+id/btn_show_soft_input"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_show_soft_input" />
<TextView
android:id="@+id/tv_about_keyboard"
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_toggle_soft_input"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_toggle_soft_input" />
<Button
android:id="@+id/btn_hide_soft_input"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_hide_soft_input" />
<Button
android:id="@+id/btn_keyboard_in_fragment"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_show_dialog" />
<Button
android:id="@+id/btn_show_soft_input"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_show_soft_input" />
<EditText
android:id="@+id/et_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<Button
android:id="@+id/btn_toggle_soft_input"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_toggle_soft_input" />
<Button
android:id="@+id/btn_keyboard_in_fragment"
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keyboard_show_dialog" />
<EditText
android:id="@+id/et_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
<EditText
android:id="@+id/et_input10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:inputType="text" />
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -7,8 +7,8 @@ buildscript {
min_sdk_version = 14
target_sdk_version = 27
version_code = 1_017_000
version_name = '1.17.0'// E.g 1.9.72 => 1,009,072
version_code = 1_017_001
version_name = '1.17.1'// E.g 1.9.72 => 1,009,072
// App dependencies
support_version = '27.1.0'
......@@ -26,7 +26,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
......
* 18/06/25 新增 KeyboardUtils#fixAndroidBug5497,发布 1.17.1 版本
* 18/06/21 修复 FragmentUtils#add 死循环的 BUG
* 18/06/14 替换 CacheUtils 为 CacheDiskUtils,CacheUtils 标记 deprecated,发布 1.17.0 版本
* 18/06/13 新增 CacheMemoryUtils 和 CacheDoubleUtils
* 18/06/12 完善 FragmentUtils#add 和 replace 新增 tag
......
......@@ -2,7 +2,7 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.17.0'
implementation 'com.blankj:utilcode:1.17.1'
```
......@@ -384,6 +384,7 @@ toggleSoftInput : 切换键盘显示与否状态
isSoftInputVisible : 判断软键盘是否可见
registerSoftInputChangedListener : 注册软键盘改变监听器
unregisterSoftInputChangedListener: 注销软键盘改变监听器
fixAndroidBug5497 : 修复安卓 5497 BUG
fixSoftInputLeaks : 修复软键盘内存泄漏
clickBlankArea2HideSoftInput : 点击屏幕空白区域隐藏软键盘
```
......@@ -467,6 +468,7 @@ request : 开始请求
```
isPhone : 判断设备是否是手机
getDeviceId : 获取设备码
getSerial : 获取序列号
getIMEI : 获取 IMEI 码
getMEID : 获取 MEID 码
getIMSI : 获取 IMSI 码
......@@ -610,7 +612,6 @@ setLineHeight : 设置行高
setQuoteColor : 设置引用线的颜色
setLeadingMargin : 设置缩进
setBullet : 设置列表标记
setIconMargin : 设置图标
setFontSize : 设置字体尺寸
setFontProportion : 设置字体比例
setFontXProportion: 设置字体横向比例
......
......@@ -2,7 +2,7 @@
Gradle:
```groovy
implementation 'com.blankj:utilcode:1.17.0'
implementation 'com.blankj:utilcode:1.17.1'
```
......@@ -384,6 +384,7 @@ toggleSoftInput
isSoftInputVisible
registerSoftInputChangedListener
unregisterSoftInputChangedListener
fixAndroidBug5497
fixSoftInputLeaks
clickBlankArea2HideSoftInput
```
......@@ -467,6 +468,7 @@ request
```
isPhone
getDeviceId
getSerial
getIMEI
getMEID
getIMSI
......@@ -610,7 +612,6 @@ setLineHeight
setQuoteColor
setLeadingMargin
setBullet
setIconMargin
setFontSize
setFontProportion
setFontXProportion
......
......@@ -852,7 +852,7 @@ public final class AppUtils {
if (len <= 0) return "";
char[] ret = new char[len << 1];
for (int i = 0, j = 0; i < len; i++) {
ret[j++] = HEX_DIGITS[bytes[i] >>> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] >> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] & 0x0f];
}
return new String(ret);
......
......@@ -126,7 +126,7 @@ public final class ConvertUtils {
if (len <= 0) return "";
char[] ret = new char[len << 1];
for (int i = 0, j = 0; i < len; i++) {
ret[j++] = hexDigits[bytes[i] >>> 4 & 0x0f];
ret[j++] = hexDigits[bytes[i] >> 4 & 0x0f];
ret[j++] = hexDigits[bytes[i] & 0x0f];
}
return new String(ret);
......
......@@ -1141,7 +1141,7 @@ public final class EncryptUtils {
if (len <= 0) return "";
char[] ret = new char[len << 1];
for (int i = 0, j = 0; i < len; i++) {
ret[j++] = HEX_DIGITS[bytes[i] >>> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] >> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] & 0x0f];
}
return new String(ret);
......
......@@ -1170,7 +1170,7 @@ public final class FileUtils {
if (len <= 0) return "";
char[] ret = new char[len << 1];
for (int i = 0, j = 0; i < len; i++) {
ret[j++] = HEX_DIGITS[bytes[i] >>> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] >> 4 & 0x0f];
ret[j++] = HEX_DIGITS[bytes[i] & 0x0f];
}
return new String(ret);
......
......@@ -1430,9 +1430,8 @@ public final class FragmentUtils {
if (args == null) return;
name = args.getString(ARGS_TAG, fragment.getClass().getName());
Fragment fragmentByTag = fm.findFragmentByTag(name);
while (fragmentByTag != null && fragmentByTag.isAdded()) {
if (fragmentByTag != null && fragmentByTag.isAdded()) {
ft.remove(fragmentByTag);
fragmentByTag = fm.findFragmentByTag(name);
}
ft.add(args.getInt(ARGS_ID), fragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(fragment);
......
......@@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import java.lang.reflect.Field;
......@@ -26,6 +27,7 @@ public final class KeyboardUtils {
private static int sContentViewInvisibleHeightPre;
private static OnGlobalLayoutListener onGlobalLayoutListener;
private static OnSoftInputChangedListener onSoftInputChangedListener;
private static int sContentViewInvisibleHeightPre5497;
private KeyboardUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
......@@ -125,11 +127,15 @@ public final class KeyboardUtils {
}
private static int getContentViewInvisibleHeight(final Activity activity) {
final View contentView = activity.findViewById(android.R.id.content);
final FrameLayout contentView = activity.findViewById(android.R.id.content);
final View contentViewChild = contentView.getChildAt(0);
final Rect outRect = new Rect();
contentView.getWindowVisibleDisplayFrame(outRect);
LogUtils.d(contentView.getTop(), contentView.getBottom(), outRect.top, outRect.bottom);
return contentView.getBottom() - outRect.bottom;
contentViewChild.getWindowVisibleDisplayFrame(outRect);
LogUtils.d(
contentViewChild.getTop(), contentViewChild.getBottom(),
outRect.top, outRect.bottom
);
return contentViewChild.getBottom() - outRect.bottom;
}
/**
......@@ -144,7 +150,7 @@ public final class KeyboardUtils {
if ((flags & WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) != 0) {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
final View contentView = activity.findViewById(android.R.id.content);
final FrameLayout contentView = activity.findViewById(android.R.id.content);
sContentViewInvisibleHeightPre = getContentViewInvisibleHeight(activity);
onSoftInputChangedListener = listener;
onGlobalLayoutListener = new OnGlobalLayoutListener() {
......@@ -159,7 +165,8 @@ public final class KeyboardUtils {
}
}
};
contentView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
contentView.getViewTreeObserver()
.addOnGlobalLayoutListener(onGlobalLayoutListener);
}
/**
......@@ -175,6 +182,38 @@ public final class KeyboardUtils {
onGlobalLayoutListener = null;
}
/**
* Fix the bug of 5497 in Android.
*
* @param activity The activity.
*/
public static void fixAndroidBug5497(final Activity activity) {
final int flags = activity.getWindow().getAttributes().flags;
if ((flags & WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) != 0) {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
final FrameLayout contentView = activity.findViewById(android.R.id.content);
final View contentViewChild = contentView.getChildAt(0);
final int paddingBottom = contentViewChild.getPaddingBottom();
sContentViewInvisibleHeightPre5497 = getContentViewInvisibleHeight(activity);
contentView.getViewTreeObserver()
.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int height = getContentViewInvisibleHeight(activity);
if (sContentViewInvisibleHeightPre5497 != height) {
contentViewChild.setPadding(
contentViewChild.getPaddingLeft(),
contentViewChild.getPaddingTop(),
contentViewChild.getPaddingRight(),
paddingBottom + height
);
sContentViewInvisibleHeightPre5497 = height;
}
}
});
}
/**
* Fix the leaks of soft input.
* <p>Call the function in {@link Activity#onDestroy()}.</p>
......
......@@ -40,6 +40,7 @@ public final class NetworkUtils {
}
public enum NetworkType {
NETWORK_ETHERNET,
NETWORK_WIFI,
NETWORK_4G,
NETWORK_3G,
......@@ -257,10 +258,6 @@ public final class NetworkUtils {
return tm != null ? tm.getNetworkOperatorName() : "";
}
private static final int NETWORK_TYPE_GSM = 16;
private static final int NETWORK_TYPE_TD_SCDMA = 17;
private static final int NETWORK_TYPE_IWLAN = 18;
/**
* Return type of network.
* <p>Must hold
......@@ -268,12 +265,13 @@ public final class NetworkUtils {
*
* @return type of network
* <ul>
* <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_4G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_3G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_2G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN} </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_NO } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_ETHERNET} </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_4G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_3G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_2G } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN } </li>
* <li>{@link NetworkUtils.NetworkType#NETWORK_NO } </li>
* </ul>
*/
@RequiresPermission(ACCESS_NETWORK_STATE)
......@@ -281,13 +279,14 @@ public final class NetworkUtils {
NetworkType netType = NetworkType.NETWORK_NO;
NetworkInfo info = getActiveNetworkInfo();
if (info != null && info.isAvailable()) {
if (info.getType() == ConnectivityManager.TYPE_WIFI) {
if (info.getType() == ConnectivityManager.TYPE_ETHERNET) {
netType = NetworkType.NETWORK_ETHERNET;
} else if (info.getType() == ConnectivityManager.TYPE_WIFI) {
netType = NetworkType.NETWORK_WIFI;
} else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
switch (info.getSubtype()) {
case NETWORK_TYPE_GSM:
case TelephonyManager.NETWORK_TYPE_GSM:
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_EDGE:
......@@ -296,7 +295,7 @@ public final class NetworkUtils {
netType = NetworkType.NETWORK_2G;
break;
case NETWORK_TYPE_TD_SCDMA:
case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
......@@ -309,7 +308,7 @@ public final class NetworkUtils {
netType = NetworkType.NETWORK_3G;
break;
case NETWORK_TYPE_IWLAN:
case TelephonyManager.NETWORK_TYPE_IWLAN:
case TelephonyManager.NETWORK_TYPE_LTE:
netType = NetworkType.NETWORK_4G;
break;
......
......@@ -8,6 +8,7 @@ import android.os.Build;
import android.support.annotation.RequiresPermission;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import java.util.List;
......@@ -52,9 +53,32 @@ public final class PhoneUtils {
public static String getDeviceId() {
TelephonyManager tm =
(TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (tm == null) return "";
String imei = tm.getImei();
if (!TextUtils.isEmpty(imei)) return imei;
String meid = tm.getMeid();
return TextUtils.isEmpty(meid) ? "" : meid;
}
return tm != null ? tm.getDeviceId() : "";
}
/**
* Return the serial of device.
*
* @return the serial of device
*/
@SuppressLint("HardwareIds")
@RequiresPermission(READ_PHONE_STATE)
public static String getSerial() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return Build.getSerial();
} else {
return Build.SERIAL;
}
}
/**
* Return the IMEI.
* <p>Must hold
......
......@@ -98,7 +98,7 @@ public final class ShellUtils {
final boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null);
return new CommandResult(result, "", "");
}
Process process = null;
BufferedReader successResult = null;
......@@ -121,10 +121,12 @@ public final class ShellUtils {
if (isNeedResultMsg) {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(new InputStreamReader(process.getInputStream(),
"UTF-8"));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream(),
"UTF-8"));
successResult = new BufferedReader(
new InputStreamReader(process.getInputStream(), "UTF-8")
);
errorResult = new BufferedReader(
new InputStreamReader(process.getErrorStream(), "UTF-8")
);
String line;
if ((line = successResult.readLine()) != null) {
successMsg.append(line);
......@@ -169,8 +171,8 @@ public final class ShellUtils {
}
return new CommandResult(
result,
successMsg == null ? null : successMsg.toString(),
errorMsg == null ? null : errorMsg.toString()
successMsg == null ? "" : successMsg.toString(),
errorMsg == null ? "" : errorMsg.toString()
);
}
......@@ -187,5 +189,12 @@ public final class ShellUtils {
this.successMsg = successMsg;
this.errorMsg = errorMsg;
}
@Override
public String toString() {
return "result: " + result + "\n" +
"successMsg: " + successMsg + "\n" +
"errorMsg: " + errorMsg;
}
}
}
......@@ -796,37 +796,6 @@ public final class SpanUtils {
flag
);
}
// if (imGapWidth != -1) {
// if (imBitmap != null) {
// mBuilder.setSpan(
// new CustomIconMarginSpan(imBitmap, imGapWidth, imAlign),
// start,
// end,
// flag
// );
// } else if (imDrawable != null) {
// mBuilder.setSpan(
// new CustomIconMarginSpan(imDrawable, imGapWidth, imAlign),
// start,
// end,
// flag
// );
// } else if (imUri != null) {
// mBuilder.setSpan(
// new CustomIconMarginSpan(imUri, imGapWidth, imAlign),
// start,
// end,
// flag
// );
// } else if (imResourceId != -1) {
// mBuilder.setSpan(
// new CustomIconMarginSpan(imResourceId, imGapWidth, imAlign),
// start,
// end,
// flag
// );
// }
// }
if (fontSize != -1) {
mBuilder.setSpan(new AbsoluteSizeSpan(fontSize, fontSizeIsDp), start, end, flag);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册