Skip to content

Commit 9fea09a

Browse files
committed
[commit] 增加tips
1 parent 25fdf7c commit 9fea09a

File tree

9 files changed

+93
-16
lines changed

9 files changed

+93
-16
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ compile 'com.code19.library:library:0.0.6'
1313
- 能力一般,水平有限,难免有Bug,如果有任何问题,请<a href="https://github.com/h4de5ing/AndroidCommon/issues">反馈</a>
1414
- 如果你有更好的代码,请提交<a href="https://github.com/h4de5ing/AndroidCommon/pulls">Pull request</a>
1515

16-
## app Module中的类:
17-
MainActivity.java 测试项目中的主类
18-
HandlerActivity.java Handler的正确使用方式事例
19-
16+
2017
## library Module中的类:
2118

2219
- AppUtils.java 应用工具类
@@ -78,6 +75,8 @@ compile 'com.code19.library:library:0.0.6'
7875
* getTime 获取系统时间
7976
* subtractDate 计算两个时间差
8077
* getDateAfter 得到几天后的时间
78+
* getWeekOfMonth 获取当前时间为本月的第几周
79+
* getDayOfWeek 获取当前时间为本周的第几天
8180

8281
- DensityUtil.java 屏幕工具类
8382
* dip2px dp转像素
@@ -204,10 +203,12 @@ compile 'com.code19.library:library:0.0.6'
204203
* isContainChinese 是否包含中文
205204
* strFormat2 不足2位前面补0
206205
* convert2Int 类型安全转换
206+
* decimalFormat 指定小数输出
207207

208208
- SystemUtils.java 系统工具
209209
* sendSMS 调用系统发送短信
210210
* forwardToDial 跳转到拨号
211+
* callPhone 直接呼叫号码
211212
* sendMail 发邮件
212213
* hideKeyBoard 隐藏系统键盘
213214
* isBackground 判断当前应用程序是否后台运行
@@ -254,6 +255,7 @@ compile 'com.code19.library:library:0.0.6'
254255
* matcherIdentityCard 判断身份证号码格式
255256
* isNumeric 是否数值型
256257
* testRegex 是否匹配正则
258+
* checkPostcode 匹配中国邮政编码
257259
258260
- ViewUtils.java View工具
259261
* removeSelfFromParent

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
</activity>
4343
<activity android:name=".ui.activity.DeviceActivity">
4444
</activity>
45-
<activity android:name=".ui.activity.VerificationActivity">
45+
<activity
46+
android:name=".ui.activity.VerificationActivity"
47+
android:windowSoftInputMode="adjustPan|stateAlwaysVisible"
48+
><!--界面不被键盘遮住-->
49+
<!--键盘遮住界面android:windowSoftInputMode="adjustResize"-->
4650
</activity>
4751
</application>
4852

app/src/main/res/layout/activity_main.xml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,40 @@
7474
android:layout_height="wrap_content"
7575
android:background="?android:attr/selectableItemBackground"
7676
android:text="@string/virificationutils"/>
77-
77+
<EditText
78+
android:layout_width="match_parent"
79+
android:layout_height="wrap_content"
80+
/>
81+
<!--
82+
android:inputType="phone"
83+
android:inputType="none"
84+
android:inputType="text"
85+
android:inputType="textCapCharacters" 字母大写
86+
android:inputType="textCapWords" 首字母大写
87+
android:inputType="textCapSentences" 仅第一个字母大写
88+
android:inputType="textAutoCorrect" 自动完成
89+
android:inputType="textAutoComplete" 自动完成
90+
android:inputType="textMultiLine" 多行输入
91+
android:inputType="textImeMultiLine" 输入法多行(如果支持)
92+
android:inputType="textNoSuggestions" 不提示
93+
android:inputType="textUri" 网址
94+
android:inputType="textEmailAddress" 电子邮件地址
95+
android:inputType="textEmailSubject" 邮件主题
96+
android:inputType="textShortMessage" 短讯
97+
android:inputType="textLongMessage" 长信息
98+
android:inputType="textPersonName" 人名
99+
android:inputType="textPostalAddress" 地址
100+
android:inputType="textPassword" 密码
101+
android:inputType="textVisiblePassword" 可见密码
102+
android:inputType="textWebEditText" 作为网页表单的文本
103+
android:inputType="textFilter" 文本筛选过滤
104+
android:inputType="textPhonetic" 拼音输入
105+
//数值类型
106+
android:inputType="number" 数字
107+
android:inputType="numberSigned" 带符号数字格式
108+
android:inputType="numberDecimal" 带小数点的浮点格式
109+
android:inputType="phone" 拨号键盘
110+
android:inputType="datetime" 时间日期
111+
android:inputType="date" 日期键盘
112+
android:inputType="time" 时间键盘-->
78113
</LinearLayout>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.0'
8+
classpath 'com.android.tools.build:gradle:2.1.2'
99
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
1010
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1111

library/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
2828
<uses-permission android:name="android.permission.INTERNET"/>
2929
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
30+
<uses-permission android:name="android.permission.CALL_PHONE"/>
3031

3132
<application
3233
android:allowBackup="true"

library/src/main/java/com/code19/library/DateUtils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
/**
2525
* Create by h4de5ing 2016/5/7 007
26-
*
2726
*/
2827
public class DateUtils {
2928
private static final SimpleDateFormat DATE_FORMAT_DATETIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -81,4 +80,21 @@ public static Date getDateAfter(Date d, int day) {
8180
now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
8281
return now.getTime();
8382
}
83+
84+
public static int getWeekOfMonth() {
85+
Calendar calendar = Calendar.getInstance();
86+
int week = calendar.get(Calendar.WEEK_OF_MONTH);
87+
return week - 1;
88+
}
89+
90+
public static int getDayOfWeek() {
91+
Calendar calendar = Calendar.getInstance();
92+
int day = calendar.get(Calendar.DAY_OF_WEEK);
93+
if (day == 1) {
94+
day = 7;
95+
} else {
96+
day = day - 1;
97+
}
98+
return day;
99+
}
84100
}

library/src/main/java/com/code19/library/StringUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.code19.library;
22

3+
import java.text.DecimalFormat;
4+
35
/**
46
* Created by Gh0st on 2016/6/2 002.
57
*/
@@ -221,4 +223,9 @@ public static int convert2Int(Object value, int defaultValue) {
221223
}
222224
}
223225

226+
public static String decimalFormat(String s, String format) {
227+
DecimalFormat decimalFormat = new DecimalFormat(format);
228+
return decimalFormat.format(s);
229+
}
230+
224231
}

library/src/main/java/com/code19/library/SystemUtils.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.code19.library;
1717

18+
import android.Manifest;
1819
import android.annotation.SuppressLint;
1920
import android.app.Activity;
2021
import android.app.ActivityManager;
@@ -32,6 +33,7 @@
3233
import android.net.Uri;
3334
import android.os.Build;
3435
import android.os.Parcelable;
36+
import android.support.v4.app.ActivityCompat;
3537
import android.text.TextUtils;
3638
import android.view.inputmethod.InputMethodManager;
3739
import android.widget.EditText;
@@ -56,15 +58,22 @@ public static void sendSMS(Context cxt, String smsBody) {
5658

5759
public static void forwardToDial(Activity activity, String phoneNumber) {
5860
if (activity != null && !TextUtils.isEmpty(phoneNumber)) {
59-
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
60-
activity.startActivity(intent);
61+
activity.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)));
62+
}
63+
}
64+
65+
public static void callPhone(Activity activity, String phoneNumber) {
66+
if (activity != null && !TextUtils.isEmpty(phoneNumber)) {
67+
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
68+
return;
69+
}
70+
activity.startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)));
6171
}
6272
}
6373

6474
public static void sendMail(Context mContext, String mailID) {
6575
Uri uri = Uri.parse("mailto:" + mailID);
66-
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
67-
mContext.startActivity(intent);
76+
mContext.startActivity(new Intent(Intent.ACTION_SENDTO, uri));
6877
}
6978

7079
public static void hideKeyBoard(Activity aty) {
@@ -73,8 +82,7 @@ public static void hideKeyBoard(Activity aty) {
7382

7483

7584
public static boolean isBackground(Context context) {
76-
ActivityManager activityManager = (ActivityManager) context
77-
.getSystemService(Context.ACTIVITY_SERVICE);
85+
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
7886
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
7987
for (RunningAppProcessInfo appProcess : appProcesses) {
8088
if (appProcess.processName.equals(context.getPackageName())) {
@@ -190,8 +198,7 @@ public static String hexdigest(byte[] paramArrayOfByte) {
190198

191199

192200
public static int getDeviceUsableMemory(Context cxt) {
193-
ActivityManager am = (ActivityManager) cxt
194-
.getSystemService(Context.ACTIVITY_SERVICE);
201+
ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
195202
MemoryInfo mi = new MemoryInfo();
196203
am.getMemoryInfo(mi);
197204
return (int) (mi.availMem / (1024 * 1024));

library/src/main/java/com/code19/library/VerificationUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,9 @@ public static boolean isNumeric(String input) {
218218
public static boolean testRegex(String regex, String inputValue) {
219219
return Pattern.compile(regex).matcher(inputValue).matches();
220220
}
221+
222+
public static boolean checkPostcode(String postcode) {
223+
String regex = "[1-9]\\d{5}";
224+
return Pattern.matches(regex, postcode);
225+
}
221226
}

0 commit comments

Comments
 (0)