diff --git a/androidframework/.gitignore b/androidframework/.gitignore
deleted file mode 100644
index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000
--- a/androidframework/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/androidframework/androidframework.iml b/androidframework/androidframework.iml
deleted file mode 100644
index 1410860b71f8b9a7dbdaaadfc63cc7d061419f58..0000000000000000000000000000000000000000
--- a/androidframework/androidframework.iml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
根据路径名是否符合和文件是否存在判断是否安装成功 - *
更好的做法应该是startActivityForResult回调判断是否安装成功比较妥当 - *
这里做不了回调,后续自己做处理 - */ - public static boolean installApp(Context context, String filePath) { - if (filePath != null && filePath.length() > 4 - && filePath.toLowerCase().substring(filePath.length() - 4).equals(".apk")) { - Intent intent = new Intent(Intent.ACTION_VIEW); - File file = new File(filePath); - if (file.exists() && file.isFile() && file.length() > 0) { - intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - return true; - } - } - return false; - } - - /** - * 卸载指定包名的App - *
这里卸载成不成功只判断了packageName是否为空 - *
如果要根据是否卸载成功应该用startActivityForResult回调判断是否还存在比较妥当 - *
这里做不了回调,后续自己做处理 - */ - public boolean uninstallApp(Context context, String packageName) { - if (!TextUtils.isEmpty(packageName)) { - Intent intent = new Intent(Intent.ACTION_DELETE); - intent.setData(Uri.parse("package:" + packageName)); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent); - return true; - } - return false; - } - - /** - * 封装App信息的Bean类 - */ - public static class AppInfo { - - private String name; - private Drawable icon; - private String packagName; - private String versionName; - private int versionCode; - private boolean isSD; - private boolean isUser; - - public Drawable getIcon() { - return icon; - } - - public void setIcon(Drawable icon) { - this.icon = icon; - } - - public boolean isSD() { - return isSD; - } - - public void setSD(boolean SD) { - isSD = SD; - } - - public boolean isUser() { - return isUser; - } - - public void setUser(boolean user) { - isUser = user; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPackagName() { - return packagName; - } - - public void setPackagName(String packagName) { - this.packagName = packagName; - } - - public int getVersionCode() { - return versionCode; - } - - public void setVersionCode(int versionCode) { - this.versionCode = versionCode; - } - - public String getVersionName() { - return versionName; - } - - public void setVersionName(String versionName) { - this.versionName = versionName; - } - - /** - * @param name 名称 - * @param icon 图标 - * @param packagName 包名 - * @param versionName 版本号 - * @param versionCode 版本Code - * @param isSD 是否安装在SD卡 - * @param isUser 是否是用户程序 - */ - public AppInfo(String name, Drawable icon, String packagName, - String versionName, int versionCode, boolean isSD, boolean isUser) { - this.setName(name); - this.setIcon(icon); - this.setPackagName(packagName); - this.setVersionName(versionName); - this.setVersionCode(versionCode); - this.setSD(isSD); - this.setUser(isUser); - } - - /*@Override - public String toString() { - return getName() + "\n" - + getIcon() + "\n" - + getPackagName() + "\n" - + getVersionName() + "\n" - + getVersionCode() + "\n" - + isSD() + "\n" - + isUser() + "\n"; - }*/ - } - - /** - * 获取当前App信息 - *
AppInfo(名称,图标,包名,版本号,版本Code,是否安装在SD卡,是否是用户程序) - */ - public static AppInfo getAppInfo(Context context) { - PackageManager pm = context.getPackageManager(); - PackageInfo pi = null; - try { - pi = pm.getPackageInfo(context.getApplicationContext().getPackageName(), 0); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - return pi != null ? getBean(pm, pi) : null; - } - - /** - * 得到AppInfo的Bean - */ - private static AppInfo getBean(PackageManager pm, PackageInfo pi) { - ApplicationInfo ai = pi.applicationInfo; - String name = ai.loadLabel(pm).toString(); - Drawable icon = ai.loadIcon(pm); - String packageName = pi.packageName; - String versionName = pi.versionName; - int versionCode = pi.versionCode; - boolean isSD = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM; - boolean isUser = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM; - return new AppInfo(name, icon, packageName, versionName, versionCode, isSD, isUser); - } - - /** - * 获取所有已安装App信息 - *
AppInfo(名称,图标,包名,版本号,版本Code,是否安装在SD卡,是否是用户程序) - *
依赖上面的getBean方法
- */
- public static List 需添加 并且必须是系统应用该方法才有效
- */
- public static boolean isAppBackground(Context context) {
- ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- @SuppressWarnings("deprecation")
- List 需添加权限 一般是/storage/emulated/0/
- */
- public static String getSDCardPath() {
- return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator;
- }
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/EncryptUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/EncryptUtils.java
deleted file mode 100644
index ce6dae179e482563e76849bb1c96ffc5e4f3d1dc..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/EncryptUtils.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/*********************************************
- * author: Blankj on 2016/8/2 21:22
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class EncryptUtils {
-
- private EncryptUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * MD5加密
- *
- * @param data 明文字符串
- * @return 密文
- */
- public static String getMD5(String data) {
- return getMD5(data.getBytes());
- }
-
- /**
- * MD5加密
- *
- * @param data 明文字符串
- * @param salt 盐
- * @return 密文
- */
- public static String getMD5(String data, String salt) {
- return bytes2Hex(encryptMD5((data + salt).getBytes()));
- }
-
- /**
- * MD5加密
- *
- * @param data 明文字节数组
- * @return 密文
- */
- public static String getMD5(byte[] data) {
- return bytes2Hex(encryptMD5(data));
- }
-
- /**
- * MD5加密
- *
- * @param data 明文字节数组
- * @param salt 盐字节数组
- * @return 密文
- */
- public static String getMD5(byte[] data, byte[] salt) {
- byte[] dataSalt = new byte[data.length + salt.length];
- System.arraycopy(data, 0, dataSalt, 0, data.length);
- System.arraycopy(salt, 0, dataSalt, data.length, salt.length);
- return bytes2Hex(encryptMD5(dataSalt));
- }
-
- /**
- * MD5加密
- *
- * @param data 明文字节数组
- * @return 密文字节数组
- */
- public static byte[] encryptMD5(byte[] data) {
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(data);
- return md.digest();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
- return new byte[0];
- }
-
- /**
- * 获取文件的MD5校验码
- *
- * @param filePath 文件路径
- * @return 文件的MD5校验码
- */
- public static String getMD5File(String filePath) {
- FileInputStream in = null;
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- in = new FileInputStream(filePath);
- int len;
- byte[] buffer = new byte[1024];
- while ((len = in.read(buffer)) != -1) {
- md.update(buffer, 0, len);
- }
- return bytes2Hex(md.digest());
- } catch (NoSuchAlgorithmException | IOException e) {
- e.printStackTrace();
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignored) {
- }
- }
- }
- return "";
- }
-
- /**
- * SHA加密
- *
- * @param data 明文字符串
- * @return 密文
- */
- public static String getSHA(String data) {
- return getSHA(data.getBytes());
- }
-
- /**
- * SHA加密
- *
- * @param data 明文字节数组
- * @return 密文
- */
- public static String getSHA(byte[] data) {
- return bytes2Hex(encryptSHA(data));
- }
-
- /**
- * SHA加密
- *
- * @param data 明文字节数组
- * @return 密文字节数组
- */
- public static byte[] encryptSHA(byte[] data) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- md.update(data);
- return md.digest();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
- return new byte[0];
- }
-
- /**
- * 一个byte转为2个hex字符
- */
- public static String bytes2Hex(byte[] src) {
- char[] res = new char[src.length * 2];
- final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
- for (int i = 0, j = 0; i < src.length; i++) {
- res[j++] = hexDigits[src[i] >>> 4 & 0x0f];
- res[j++] = hexDigits[src[i] & 0x0f];
- }
- return new String(res);
- }
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/KeyboardUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/KeyboardUtils.java
deleted file mode 100644
index e3df214abc7e12d92bdf418565c421c216114ed4..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/KeyboardUtils.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import android.app.Activity;
-import android.content.Context;
-import android.util.Log;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-
-/*********************************************
- * author: Blankj on 2016/8/2 21:18
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class KeyboardUtils {
-
- private KeyboardUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * 动态隐藏软键盘
- */
- public static void hideSoftInput(Activity activity) {
- View view = activity.getWindow().peekDecorView();
- if (view != null) {
- InputMethodManager inputmanger = (InputMethodManager) activity
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- }
-
- /**
- * 动态隐藏软键盘
- */
- public static void hideSoftInput(Context context, EditText edit) {
- edit.clearFocus();
- InputMethodManager inputmanger = (InputMethodManager) context
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0);
- }
-
- /**
- * 点击屏幕空白区域隐藏软键盘(方法1)
- * 在onTouch中处理,未获焦点则隐藏
- * 参照以下注释代码
- */
- public static void clickBlankArea2HideSoftInput0() {
- Log.i("tips", "U should copy the following code.");
- /*
- @Override
- public boolean onTouchEvent (MotionEvent event){
- if (null != this.getCurrentFocus()) {
- InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
- return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
- }
- return super.onTouchEvent(event);
- }
- */
- }
-
- /**
- * 点击屏幕空白区域隐藏软键盘(方法2)
- * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘
- * 需重写dispatchTouchEvent
- * 参照以下注释代码
- */
- public static void clickBlankArea2HideSoftInput1() {
- Log.i("tips", "U should copy the following code.");
- /*
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- View v = getCurrentFocus();
- if (isShouldHideKeyboard(v, ev)) {
- hideKeyboard(v.getWindowToken());
- }
- }
- 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;
- }
-
- // 获取InputMethodManager,隐藏软键盘
- private void hideKeyboard(IBinder token) {
- if (token != null) {
- InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
- }
- }
- */
- }
-
- /**
- * 动态显示软键盘
- */
- public static void showSoftInput(Context context, EditText edit) {
- edit.setFocusable(true);
- edit.setFocusableInTouchMode(true);
- edit.requestFocus();
- InputMethodManager inputManager = (InputMethodManager) context
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.showSoftInput(edit, 0);
- }
-
- /**
- * 切换键盘显示与否状态
- */
- public static void toggleSoftInput(Context context, EditText edit) {
- edit.setFocusable(true);
- edit.setFocusableInTouchMode(true);
- edit.requestFocus();
- InputMethodManager inputManager = (InputMethodManager) context
- .getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
- }
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/NetworkUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/NetworkUtils.java
deleted file mode 100644
index 361dc29cbd9ef1684a354f49c083e9be994c7ce2..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/NetworkUtils.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.telephony.TelephonyManager;
-
-/*********************************************
- * author: Blankj on 2016/8/1 21:33
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class NetworkUtils {
-
- private NetworkUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * 打开网络设置界面
- * 3.0以下打开设置界面
- */
- public static void openWirelessSettings(Context context) {
- if (android.os.Build.VERSION.SDK_INT > 10) {
- context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
- } else {
- context.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
- }
- }
-
- /**
- * 判断是否网络连接
- * 需添加权限 需添加权限 如中国联通、中国移动、中国电信
- */
- public static String getNetworkOperatorName(Context context) {
- TelephonyManager tm = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- return tm != null ? tm.getNetworkOperatorName() : null;
- }
-
- /**
- * 获取移动终端类型
- * 联通的3G为UMTS或HSDPA,移动和联通的2G为GPRS或EGDE,电信的2G为CDMA,电信的3G为EVDO
- */
- public static int getNetworkTpye(Context context) {
- TelephonyManager tm = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- switch (tm.getNetworkType()) {
- case TelephonyManager.NETWORK_TYPE_GPRS:
- case TelephonyManager.NETWORK_TYPE_EDGE:
- case TelephonyManager.NETWORK_TYPE_CDMA:
- case TelephonyManager.NETWORK_TYPE_1xRTT:
- case TelephonyManager.NETWORK_TYPE_IDEN:
- return Constants.NETWORK_CLASS_2_G;
- case TelephonyManager.NETWORK_TYPE_UMTS:
- case TelephonyManager.NETWORK_TYPE_EVDO_0:
- case TelephonyManager.NETWORK_TYPE_EVDO_A:
- case TelephonyManager.NETWORK_TYPE_HSDPA:
- case TelephonyManager.NETWORK_TYPE_HSUPA:
- case TelephonyManager.NETWORK_TYPE_HSPA:
- case TelephonyManager.NETWORK_TYPE_EVDO_B:
- case TelephonyManager.NETWORK_TYPE_EHRPD:
- case TelephonyManager.NETWORK_TYPE_HSPAP:
- return Constants.NETWORK_CLASS_3_G;
- case TelephonyManager.NETWORK_TYPE_LTE:
- return Constants.NETWORK_CLASS_4_G;
- default:
- return Constants.NETWORK_CLASS_UNKNOWN;
- }
- }
-
- public class Constants {
- // Unknown network class
- public static final int NETWORK_CLASS_UNKNOWN = 0;
- // wifi network
- public static final int NETWORK_WIFI = 1;
- // "2G" networks
- public static final int NETWORK_CLASS_2_G = 2;
- // "3G" networks
- public static final int NETWORK_CLASS_3_G = 3;
- // "4G" networks
- public static final int NETWORK_CLASS_4_G = 4;
- }
-
- /**
- * 获取当前手机的网络类型(WIFI,2G,3G,4G)
- * 需添加权限 需要用到上面的方法
- */
- public static int getCurNetworkType(Context context) {
- int netWorkType = Constants.NETWORK_CLASS_UNKNOWN;
- ConnectivityManager cm = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo networkInfo = cm.getActiveNetworkInfo();
- if (networkInfo != null && networkInfo.isConnected()) {
- int type = networkInfo.getType();
- if (type == ConnectivityManager.TYPE_WIFI) {
- netWorkType = Constants.NETWORK_WIFI;
- } else if (type == ConnectivityManager.TYPE_MOBILE) {
- netWorkType = getNetworkTpye(context);
- }
- }
- return netWorkType;
- }
-
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/PhoneUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/PhoneUtils.java
deleted file mode 100644
index 8d259ccb37fd324939b396765f836f5dffd5a2f3..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/PhoneUtils.java
+++ /dev/null
@@ -1,289 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.SystemClock;
-import android.provider.Settings;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.Xml;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-/*********************************************
- * author: Blankj on 2016/8/1 19:57
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class PhoneUtils {
-
- private PhoneUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * 判断设备是否是手机
- */
- public static boolean isPhone(Context context) {
- TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- return tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
- }
-
- /**
- * 获取当前设备的IMIE
- * 需与上面的isPhone一起使用
- * 需添加权限 需添加权限 返回如下
- * 需添加权限 需添加权限 需添加权限 参照以下注释代码
- */
- public static void getContantNum() {
- Log.i("tips", "U should copy the following code.");
- /*
- Intent intent = new Intent();
- intent.setAction("android.intent.action.PICK");
- intent.setType("vnd.android.cursor.dir/phone_v2");
- startActivityForResult(intent, 0);
-
- @Override
- protected void onActivityResult ( int requestCode, int resultCode, Intent data){
- super.onActivityResult(requestCode, resultCode, data);
- if (data != null) {
- Uri uri = data.getData();
- String num = null;
- // 创建内容解析者
- ContentResolver contentResolver = getContentResolver();
- Cursor cursor = contentResolver.query(uri,
- null, null, null, null);
- while (cursor.moveToNext()) {
- num = cursor.getString(cursor.getColumnIndex("data1"));
- }
- cursor.close();
- num = num.replaceAll("-", "");//替换的操作,555-6 -> 5556
- }
- }
- */
- }
-
- /**
- * 获取手机短信并保存到xml中
- * 需添加权限 需添加权限
- * 移动:134(0-8)、135、136、137、138、139、147、150、151、152、157、158、159、178、182、183、184、187、188
- * 联通:130、131、132、145、155、156、175、176、185、186
- * 电信:133、153、173、177、180、181、189
- * 全球星:1349
- * 虚拟运营商:170
- */
- private static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-8])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";
- /**
- * 验证座机号,正确格式:xxx/xxxx-xxxxxxx/xxxxxxxx/
- */
- private static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
- /**
- * 验证邮箱
- */
- private static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
- /**
- * 验证url
- */
- private static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
- /**
- * 验证汉字
- */
- private static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
- /**
- * 验证用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
- */
- private static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?= 19方可使用)
- * 可在Activity的onCreat()中调用
- * 需在顶部控件布局中加入以下属性让内容出现在状态栏之下
- * android:clipToPadding="true"
- * android:fitsSystemWindows="true"
- */
- public static void setTransparentStatusBar(Activity activity) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- //透明状态栏
- activity.getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
- //透明导航栏
- activity.getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
- }
- }
-
- /**
- * 隐藏状态栏
- * 也就是设置全屏,一定要在setContentView之前调用,否则报错
- * 此方法Activity可以继承AppCompatActivity
- * 启动的时候状态栏会显示一下再隐藏,比如QQ的欢迎界面
- * 在配置文件中Activity加属性android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- * 如加了以上配置Activity不能继承AppCompatActivity,会报错
- */
- public static void hideStatusBar(Activity activity) {
- activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
- activity.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN,
- LayoutParams.FLAG_FULLSCREEN);
- }
-
- /**
- * 获取状态栏高度
- */
- public static int getStatusBarHeight(Context context) {
- int result = 0;
- int resourceId = context.getResources()
- .getIdentifier("status_bar_height", "dimen", "android");
- if (resourceId > 0) {
- result = context.getResources().getDimensionPixelSize(resourceId);
- }
- return result;
- }
-
- /**
- * 判断状态栏是否存在
- *
- * @param activity
- * @return 还有一种就是在Activity中加属性android:screenOrientation="landscape"
- * 不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏时会执行两次
- * 设置Activity的android:configChanges="orientation"时,切屏还是会重新调用各个生命周期,切横、竖屏时只会执行一次
- * 设置Activity的android:configChanges="orientation|keyboardHidden|screenSize"(4.0以上必须带最后一个参数)时
- * 切屏不会重新调用各个生命周期,只会执行onConfigurationChanged方法
- */
- public static void setLandscape(Activity activity) {
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- }
-
- /**
- * 获取当前屏幕截图,包含状态栏
- */
- public static Bitmap captureWithStatusBar(Activity activity) {
- View view = activity.getWindow().getDecorView();
- view.setDrawingCacheEnabled(true);
- view.buildDrawingCache();
- Bitmap bmp = view.getDrawingCache();
- int width = getScreenWidth(activity);
- int height = getScreenHeight(activity);
- Bitmap bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
- view.destroyDrawingCache();
- return bp;
- }
-
- /**
- * 获取当前屏幕截图,不包含状态栏
- * 需要用到上面获取状态栏高度的方法
- */
- public static Bitmap captureWithoutStatusBar(Activity activity) {
- View view = activity.getWindow().getDecorView();
- view.setDrawingCacheEnabled(true);
- view.buildDrawingCache();
- Bitmap bmp = view.getDrawingCache();
- int statusBarHeight = getStatusBarHeight(activity);
- int width = getScreenWidth(activity);
- int height = getScreenHeight(activity);
- Bitmap bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
- view.destroyDrawingCache();
- return bp;
- }
-
- /**
- * 判断是否锁屏
- */
- public static boolean isScreenLock(Context context) {
- KeyguardManager km = (KeyguardManager) context
- .getSystemService(Context.KEYGUARD_SERVICE);
- return km.inKeyguardRestrictedInputMode();
- }
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/SizeUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/SizeUtils.java
deleted file mode 100644
index d7acdc5960a82d61ef0df749bf2e04fba84eb7d4..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/SizeUtils.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import android.content.Context;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.View;
-
-/*********************************************
- * author: Blankj on 2016/8/1 19:12
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class SizeUtils {
-
- private SizeUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * dp转px
- */
- public static int dp2px(Context context, float dpValue) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (dpValue * scale + 0.5f);
- }
-
- /**
- * px转dp
- */
- public static int px2dp(Context context, float pxValue) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (pxValue / scale + 0.5f);
- }
-
- /**
- * sp转px
- */
- public static int sp2px(Context context, float spValue) {
- final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
- return (int) (spValue * fontScale + 0.5f);
- }
-
- /**
- * px转sp
- */
- public static int px2sp(Context context, float pxValue) {
- final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
- return (int) (pxValue / fontScale + 0.5f);
- }
-
- /**
- * 各种单位转换
- * 该方法存在于TypedValue
- */
- public static float applyDimension(int unit, float value, DisplayMetrics metrics) {
- switch (unit) {
- case TypedValue.COMPLEX_UNIT_PX:
- return value;
- case TypedValue.COMPLEX_UNIT_DIP:
- return value * metrics.density;
- case TypedValue.COMPLEX_UNIT_SP:
- return value * metrics.scaledDensity;
- case TypedValue.COMPLEX_UNIT_PT:
- return value * metrics.xdpi * (1.0f / 72);
- case TypedValue.COMPLEX_UNIT_IN:
- return value * metrics.xdpi;
- case TypedValue.COMPLEX_UNIT_MM:
- return value * metrics.xdpi * (1.0f / 25.4f);
- }
- return 0;
- }
-
- /**
- * 在onCreate()即可强行获取View的尺寸
- * 需回调onGetSizeListener接口,在onGetSize中获取view宽高
- * 用法示例如下所示
- * SizeUtils.forceGetViewSize(view);
- * SizeUtils.setListener(new SizeUtils.onGetSizeListener() {
- * @Override
- * public void onGetSize(View view) {
- * Log.d("tag", view.getWidth() + " " + view.getHeight());
- * }
- * });
- */
- public static void forceGetViewSize(final View view) {
- view.post(new Runnable() {
- @Override
- public void run() {
- if (mListener != null) {
- mListener.onGetSize(view);
- }
- }
- });
- }
-
- /**
- * 获取到View尺寸的监听
- */
- public interface onGetSizeListener {
- void onGetSize(View view);
- }
- public static void setListener(onGetSizeListener listener) {
- mListener = listener;
- }
- private static onGetSizeListener mListener;
-
- /**
- * ListView中提前测量View尺寸,如headerView
- * 用的时候去掉注释拷贝到ListView中即可
- * 参照以下注释代码
- */
- public static void measureViewInLV(View view) {
- Log.i("tips", "U should copy the following code.");
- /*
- ViewGroup.LayoutParams p = view.getLayoutParams();
- if (p == null) {
- p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- }
- int width = ViewGroup.getChildMeasureSpec(0, 0, p.width);
- int height;
- int tempHeight = p.height;
- if (tempHeight > 0) {
- height = MeasureSpec.makeMeasureSpec(tempHeight,
- MeasureSpec.EXACTLY);
- } else {
- height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- }
- view.measure(width, height);
- */
- }
-}
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/TimeUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/TimeUtils.java
deleted file mode 100644
index f9586ba2a3f52a79f1a7fd26f88b867aaa9b1308..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/TimeUtils.java
+++ /dev/null
@@ -1,308 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/*********************************************
- * author: Blankj on 2016/8/3 20:25
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class TimeUtils {
-
- private TimeUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- *
- * 在工具类中经常使用到工具类的格式化描述,这个主要是一个日期的操作类,所以日志格式主要使用 SimpleDateFormat的定义格式.
- *
- * 格式的意义如下: 日期和时间模式
- * 定义了以下模式字母(所有其他字符 'A' 到 'Z' 和 'a' 到 'z' 都被保留):
- *
- * 格式为yyyy-MM-dd HH:mm:ss
- */
- public static String milliseconds2String(long milliseconds) {
- return milliseconds2String(milliseconds, DEFAULT_SDF);
- }
-
- /**
- * 将时间戳转为时间字符串
- * 格式为用户自定义
- */
- public static String milliseconds2String(long milliseconds, SimpleDateFormat format) {
- return format.format(new Date(milliseconds));
- }
-
- /**
- * 将时间字符串转为时间戳
- * 格式为yyyy-MM-dd HH:mm:ss
- */
- public static long string2Milliseconds(String time) {
- return string2Milliseconds(time, DEFAULT_SDF);
- }
-
- /**
- * 将时间字符串转为时间戳
- * 格式为用户自定义
- */
- public static long string2Milliseconds(String time, SimpleDateFormat format) {
- try {
- return format.parse(time).getTime();
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return -1;
- }
-
- /**
- * 将时间字符串转为Date类型
- * 格式为yyyy-MM-dd HH:mm:ss
- */
- public static Date string2Date(String formatDate) {
- return string2Date(formatDate, DEFAULT_SDF);
- }
-
- /**
- * 将时间字符串转为Date类型
- * 格式为用户自定义
- */
- public static Date string2Date(String formatDate, SimpleDateFormat format) {
- return new Date(string2Milliseconds(formatDate, format));
- }
-
- /**
- * 将Date类型转为时间字符串
- * 格式为yyyy-MM-dd HH:mm:ss
- */
- public static String date2String(Date date) {
- return date2String(date, DEFAULT_SDF);
- }
-
- /**
- * 将Date类型转为时间字符串
- * 格式为用户自定义
- */
- public static String date2String(Date date, SimpleDateFormat format) {
- return format.format(date);
- }
-
- /**
- * 将Date类型转为时间戳
- */
- public static long date2Milliseconds(Date date) {
- return date.getTime();
- }
-
- /**
- * 将时间戳转为Date类型
- */
- public static Date milliseconds2Date(long milliseconds) {
- return new Date(milliseconds);
- }
-
- /**
- * 毫秒时间戳单位转换(单位:unit)
- * time1和time2格式都为yyyy-MM-dd HH:mm:ss
- */
- public static long getIntervalTime(String time1, String time2, int unit) {
- return getIntervalTime(time1, time2, unit, DEFAULT_SDF);
- }
-
- /**
- * 获取两个时间差(单位:unit)
- * time1和time2格式都为format
- */
- public static long getIntervalTime(String time1, String time2, int unit, SimpleDateFormat format) {
- return milliseconds2Unit(string2Milliseconds(time1, format)
- - string2Milliseconds(time2, format), unit);
- }
-
- /**
- * 获取两个时间差(单位:unit)
- * time1和time2都为Date
- */
- public static long getIntervalTime(Date time1, Date time2, int unit) {
- return milliseconds2Unit(date2Milliseconds(time2) - date2Milliseconds(time1), unit);
- }
-
- /**
- * 获取当前时间
- * 单位(毫秒)
- */
- public static long getCurTimeMills() {
- return System.currentTimeMillis();
- }
-
- /**
- * 获取当前时间
- * 格式为yyyy-MM-dd HH:mm:ss
- */
- public static String getCurTimeString() {
- return milliseconds2String(getCurTimeMills());
- }
-
- /**
- * 获取当前时间
- * 格式为用户自定义
- */
- public static String getCurTimeString(SimpleDateFormat format) {
- return milliseconds2String(getCurTimeMills(), format);
- }
-
- /**
- * 获取当前时间
- * Date类型
- */
- public static Date getCurTimeDate() {
- return new Date();
- }
-
- /**
- * 获取与当前时间的差(单位:unit)
- * time1和time2格式都为yyyy-MM-dd HH:mm:ss
- */
- public static long getIntervalByNow(String time, int unit) {
- return getIntervalByNow(time, unit, DEFAULT_SDF);
- }
-
- /**
- * 获取与当前时间的差(单位:unit)
- * time1和time2格式都为format
- */
- public static long getIntervalByNow(String time, int unit, SimpleDateFormat format) {
- return getIntervalTime(getCurTimeString(), time, unit, format);
- }
-
- /**
- * 获取与当前时间的差(单位:unit)
- * time1和time2格式都为format
- */
- public static long getIntervalByNow(Date time, int unit) {
- return getIntervalTime(getCurTimeDate(), time, unit);
- }
-
- /**
- * 判断闰年
- */
- public static boolean isLeapYear(int year) {
- return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
- }
-
-}
-
diff --git a/androidframework/src/main/java/com/blankj/androidframework/utils/UnclassifiedUtils.java b/androidframework/src/main/java/com/blankj/androidframework/utils/UnclassifiedUtils.java
deleted file mode 100644
index 3c94ff28bfd4349fdd7a975b43984a439653d8a8..0000000000000000000000000000000000000000
--- a/androidframework/src/main/java/com/blankj/androidframework/utils/UnclassifiedUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.blankj.androidframework.utils;
-
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningServiceInfo;
-import android.content.ComponentName;
-import android.content.Context;
-
-import java.util.List;
-
-/*********************************************
- * author: Blankj on 2016/8/2 21:24
- * blog: http://blankj.com
- * e-mail: blankj@qq.com
- *********************************************/
-public class UnclassifiedUtils {
-
- private UnclassifiedUtils() {
- throw new UnsupportedOperationException("u can't fuck me...");
- }
-
- /**
- * 获取服务是否开启
- * @param className 完整包名的服务类名
- */
- public static boolean isRunningService(String className, Context context) {
- // 进程的管理者,活动的管理者
- ActivityManager activityManager = (ActivityManager)
- context.getSystemService(Context.ACTIVITY_SERVICE);
- // 获取正在运行的服务,最多获取1000个
- List
- * PHONE_TYPE_NONE : 0 手机制式未知
- * PHONE_TYPE_GSM : 1 手机制式为GSM,移动和联通
- * PHONE_TYPE_CDMA : 2 手机制式为CDMA,电信
- * PHONE_TYPE_SIP : 3
- *
- */
- public static int getPhoneType(Context context) {
- TelephonyManager tm = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- return tm != null ? tm.getPhoneType() : -1;
- }
-
- /**
- * 获取手机连接的网络类型(2G,3G,4G)
- *
- * DeviceId(IMEI) = 99000311726612
- * DeviceSoftwareVersion = 00
- * Line1Number =
- * NetworkCountryIso = cn
- * NetworkOperator = 46003
- * NetworkOperatorName = 中国电信
- * NetworkType = 6
- * honeType = 2
- * SimCountryIso = cn
- * SimOperator = 46003
- * SimOperatorName = 中国电信
- * SimSerialNumber = 89860315045710604022
- * SimState = 5
- * SubscriberId(IMSI) = 460030419724900
- * VoiceMailNumber = *86
- *
- */
- public static String getPhoneStatus(Context context) {
- TelephonyManager tm = (TelephonyManager) context
- .getSystemService(Context.TELEPHONY_SERVICE);
- String str = "";
- str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
- str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
- str += "Line1Number = " + tm.getLine1Number() + "\n";
- str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
- str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
- str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
- str += "NetworkType = " + tm.getNetworkType() + "\n";
- str += "honeType = " + tm.getPhoneType() + "\n";
- str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
- str += "SimOperator = " + tm.getSimOperator() + "\n";
- str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
- str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
- str += "SimState = " + tm.getSimState() + "\n";
- str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
- str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
- return str;
- }
-
- /**
- * 跳至填充好phoneNumber的拨号界面
- */
- public static void dial(Context context, String phoneNumber) {
- context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)));
- }
-
- /**
- * 拨打phoneNumber
- *
- *
- */
- public static boolean isStatusBarExists(Activity activity) {
- WindowManager.LayoutParams params = activity.getWindow().getAttributes();
- return (params.flags & LayoutParams.FLAG_FULLSCREEN) != LayoutParams.FLAG_FULLSCREEN;
- }
-
- /**
- * 获取ActionBar高度
- */
- public static int getActionBarHeight(Activity activity) {
- TypedValue tv = new TypedValue();
- if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
- return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
- }
- return 0;
- }
-
- /**
- * 设置屏幕为横屏
- *
- * 日期和时间格式由日期和时间模式字符串指定。在日期和时间模式字符串中,未加引号的字母 'A' 到 'Z' 和 'a' 到 'z'
- * 被解释为模式字母,用来表示日期或时间字符串元素。文本可以使用单引号 (') 引起来,以免进行解释。"''"
- * 表示单引号。所有其他字符均不解释;只是在格式化时将它们简单复制到输出字符串,或者在分析时与输入字符串进行匹配。
- *
- *
- *
- *
- * 字母 日期或时间元素 表示 示例
- * G Era 标志符 Text AD
- * y 年 Year 1996; 96
- * M 年中的月份 Month July; Jul; 07
- * w 年中的周数 Number 27
- * W 月份中的周数 Number 2
- * D 年中的天数 Number 189
- * d 月份中的天数 Number 10
- * F 月份中的星期 Number 2
- * E 星期中的天数 Text Tuesday; Tue
- * a Am/pm 标记 Text PM
- * H 一天中的小时数(0-23) Number 0
- * k 一天中的小时数(1-24) Number 24
- * K am/pm 中的小时数(0-11) Number 0
- * h am/pm 中的小时数(1-12) Number 12
- * m 小时中的分钟数 Number 30
- * s 分钟中的秒数 Number 55
- * S 毫秒数 Number 978
- * z 时区 General time zone Pacific Standard Time; PST; GMT-08:00
- * Z 时区 RFC 822 time zone -0800
- * yyyy-MM-dd 1969-12-31
- * yyyy-MM-dd 1970-01-01
- * yyyy-MM-dd HH:mm 1969-12-31 16:00
- * yyyy-MM-dd HH:mm 1970-01-01 00:00
- * yyyy-MM-dd HH:mmZ 1969-12-31 16:00-0800
- * yyyy-MM-dd HH:mmZ 1970-01-01 00:00+0000
- * yyyy-MM-dd HH:mm:ss.SSSZ 1969-12-31 16:00:00.000-0800
- * yyyy-MM-dd HH:mm:ss.SSSZ 1970-01-01 00:00:00.000+0000
- * yyyy-MM-dd'T'HH:mm:ss.SSSZ 1969-12-31T16:00:00.000-0800
- * yyyy-MM-dd'T'HH:mm:ss.SSSZ 1970-01-01T00:00:00.000+0000
- *
- */
- public static final SimpleDateFormat DEFAULT_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- /**
- * 各时间单位与毫秒的倍数
- */
- public static final int UNIT_MSEC = 1;
- public static final int UNIT_SEC = 1000;
- public static final int UNIT_MIN = 60000;
- public static final int UNIT_HOUR = 3600000;
- public static final int UNIT_DAY = 86400000;
-
- /**
- * 将时间戳转为时间字符串
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- */
- private static long milliseconds2Unit(long milliseconds, int unit) {
- switch (unit) {
- case UNIT_MSEC:
- case UNIT_SEC:
- case UNIT_MIN:
- case UNIT_HOUR:
- case UNIT_DAY:
- return Math.abs(milliseconds) / unit;
- }
- return -1;
- }
-
- /**
- * 获取两个时间差(单位:unit)
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *
- * UNIT_MSEC:毫秒
- * UNIT_SEC :秒
- * UNIT_MIN :分
- * UNIT_HOUR:小时
- * UNIT_DAY :天
- *