Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
060588ca
Commit
060588ca
authored
Nov 16, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认短信、百度活体Demo
parent
8072c988
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
111 additions
and
46 deletions
+111
-46
build.gradle
+1
-1
libs/armeabi-v7a/libsignal.so
+0
-0
libs/armeabi/libsignal.so
+0
-0
src/main/AndroidManifest.xml
+1
-0
src/main/java/tech/starwin/LibConfig.java
+4
-0
src/main/java/tech/starwin/base/BaseApplication.java
+5
-0
src/main/java/tech/starwin/service/sms/SmsReceiver.java
+30
-11
src/main/java/tech/starwin/utils/BitmapUtils.java
+9
-0
src/main/java/tech/starwin/utils/PreferencesManager.java
+9
-1
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
+0
-10
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
+4
-17
src/main/java/tech/starwin/utils/ui_utils/UIHelper.java
+31
-4
src/main/res/values/strings.xml
+1
-1
src/main/res/values/styles.xml
+16
-1
No files found.
build.gradle
View file @
060588ca
...
...
@@ -10,7 +10,7 @@ android {
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
ndk
{
abiFilters
'armeabi'
//, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
abiFilters
'armeabi
-v7a'
//,'armeabi
' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
buildTypes
{
...
...
libs/armeabi-v7a/libsignal.so
0 → 100755
View file @
060588ca
File added
libs/armeabi/libsignal.so
deleted
100755 → 0
View file @
8072c988
File deleted
src/main/AndroidManifest.xml
View file @
060588ca
...
...
@@ -216,6 +216,7 @@
<!-- provides ongoing call UI -->
<intent-filter>
<action
android:name=
"android.intent.action.DIAL"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
...
...
src/main/java/tech/starwin/LibConfig.java
View file @
060588ca
...
...
@@ -69,6 +69,8 @@ public class LibConfig {
public
static
int
LOADING_BACKGROUND
;
//loading旋转背景
public
static
int
MAIN_COLOR
;
//主题色
public
static
ButterKnifeBinder
butterKnifeBinder
;
public
static
Context
getContext
()
{
...
...
@@ -121,6 +123,8 @@ public class LibConfig {
OctopusManager
.
getInstance
().
setTitleColorResId
(
R
.
color
.
white
);
OctopusManager
.
getInstance
().
setShowWarnDialog
(
true
);
OctopusManager
.
getInstance
().
setStatusBarBg
(
MAIN_COLOR
);
// FirebaseDynamicLinks.getInstance()
// .getDynamicLink(getIntent())
// .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
...
...
src/main/java/tech/starwin/base/BaseApplication.java
View file @
060588ca
...
...
@@ -31,9 +31,14 @@ public abstract class BaseApplication extends MultiDexApplication {
super
.
onCreate
();
AppLanguageUtils
.
setLanguage
(
this
,
LibConfig
.
LANGUAGE
);
LibConfig
.
initLib
(
this
);
afterOnCreate
();
}
public
abstract
void
afterOnCreate
();
public
abstract
void
initLibCnofig
();
}
src/main/java/tech/starwin/service/sms/SmsReceiver.java
View file @
060588ca
package
tech
.
starwin
.
service
.
sms
;
import
android.app.PendingIntent
;
import
android.content.BroadcastReceiver
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.provider.Telephony
;
import
android.support.v4.app.NotificationCompat
;
import
android.telephony.SmsMessage
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.context_utils.ActivityJumper
;
import
tech.starwin.utils.ui_utils.UIHelper
;
/**
...
...
@@ -26,7 +28,9 @@ public class SmsReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
LibConfig
.
getContext
().
getPackageManager
().
clearPackagePreferredActivities
(
LibConfig
.
APPLICATION_ID
);
if
(
"android.provider.Telephony.SMS_RECEIVED"
.
equals
(
intent
.
getAction
()))
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
//如果是默认短信应用,收到短信主动保存到数据库
if
(
"android.provider.Telephony.SMS_RECEIVED"
.
equals
(
intent
.
getAction
())
&&
Telephony
.
Sms
.
getDefaultSmsPackage
(
context
).
equals
(
context
.
getPackageName
()))
{
Bundle
bundle
=
intent
.
getExtras
();
if
(
bundle
!=
null
)
{
Object
[]
pdus
=
(
Object
[])
bundle
.
get
(
"pdus"
);
...
...
@@ -45,18 +49,33 @@ public class SmsReceiver extends BroadcastReceiver {
context
.
getContentResolver
().
insert
(
Uri
.
parse
(
"content://sms/sent"
),
values
);
//插入短信库
long
msgDate
=
msg
.
getTimestampMillis
();
LogUtils
.
d
(
"cky"
,
"message from: "
+
msgAddress
+
", message body: "
+
msgBody
+
", message date: "
+
msgDate
);
//通知栏提醒
notifySms
(
context
,
msgAddress
,
msgBody
);
}
// TODO 弹出短信通知,点击通知跳转短信列表或详情页
// ActivityJumper.startSmsList(context);
}
}
}
}
/**
* 添加一条短信通知
*/
public
void
notifySms
(
Context
context
,
String
title
,
String
body
)
{
//点击通知栏进入系统短信列表
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
setType
(
"vnd.android-dir/mms-sms"
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
0
,
intent
,
0
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
context
,
LibConfig
.
APPLICATION_ID
)
.
setContentTitle
(
title
)
// 设置通知时间,此事件用于通知栏排序
.
setContentText
(
body
)
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
.
setTicker
(
title
)
.
setContentIntent
(
pendingIntent
);
UIHelper
.
notifyNotification
(
context
,
builder
);
// ActivityJumper.startSmsList(context);
// String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
// Intent systemIntent = new Intent(intent.getAction(), intent.getData());
// systemIntent.putExtras(intent.getExtras());
// systemIntent.setPackage(defaultPkg);
// context.sendBroadcast(systemIntent);
}
}
src/main/java/tech/starwin/utils/BitmapUtils.java
View file @
060588ca
...
...
@@ -6,6 +6,7 @@ import android.graphics.Matrix;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.media.ExifInterface
;
import
android.util.Base64
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
...
...
@@ -260,6 +261,14 @@ public class BitmapUtils {
/**
* Base64 转 bitmap
*/
public
static
Bitmap
base64ToBitmap
(
String
base64
)
{
byte
[]
decode
=
Base64
.
decode
(
base64
,
Base64
.
DEFAULT
);
return
BitmapFactory
.
decodeByteArray
(
decode
,
0
,
decode
.
length
);
}
/**
* Drawable转Bitmap
*/
public
static
Bitmap
drawableToBmp
(
Drawable
drawable
)
{
...
...
src/main/java/tech/starwin/utils/PreferencesManager.java
View file @
060588ca
...
...
@@ -5,6 +5,13 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.text.TextUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.json.JSONException
;
import
org.json.JSONStringer
;
import
java.util.HashMap
;
import
java.util.Map
;
import
tech.starwin.mvp.beans.GatewayInfoBean
;
...
...
@@ -109,7 +116,7 @@ public class PreferencesManager {
}
/**
* 存取活体识别截图
* 存取
依图
活体识别截图
*/
public
void
saveVerificationData
(
byte
[]
data
)
{
if
(
data
==
null
)
{
...
...
@@ -124,6 +131,7 @@ public class PreferencesManager {
}
/**
* 更新政策 是否同意 状态
*/
...
...
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
View file @
060588ca
...
...
@@ -76,16 +76,6 @@ public class ActivityJumper {
}
/**
* 短信列表界面
*/
public
static
void
startSmsList
(
Context
context
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
setType
(
"vnd.android-dir/mms-sms"
);
context
.
startActivity
(
intent
);
}
public
static
class
Builder
{
private
Intent
intent
;
private
Context
fromContext
;
...
...
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
View file @
060588ca
...
...
@@ -107,26 +107,10 @@ public class PermissionsHelper {
}
/**
* 申请将指定包设置为默认短信应用(无Dialog提示)
*/
public
static
void
resetDefaultSms
(
Context
context
)
{
try
{
String
defaultPkg
=
PreferencesManager
.
get
().
getDefaultSmsPackage
();
if
(!
TextUtils
.
isEmpty
(
defaultPkg
))
{
Class
<?>
smsClass
=
Class
.
forName
(
"com.android.internal.telephony.SmsApplication"
);
Method
method
=
smsClass
.
getMethod
(
"setDefaultApplication"
,
String
.
class
,
Context
.
class
);
method
.
invoke
(
null
,
defaultPkg
,
context
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 申请将指定包设置为默认短信应用
*/
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
KITKAT
)
public
static
void
setDefaultSmsApp
(
FragmentActivity
activity
,
EasyActivityResult
.
OnResultListener
listener
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
String
defaultPkg
=
Telephony
.
Sms
.
getDefaultSmsPackage
(
activity
);
...
...
@@ -138,13 +122,14 @@ public class PermissionsHelper {
}
else
{
listener
.
onActivityResult
(
0
,
Activity
.
RESULT_OK
,
null
);
}
}
else
{
listener
.
onActivityResult
(
0
,
Activity
.
RESULT_CANCELED
,
null
);
}
}
/**
* 申请将指定包设置为默认电话应用
*/
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
M
)
public
static
void
setDefaultPhoneCallApp
(
FragmentActivity
activity
,
EasyActivityResult
.
OnResultListener
listener
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
TelecomManager
tm
=
(
TelecomManager
)
activity
.
getSystemService
(
Activity
.
TELECOM_SERVICE
);
...
...
@@ -155,6 +140,8 @@ public class PermissionsHelper {
}
else
{
listener
.
onActivityResult
(
0
,
Activity
.
RESULT_OK
,
null
);
}
}
else
{
listener
.
onActivityResult
(
0
,
Activity
.
RESULT_CANCELED
,
null
);
}
}
...
...
src/main/java/tech/starwin/utils/ui_utils/UIHelper.java
View file @
060588ca
package
tech
.
starwin
.
utils
.
ui_utils
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.Instrumentation
;
import
android.app.Notification
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Color
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.support.annotation.ColorRes
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.IdRes
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.RequiresApi
;
import
android.support.annotation.StringRes
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v7.widget.DefaultItemAnimator
;
import
android.support.v7.widget.LinearLayoutManager
;
...
...
@@ -37,6 +44,8 @@ import io.reactivex.Observable;
import
io.reactivex.ObservableEmitter
;
import
io.reactivex.ObservableOnSubscribe
;
import
io.reactivex.schedulers.Schedulers
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
import
tech.starwin.utils.BitmapUtils
;
import
tech.starwin.widget.PageStateLayout
;
...
...
@@ -179,11 +188,29 @@ public class UIHelper {
textView
.
setText
(
builder
);
}
/**
* public void
*
* */
* 显示通知
*/
public
static
void
notifyNotification
(
Context
context
,
NotificationCompat
.
Builder
builder
)
{
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
builder
.
setWhen
(
System
.
currentTimeMillis
())
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setAutoCancel
(
true
)
.
setDefaults
(
Notification
.
DEFAULT_ALL
)
.
setPriority
(
NotificationCompat
.
PRIORITY_HIGH
)
.
setOngoing
(
true
);
// 兼容android O
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
NotificationChannel
channel
=
new
NotificationChannel
(
LibConfig
.
APPLICATION_ID
,
LibConfig
.
APPLICATION_ID
,
NotificationManager
.
IMPORTANCE_DEFAULT
);
notificationManager
.
createNotificationChannel
(
channel
);
builder
.
setChannelId
(
LibConfig
.
APPLICATION_ID
);
}
// 通知系统展示通知栏
notificationManager
.
notify
(
"test"
,
111
,
builder
.
build
());
}
/**
* 打开软键盘
...
...
src/main/res/values/strings.xml
View file @
060588ca
...
...
@@ -244,7 +244,7 @@
<string
name=
"text_shoot_kpt_front"
>
Foto Halaman Depan KTP
</string>
<string
name=
"text_shoot_photo_clear_tips"
>
Foto harus jelas
</string>
<string
name=
"text_button_start_taking_photos"
>
Mulai
</string>
<string
name=
"text_cancel"
>
Batal
</string>
<string
name=
"text_cancel"
>
Batal
</string>
P
<string
name=
"text_rejected"
>
Ditolak
</string>
<string
name=
"text_in_review"
>
Dalam proses
</string>
<string
name=
"text_take_photo_tips"
>
Klik lagi untuk kirim atau klik tombol "Batal" untuk membatalkan
</string>
...
...
src/main/res/values/styles.xml
View file @
060588ca
...
...
@@ -18,13 +18,28 @@
<!--<!–<item name="android:windowExitAnimation">@android:anim/fade_out</item>–>-->
<!--</style>-->
<style
name=
"default_animation"
parent=
"@android:style/Animation.Translucent"
>
<item
name=
"android:windowEnterAnimation"
>
@anim/slide_open_enter
</item>
<item
name=
"android:windowExitAnimation"
>
@anim/slide_close_exit
</item>
<item
name=
"android:taskOpenEnterAnimation"
>
@anim/slide_open_enter
</item>
<item
name=
"android:taskOpenExitAnimation"
>
@anim/slide_open_exit
</item>
<item
name=
"android:activityOpenEnterAnimation"
>
@anim/slide_open_enter
</item>
<item
name=
"android:activityOpenExitAnimation"
>
@anim/slide_open_exit
</item>
<item
name=
"android:activityCloseEnterAnimation"
>
@anim/slide_close_enter
</item>
<item
name=
"android:activityCloseExitAnimation"
>
@anim/slide_close_exit
</item>
<item
name=
"android:taskCloseEnterAnimation"
>
@anim/slide_close_enter
</item>
<item
name=
"android:taskCloseExitAnimation"
>
@anim/slide_close_exit
</item>
<item
name=
"android:taskToBackEnterAnimation"
>
@anim/slide_close_enter
</item>
<item
name=
"android:taskToBackExitAnimation"
>
@anim/slide_close_exit
</item>
</style>
<style
name=
"style_bg_transparent_dialog"
parent=
"Base.Theme.AppCompat.Light.Dialog"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
</style>
<style
name=
"QMTheme"
parent=
"QMUI.Compat.NoActionBar"
>
<
!--<item name="android:windowAnimationStyle">@style/noAnimation</item>--
>
<
item
name=
"android:windowAnimationStyle"
>
@style/default_animation
</item
>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<!-- toolbar(actionbar)颜色 -->
<item
name=
"colorPrimary"
>
@color/main_color
</item>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment