Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lify
RvApp
Commits
8fa9d751
Commit
8fa9d751
authored
Jul 01, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加版本升级功能,目前差一个提示界面
parent
e5ded45f
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
651 additions
and
26 deletions
+651
-26
AndroidManifest.xml
RvClient/src/main/AndroidManifest.xml
+3
-0
MainActivity.java
RvClient/src/main/java/com/test/rv/MainActivity.java
+63
-8
ApiConfig.java
...e_home/src/main/java/com/rv/home/rv/module/ApiConfig.java
+3
-1
build.gradle
module_mine/build.gradle
+1
-0
AndroidManifest.xml
module_mine/src/main/AndroidManifest.xml
+6
-0
SettingActivity.java
...src/main/java/com/rv/rvmine/traveler/SettingActivity.java
+70
-11
build.gradle
plugin_member/build.gradle
+2
-4
MemberPresenter.java
...rc/main/java/com/rv.member/presenter/MemberPresenter.java
+1
-1
.gitignore
plugin_version/.gitignore
+1
-0
build.gradle
plugin_version/build.gradle
+35
-0
proguard-rules.pro
plugin_version/proguard-rules.pro
+21
-0
AndroidManifest.xml
plugin_version/src/main/AndroidManifest.xml
+24
-0
VersionUpdateDialog.java
...ion/src/main/java/com/rv/version/VersionUpdateDialog.java
+92
-0
VersionCheckBean.java
...n/src/main/java/com/rv/version/bean/VersionCheckBean.java
+126
-0
UpdateAppReceiver.java
.../main/java/com/rv/version/receiver/UpdateAppReceiver.java
+135
-0
logo.png
plugin_version/src/main/res/drawable/logo.png
+0
-0
dialog_update_view.xml
plugin_version/src/main/res/layout/dialog_update_view.xml
+62
-0
strings.xml
plugin_version/src/main/res/values/strings.xml
+5
-0
settings.gradle
settings.gradle
+1
-1
No files found.
RvClient/src/main/AndroidManifest.xml
View file @
8fa9d751
...
...
@@ -28,6 +28,9 @@
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<!-- 用于读取手机当前的状态 -->
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<!-- 用于申请调用A-GPS模块 -->
<uses-permission
android:name=
"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
/>
<!-- 用于申请获取蓝牙信息进行室内定位 -->
<uses-permission
android:name=
"android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"
/>
<!-- 暂时不用 -->
<!-- <uses-permission android:name="android.permission.BLUETOOTH" /> -->
<!-- <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> -->
...
...
RvClient/src/main/java/com/test/rv/MainActivity.java
View file @
8fa9d751
...
...
@@ -2,13 +2,17 @@ package com.test.rv;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.v4.content.ContextCompat
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.ruiwenliu.wrapper.base.BaseActivity
;
import
com.ruiwenliu.wrapper.base.BaseBean
;
...
...
@@ -17,15 +21,21 @@ import com.ruiwenliu.wrapper.util.listener.SwitchFragment;
import
com.ruiwenliu.wrapper.weight.CustomScrollViewPager
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.rv.camp.CampFragment
;
import
com.rv.home.rv.module.ApiConfig
;
import
com.rv.home.rv.module.basic.presenter.CommonPresenter
;
import
com.rv.home.rv.module.ui.main.adapter.TabAdapter
;
import
com.rv.home.rv.module.ui.main.home.HomeFragment
;
import
com.rv.rvmine.MineFragment
;
import
com.rv.rvmine.traveler.SettingActivity
;
import
com.rv.tourism.R2
;
import
com.rv.tourism.TourismFragment
;
import
com.rv.version.bean.VersionCheckBean
;
import
com.rv.version.util.UpdateAppUtils
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
butterknife.BindView
;
import
butterknife.OnClick
;
...
...
@@ -33,7 +43,7 @@ import butterknife.OnClick;
public
class
MainActivity
extends
BaseActivity
<
CommonPresenter
>
{
// @BindView(R2.id.pager_view_fragment)
// @BindView(R2.id.pager_view_fragment)
CustomScrollViewPager
viewPager
;
@BindView
(
R2
.
id
.
iv_home
)
ImageView
ivHome
;
...
...
@@ -63,6 +73,8 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
private
final
int
TYPE_MINE
=
4
;
//我的
private
long
exitTime
=
0
;
private
UpdateAppUtils
updateAppUtils
;
public
static
Intent
getIntent
(
Context
context
)
{
return
new
Intent
(
context
,
MainActivity
.
class
);
}
...
...
@@ -74,6 +86,7 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
@Override
protected
void
initView
(
Bundle
savedInstanceState
,
TitleView
titleView
,
Intent
intent
)
{
updateAppUtils
=
UpdateAppUtils
.
from
(
MainActivity
.
this
);
viewPager
=
findViewById
(
R
.
id
.
pager_view_fragment
);
showTitle
(
false
);
mAdapter
=
new
TabAdapter
(
getSupportFragmentManager
(),
getListFragment
());
...
...
@@ -91,27 +104,45 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
@Override
protected
void
loadData
(
Bundle
savedInstanceState
,
Intent
intent
)
{
checkVersion
();
}
@Override
public
void
onShowResult
(
int
requestType
,
BaseBean
result
)
{
switch
(
requestType
)
{
case
0
:
VersionCheckBean
versionCheckBean
=
(
VersionCheckBean
)
result
;
if
(
versionCheckBean
!=
null
&&
versionCheckBean
.
isRel
()
==
false
)
{
if
(
versionCheckBean
!=
null
&&
!
TextUtils
.
isEmpty
(
versionCheckBean
.
getData
().
getDownloadUrl
()))
{
updateAppUtils
.
serverVersionCode
(
versionCheckBean
.
getData
().
getWeigh
())
.
serverVersionName
(
versionCheckBean
.
getData
().
getVersionName
())
.
apkPath
(
versionCheckBean
.
getData
().
getDownloadUrl
())
.
updateInfo
(
versionCheckBean
.
getData
().
getContent
())
.
apkSize
(
versionCheckBean
.
getData
().
getPackagesize
())
.
isForce
(
false
)
.
update
();
}
}
break
;
default
:
break
;
}
}
@OnClick
({
R2
.
id
.
rl_home
,
R2
.
id
.
rl_travel
,
R2
.
id
.
rl_camp
,
R2
.
id
.
rl_found
,
R2
.
id
.
rl_mine
})
public
void
onViewClicked
(
View
view
)
{
int
id
=
view
.
getId
();
if
(
id
==
R
.
id
.
rl_home
)
{
if
(
id
==
R
.
id
.
rl_home
)
{
setCurrent
(
TYPE_HOME_PAGE
);
}
else
if
(
id
==
R
.
id
.
rl_travel
)
{
}
else
if
(
id
==
R
.
id
.
rl_travel
)
{
setCurrent
(
TYPE_TRAVEL
);
}
else
if
(
id
==
R
.
id
.
rl_camp
)
{
}
else
if
(
id
==
R
.
id
.
rl_camp
)
{
setCurrent
(
TYPE_CAMP
);
}
else
if
(
id
==
R
.
id
.
rl_found
)
{
}
else
if
(
id
==
R
.
id
.
rl_found
)
{
// setCurrent(TYPE_FOUND);
}
else
if
(
id
==
R
.
id
.
rl_mine
)
{
}
else
if
(
id
==
R
.
id
.
rl_mine
)
{
setCurrent
(
TYPE_MINE
);
}
}
...
...
@@ -156,6 +187,19 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
switch
(
requestCode
)
{
case
1001
:
if
(
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
updateAppUtils
.
download
();
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"授权失败,无法下载最新App"
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
}
}
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
...
...
@@ -176,6 +220,17 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
}
}
/****
* 检测版本
*/
private
void
checkVersion
()
{
Map
<
String
,
Object
>
headMap
=
new
LinkedHashMap
<>();
String
versionName
=
updateAppUtils
.
getAppVersionName
(
this
);
if
(!
TextUtils
.
isEmpty
(
versionName
))
{
mPresenter
.
getData
(
0
,
String
.
format
(
ApiConfig
.
HTTP_URL_VERSION_CHECK
,
versionName
),
VersionCheckBean
.
class
,
headMap
,
true
);
}
}
/**
* 退出APP
*/
...
...
module_home/src/main/java/com/rv/home/rv/module/ApiConfig.java
View file @
8fa9d751
...
...
@@ -58,7 +58,9 @@ public class ApiConfig {
public
static
String
HTTP_URL_MEMBER_LIST
=
RvFrameConfig
.
ADMIN_POST
+
"/member/app/unauth/level/list"
;
// 会员等级列表
public
static
String
HTTP_URL_MEMBER_CREATE_ORDER
_
=
RvFrameConfig
.
HOST
+
"/api/order/orderMember/add"
;
// 创建订单
public
static
String
HTTP_URL_MEMBER_CREATE_ORDER
=
RvFrameConfig
.
HOST
+
"/api/order/orderMember/add"
;
// 创建订单
public
static
String
COMMIT_ORDER_PAY
=
RvFrameConfig
.
HOST
+
"/api/order/baseOrder/pay"
;
//订单支付
public
static
String
HTTP_URL_VERSION_CHECK
=
"/api/app/version/app/unauth/info?version=%s"
;
// 检测版本
}
module_mine/build.gradle
View file @
8fa9d751
...
...
@@ -43,4 +43,5 @@ dependencies {
annotationProcessor
'com.alibaba:arouter-compiler:1.1.4'
implementation
'top.zibin:Luban:1.1.3'
implementation
project
(
':plugin_member'
)
api
project
(
':plugin_version'
)
}
module_mine/src/main/AndroidManifest.xml
View file @
8fa9d751
...
...
@@ -2,4 +2,10 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.rv.rvmine"
>
<application>
<activity
android:name=
"com.rv.version.activity.UpdateAppActivity"
/>
</application>
</manifest>
\ No newline at end of file
module_mine/src/main/java/com/rv/rvmine/traveler/SettingActivity.java
View file @
8fa9d751
...
...
@@ -2,22 +2,29 @@ package com.rv.rvmine.traveler;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.Toast
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.alibaba.android.arouter.launcher.ARouter
;
import
com.frame.base.url.Constance
;
import
com.ruiwenliu.wrapper.base.BaseBean
;
import
com.ruiwenliu.wrapper.base.BaseStatusActivity
;
import
com.ruiwenliu.wrapper.util.UtilsManager
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.rv.home.rv.module.ApiConfig
;
import
com.rv.home.rv.module.basic.presenter.CommonPresenter
;
import
com.rv.home.rv.module.ui.login.RegisteredActivity
;
import
com.rv.rvmine.R
;
import
com.rv.rvmine.R2
;
import
com.rv.version.bean.VersionCheckBean
;
import
com.rv.version.util.UpdateAppUtils
;
import
com.yuyife.okgo.OkGoUtil
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
...
...
@@ -27,6 +34,8 @@ import butterknife.OnClick;
public
class
SettingActivity
extends
BaseStatusActivity
<
CommonPresenter
>
{
private
UpdateAppUtils
updateAppUtils
;
@Override
protected
int
setLayout
()
{
return
R
.
layout
.
activity_setting
;
...
...
@@ -44,6 +53,27 @@ public class SettingActivity extends BaseStatusActivity<CommonPresenter> {
@Override
public
void
onShowResult
(
int
requestType
,
BaseBean
result
)
{
switch
(
requestType
)
{
case
0
:
VersionCheckBean
versionCheckBean
=
(
VersionCheckBean
)
result
;
if
(
versionCheckBean
!=
null
&&
versionCheckBean
.
isRel
()
==
false
)
{
if
(
versionCheckBean
!=
null
&&
!
TextUtils
.
isEmpty
(
versionCheckBean
.
getData
().
getDownloadUrl
()))
{
updateAppUtils
.
serverVersionCode
(
versionCheckBean
.
getData
().
getWeigh
())
.
serverVersionName
(
versionCheckBean
.
getData
().
getVersionName
())
.
apkPath
(
versionCheckBean
.
getData
().
getDownloadUrl
())
.
updateInfo
(
versionCheckBean
.
getData
().
getContent
())
.
apkSize
(
versionCheckBean
.
getData
().
getPackagesize
())
.
isForce
(
false
)
.
update
();
}
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"当前已是最新版本"
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
default
:
break
;
}
}
...
...
@@ -51,29 +81,32 @@ public class SettingActivity extends BaseStatusActivity<CommonPresenter> {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
ButterKnife
.
bind
(
this
);
if
(
updateAppUtils
==
null
)
{
updateAppUtils
=
UpdateAppUtils
.
from
(
SettingActivity
.
this
);
}
}
@OnClick
({
R2
.
id
.
rl_item_change_password
,
R2
.
id
.
ll_item_app_push
,
R2
.
id
.
rl_item_clear_cache
,
R2
.
id
.
rl_item_check_for_updates
,
R2
.
id
.
rl_item_about_us
,
R2
.
id
.
tv_out_sign
})
@OnClick
({
R2
.
id
.
rl_item_change_password
,
R2
.
id
.
ll_item_app_push
,
R2
.
id
.
rl_item_clear_cache
,
R2
.
id
.
rl_item_check_for_updates
,
R2
.
id
.
rl_item_about_us
,
R2
.
id
.
tv_out_sign
})
public
void
onViewClicked
(
View
view
)
{
int
id
=
view
.
getId
();
if
(
id
==
R
.
id
.
rl_item_change_password
){
if
(
id
==
R
.
id
.
rl_item_change_password
)
{
//修改密码
startActivity
(
RegisteredActivity
.
getIntent
(
mActivity
,
1
));
}
else
if
(
id
==
R
.
id
.
ll_item_app_push
)
{
}
else
if
(
id
==
R
.
id
.
ll_item_app_push
)
{
//App推送消息
showToast
(
"亲,该功能还在开发中。。。"
);
}
else
if
(
id
==
R
.
id
.
rl_item_clear_cache
)
{
}
else
if
(
id
==
R
.
id
.
rl_item_clear_cache
)
{
//清除缓存
showToast
(
"亲,该功能还在开发中。。。"
);
}
else
if
(
id
==
R
.
id
.
rl_item_check_for_updates
)
{
}
else
if
(
id
==
R
.
id
.
rl_item_check_for_updates
)
{
//检查更新
showToast
(
"亲,该功能还在开发中。。。"
);
}
else
if
(
id
==
R
.
id
.
rl_item_about_us
)
{
checkVersion
(
);
}
else
if
(
id
==
R
.
id
.
rl_item_about_us
)
{
//关于我们
startActivity
(
AboutUsActivity
.
getIntent
(
mActivity
));
}
else
if
(
id
==
R
.
id
.
tv_out_sign
)
{
}
else
if
(
id
==
R
.
id
.
tv_out_sign
)
{
//退出登录
UtilsManager
.
getInstance
(
mActivity
).
clearShareData
(
"city_json"
);
UtilsManager
.
getInstance
(
mActivity
).
setShNull
();
...
...
@@ -83,4 +116,30 @@ public class SettingActivity extends BaseStatusActivity<CommonPresenter> {
finish
();
}
}
/****
* 检测版本
*/
private
void
checkVersion
()
{
Map
<
String
,
Object
>
headMap
=
new
LinkedHashMap
<>();
String
versionName
=
UpdateAppUtils
.
getAppVersionName
(
this
);
if
(!
TextUtils
.
isEmpty
(
versionName
))
{
mPresenter
.
getData
(
0
,
String
.
format
(
ApiConfig
.
HTTP_URL_VERSION_CHECK
,
versionName
),
VersionCheckBean
.
class
,
headMap
,
true
);
}
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
switch
(
requestCode
)
{
case
1001
:
if
(
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
updateAppUtils
.
download
();
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"授权失败,无法下载最新App"
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
}
}
}
plugin_member/build.gradle
View file @
8fa9d751
...
...
@@ -2,15 +2,13 @@ apply plugin: 'com.android.library'
apply
plugin:
'com.jakewharton.butterknife'
android
{
compileSdkVersion
2
9
compileSdkVersion
2
8
defaultConfig
{
minSdkVersion
19
targetSdkVersion
29
versionCode
1
versionName
"1.0"
targetSdkVersion
28
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
...
...
plugin_member/src/main/java/com/rv.member/presenter/MemberPresenter.java
View file @
8fa9d751
...
...
@@ -44,7 +44,7 @@ public class MemberPresenter extends CommonPresenter {
Map
<
String
,
Object
>
headMap
=
new
LinkedHashMap
<>();
if
(
OkGoUtil
.
getToken
()
!=
null
)
headMap
.
put
(
"Authorization"
,
OkGoUtil
.
getToken
());
postBodyData
(
RvFrameConfig
.
ADMIN_POST
,
position
,
ApiConfig
.
HTTP_URL_MEMBER_CREATE_ORDER
_
,
MemberOrderBean
.
class
,
memberOrderPostBodyBean
,
headMap
,
true
);
postBodyData
(
RvFrameConfig
.
ADMIN_POST
,
position
,
ApiConfig
.
HTTP_URL_MEMBER_CREATE_ORDER
,
MemberOrderBean
.
class
,
memberOrderPostBodyBean
,
headMap
,
true
);
}
/**
...
...
plugin_version/.gitignore
0 → 100644
View file @
8fa9d751
/build
plugin_version/build.gradle
0 → 100644
View file @
8fa9d751
apply
plugin:
'com.android.library'
android
{
compileSdkVersion
29
defaultConfig
{
minSdkVersion
19
targetSdkVersion
29
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
implementation
'com.android.support:appcompat-v7:28.0.0'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
implementation
'com.liulishuo.filedownloader:library:1.6.8'
implementation
project
(
':RvWrapper'
)
}
plugin_version/proguard-rules.pro
0 → 100644
View file @
8fa9d751
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
plugin_version/src/main/AndroidManifest.xml
0 → 100644
View file @
8fa9d751
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.rv.version"
>
<application>
<receiver
android:name=
"com.rv.version.receiver.UpdateAppReceiver"
>
<intent-filter>
<action
android:name=
"teprinciple.update"
/>
</intent-filter>
</receiver>
<provider
android:name=
"android.support.v4.content.FileProvider"
android:authorities=
"${applicationId}.fileprovider"
android:exported=
"false"
android:grantUriPermissions=
"true"
>
<meta-data
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/update_file_paths"
/>
</provider>
</application>
</manifest>
plugin_version/src/main/java/com/rv/version/VersionUpdateDialog.java
0 → 100644
View file @
8fa9d751
package
com
.
rv
.
version
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.TextView
;
import
com.rv.version.bean.UpdateBean
;
public
class
VersionUpdateDialog
extends
Dialog
{
public
VersionUpdateDialog
(
@NonNull
Context
context
)
{
super
(
context
);
}
public
VersionUpdateDialog
(
Context
context
,
int
themeResId
)
{
super
(
context
,
themeResId
);
}
public
static
class
Builder
{
private
Context
mContext
;
private
UpdateBean
updateBean
;
private
TextView
txtSure
;
private
TextView
txtContent
;
private
TextView
txtSize
;
private
DownloadListener
mListener
;
public
Builder
(
Context
context
,
DownloadListener
listener
)
{
mContext
=
context
;
this
.
mListener
=
listener
;
}
public
interface
DownloadListener
{
void
download
();
}
public
Builder
show
()
{
final
VersionUpdateDialog
dialog
=
create
();
dialog
.
show
();
return
this
;
}
public
Builder
setData
(
UpdateBean
updateBean
)
{
this
.
updateBean
=
updateBean
;
return
this
;
}
/**
* 创建定制的对话框
*/
public
VersionUpdateDialog
create
()
{
LayoutInflater
inflater
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
final
VersionUpdateDialog
dialog
=
new
VersionUpdateDialog
(
mContext
,
R
.
style
.
CustomDialog
);
// 获取对话框的布局
View
layout
=
inflater
.
inflate
(
R
.
layout
.
dialog_update_view
,
null
);
// 为对话框添加布局和设置大小
dialog
.
addContentView
(
layout
,
new
WindowManager
.
LayoutParams
(
WindowManager
.
LayoutParams
.
MATCH_PARENT
,
WindowManager
.
LayoutParams
.
WRAP_CONTENT
));
this
.
txtSize
=
layout
.
findViewById
(
R
.
id
.
txt_size
);
this
.
txtContent
=
layout
.
findViewById
(
R
.
id
.
txt_content
);
this
.
txtSure
=
layout
.
findViewById
(
R
.
id
.
txt_sure
);
if
(
this
.
updateBean
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
this
.
updateBean
.
getUpdateInfo
()))
{
txtContent
.
setText
(
this
.
updateBean
.
getUpdateInfo
());
}
if
(!
TextUtils
.
isEmpty
(
this
.
updateBean
.
getPackageSize
()))
{
txtSize
.
setText
(
this
.
updateBean
.
getPackageSize
());
}
}
this
.
txtSure
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
mListener
!=
null
)
{
mListener
.
download
();
}
dialog
.
dismiss
();
}
});
//默认不能点击对话框其他区域退出 和按返回键退出
dialog
.
setCancelable
(
false
);
dialog
.
setContentView
(
layout
);
return
dialog
;
}
}
}
plugin_version/src/main/java/com/rv/version/bean/VersionCheckBean.java
0 → 100644
View file @
8fa9d751
package
com
.
rv
.
version
.
bean
;
import
com.ruiwenliu.wrapper.base.BaseBean
;
public
class
VersionCheckBean
extends
BaseBean
{
private
VersionBean
data
;
private
boolean
rel
;
public
VersionBean
getData
()
{
return
data
;
}
public
void
setData
(
VersionBean
data
)
{
this
.
data
=
data
;
}
public
boolean
isRel
()
{
return
rel
;
}
public
void
setRel
(
boolean
rel
)
{
this
.
rel
=
rel
;
}
public
static
class
VersionBean
{
private
int
id
;
private
int
sysType
;
private
String
version
;
private
String
versionName
;
private
String
packagesize
;
private
String
content
;
private
String
downloadUrl
;
private
int
downloadSwitch
;
private
int
weigh
;
private
int
crtTime
;
private
int
isDel
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getSysType
()
{
return
sysType
;
}
public
void
setSysType
(
int
sysType
)
{
this
.
sysType
=
sysType
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getVersionName
()
{
return
versionName
;
}
public
void
setVersionName
(
String
versionName
)
{
this
.
versionName
=
versionName
;
}
public
String
getPackagesize
()
{
return
packagesize
;
}
public
void
setPackagesize
(
String
packagesize
)
{
this
.
packagesize
=
packagesize
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getDownloadUrl
()
{
return
downloadUrl
;
}
public
void
setDownloadUrl
(
String
downloadUrl
)
{
this
.
downloadUrl
=
downloadUrl
;
}
public
int
getDownloadSwitch
()
{
return
downloadSwitch
;
}
public
void
setDownloadSwitch
(
int
downloadSwitch
)
{
this
.
downloadSwitch
=
downloadSwitch
;
}
public
int
getWeigh
()
{
return
weigh
;
}
public
void
setWeigh
(
int
weigh
)
{
this
.
weigh
=
weigh
;
}
public
int
getCrtTime
()
{
return
crtTime
;
}
public
void
setCrtTime
(
int
crtTime
)
{
this
.
crtTime
=
crtTime
;
}
public
int
getIsDel
()
{
return
isDel
;
}
public
void
setIsDel
(
int
isDel
)
{
this
.
isDel
=
isDel
;
}
}
}
plugin_version/src/main/java/com/rv/version/receiver/UpdateAppReceiver.java
0 → 100644
View file @
8fa9d751
package
com
.
rv
.
version
.
receiver
;
import
android.app.Notification
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.support.v4.content.FileProvider
;
import
com.rv.version.R
;
import
com.rv.version.util.DownloadAppUtils
;
import
com.rv.version.util.UpdateAppUtils
;
import
java.io.File
;
/**
* Created by Teprinciple on 2017/11/3.
*/
public
class
UpdateAppReceiver
extends
BroadcastReceiver
{
private
String
notificationChannel
=
"1001"
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
int
progress
=
intent
.
getIntExtra
(
"progress"
,
0
);
String
title
=
intent
.
getStringExtra
(
"title"
);
NotificationManager
nm
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
// 显示通知栏
int
notifyId
=
1
;
if
(
UpdateAppUtils
.
showNotification
)
{
showNotification
(
context
,
notifyId
,
progress
,
title
,
notificationChannel
,
nm
);
}
// 下载完成
if
(
progress
==
100
)
{
handleDownloadComplete
(
context
,
notifyId
,
nm
);
}
}
/**
* 下载完成后的逻辑
*/
private
void
handleDownloadComplete
(
Context
context
,
int
notifyId
,
NotificationManager
nm
)
{
// 关闭通知栏
if
(
nm
!=
null
)
{
nm
.
cancel
(
notifyId
);
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
O
)
{
nm
.
deleteNotificationChannel
(
notificationChannel
);
}
}
// 安装apk
if
(
DownloadAppUtils
.
downloadUpdateApkFilePath
!=
null
)
{
toInstall
(
context
);
}
}
/**
* 通知栏显示
*/
private
void
showNotification
(
Context
context
,
int
notifyId
,
int
progress
,
String
title
,
String
notificationChannel
,
NotificationManager
nm
)
{
String
notificationName
=
"notification"
;
// 适配8.0
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
// 通知渠道
NotificationChannel
channel
=
new
NotificationChannel
(
notificationChannel
,
notificationName
,
NotificationManager
.
IMPORTANCE_MIN
);
channel
.
enableLights
(
false
);
// 是否在桌面icon右上角展示小红点
channel
.
setShowBadge
(
false
);
// 是否在久按桌面图标时显示此渠道的通知
channel
.
enableVibration
(
false
);
channel
.
setVibrationPattern
(
new
long
[]{
0
});
channel
.
setSound
(
null
,
null
);
// 最后在notificationmanager中创建该通知渠道
nm
.
createNotificationChannel
(
channel
);
}
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
context
);
builder
.
setVibrate
(
null
);
builder
.
setVibrate
(
new
long
[]{
0
l
});
//NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
builder
.
setChannelId
(
notificationChannel
);
}
if
(
progress
==
-
1
)
{
builder
.
setContentTitle
(
"下载准备中 "
+
title
);
builder
.
setSmallIcon
(
R
.
drawable
.
logo
);
// builder.setProgress(100, progress, false);
}
else
{
builder
.
setContentTitle
(
"正在下载 "
+
title
);
builder
.
setSmallIcon
(
R
.
drawable
.
logo
);
builder
.
setProgress
(
100
,
progress
,
false
);
}
Notification
notification
=
null
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
notification
=
builder
.
build
();
}
else
{
notification
=
builder
.
getNotification
();
}
nm
.
notify
(
notifyId
,
notification
);
}
/**
* 跳转安装
*/
private
void
toInstall
(
Context
context
)
{
Intent
i
=
new
Intent
(
Intent
.
ACTION_VIEW
);
File
apkFile
=
new
File
(
DownloadAppUtils
.
downloadUpdateApkFilePath
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
i
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
Uri
contentUri
=
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()
+
".fileprovider"
,
apkFile
);
i
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
);
}
else
{
i
.
setDataAndType
(
Uri
.
fromFile
(
apkFile
),
"application/vnd.android.package-archive"
);
}
i
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
context
.
startActivity
(
i
);
}
}
\ No newline at end of file
plugin_version/src/main/res/drawable/logo.png
0 → 100644
View file @
8fa9d751
56.3 KB
plugin_version/src/main/res/layout/dialog_update_view.xml
0 → 100644
View file @
8fa9d751
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
>
<LinearLayout
android:id=
"@+id/ll_main"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@color/white"
android:gravity=
"center_horizontal"
android:minWidth=
"330dp"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/txt_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:text=
"升级"
android:textColor=
"#ff333333"
android:textSize=
"24sp"
/>
<TextView
android:id=
"@+id/txt_size"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:gravity=
"center"
android:textColor=
"#ff5e5e5e"
android:textSize=
"18sp"
/>
<TextView
android:id=
"@+id/txt_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:gravity=
"center"
android:textColor=
"#ff5e5e5e"
android:textSize=
"18sp"
/>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"50dp"
>
<TextView
android:id=
"@+id/txt_sure"
android:layout_width=
"0.0dip"
android:layout_height=
"fill_parent"
android:layout_weight=
"1.0"
android:gravity=
"center"
android:maxLines=
"1"
android:text=
"升级"
android:textSize=
"22sp"
/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
plugin_version/src/main/res/values/strings.xml
0 → 100644
View file @
8fa9d751
<resources>
<string
name=
"app_name"
>
Library
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"sure"
>
确认
</string>
</resources>
settings.gradle
View file @
8fa9d751
//include ':WXPay'
include
':RvFrame'
,
':plugin_search'
,
':component_utils'
,
':memer'
,
':plugin_member'
include
':RvFrame'
,
':plugin_search'
,
':component_utils'
,
':memer'
,
':plugin_member'
,
':plugin_version'
include
':RvTravel'
include
':RvClient'
include
':RvWrapper'
...
...
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