提交 2ba5a178 编写于 作者: C cmj

see 01/13 log

上级 939a4963
......@@ -31,7 +31,7 @@ public class DeviceActivity extends Activity
findViewById(R.id.btn_reboot_to_recovery).setOnClickListener(this);
findViewById(R.id.btn_reboot_to_bootloader).setOnClickListener(this);
tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRoot()
tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRooted()
+ "\ngetSDKVersion: " + DeviceUtils.getSDKVersion()
+ "\ngetAndroidID: " + DeviceUtils.getAndroidID()
+ "\ngetMacAddress: " + DeviceUtils.getMacAddress()
......
......@@ -58,6 +58,7 @@ public class NetworkActivity extends Activity
+ "\ngetWifiEnabled: " + NetworkUtils.getWifiEnabled()
+ "\nisWifiConnected: " + NetworkUtils.isWifiConnected()
+ "\nisWifiAvailable: " + NetworkUtils.isWifiAvailable()
+ "\nisAvailableByPing: " + NetworkUtils.isAvailableByPing()
+ "\ngetNetworkOperatorName: " + NetworkUtils.getNetworkOperatorName()
+ "\ngetNetworkTypeName: " + NetworkUtils.getNetworkType()
+ "\ngetIPAddress: " + NetworkUtils.getIPAddress(true)
......
......@@ -6,7 +6,6 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
}
......@@ -26,5 +25,5 @@ dependencies {
testCompile rootProject.ext.deps.truth
testCompile rootProject.ext.deps.robolectric
}
apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
//gradlew bintrayUpload
......@@ -28,10 +28,11 @@ public class CrashUtils
private volatile static CrashUtils mInstance;
private UncaughtExceptionHandler mHandler;
private boolean mInitialized;
private String crashDir;
private String versionName;
private int versionCode;
private boolean mInitialized;
private String crashDir;
private String versionName;
private int versionCode;
private CrashUtils() {
}
......@@ -62,9 +63,13 @@ public class CrashUtils
public boolean init() {
if (mInitialized) return true;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
crashDir = Utils.getContext().getExternalCacheDir().getPath() + File.separator + "crash" + File.separator;
File baseCache = Utils.getContext().getExternalCacheDir();
if (baseCache == null) return false;
crashDir = baseCache.getPath() + File.separator + "crash" + File.separator;
} else {
crashDir = Utils.getContext().getCacheDir().getPath() + File.separator + "crash" + File.separator;
File baseCache = Utils.getContext().getCacheDir();
if (baseCache == null) return false;
crashDir = baseCache.getPath() + File.separator + "crash" + File.separator;
}
try {
PackageInfo pi = Utils.getContext().getPackageManager().getPackageInfo(Utils.getContext().getPackageName(), 0);
......
......@@ -3,11 +3,11 @@ package com.blankj.utilcode.utils;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import android.webkit.MimeTypeMap;
import java.io.File;
......@@ -46,11 +46,17 @@ public class IntentUtils {
if (file == null) return null;
Intent intent = new Intent(Intent.ACTION_VIEW);
String type;
if (Build.VERSION.SDK_INT < 23) {
type = "application/vnd.android.package-archive";
} else {
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(FileUtils.getFileExtension(file));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri contentUri = FileProvider.getUriForFile(Utils.getContext(), "com.your.package.fileProvider", file);
intent.setDataAndType(contentUri, type);
}
intent.setDataAndType(Uri.fromFile(file), type);
return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
......@@ -179,6 +185,11 @@ public class IntentUtils {
return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
// public static Intent getDailIntent(){
//
// }
/**
* 获取拍照的意图
*
......
......@@ -52,9 +52,9 @@ public class NetworkUtils {
*/
public static void openWirelessSettings() {
if (android.os.Build.VERSION.SDK_INT > 10) {
Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else {
Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}
......@@ -88,7 +88,7 @@ public class NetworkUtils {
* @return {@code true}: 可用<br>{@code false}: 不可用
*/
public static boolean isAvailableByPing() {
ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 123.125.114.144", false);
ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 223.5.5.5", false);
boolean ret = result.result == 0;
if (result.errorMsg != null) {
LogUtils.d("isAvailableByPing errorMsg", result.errorMsg);
......
......@@ -49,7 +49,7 @@ public class PhoneUtils {
* 获取IMEI码
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return IMIE
* @return IMEI
*/
@SuppressLint("HardwareIds")
public static String getIMEI() {
......@@ -61,7 +61,7 @@ public class PhoneUtils {
* 获取IMSI码
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return IMIE
* @return IMSI
*/
@SuppressLint("HardwareIds")
public static String getIMSI() {
......@@ -178,7 +178,9 @@ public class PhoneUtils {
* @param phoneNumber 电话号码
*/
public static void dial(String phoneNumber) {
Utils.getContext().startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)));
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Utils.getContext().startActivity(intent);
}
/**
......@@ -188,7 +190,9 @@ public class PhoneUtils {
* @param phoneNumber 电话号码
*/
public static void call(String phoneNumber) {
Utils.getContext().startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber)));
Intent intent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Utils.getContext().startActivity(intent);
}
/**
......
......@@ -56,7 +56,7 @@ public class SDCardUtils {
}
}
if (p.waitFor() != 0 && p.exitValue() == 1) {
return " 命令执行失败";
break;
}
}
} catch (Exception e) {
......
......@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.Surface;
import android.view.View;
......@@ -157,4 +158,28 @@ public class ScreenUtils {
.getSystemService(Context.KEYGUARD_SERVICE);
return km.inKeyguardRestrictedInputMode();
}
/**
* 设置进入休眠时长
* <uses-permission android:name="android.permission.WRITE_SETTINGS" />
*
* @param duration 时长
*/
public static void setSleepDuration(int duration) {
Settings.System.putInt(Utils.getContext().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, duration);
}
/**
* 获取进入休眠时长
*
* @return 进入休眠时长,报错返回-123
*/
public static int getSleepDuration() {
try {
return Settings.System.getInt(Utils.getContext().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return -123;
}
}
}
\ No newline at end of file
package com.blankj.utilcode.utils;
import android.support.annotation.ColorInt;
import android.support.design.widget.BaseTransientBottomBar;
import android.support.design.widget.Snackbar;
import android.view.Gravity;
import android.view.LayoutInflater;
......@@ -89,7 +88,6 @@ public class SnackbarUtils {
*
* @param parent 父视图(CoordinatorLayout或者DecorView)
* @param text 文本
* @param duration 自定义时长
* @param textColor 文本颜色
* @param bgColor 背景色
*/
......@@ -102,7 +100,6 @@ public class SnackbarUtils {
*
* @param parent 父视图(CoordinatorLayout或者DecorView)
* @param text 文本
* @param duration 自定义时长
* @param textColor 文本颜色
* @param bgColor 背景色
* @param actionText 事件文本
......@@ -128,7 +125,7 @@ public class SnackbarUtils {
* @param listener 监听器
*/
private static void showSnackbar(View parent, CharSequence text,
@BaseTransientBottomBar.Duration int duration,
int duration,
@ColorInt int textColor, @ColorInt int bgColor,
CharSequence actionText, int actionTextColor,
View.OnClickListener listener) {
......
......@@ -3,7 +3,9 @@ package com.blankj.utilcode.utils;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* <pre>
......@@ -15,39 +17,70 @@ import java.util.List;
*/
public class DogeTest {
private static List<File> dogeFiles = new ArrayList<>();
private static int[] indexes = {0, 50, 100, 150, 200, 300, 400, 450, 500, 550, 600, 700};
private static int bitNum = 3;
static {
dogeFiles.add(new File("F:/MyGithub/doge-expression/_00_000_049_SingleRun"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_01_050_099_Tear"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_02_100_149_Lines"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_03_150_199_MoreRun"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_04_200_299_ToLeft"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_05_300_399_ToRight"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_06_400_449_Big"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_07_450_499_Hug"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_08_500_549_Wang"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_09_550_599_ToWall"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_10_600_699_OtherGif"));
dogeFiles.add(new File("F:/MyGithub/doge-expression/_11_700_799_OtherJpg"));
}
@Test
public void generateDogeMD() throws Exception {
bitNum = 4;
renameDogeNames();
bitNum = 3;
renameDogeNames();
StringBuilder sb = new StringBuilder();
sb.append("卡通doge的表情大集合,喜爱doge的朋友的福利到了,花了大半天的时间整理出来的狗东西,就被你们这么轻而易举地拿走了,现附上QQ表情包链接[doge-expression.eif](https://github.com/Blankj/doge-expression/blob/master/doge-expression.eif)(进去点击Download即可)\n\n");
sb.append("卡通doge的表情大集合,喜爱doge的朋友的福利到了,花了很多的时间整理出来的狗东西,就被你们这么轻而易举地拿走了,现附上QQ表情包链接[doge-expression.eif](https://raw.githubusercontent.com/Blankj/doge-expression/master/doge-expression.eif)(进去点击Download即可)\n\n");
sb.append("下面展示doge各种姿势,请系好安全带,开车啦,滴滴滴~~\n\n");
File file = new File("F:/MyGithub/doge-expression/expression");
List<File> files = FileUtils.listFilesInDir(file);
for (File f : files) {
String name = f.getName();
sb.append("![")
.append(name)
.append("]")
.append("(https://github.com/Blankj/doge-expression/raw/master/expression/")
.append(name)
.append(") \n");
for (int i = 0; i < dogeFiles.size(); ++i) {
List<File> files = FileUtils.listFilesInDir(dogeFiles.get(i));
for (File f : files) {
String name = f.getName();
sb.append("![")
.append(name)
.append("]")
.append("(https://github.com/Blankj/doge-expression/raw/master/")
.append(f.getParentFile().getName())
.append("/")
.append(name)
.append(") \n");
}
}
// System.out.println(sb.toString());
FileUtils.writeFileFromString("F:/MyGithub/doge-expression/README.md", sb.toString(), false);
}
@Test
public void generateDogeNames() throws Exception {
StringBuilder sb = new StringBuilder();
File file = new File("F:/MyGithub/doge-expression/expression");
List<File> files = FileUtils.listFilesInDir(file);
for (File f : files) {
String name = f.getName();
sb.append("![")
.append(name)
.append("]")
.append("(https://github.com/Blankj/doge-expression/raw/master/expression/")
.append(name)
.append(") \n");
public void renameDogeNames() throws Exception {
for (int i = 0; i < dogeFiles.size(); ++i) {
List<File> files = FileUtils.listFilesInDir(dogeFiles.get(i));
int index = indexes[i];
for (File f : files) {
String name = f.getName();
String rename = String.format(
Locale.getDefault(),
"%s%0" + bitNum + "d%s",
f.getParent() + File.separator,
index++,
name.substring(name.length() - 4)
);
f.renameTo(new File(rename));
}
}
FileUtils.writeFileFromString("F:/MyGithub/doge-expression/README.md", sb.toString(), false);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册