Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0e112132
authored
Jun 10, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
12411422
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
853 additions
and
87 deletions
app/build.gradle
app/src/androidTest/java/com/polysoft/nafmii/ExampleInstrumentedTest.java
app/src/main/AndroidManifest.xml
app/src/main/java/com/polysoft/nafmii/constants/Constants.java
app/src/main/java/com/polysoft/nafmii/constants/ServerApi.java
app/src/main/java/com/polysoft/nafmii/fragment/AdvertisementFragment.java
app/src/main/java/com/polysoft/nafmii/fragment/FingerprintDialogFragment.java
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
app/src/main/java/com/polysoft/nafmii/utils/BitmapUtils.java
app/src/main/java/com/polysoft/nafmii/utils/LogUtil.java
app/src/main/java/com/polysoft/nafmii/utils/StatusBarUtils.java
app/src/main/java/com/polysoft/nafmii/webview/MyWebChromeClient.java
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
app/src/main/java/com/polysoft/nafmii/webview/X5WebviewUtils.java
app/src/main/java/com/polysoft/nafmii/wechat/WechatApi.java
app/src/main/java/com/polysoft/nafmii/MyApplication.java → app/src/main/java/com/whaty/nafmii/MyApplication.java
app/src/main/java/com/polysoft/nafmii/activity/BaseActivity.java → app/src/main/java/com/whaty/nafmii/activity/BaseActivity.java
app/src/main/java/com/polysoft/nafmii/activity/GuideActivity.java → app/src/main/java/com/whaty/nafmii/activity/GuideActivity.java
app/src/main/java/com/polysoft/nafmii/activity/HomeActivity.java → app/src/main/java/com/whaty/nafmii/activity/HomeActivity.java
app/src/main/java/com/polysoft/nafmii/activity/InputUrlActivity.java → app/src/main/java/com/whaty/nafmii/activity/InputUrlActivity.java
app/src/main/java/com/polysoft/nafmii/activity/MainActivity.java → app/src/main/java/com/whaty/nafmii/activity/MainActivity.java
app/src/main/java/com/polysoft/nafmii/activity/WebviewActivity.java → app/src/main/java/com/whaty/nafmii/activity/WebviewActivity.java
app/src/main/java/com/polysoft/nafmii/activity/home/ModuleUrlHandle.java → app/src/main/java/com/whaty/nafmii/activity/home/ModuleUrlHandle.java
app/src/main/java/com/polysoft/nafmii/activity/home/ModulesFragmentMgr.java → app/src/main/java/com/whaty/nafmii/activity/home/ModulesFragmentMgr.java
app/src/main/java/com/whaty/nafmii/wxapi/WXEntryActivity.java
app/src/main/java/com/whaty/nafmii/wxapi/WXPayEntryActivity.java
app/src/main/res/values/strings.xml
app/src/main/res/xml/provider_paths.xml
app/src/test/java/com/polysoft/nafmii/ExampleUnitTest.java
app/build.gradle
View file @
0e11213
...
...
@@ -7,7 +7,7 @@ android {
buildToolsVersion
"30.0.3"
defaultConfig
{
applicationId
"com.
polysoft
.nafmii"
applicationId
"com.
whaty
.nafmii"
minSdkVersion
24
targetSdkVersion
29
versionCode
1
...
...
@@ -17,7 +17,6 @@ android {
buildConfigField
"String"
,
"API_HOST"
,
"\"http://new.ynyc6666.com/shop/server/\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"1234567890\""
buildConfigField
"boolean"
,
"SHOW_INPUT"
,
"true"
ndk
{
abiFilters
"armeabi"
,
"armeabi-v7a"
,
"x86"
,
"mips"
}
...
...
@@ -39,7 +38,7 @@ android {
resValue
"string"
,
"app_name"
,
"Nafmii-beta"
applicationIdSuffix
"beta"
}
de
v
{
de
bug
{
minifyEnabled
false
resValue
"string"
,
"app_name"
,
"Nafmii-dev"
applicationIdSuffix
"dev"
...
...
@@ -49,6 +48,14 @@ android {
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
}
signingConfigs
{
debug
{
storeFile
file
(
'D:\\studio-workspace\\nafmii\\nafmii.keystore'
)
storePassword
'whaty123'
keyPassword
'whaty123'
keyAlias
'whaty'
}
}
ndkVersion
'20.0.5594570'
}
...
...
app/src/androidTest/java/com/polysoft/nafmii/ExampleInstrumentedTest.java
deleted
100644 → 0
View file @
1241142
package
com
.
polysoft
.
nafmii
;
import
android.content.Context
;
import
androidx.test.platform.app.InstrumentationRegistry
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
org
.
junit
.
Assert
.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith
(
AndroidJUnit4
.
class
)
public
class
ExampleInstrumentedTest
{
@Test
public
void
useAppContext
()
{
// Context of the app under test.
Context
appContext
=
InstrumentationRegistry
.
getInstrumentation
().
getTargetContext
();
assertEquals
(
"com.polysoft.nafmill"
,
appContext
.
getPackageName
());
}
}
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
0e11213
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.
polysoft
.nafmii"
>
package=
"com.
whaty
.nafmii"
>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.USE_FINGERPRINT"
/>
...
...
@@ -54,6 +54,16 @@
android:name=
"com.tencent.smtt.export.external.DexClassLoaderProviderService"
android:label=
"dexopt"
android:process=
":dexopt"
/>
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"${applicationId}.fileprovider"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/provider_paths"
/>
</provider>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/polysoft/nafmii/constants/Constants.java
View file @
0e11213
...
...
@@ -3,7 +3,7 @@ package com.polysoft.nafmii.constants;
public
class
Constants
{
public
static
final
String
MODULE_URL_HOME
=
"file:///android_asset/dist/index.html#/"
;
public
static
final
String
MODULE_URL_MY
=
""
;
public
static
final
String
MODULE_URL_MY
=
"
file:///android_asset/dist/index.html#/user/center
"
;
public
static
final
String
MODULE_URL_MEMBER
=
""
;
public
static
final
String
MODULE_URL_LEARN
=
"http://debugtbs.qq.com"
;
...
...
app/src/main/java/com/polysoft/nafmii/constants/ServerApi.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
constants
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.enums.StateEnum
;
import
com.polysoft.nafmii.net.OkhttpApi
;
import
com.polysoft.nafmii.net.RequestBack
;
import
com.whaty.nafmii.BuildConfig
;
import
java.util.Map
;
...
...
app/src/main/java/com/polysoft/nafmii/fragment/AdvertisementFragment.java
View file @
0e11213
...
...
@@ -19,11 +19,11 @@ import com.alibaba.fastjson.JSONObject;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.target.DrawableImageViewTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.activity.HomeActivity
;
import
com.polysoft.nafmii.activity.InputUrlActivity
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.whaty.nafmii.BuildConfig
;
import
com.whaty.nafmii.R
;
import
com.whaty.nafmii.activity.HomeActivity
;
import
com.whaty.nafmii.activity.InputUrlActivity
;
public
class
AdvertisementFragment
extends
Fragment
implements
View
.
OnClickListener
{
...
...
app/src/main/java/com/polysoft/nafmii/fragment/FingerprintDialogFragment.java
View file @
0e11213
...
...
@@ -15,7 +15,7 @@ import android.widget.Toast;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.DialogFragment
;
import
com.
polysoft
.nafmii.R
;
import
com.
whaty
.nafmii.R
;
import
javax.crypto.Cipher
;
...
...
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
fragment
;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
...
...
@@ -11,13 +14,22 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.broadcast.PhotosReceiver
;
import
com.polysoft.nafmii.utils.BitmapUtils
;
import
com.polysoft.nafmii.utils.FileProviderUtils
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.PermissionUtils
;
import
com.polysoft.nafmii.utils.ToastUtils
;
import
com.polysoft.nafmii.webview.IWebview
;
import
com.polysoft.nafmii.webview.MyWebChromeClient
;
import
com.polysoft.nafmii.webview.MyWebViewClient
;
import
com.polysoft.nafmii.webview.WebviewHandler
;
import
com.polysoft.nafmii.webview.WebviewLoadListener
;
import
com.polysoft.nafmii.webview.X5WebviewUtils
;
import
com.tencent.smtt.sdk.WebView
;
import
com.whaty.nafmii.R
;
import
java.io.File
;
public
class
WebViewFragment
extends
Fragment
implements
WebviewLoadListener
{
...
...
@@ -27,6 +39,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
private
WebView
webView
;
private
WebviewHandler
webviewHandler
;
private
ValueCallback
<
Uri
[]>
filePathCallback
;
public
static
WebViewFragment
newInstances
(
String
url
)
{
WebViewFragment
fragment
=
new
WebViewFragment
();
...
...
@@ -56,6 +69,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
private
void
initWebview
()
{
WebView
webView
=
X5WebviewUtils
.
create
(
getActivity
());
webView
.
setWebChromeClient
(
new
MyWebChromeClient
(
this
));
webView
.
setWebViewClient
(
new
MyWebViewClient
(
this
));
this
.
webviewHandler
=
new
WebviewHandler
(
this
,
webView
);
...
...
@@ -91,6 +105,64 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
@Override
public
void
onShowFileChooser
(
ValueCallback
<
Uri
[]>
filePathCallback
,
String
[]
acceptTypes
,
boolean
isCapture
)
{
String
[]
permissions
=
new
String
[]{
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
if
(
PermissionUtils
.
checkAndRequestMorePermissions
(
getContext
(),
permissions
))
{
Intent
intent
=
IntentUtils
.
chooserIntent
(
super
.
getContext
());
if
(
null
!=
intent
)
{
this
.
filePathCallback
=
filePathCallback
;
super
.
startActivityForResult
(
intent
,
IntentUtils
.
ACTIVITY_CODE_CHOOSERFILE
);
}
else
{
filePathCallback
.
onReceiveValue
(
null
);
}
}
else
{
filePathCallback
.
onReceiveValue
(
null
);
}
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
@org
.
jetbrains
.
annotations
.
Nullable
Intent
data
)
{
if
(
IntentUtils
.
ACTIVITY_CODE_CHOOSERFILE
==
requestCode
)
{
if
(
Activity
.
RESULT_OK
!=
resultCode
)
{
ToastUtils
.
showLong
(
"操作失败!"
);
this
.
filePathCallback
.
onReceiveValue
(
null
);
}
else
if
(
null
!=
this
.
filePathCallback
)
{
if
(
null
!=
data
&&
null
!=
data
.
getData
())
{
Uri
imgUrl
=
data
.
getData
();
String
newFilepath
=
IntentUtils
.
getTakePhotoPath
(
super
.
getContext
());
String
filepath
=
FileProviderUtils
.
getUriPath
(
super
.
getContext
(),
imgUrl
);
File
file
=
BitmapUtils
.
compressBitmap
(
filepath
,
newFilepath
);
Uri
uri
=
FileProviderUtils
.
getUriForFile
(
super
.
getContext
(),
file
);
this
.
filePathCallback
.
onReceiveValue
(
new
Uri
[]{
uri
});
}
else
{
String
filepath
=
IntentUtils
.
getTakePhotoPath
(
super
.
getContext
());
File
file
=
BitmapUtils
.
compressBitmap
(
filepath
);
if
(
file
.
exists
())
{
Uri
uri
=
FileProviderUtils
.
getUriForFile
(
super
.
getContext
(),
file
);
this
.
filePathCallback
.
onReceiveValue
(
new
Uri
[]{
uri
});
}
else
{
this
.
filePathCallback
.
onReceiveValue
(
null
);
}
}
}
this
.
filePathCallback
=
null
;
}
else
if
(
IntentUtils
.
ACTIVITY_CODE_CAMERA
==
requestCode
||
IntentUtils
.
ACTIVITY_CODE_ALBUM
==
requestCode
)
{
if
(
Activity
.
RESULT_OK
==
resultCode
)
{
if
(
IntentUtils
.
ACTIVITY_CODE_CAMERA
==
requestCode
)
{
String
filepath
=
IntentUtils
.
getTakePhotoPath
(
super
.
getContext
());
File
file
=
BitmapUtils
.
compressBitmap
(
filepath
);
PhotosReceiver
.
sendBroadcastCamera
(
super
.
getContext
(),
file
.
getAbsolutePath
());
}
else
if
(
null
!=
data
&&
null
!=
data
.
getData
()){
Uri
imgUrl
=
data
.
getData
();
String
newFilepath
=
IntentUtils
.
getTakePhotoPath
(
super
.
getContext
());
String
filepath
=
FileProviderUtils
.
getUriPath
(
super
.
getContext
(),
imgUrl
);
File
file
=
BitmapUtils
.
compressBitmap
(
filepath
,
newFilepath
);
PhotosReceiver
.
sendBroadcastAlbum
(
super
.
getContext
(),
file
.
getAbsolutePath
());
}
}
else
{
ToastUtils
.
showLong
(
"操作失败!"
);
}
}
}
}
\ No newline at end of file
app/src/main/java/com/polysoft/nafmii/utils/BitmapUtils.java
0 → 100644
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
utils
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.net.Uri
;
import
android.util.Base64
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* Bitmap 工具类
*
* <p>
* 压缩算法来自luban压缩开源工具
* </p>
*
* @author zhiyuan
* @date 2018/4/17
* @see <a href="https://github.com/Curzibn/Luban">luban github文档</a>
*/
public
class
BitmapUtils
{
private
static
final
String
TAG
=
"BitmapUtils"
;
public
static
String
bitmap2base64
(
String
filepath
)
{
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
filepath
);
ByteArrayOutputStream
baos
=
null
;
try
{
baos
=
new
ByteArrayOutputStream
();
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
95
,
baos
);
return
Base64
.
encodeToString
(
baos
.
toByteArray
(),
Base64
.
NO_WRAP
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
null
!=
baos
)
{
try
{
baos
.
close
();
}
catch
(
IOException
ioException
)
{
ioException
.
printStackTrace
();
}
}
if
(
null
!=
bitmap
)
{
bitmap
.
recycle
();
}
}
return
""
;
}
/**
* 比例压缩,具体算法来自luban压缩工具
*
* @param filepath 图片路径
* @return 压缩后的文件
*/
public
static
File
compressBitmap
(
String
filepath
)
{
File
file
=
new
File
(
filepath
);
String
newName
=
"temp_"
+
file
.
getName
();
String
newPath
=
new
File
(
file
.
getParent
(),
newName
).
getAbsolutePath
();
return
compressBitmap
(
filepath
,
newPath
,
95
);
}
public
static
File
compressBitmap
(
String
filepath
,
String
newPath
)
{
return
compressBitmap
(
filepath
,
newPath
,
95
);
}
/**
* 比例压缩,具体算法来自luban压缩工具
*
* @param filepath 图片路径
* @param quality 压缩质量
* @return 压缩后的文件
*/
public
static
File
compressBitmap
(
String
filepath
,
String
newPath
,
int
quality
)
{
File
file
=
new
File
(
filepath
);
if
(!
file
.
exists
())
{
return
file
;
}
File
newFile
=
new
File
(
newPath
);
newFile
.
getParentFile
().
mkdirs
();
if
(
newFile
.
exists
())
{
newFile
.
delete
();
}
int
sampleSize
=
getSampleSize
(
file
.
getAbsolutePath
());
compress
(
file
.
getAbsolutePath
(),
newFile
.
getAbsolutePath
(),
sampleSize
,
quality
);
return
newFile
;
}
/**
* 获取压缩比例,具体算法来自luban压缩工具
*
* @return bitmap压缩比例
*/
public
static
int
getSampleSize
(
String
filePath
)
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
options
.
inJustDecodeBounds
=
true
;
options
.
inSampleSize
=
1
;
BitmapFactory
.
decodeFile
(
filePath
,
options
);
int
srcWidth
=
options
.
outWidth
;
int
srcHeight
=
options
.
outHeight
;
srcWidth
=
srcWidth
%
2
==
1
?
srcWidth
+
1
:
srcWidth
;
srcHeight
=
srcHeight
%
2
==
1
?
srcHeight
+
1
:
srcHeight
;
int
longSide
=
Math
.
max
(
srcWidth
,
srcHeight
);
int
shortSide
=
Math
.
min
(
srcWidth
,
srcHeight
);
float
scale
=
((
float
)
shortSide
/
longSide
);
if
(
scale
<=
1
&&
scale
>
0.5625
)
{
if
(
longSide
<
1664
)
{
return
1
;
}
else
if
(
longSide
>=
1664
&&
longSide
<
4990
)
{
return
2
;
}
else
if
(
longSide
>
4990
&&
longSide
<
10240
)
{
return
4
;
}
else
{
return
longSide
/
1280
==
0
?
1
:
longSide
/
1280
;
}
}
else
if
(
scale
<=
0.5625
&&
scale
>
0.5
)
{
return
longSide
/
1280
==
0
?
1
:
longSide
/
1280
;
}
else
{
return
(
int
)
Math
.
ceil
(
longSide
/
(
1280.0
/
scale
));
}
}
/**
* 压缩图片,使用luban算法
*
* @param filePath 图片文件地址
*/
public
static
void
compress
(
String
filePath
,
String
cacheFilePath
)
{
compress
(
filePath
,
cacheFilePath
,
getSampleSize
(
filePath
),
60
);
}
/**
* 压缩图片
*
* @param filePath 图片路径
* @param cacheFilePath 缓存图片路径
* @param sampleSize 压缩比
* @param quality 质量
*/
public
static
void
compress
(
String
filePath
,
String
cacheFilePath
,
int
sampleSize
,
int
quality
)
{
//获取bitmap数据
BitmapFactory
.
Options
bitmapOptions
=
new
BitmapFactory
.
Options
();
bitmapOptions
.
inPreferredConfig
=
Bitmap
.
Config
.
RGB_565
;
bitmapOptions
.
inJustDecodeBounds
=
false
;
bitmapOptions
.
inSampleSize
=
sampleSize
;
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
filePath
,
bitmapOptions
);
if
(
bitmap
!=
null
)
{
writeToFile
(
bitmap
,
cacheFilePath
,
Bitmap
.
CompressFormat
.
JPEG
,
quality
);
bitmap
.
recycle
();
}
}
/**
* Bitmap 写入文件
*
* @param bitmap bitmap
* @param cacheFilePath 文件地址
*/
public
static
void
writeToFile
(
Bitmap
bitmap
,
String
cacheFilePath
,
Bitmap
.
CompressFormat
compressFormat
,
int
quality
)
{
if
(
bitmap
==
null
)
{
LogUtil
.
e
(
TAG
,
"尝试将空文件写入本地:bitmap "
+
bitmap
+
" cacheFilePath: "
+
cacheFilePath
+
" compressFormat:"
+
compressFormat
);
return
;
}
//写入原始文件
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
bitmap
.
compress
(
compressFormat
,
quality
,
bos
);
File
dir
=
new
File
(
cacheFilePath
);
File
parent
=
dir
.
getParentFile
();
LogUtil
.
i
(
TAG
,
"尝试将图片写入文件:"
+
dir
);
if
(!
parent
.
exists
())
{
boolean
succeed
=
parent
.
mkdirs
();
LogUtil
.
i
(
TAG
,
"文件上级目录不存在,准备创建成功:"
+
succeed
);
}
FileOutputStream
fos
=
null
;
try
{
fos
=
new
FileOutputStream
(
cacheFilePath
);
fos
.
write
(
bos
.
toByteArray
());
fos
.
flush
();
bos
.
flush
();
fos
.
close
();
bos
.
close
();
LogUtil
.
i
(
TAG
,
"文件写入成功!"
);
}
catch
(
Exception
e
)
{
LogUtil
.
e
(
TAG
,
"文件写入失败!"
+
e
.
getMessage
());
e
.
printStackTrace
();
}
finally
{
if
(
fos
!=
null
)
{
try
{
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
/**
* 压缩图片,使用谷歌压缩算法
*
* @param imagePath 需要压缩的图片路径
* @param cacheFilePath 缓存图片路径
*/
public
static
void
zipImage
(
String
imagePath
,
String
cacheFilePath
)
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
options
.
inJustDecodeBounds
=
true
;
BitmapFactory
.
decodeFile
(
imagePath
,
options
);
options
.
inSampleSize
=
computeInitialSampleSize
(
options
,
480
,
480
*
960
);
options
.
inJustDecodeBounds
=
false
;
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
imagePath
,
options
);
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
cacheFilePath
);
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
90
,
fos
);
fos
.
flush
();
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
bitmap
.
recycle
();
bitmap
=
null
;
System
.
gc
();
}
private
static
int
computeInitialSampleSize
(
BitmapFactory
.
Options
options
,
int
minSideLength
,
int
maxNumOfPixels
)
{
double
w
=
options
.
outWidth
;
double
h
=
options
.
outHeight
;
int
lowerBound
=
(
maxNumOfPixels
==
-
1
)
?
1
:
(
int
)
Math
.
ceil
(
Math
.
sqrt
(
w
*
h
/
maxNumOfPixels
));
int
upperBound
=
(
minSideLength
==
-
1
)
?
128
:
(
int
)
Math
.
min
(
Math
.
floor
(
w
/
minSideLength
),
Math
.
floor
(
h
/
minSideLength
));
if
(
upperBound
<
lowerBound
)
{
// return the larger one when there is no overlapping zone.
return
lowerBound
;
}
if
((
maxNumOfPixels
==
-
1
)
&&
(
minSideLength
==
-
1
))
{
return
1
;
}
else
if
(
minSideLength
==
-
1
)
{
return
lowerBound
;
}
else
{
return
upperBound
;
}
}
public
static
Bitmap
loadBitmap
(
String
pathName
,
float
ww
,
float
hh
)
{
Bitmap
b
=
null
;
try
{
BitmapFactory
.
Options
opts
=
new
BitmapFactory
.
Options
();
opts
.
inJustDecodeBounds
=
true
;
b
=
BitmapFactory
.
decodeFile
(
pathName
,
opts
);
int
originalWidth
=
opts
.
outWidth
;
int
originalHeight
=
opts
.
outHeight
;
// float hh = 1280f;// 这里设置高度为800f
// float ww = 720f;// 这里设置宽度为480f
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int
be
=
1
;
// be=1表示不缩放
if
(
originalWidth
>
originalHeight
&&
originalWidth
>
ww
)
{
// 如果宽度大的话根据宽度固定大小缩放
be
=
(
int
)
(
originalWidth
/
ww
);
}
else
if
(
originalWidth
<
originalHeight
&&
originalHeight
>
hh
)
{
// 如果高度高的话根据宽度固定大小缩放
be
=
(
int
)
(
originalHeight
/
hh
);
}
if
(
be
<=
0
)
be
=
1
;
LogUtil
.
d
(
"decodeFile"
,
"originalWidth:"
+
originalWidth
+
",originalHeight:"
+
originalHeight
+
",be:"
+
be
);
BitmapFactory
.
Options
optso
=
new
BitmapFactory
.
Options
();
optso
.
inJustDecodeBounds
=
false
;
optso
.
inPreferredConfig
=
Bitmap
.
Config
.
RGB_565
;
optso
.
inSampleSize
=
be
;
b
=
BitmapFactory
.
decodeFile
(
pathName
,
optso
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
LogUtil
.
e
(
TAG
,
"sdCardToByte: loadbitmap11"
+
e
.
getMessage
());
b
=
null
;
}
catch
(
OutOfMemoryError
e
)
{
e
.
printStackTrace
();
LogUtil
.
e
(
TAG
,
"sdCardToByte: loadbitmap22"
+
e
.
getMessage
());
b
=
null
;
}
return
b
;
}
public
static
void
saveBitmap
(
String
copyfilename
,
Bitmap
bm
)
{
LogUtil
.
e
(
"saveBitmap"
,
"保存图片"
);
File
f
=
new
File
(
copyfilename
);
if
(
f
.
exists
())
{
f
.
delete
();
}
try
{
FileOutputStream
out
=
new
FileOutputStream
(
f
);
bm
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
70
,
out
);
out
.
flush
();
out
.
close
();
LogUtil
.
i
(
"saveBitmap"
,
"已经保存"
);
}
catch
(
FileNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
public
static
byte
[]
sdCardToByte
(
Context
context
,
Uri
uri
,
int
ww
,
int
hh
)
{
Bitmap
bitmap
=
decodeUri
(
context
,
uri
,
ww
,
hh
);
if
(
bitmap
==
null
)
return
null
;
LogUtil
.
e
(
TAG
,
"sdCardToByte: bitmap"
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
baos
);
byte
[]
byteArray
=
baos
.
toByteArray
();
return
byteArray
;
}
public
static
Bitmap
newLoadBitmap
(
Context
context
,
String
pathName
,
float
ww
,
float
hh
)
{
Bitmap
b
=
null
;
try
{
BitmapFactory
.
Options
opts
=
new
BitmapFactory
.
Options
();
opts
.
inJustDecodeBounds
=
true
;
File
picture
=
new
File
(
pathName
);
Uri
filepath
=
FileProviderUtils
.
getUriForFile
(
context
,
picture
);
b
=
BitmapFactory
.
decodeFile
(
filepath
.
getPath
(),
opts
);
int
originalWidth
=
opts
.
outWidth
;
int
originalHeight
=
opts
.
outHeight
;
int
be
=
1
;
// be=1表示不缩放
if
(
originalWidth
>
originalHeight
&&
originalWidth
>
ww
)
{
// 如果宽度大的话根据宽度固定大小缩放
be
=
(
int
)
(
originalWidth
/
ww
);
}
else
if
(
originalWidth
<
originalHeight
&&
originalHeight
>
hh
)
{
// 如果高度高的话根据宽度固定大小缩放
be
=
(
int
)
(
originalHeight
/
hh
);
}
if
(
be
<=
0
)
be
=
1
;
LogUtil
.
d
(
"decodeFile"
,
"originalWidth:"
+
originalWidth
+
",originalHeight:"
+
originalHeight
+
",be:"
+
be
);
BitmapFactory
.
Options
optso
=
new
BitmapFactory
.
Options
();
optso
.
inJustDecodeBounds
=
false
;
optso
.
inPreferredConfig
=
Bitmap
.
Config
.
RGB_565
;
optso
.
inSampleSize
=
be
;
b
=
BitmapFactory
.
decodeFile
(
filepath
.
getPath
(),
optso
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
LogUtil
.
e
(
TAG
,
"sdCardToByte: loadbitmap11"
+
e
.
getMessage
());
b
=
null
;
}
catch
(
OutOfMemoryError
e
)
{
e
.
printStackTrace
();
LogUtil
.
e
(
TAG
,
"sdCardToByte: loadbitmap22"
+
e
.
getMessage
());
b
=
null
;
}
return
b
;
}
/**
* 读取一个缩放后的图片,限定图片大小,避免OOM
* http://blog.sina.com.cn/s/blog_5de73d0b0100zfm8.html
*
* @param uri 图片uri,支持“file://”、“content://”
* @param maxWidth 最大允许宽度
* @param maxHeight 最大允许高度
* @return 返回一个缩放后的Bitmap,失败则返回null
*/
public
static
Bitmap
decodeUri
(
Context
context
,
Uri
uri
,
int
maxWidth
,
int
maxHeight
)
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
options
.
inJustDecodeBounds
=
true
;
//只读取图片尺寸
resolveUri
(
context
,
uri
,
options
);
//计算实际缩放比例
int
scale
=
1
;
for
(
int
i
=
0
;
i
<
Integer
.
MAX_VALUE
;
i
++)
{
if
((
options
.
outWidth
/
scale
>
maxWidth
&&
options
.
outWidth
/
scale
>
maxWidth
*
1.4
)
||
(
options
.
outHeight
/
scale
>
maxHeight
&&
options
.
outHeight
/
scale
>
maxHeight
*
1.4
))
{
scale
++;
}
else
{
break
;
}
}
options
.
inSampleSize
=
scale
;
options
.
inJustDecodeBounds
=
false
;
//读取图片内容
options
.
inPreferredConfig
=
Bitmap
.
Config
.
RGB_565
;
//根据情况进行修改
Bitmap
bitmap
=
null
;
try
{
bitmap
=
resolveUriForBitmap
(
context
,
uri
,
options
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
return
bitmap
;
}
// http://blog.sina.com.cn/s/blog_5de73d0b0100zfm8.html
private
static
void
resolveUri
(
Context
context
,
Uri
uri
,
BitmapFactory
.
Options
options
)
{
if
(
uri
==
null
)
{
return
;
}
String
scheme
=
uri
.
getScheme
();
if
(
ContentResolver
.
SCHEME_CONTENT
.
equals
(
scheme
)
||
ContentResolver
.
SCHEME_FILE
.
equals
(
scheme
))
{
InputStream
stream
=
null
;
try
{
stream
=
context
.
getContentResolver
().
openInputStream
(
uri
);
BitmapFactory
.
decodeStream
(
stream
,
null
,
options
);
}
catch
(
Exception
e
)
{
LogUtil
.
w
(
"resolveUri"
,
"Unable to open content: "
+
uri
,
e
);
}
finally
{
if
(
stream
!=
null
)
{
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
LogUtil
.
w
(
"resolveUri"
,
"Unable to close content: "
+
uri
,
e
);
}
}
}
}
else
if
(
ContentResolver
.
SCHEME_ANDROID_RESOURCE
.
equals
(
scheme
))
{
LogUtil
.
w
(
"resolveUri"
,
"Unable to close content: "
+
uri
);
}
else
{
LogUtil
.
w
(
"resolveUri"
,
"Unable to close content: "
+
uri
);
}
}
// http://blog.sina.com.cn/s/blog_5de73d0b0100zfm8.html
private
static
Bitmap
resolveUriForBitmap
(
Context
context
,
Uri
uri
,
BitmapFactory
.
Options
options
)
{
if
(
uri
==
null
)
{
return
null
;
}
Bitmap
bitmap
=
null
;
String
scheme
=
uri
.
getScheme
();
if
(
ContentResolver
.
SCHEME_CONTENT
.
equals
(
scheme
)
||
ContentResolver
.
SCHEME_FILE
.
equals
(
scheme
))
{
InputStream
stream
=
null
;
try
{
stream
=
context
.
getContentResolver
().
openInputStream
(
uri
);
bitmap
=
BitmapFactory
.
decodeStream
(
stream
,
null
,
options
);
}
catch
(
Exception
e
)
{
LogUtil
.
w
(
"resolveUriForBitmap"
,
"Unable to open content: "
+
uri
,
e
);
}
finally
{
if
(
stream
!=
null
)
{
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
LogUtil
.
w
(
"resolveUriForBitmap"
,
"Unable to close content: "
+
uri
,
e
);
}
}
}
}
else
if
(
ContentResolver
.
SCHEME_ANDROID_RESOURCE
.
equals
(
scheme
))
{
LogUtil
.
w
(
"resolveUriForBitmap"
,
"Unable to close content: "
+
uri
);
}
else
{
LogUtil
.
w
(
"resolveUriForBitmap"
,
"Unable to close content: "
+
uri
);
}
return
bitmap
;
}
}
app/src/main/java/com/polysoft/nafmii/utils/LogUtil.java
0 → 100644
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
utils
;
import
android.util.Log
;
/**
* create: 2020/6/9
* author: zw
* do:打印工具类F
*/
public
class
LogUtil
{
public
static
int
logGrade
=
6
;
public
static
void
e
(
String
TAG
,
String
Message
)
{
if
(
logGrade
<=
5
)
{
Log
.
e
(
TAG
,
Message
);
}
}
public
static
void
e
(
String
TAG
,
String
Message
,
Throwable
thr
)
{
if
(
logGrade
<=
5
)
{
Log
.
e
(
TAG
,
Message
,
thr
);
}
}
public
static
void
w
(
String
TAG
,
String
Message
)
{
if
(
logGrade
<=
4
)
{
Log
.
w
(
TAG
,
Message
);
}
}
public
static
void
w
(
String
TAG
,
String
Message
,
Throwable
thr
)
{
if
(
logGrade
<=
4
)
{
Log
.
w
(
TAG
,
Message
,
thr
);
}
}
public
static
void
i
(
String
TAG
,
String
Message
)
{
if
(
logGrade
<=
3
)
{
Log
.
i
(
TAG
,
Message
);
}
}
public
static
void
i
(
String
TAG
,
String
Message
,
Throwable
thr
)
{
if
(
logGrade
<=
3
)
{
Log
.
i
(
TAG
,
Message
,
thr
);
}
}
public
static
void
d
(
String
TAG
,
String
Message
)
{
if
(
logGrade
<=
2
)
{
Log
.
d
(
TAG
,
Message
);
}
}
public
static
void
d
(
String
TAG
,
String
Message
,
Throwable
thr
)
{
if
(
logGrade
<=
2
)
{
Log
.
d
(
TAG
,
Message
,
thr
);
}
}
}
app/src/main/java/com/polysoft/nafmii/utils/StatusBarUtils.java
View file @
0e11213
...
...
@@ -14,8 +14,6 @@ import android.widget.FrameLayout;
import
androidx.annotation.IntDef
;
import
com.polysoft.nafmii.R
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.reflect.Field
;
...
...
app/src/main/java/com/polysoft/nafmii/webview/MyWebChromeClient.java
0 → 100644
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
webview
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
com.tencent.smtt.export.external.interfaces.ConsoleMessage
;
import
com.tencent.smtt.export.external.interfaces.JsResult
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebView
;
public
class
MyWebChromeClient
extends
WebChromeClient
{
private
final
WebviewLoadListener
listener
;
public
MyWebChromeClient
(
WebviewLoadListener
listener
)
{
this
.
listener
=
listener
;
}
@Override
public
boolean
onJsAlert
(
WebView
view
,
String
url
,
String
message
,
JsResult
result
)
{
return
super
.
onJsAlert
(
view
,
url
,
message
,
result
);
}
@Override
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
if
(
null
!=
this
.
listener
)
{
this
.
listener
.
onWebviewLoad
(
WebviewLoadListener
.
TYPE_PROGRESS
,
newProgress
);
}
super
.
onProgressChanged
(
view
,
newProgress
);
}
/**
* 16(Android 4.1.2) <= API <= 20(Android 4.4W.2)回调此方法
*/
public
void
openFileChooser
(
final
ValueCallback
<
Uri
>
uploadMsg
,
String
acceptType
,
String
capture
)
{
if
(
null
==
this
.
listener
)
{
return
;
}
this
.
listener
.
onShowFileChooser
((
ValueCallback
<
Uri
[]>)
value
->
{
for
(
Uri
uri
:
value
)
{
uploadMsg
.
onReceiveValue
(
uri
);
}
},
new
String
[]{
acceptType
},
TextUtils
.
isEmpty
(
capture
));
}
@Override
public
boolean
onShowFileChooser
(
WebView
webView
,
ValueCallback
<
Uri
[]>
filePathCallback
,
FileChooserParams
fileChooserParams
)
{
if
(
null
==
this
.
listener
)
{
return
super
.
onShowFileChooser
(
webView
,
filePathCallback
,
fileChooserParams
);
}
String
[]
acceptTypes
=
fileChooserParams
.
getAcceptTypes
();
boolean
captureEnabled
=
fileChooserParams
.
isCaptureEnabled
();
this
.
listener
.
onShowFileChooser
(
filePathCallback
,
acceptTypes
,
captureEnabled
);
return
true
;
}
@Override
public
void
onCloseWindow
(
WebView
window
)
{
super
.
onCloseWindow
(
window
);
}
@Override
public
boolean
onConsoleMessage
(
ConsoleMessage
consoleMessage
)
{
return
super
.
onConsoleMessage
(
consoleMessage
);
}
}
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
View file @
0e11213
...
...
@@ -4,9 +4,9 @@ import android.text.TextUtils;
import
androidx.fragment.app.Fragment
;
import
com.polysoft.nafmii.activity.HomeActivity
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.tencent.smtt.sdk.WebView
;
import
com.whaty.nafmii.activity.HomeActivity
;
public
class
WebviewHandler
implements
IWebview
{
...
...
app/src/main/java/com/polysoft/nafmii/webview/X5WebviewUtils.java
View file @
0e11213
...
...
@@ -6,11 +6,11 @@ import android.os.Build;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.tencent.smtt.export.external.extension.interfaces.IX5WebSettingsExtension
;
import
com.tencent.smtt.export.external.extension.interfaces.IX5WebViewExtension
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebView
;
import
com.whaty.nafmii.BuildConfig
;
public
class
X5WebviewUtils
{
...
...
app/src/main/java/com/polysoft/nafmii/wechat/WechatApi.java
View file @
0e11213
...
...
@@ -12,8 +12,6 @@ import com.alibaba.fastjson.JSON;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.target.SimpleTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.R
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelmsg.SendMessageToWX
;
import
com.tencent.mm.opensdk.modelmsg.WXMediaMessage
;
...
...
@@ -22,6 +20,8 @@ import com.tencent.mm.opensdk.modelpay.PayReq;
import
com.tencent.mm.opensdk.openapi.IWXAPI
;
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
;
import
com.tencent.mm.opensdk.openapi.WXAPIFactory
;
import
com.whaty.nafmii.BuildConfig
;
import
com.whaty.nafmii.R
;
public
class
WechatApi
{
...
...
app/src/main/java/com/
polysoft
/nafmii/MyApplication.java
→
app/src/main/java/com/
whaty
/nafmii/MyApplication.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
;
package
com
.
whaty
.
nafmii
;
import
android.app.Application
;
import
com.polysoft.nafmii.utils.CtxUtils
;
import
com.polysoft.nafmii.webview.X5Core
;
import
me.jessyan.autosize.AutoSizeConfig
;
import
ren.yale.android.cachewebviewlib.WebViewCacheInterceptor
;
...
...
@@ -20,7 +19,7 @@ public class MyApplication extends Application {
.
setDesignHeightInDp
(
896
);
WebViewCacheInterceptor
.
Builder
builder
=
new
WebViewCacheInterceptor
.
Builder
(
this
);
builder
.
setDebug
(
BuildConfig
.
DEBUG
);
//
builder.setDebug(BuildConfig.DEBUG);
WebViewCacheInterceptorInst
.
getInstance
().
init
(
builder
);
}
}
app/src/main/java/com/
polysoft
/nafmii/activity/BaseActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/BaseActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.os.Bundle
;
import
android.view.KeyEvent
;
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/GuideActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/GuideActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.os.Bundle
;
import
android.view.KeyEvent
;
...
...
@@ -11,10 +11,10 @@ import androidx.annotation.NonNull;
import
androidx.viewpager.widget.PagerAdapter
;
import
androidx.viewpager.widget.ViewPager
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
com.whaty.nafmii.BuildConfig
;
import
com.whaty.nafmii.R
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/HomeActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/HomeActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.annotation.SuppressLint
;
import
android.view.KeyEvent
;
...
...
@@ -7,10 +7,10 @@ import android.widget.RadioButton;
import
androidx.fragment.app.Fragment
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.activity.home.ModulesFragmentMgr
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.whaty.nafmii.R
;
import
com.whaty.nafmii.activity.home.ModulesFragmentMgr
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/InputUrlActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/InputUrlActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
import
androidx.appcompat.app.AppCompatActivity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.RadioButton
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
androidx.appcompat.app.AppCompatActivity
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
com.polysoft.nafmii.utils.ToastUtils
;
import
com.whaty.nafmii.R
;
public
class
InputUrlActivity
extends
AppCompatActivity
{
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/MainActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/MainActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.Manifest
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.util.Log
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentTransaction
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.constants.ServerApi
;
import
com.polysoft.nafmii.enums.StateEnum
;
import
com.polysoft.nafmii.fragment.AdvertisementFragment
;
import
com.polysoft.nafmii.fragment.FingerprintDialogFragment
;
import
com.polysoft.nafmii.net.RequestBack
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.PermissionUtils
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
com.polysoft.nafmii.utils.ToastUtils
;
import
com.polysoft.nafmii.webview.X5Core
;
import
com.whaty.nafmii.R
;
public
class
MainActivity
extends
BaseActivity
{
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/WebviewActivity.java
→
app/src/main/java/com/
whaty
/nafmii/activity/WebviewActivity.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
;
package
com
.
whaty
.
nafmii
.
activity
;
import
android.os.Bundle
;
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/home/ModuleUrlHandle.java
→
app/src/main/java/com/
whaty
/nafmii/activity/home/ModuleUrlHandle.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
.
home
;
package
com
.
whaty
.
nafmii
.
activity
.
home
;
import
android.app.Activity
;
import
android.content.Intent
;
...
...
app/src/main/java/com/
polysoft
/nafmii/activity/home/ModulesFragmentMgr.java
→
app/src/main/java/com/
whaty
/nafmii/activity/home/ModulesFragmentMgr.java
View file @
0e11213
package
com
.
polysoft
.
nafmii
.
activity
.
home
;
package
com
.
whaty
.
nafmii
.
activity
.
home
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentActivity
;
...
...
app/src/main/java/com/whaty/nafmii/wxapi/WXEntryActivity.java
0 → 100644
View file @
0e11213
package
com
.
whaty
.
nafmii
.
wxapi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
com.polysoft.nafmii.broadcast.ShareReceiver
;
import
com.polysoft.nafmii.wechat.ShareResult
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseResp
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
;
public
class
WXEntryActivity
extends
Activity
implements
IWXAPIEventHandler
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
getIntent
(),
this
);
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
setIntent
(
intent
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
intent
,
this
);
}
@Override
public
void
onReq
(
BaseReq
baseReq
)
{
}
@Override
public
void
onResp
(
BaseResp
resp
)
{
if
(
resp
instanceof
SendAuth
.
Resp
)
{
}
int
code
=
resp
.
errCode
;
if
(
code
==
BaseResp
.
ErrCode
.
ERR_OK
)
{
// 分享成功
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareSuccess
());
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareCancel
());
}
else
{
// 分享失败
String
errStr
=
resp
.
errStr
;
ShareReceiver
.
sendBroadcast
(
this
,
ShareResult
.
shareFail
(
errStr
));
}
super
.
finish
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
}
}
app/src/main/java/com/whaty/nafmii/wxapi/WXPayEntryActivity.java
0 → 100644
View file @
0e11213
package
com
.
whaty
.
nafmii
.
wxapi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
com.polysoft.nafmii.wechat.WechatApi
;
import
com.tencent.mm.opensdk.constants.ConstantsAPI
;
import
com.tencent.mm.opensdk.modelbase.BaseReq
;
import
com.tencent.mm.opensdk.modelbase.BaseResp
;
import
com.tencent.mm.opensdk.openapi.IWXAPI
;
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
;
public
class
WXPayEntryActivity
extends
Activity
implements
IWXAPIEventHandler
{
private
static
final
String
TAG
=
WXPayEntryActivity
.
class
.
getName
();
private
IWXAPI
api
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
getIntent
(),
this
);
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
setIntent
(
intent
);
WechatApi
.
getInstance
(
this
).
handleIntent
(
intent
,
this
);
}
@Override
public
void
onReq
(
BaseReq
req
)
{
}
@Override
public
void
onResp
(
BaseResp
resp
)
{
Log
.
d
(
TAG
,
"onPayFinish, errCode = "
+
resp
.
errCode
);
if
(
resp
.
getType
()
!=
ConstantsAPI
.
COMMAND_PAY_BY_WX
)
{
return
;
}
int
code
=
resp
.
errCode
;
if
(
code
==
BaseResp
.
ErrCode
.
ERR_OK
)
{
// 支付成功
// PayReceiver.sendBroadcast(this, PayResult.success(PayMode.WECHATPAY, null));
}
else
if
(
code
==
BaseResp
.
ErrCode
.
ERR_USER_CANCEL
)
{
// 用户取消
// PayReceiver.sendBroadcast(this, PayResult.cancel(PayMode.WECHATPAY));
}
else
{
// 支付失败
String
errStr
=
resp
.
errStr
;
// PayReceiver.sendBroadcast(this, PayResult.fail(PayMode.WECHATPAY, errStr));
}
super
.
finish
();
}
}
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
0e11213
<resources>
<string
name=
"app_name"
>
nafmii
</string>
<string
name=
"dummy_button"
>
Dummy Button
</string>
<string
name=
"dummy_content"
>
DUMMY\nCONTENT
</string>
<string
name=
"title_activity_base"
>
BaseActivity
</string>
...
...
app/src/main/res/xml/provider_paths.xml
0 → 100644
View file @
0e11213
<?xml version="1.0" encoding="utf-8"?>
<paths
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<external-path
name=
"external_files"
path=
"."
/>
<external-path
name=
"rc_external_path"
path=
"."
/>
<external-path
path=
"Android/data/com.example.fcmapp/"
name=
"files_root"
/>
<external-path
name=
"name"
path=
"."
/>
<external-path
name=
"external"
path=
"."
/>
<external-path
path=
"."
name=
"external_storage_root"
/>
</paths>
app/src/test/java/com/polysoft/nafmii/ExampleUnitTest.java
deleted
100644 → 0
View file @
1241142
package
com
.
polysoft
.
nafmii
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public
class
ExampleUnitTest
{
@Test
public
void
addition_isCorrect
()
{
assertEquals
(
4
,
2
+
2
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment