Skip to content

Commit 24a5ba4

Browse files
committed
see 12/20 log
1 parent 28a7c2f commit 24a5ba4

File tree

13 files changed

+501
-32
lines changed

13 files changed

+501
-32
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
77
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
88

9+
<!--flashlight-->
10+
<uses-permission android:name="android.permission.CAMERA" />
11+
<uses-feature android:name="android.hardware.camera" />
12+
<uses-feature android:name="android.hardware.camera.autofocus" />
13+
<uses-feature android:name="android.hardware.camera.flash" />
14+
<uses-permission android:name="android.permission.FLASHLIGHT"/>
15+
916
<!--location-->
1017
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
1118
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
@@ -45,25 +52,29 @@
4552
<activity android:name=".activities.AppActivity"/>
4653
<activity android:name=".activities.CleanActivity"/>
4754
<activity android:name=".activities.DeviceActivity"/>
55+
<activity android:name=".activities.FlashlightActivity"/>
4856
<activity android:name=".activities.HandlerActivity"/>
4957
<activity android:name=".activities.ImageActivity"/>
5058
<activity
5159
android:name=".activities.KeyboardActivity"
5260
android:windowSoftInputMode="stateHidden|adjustPan"/>
5361
<activity android:name=".activities.LocationActivity"/>
54-
<service android:name=".services.LocationService"/>
5562
<activity android:name=".activities.MainActivity">
5663
<intent-filter>
5764
<action android:name="android.intent.action.MAIN"/>
5865
<category android:name="android.intent.category.LAUNCHER"/>
5966
</intent-filter>
6067
</activity>
6168
<activity android:name=".activities.NetworkActivity"/>
69+
<activity android:name=".activities.PermissionActivity"/>
6270
<activity android:name=".activities.PhoneActivity"/>
6371
<activity android:name=".activities.ProcessActivity"/>
6472
<activity android:name=".activities.SDCardActivity"/>
6573
<activity android:name=".activities.SnackbarActivity"/>
74+
<activity android:name=".activities.SpannableActivity"/>
6675
<activity android:name=".activities.ToastActivity"/>
76+
77+
<service android:name=".services.LocationService"/>
6778
</application>
6879

6980
</manifest>

app/src/main/java/com/blankj/androidutilcode/Services/LocationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void onCreate() {
7777
public void run() {
7878
Looper.prepare();
7979
isSuccess = LocationUtils.register(App.getInstance(), 0, 0, mOnLocationChangeListener);
80-
if (isSuccess) ToastUtils.showShortToastSafe(App.getInstance(), "init success");
80+
if (isSuccess) ToastUtils.showShortToastSafe("init success");
8181
Looper.loop();
8282
}
8383
}).start();

app/src/main/java/com/blankj/androidutilcode/activities/MainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public void snackbarClick(View view) {
8787
startActivity(new Intent(this, SnackbarActivity.class));
8888
}
8989

90+
public void spannableClick(View view) {
91+
startActivity(new Intent(this, SpannableActivity.class));
92+
}
93+
9094
public void toastClick(View view) {
9195
startActivity(new Intent(this, ToastActivity.class));
9296
}

app/src/main/java/com/blankj/androidutilcode/activities/PhoneActivity.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ protected void onCreate(Bundle savedInstanceState) {
3131
findViewById(R.id.btn_send_sms).setOnClickListener(this);
3232
findViewById(R.id.btn_send_sms_silent).setOnClickListener(this);
3333

34-
tvAboutPhone.setText("isPhone: " + PhoneUtils.isPhone(this)
35-
+ "\ngetIMEI: " + PhoneUtils.getIMEI(this)
36-
+ "\ngetIMSI: " + PhoneUtils.getIMSI(this)
37-
+ "\ngetPhoneType: " + PhoneUtils.getPhoneType(this)
38-
+ "\nisSimCardReady: " + PhoneUtils.isSimCardReady(this)
39-
+ "\ngetSimOperatorName: " + PhoneUtils.getSimOperatorName(this)
40-
+ "\ngetSimOperatorByMnc: " + PhoneUtils.getSimOperatorByMnc(this)
41-
+ "\n获取手机状态信息: " + PhoneUtils.getPhoneStatus(this)
34+
tvAboutPhone.setText("isPhone: " + PhoneUtils.isPhone()
35+
+ "\ngetIMEI: " + PhoneUtils.getIMEI()
36+
+ "\ngetIMSI: " + PhoneUtils.getIMSI()
37+
+ "\ngetPhoneType: " + PhoneUtils.getPhoneType()
38+
+ "\nisSimCardReady: " + PhoneUtils.isSimCardReady()
39+
+ "\ngetSimOperatorName: " + PhoneUtils.getSimOperatorName()
40+
+ "\ngetSimOperatorByMnc: " + PhoneUtils.getSimOperatorByMnc()
41+
+ "\n获取手机状态信息: " + PhoneUtils.getPhoneStatus()
4242
);
4343
}
4444

4545
@Override
4646
public void onClick(View view) {
4747
switch (view.getId()) {
4848
case R.id.btn_dial:
49-
PhoneUtils.dial(this, "10000");
49+
PhoneUtils.dial("10000");
5050
break;
5151
case R.id.btn_call:
52-
PhoneUtils.call(this, "10000");
52+
PhoneUtils.call("10000");
5353
break;
5454
case R.id.btn_send_sms:
55-
PhoneUtils.sendSms(this, "10000", "test");
55+
PhoneUtils.sendSms("10000", "test");
5656
break;
5757
case R.id.btn_send_sms_silent:
58-
PhoneUtils.sendSmsSilent(this, "10000", "test");
58+
PhoneUtils.sendSmsSilent("10000", "test");
5959
break;
6060
}
6161
}

app/src/main/java/com/blankj/androidutilcode/activities/SnackbarActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.os.Bundle;
66
import android.view.View;
77

8-
import com.blankj.androidutilcode.App;
98
import com.blankj.androidutilcode.R;
109
import com.blankj.utilcode.utils.SnackbarUtils;
1110
import com.blankj.utilcode.utils.ToastUtils;
@@ -48,7 +47,7 @@ public void onClick(View view) {
4847
"Short", Color.YELLOW, new View.OnClickListener() {
4948
@Override
5049
public void onClick(View v) {
51-
ToastUtils.showShortToast(App.getInstance(), "Click Short");
50+
ToastUtils.showShortToast("Click Short");
5251
}
5352
});
5453
break;
@@ -60,7 +59,7 @@ public void onClick(View v) {
6059
"Long", Color.YELLOW, new View.OnClickListener() {
6160
@Override
6261
public void onClick(View v) {
63-
ToastUtils.showLongToast(App.getInstance(), "Click Long");
62+
ToastUtils.showLongToast("Click Long");
6463
}
6564
});
6665
break;
@@ -72,7 +71,7 @@ public void onClick(View v) {
7271
"Indefinite", Color.YELLOW, new View.OnClickListener() {
7372
@Override
7473
public void onClick(View v) {
75-
ToastUtils.showShortToast(App.getInstance(), "Click Indefinite");
74+
ToastUtils.showShortToast("Click Indefinite");
7675
}
7776
});
7877
break;
@@ -85,7 +84,7 @@ public void onClick(View v) {
8584
"Short", Color.YELLOW, new View.OnClickListener() {
8685
@Override
8786
public void onClick(View v) {
88-
ToastUtils.showShortToast(App.getInstance(), "Click Short");
87+
ToastUtils.showShortToast("Click Short");
8988
}
9089
});
9190
SnackbarUtils.addView(R.layout.snackbar_add, 0);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.blankj.androidutilcode.activities;
2+
3+
import android.app.Activity;
4+
import android.graphics.Color;
5+
import android.os.Bundle;
6+
import android.text.method.LinkMovementMethod;
7+
import android.text.style.ClickableSpan;
8+
import android.view.View;
9+
import android.widget.TextView;
10+
11+
import com.blankj.androidutilcode.R;
12+
import com.blankj.utilcode.utils.SpannableStringUtils;
13+
import com.blankj.utilcode.utils.ToastUtils;
14+
15+
/**
16+
* <pre>
17+
* author: Blankj
18+
* blog : http://blankj.com
19+
* time : 2016/9/27
20+
* desc : SDCard工具类Demo
21+
* </pre>
22+
*/
23+
public class SpannableActivity extends Activity {
24+
25+
@Override
26+
protected void onCreate(Bundle savedInstanceState) {
27+
super.onCreate(savedInstanceState);
28+
setContentView(R.layout.activity_spannable);
29+
30+
ClickableSpan clickableSpan = new ClickableSpan() {
31+
@Override
32+
public void onClick(View widget) {
33+
ToastUtils.showShortToast("事件触发了");
34+
}
35+
};
36+
37+
TextView tvAboutSpannable = (TextView) findViewById(R.id.tv_about_spannable);
38+
// 响应点击事件的话必须设置以下属性
39+
tvAboutSpannable.setMovementMethod(LinkMovementMethod.getInstance());
40+
// tvAboutSpannable.setHighlightColor(Color.BLUE);
41+
tvAboutSpannable.setText(SpannableStringUtils
42+
.getBuilder("测试SpannableStringUtils").setBold().setForegroundColor(Color.YELLOW).setBackgroundColor(Color.GRAY)
43+
.append("\n测试")
44+
.append("前景色").setForegroundColor(Color.GREEN)
45+
.append("\n测试")
46+
.append("背景色").setBackgroundColor(Color.RED)
47+
.append("\n测试")
48+
.append("2倍字体").setProportion(2)
49+
.append("\n测试")
50+
.append("删除线").setStrikethrough()
51+
.append("\n测试")
52+
.append("下划线").setUnderline()
53+
.append("\n测试")
54+
.append("上标").setSuperscript()
55+
.append("\n测试")
56+
.append("下标").setSubscript()
57+
.append("\n测试")
58+
.append("粗体").setBold()
59+
.append("\n测试")
60+
.append("斜体").setItalic()
61+
.append("\n测试")
62+
.append("粗斜体").setBoldItalic()
63+
.append("\n测试")
64+
.append("图片").setResourceId(R.mipmap.ic_launcher)
65+
.append("\n测试")
66+
.append("点击事件").setClickSpan(clickableSpan)
67+
.append("\n测试")
68+
.append("AndroidUtilCode").setUrl("https://github.com/Blankj/AndroidUtilCode")
69+
.create()
70+
);
71+
}
72+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@
139139
android:text="@string/test.snackbar"
140140
/>
141141

142+
<Button
143+
style="@style/BtnFont"
144+
android:layout_width="match_parent"
145+
android:layout_height="wrap_content"
146+
android:onClick="spannableClick"
147+
android:text="@string/test.spannable"
148+
/>
149+
142150
<Button
143151
style="@style/BtnFont"
144152
android:layout_width="match_parent"

app/src/main/res/values/dimens.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<dimen name="spacing_small">8dp</dimen>
88
<dimen name="spacing_tiny">4dp</dimen>
99

10-
<dimen name="font_normal">12sp</dimen>
10+
<dimen name="font_small">12sp</dimen>
11+
<dimen name="font_normal">24sp</dimen>
1112
</resources>

app/src/main/res/values/string.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<string name="test.process">ProcessUtils Test</string>
1919
<string name="test.sdcard">SDCardUtils Test</string>
2020
<string name="test.snackbar">SnackbarUtils Test</string>
21+
<string name="test.spannable">SpannableStringUtils Test</string>
2122
<string name="test.toast">ToastUtils Test</string>
2223

2324
<!--Activity相关-->

utilcode/src/main/java/com/blankj/utilcode/utils/LogUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.blankj.utilcode.utils;
22

3-
import android.content.Context;
43
import android.os.Environment;
54
import android.util.Log;
65

@@ -307,6 +306,5 @@ public void run() {
307306
}
308307
}
309308
}).start();
310-
311309
}
312-
}
310+
}

utilcode/src/main/java/com/blankj/utilcode/utils/SnackbarUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.blankj.utilcode.utils;
22

3+
import android.support.annotation.ColorInt;
34
import android.support.design.widget.Snackbar;
45
import android.view.Gravity;
56
import android.view.LayoutInflater;
@@ -9,7 +10,6 @@
910

1011
import com.blankj.utilcode.R;
1112

12-
import java.lang.ref.ReferenceQueue;
1313
import java.lang.ref.WeakReference;
1414

1515
/**
@@ -36,7 +36,7 @@ private SnackbarUtils() {
3636
* @param textColor 文本颜色
3737
* @param bgColor 背景色
3838
*/
39-
public static void showShortSnackbar(View parent, CharSequence text, int textColor, int bgColor) {
39+
public static void showShortSnackbar(View parent, CharSequence text, @ColorInt int textColor, @ColorInt int bgColor) {
4040
showSnackbar(parent, text, Snackbar.LENGTH_SHORT, textColor, bgColor, null, -1, null);
4141
}
4242

@@ -51,7 +51,7 @@ public static void showShortSnackbar(View parent, CharSequence text, int textCol
5151
* @param actionTextColor 事件文本颜色
5252
* @param listener 监听器
5353
*/
54-
public static void showShortSnackbar(View parent, CharSequence text, int textColor, int bgColor,
54+
public static void showShortSnackbar(View parent, CharSequence text, @ColorInt int textColor, @ColorInt int bgColor,
5555
CharSequence actionText, int actionTextColor, View.OnClickListener listener) {
5656
showSnackbar(parent, text, Snackbar.LENGTH_SHORT, textColor, bgColor,
5757
actionText, actionTextColor, listener);
@@ -65,7 +65,7 @@ public static void showShortSnackbar(View parent, CharSequence text, int textCol
6565
* @param textColor 文本颜色
6666
* @param bgColor 背景色
6767
*/
68-
public static void showLongSnackbar(View parent, CharSequence text, int textColor, int bgColor) {
68+
public static void showLongSnackbar(View parent, CharSequence text, @ColorInt int textColor, @ColorInt int bgColor) {
6969
showSnackbar(parent, text, Snackbar.LENGTH_LONG, textColor, bgColor, null, -1, null);
7070
}
7171

@@ -80,7 +80,7 @@ public static void showLongSnackbar(View parent, CharSequence text, int textColo
8080
* @param actionTextColor 事件文本颜色
8181
* @param listener 监听器
8282
*/
83-
public static void showLongSnackbar(View parent, CharSequence text, int textColor, int bgColor,
83+
public static void showLongSnackbar(View parent, CharSequence text, @ColorInt int textColor, @ColorInt int bgColor,
8484
CharSequence actionText, int actionTextColor, View.OnClickListener listener) {
8585
showSnackbar(parent, text, Snackbar.LENGTH_LONG, textColor, bgColor,
8686
actionText, actionTextColor, listener);
@@ -95,7 +95,7 @@ public static void showLongSnackbar(View parent, CharSequence text, int textColo
9595
* @param textColor 文本颜色
9696
* @param bgColor 背景色
9797
*/
98-
public static void showIndefiniteSnackbar(View parent, CharSequence text, int duration, int textColor, int bgColor) {
98+
public static void showIndefiniteSnackbar(View parent, CharSequence text, int duration, @ColorInt int textColor, @ColorInt int bgColor) {
9999
showSnackbar(parent, text, duration, textColor, bgColor, null, -1, null);
100100
}
101101

@@ -111,7 +111,7 @@ public static void showIndefiniteSnackbar(View parent, CharSequence text, int du
111111
* @param actionTextColor 事件文本颜色
112112
* @param listener 监听器
113113
*/
114-
public static void showIndefiniteSnackbar(View parent, CharSequence text, int duration, int textColor, int bgColor,
114+
public static void showIndefiniteSnackbar(View parent, CharSequence text, int duration, @ColorInt int textColor, @ColorInt int bgColor,
115115
CharSequence actionText, int actionTextColor, View.OnClickListener listener) {
116116
showSnackbar(parent, text, duration, textColor, bgColor,
117117
actionText, actionTextColor, listener);
@@ -129,7 +129,7 @@ public static void showIndefiniteSnackbar(View parent, CharSequence text, int du
129129
* @param actionTextColor 事件文本颜色
130130
* @param listener 监听器
131131
*/
132-
private static void showSnackbar(View parent, CharSequence text, int duration, int textColor, int bgColor,
132+
private static void showSnackbar(View parent, CharSequence text, int duration, @ColorInt int textColor, @ColorInt int bgColor,
133133
CharSequence actionText, int actionTextColor, View.OnClickListener listener) {
134134
switch (duration) {
135135
default:

0 commit comments

Comments
 (0)