Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
LuckyFarm
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
LuckyFarm
Commits
5ee9a3b6
Commit
5ee9a3b6
authored
Nov 05, 2020
by
wangxuewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[提交人]:王雪伟
[提交简述] :幸运农场1.0.6 [实现方案] :设置加入通知开关
parent
0bb05f53
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
164 additions
and
31 deletions
+164
-31
GameActivity.kt
app/src/main/java/com/ym/game/GameActivity.kt
+48
-20
IUnitySendMessageCallback.kt
app/src/main/java/com/ym/game/IUnitySendMessageCallback.kt
+3
-0
GuideEntity.java
app/src/main/java/com/ym/game/module/GuideEntity.java
+18
-0
IGameApi.kt
app/src/main/java/com/ym/game/net/IGameApi.kt
+9
-0
NotificationService.java
...in/java/com/ym/game/notifservice/NotificationService.java
+6
-3
BaseObserver.java
library/src/main/java/com/ym/library/net/BaseObserver.java
+1
-1
NetConfig.java
library/src/main/java/com/ym/library/net/NetConfig.java
+1
-0
SettingPreference.java
...src/main/java/com/ym/library/utils/SettingPreference.java
+21
-2
SettingActivity.kt
...n/java/com/ym/userinfo/module/activity/SettingActivity.kt
+13
-3
notif_off.png
userinfo/src/main/res/drawable-xhdpi/notif_off.png
+0
-0
notif_on.png
userinfo/src/main/res/drawable-xhdpi/notif_on.png
+0
-0
checkbox_style.xml
userinfo/src/main/res/drawable/checkbox_style.xml
+8
-0
activity_setting.xml
userinfo/src/main/res/layout/activity_setting.xml
+36
-2
No files found.
app/src/main/java/com/ym/game/GameActivity.kt
View file @
5ee9a3b6
...
...
@@ -45,29 +45,36 @@ import java.lang.reflect.Method
class
GameActivity
:
UnityPlayerActivity
(),
IDialogViewCloseCallback
{
private
var
mOrderString
=
""
;
private
val
mContext
=
AppliContext
.
get
()
private
var
mRefreshLoginObservable
:
Observable
<
Boolean
>?
=
null
private
var
mRefreshLoginObservable
:
Observable
<
String
>?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
EventUtils
.
onEvent
(
"tab_imp"
,
"幸运农场"
)
if
(
SettingPreference
.
getIsShowGuide
())
{
SettingPreference
.
setIsShowGuide
(
false
)
}
mRefreshLoginObservable
=
RxBus
.
get
().
register
(
"refresh_login"
,
Boolean
::
class
.
java
)
mRefreshLoginObservable
=
RxBus
.
get
().
register
(
"refresh_login"
,
String
::
class
.
java
)
TurntableDialog
.
initTurntableAnim
()
getUserInfo
()
getRankReceive
()
checkUpdateApp
()
mRefreshLoginObservable
?.
observeOn
(
AndroidSchedulers
.
mainThread
())
?.
subscribe
({
SettingPreference
.
setToken
(
""
)
try
{
val
intent
=
Intent
(
this
@GameActivity
,
WxLoginActivity
::
class
.
java
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
AppliContext
.
get
().
startActivity
(
intent
)
}
catch
(
e
:
java
.
lang
.
Exception
)
{
when
(
it
)
{
"not_login"
->
{
SettingPreference
.
setToken
(
""
)
try
{
val
intent
=
Intent
(
this
,
WxLoginActivity
::
class
.
java
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
AppliContext
.
get
().
startActivity
(
intent
)
}
catch
(
e
:
java
.
lang
.
Exception
)
{
}
}
"open_notif"
->
{
openNotif
()
}
"close_notif"
->
{
scc
?.
let
{
unbindService
(
it
)
}
}
}
// if (mRefreshLoginObservable!=null){
// RxBus.get().unregister("refresh_login", mRefreshLoginObservable!!)//页面销毁的时候要执行 反注册
// }
},
{
})
...
...
@@ -86,7 +93,6 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
if
(
mRefreshLoginObservable
!=
null
)
{
RxBus
.
get
().
unregister
(
"refresh_login"
,
mRefreshLoginObservable
!!
)
//页面销毁的时候要执行 反注册
}
}
private
fun
checkUpdateApp
()
{
...
...
@@ -990,6 +996,24 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
}
//检查云朵加速
fun
checkCloud
(
callback
:
IUnitySendMessageCallback
?)
{
GameApiClient
.
gameApi
.
getGameCloudCheck
().
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
GuideEntity
>()
{
override
fun
onSuccess
(
result
:
GuideEntity
?)
{
callback
?.
onGetCheckCloud
(
true
,
Utils
.
obj2Str
(
result
)
)
}
override
fun
onFailure
(
e
:
Throwable
?,
code
:
String
?,
errorMsg
:
String
?)
{
callback
?.
onGetCheckCloud
(
false
,
"CloudError"
)
}
})
}
fun
GameEvent
(
keyName
:
String
,
valueName
:
String
)
{
EventUtils
.
onEvent
(
keyName
,
valueName
);
}
...
...
@@ -1024,18 +1048,22 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
private
var
myNotifService
:
NotificationService
?
=
null
private
var
scc
:
ServiceConnection
?
=
null
//打开通知栏
private
fun
openNotif
()
{
val
intent
=
Intent
(
this
,
NotificationService
::
class
.
java
)
scc
=
object
:
ServiceConnection
{
override
fun
onServiceConnected
(
name
:
ComponentName
,
service
:
IBinder
)
{
val
myBinder
:
NotificationService
.
MyBinder
=
service
as
NotificationService
.
MyBinder
myNotifService
=
myBinder
.
getService
()
}
if
(
SettingPreference
.
getNotice
())
{
val
intent
=
Intent
(
this
,
NotificationService
::
class
.
java
)
scc
=
object
:
ServiceConnection
{
override
fun
onServiceConnected
(
name
:
ComponentName
,
service
:
IBinder
)
{
val
myBinder
:
NotificationService
.
MyBinder
=
service
as
NotificationService
.
MyBinder
myNotifService
=
myBinder
.
getService
()
}
override
fun
onServiceDisconnected
(
name
:
ComponentName
)
{}
override
fun
onServiceDisconnected
(
name
:
ComponentName
)
{}
}
bindService
(
intent
,
scc
as
ServiceConnection
,
BIND_AUTO_CREATE
)
}
bindService
(
intent
,
scc
as
ServiceConnection
,
BIND_AUTO_CREATE
)
}
}
\ No newline at end of file
app/src/main/java/com/ym/game/IUnitySendMessageCallback.kt
View file @
5ee9a3b6
...
...
@@ -44,4 +44,7 @@ interface IUnitySendMessageCallback {
//红包列表成功
fun
onRedPackListSuccess
(
isSuccess
:
Boolean
,
result
:
String
)
//判断是否云朵加速
fun
onGetCheckCloud
(
isSuccess
:
Boolean
,
result
:
String
)
}
\ No newline at end of file
app/src/main/java/com/ym/game/module/GuideEntity.java
0 → 100644
View file @
5ee9a3b6
package
com
.
ym
.
game
.
module
;
/**
* @author (wangXuewei)
* @datetime 2020-11-05 15:07 GMT+8
* @detail :
*/
public
class
GuideEntity
{
private
int
status
;
public
int
getStatus
()
{
return
status
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
}
app/src/main/java/com/ym/game/net/IGameApi.kt
View file @
5ee9a3b6
...
...
@@ -23,6 +23,15 @@ interface IGameApi {
*/
@GET
(
NetConfig
.
Game
.
URL_GAME_HOME_INFO
)
fun
getGameHomeInfo
():
Observable
<
Response
<
HomeInfoEntity
>>
/**
* 云朵加速判断
* @param
* @param
* @return
*/
@GET
(
NetConfig
.
Game
.
URL_GAME_CLOUD_CHECK
)
fun
getGameCloudCheck
():
Observable
<
Response
<
GuideEntity
>>
/**
* 地块列表
...
...
app/src/main/java/com/ym/game/notifservice/NotificationService.java
View file @
5ee9a3b6
...
...
@@ -17,8 +17,10 @@ import android.os.IBinder;
import
android.widget.RemoteViews
;
import
androidx.core.app.NotificationCompat
;
import
com.ym.game.GameActivity
;
import
com.ym.library.utils.LogUtils
;
import
com.ym.library.utils.SettingPreference
;
import
com.ym.xync.R
;
import
java.lang.reflect.Method
;
...
...
@@ -132,7 +134,8 @@ public class NotificationService extends Service {
}
// startForeground(ID_FOR_CUSTOM_VIEW, notification);
// Boolean isOpen = (Boolean) SPUtils.get(context, SPUtils.SP_LONG_NOTICATION, true);
Boolean
isOpen
=
true
;
Boolean
isOpen
=
SettingPreference
.
getNotice
();
try
{
if
(
isOpen
)
{
if
(
notification
!=
null
)
{
...
...
@@ -217,8 +220,8 @@ public class NotificationService extends Service {
}
}
public
void
collapseStatusBar
()
{
@SuppressLint
(
"WrongConstant"
)
Object
service
=
getSystemService
(
"statusbar"
);
public
void
collapseStatusBar
()
{
@SuppressLint
(
"WrongConstant"
)
Object
service
=
getSystemService
(
"statusbar"
);
if
(
null
==
service
)
return
;
try
{
...
...
library/src/main/java/com/ym/library/net/BaseObserver.java
View file @
5ee9a3b6
...
...
@@ -27,7 +27,7 @@ public abstract class BaseObserver<T> implements Observer<Response<T>> {
onSuccess
(
null
);
}
}
else
if
(
TextUtils
.
equals
(
result
.
status
,
"101"
))
{
//重试设备登录和获取用户信息
RxBus
.
get
().
post
(
"refresh_login"
,
true
);
RxBus
.
get
().
post
(
"refresh_login"
,
"not_login"
);
}
else
if
(
TextUtils
.
equals
(
result
.
status
,
"160"
))
{
onFailure
(
null
,
"160"
,
"请重试"
);
//该异常可以汇报服务端
}
else
{
...
...
library/src/main/java/com/ym/library/net/NetConfig.java
View file @
5ee9a3b6
...
...
@@ -241,5 +241,6 @@ public class NetConfig {
public
static
final
String
URL_GAME_RED_PACK_RECEIVE
=
"app/v1/game/farm/rp/receive"
;
//拆红包 参数传红包id
public
static
final
String
URL_GAME_RED_PACK_AWARD_RECEIVE
=
"app/v3/common/award/multiple"
;
//翻倍领取接口
public
static
final
String
URL_GAME_CLOUD_CHECK
=
"app/v1/game/farm/cloud_check"
;
//云朵加速判断
}
}
library/src/main/java/com/ym/library/utils/SettingPreference.java
View file @
5ee9a3b6
...
...
@@ -129,6 +129,8 @@ public class SettingPreference {
private
static
final
String
SHOW_PRIVACY_PROTOCOL
=
"show_privacy_protocol"
;
//是否同意隐私协议
private
static
final
String
SHOW_FIVE_WITHDRAW
=
"show_five_withdraw"
;
//5首提现
private
static
final
String
SHOW_NOTIFICATION
=
"show_notification"
;
//通知栏
/**
* 是否第一次进入APP
*
...
...
@@ -147,6 +149,7 @@ public class SettingPreference {
editor
.
commit
();
}
/**
* 是否第一次进入APP
*
...
...
@@ -221,8 +224,6 @@ public class SettingPreference {
}
public
static
void
setH5Data
(
String
key
,
String
value
)
{
SharedPreferences
settings
=
AppliContext
.
get
().
getSharedPreferences
(
USER_SETTING
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
...
...
@@ -236,6 +237,22 @@ public class SettingPreference {
return
ad
;
}
/**
* SHOW_NOTIFICATION
* 设置通知栏
*/
public
static
void
setNotice
(
Boolean
value
)
{
SharedPreferences
settings
=
AppliContext
.
get
().
getSharedPreferences
(
USER_SETTING
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putBoolean
(
SHOW_NOTIFICATION
,
value
);
editor
.
commit
();
}
public
static
Boolean
getNotice
()
{
SharedPreferences
settings
=
AppliContext
.
get
().
getSharedPreferences
(
USER_SETTING
,
0
);
Boolean
ad
=
settings
.
getBoolean
(
SHOW_NOTIFICATION
,
true
);
return
ad
;
}
/**
* 是否开发设备
...
...
@@ -1891,6 +1908,7 @@ public class SettingPreference {
SharedPreferences
settings
=
AppliContext
.
get
().
getSharedPreferences
(
USER_SETTING
,
0
);
return
settings
.
getString
(
USER_INFRO_NAME
,
""
);
}
// 保存任务页签到日期
public
static
void
saveSignInDate
()
{
String
currentDD
=
DateUtils
.
getStringByFormat
(
System
.
currentTimeMillis
(),
"dd"
);
...
...
@@ -1902,6 +1920,7 @@ public class SettingPreference {
}
}
private
static
final
String
SIGN_IN_ISTODAY
=
"sign_in_istoDay"
;
// 获取任务页签到日期
...
...
userinfo/src/main/java/com/ym/userinfo/module/activity/SettingActivity.kt
View file @
5ee9a3b6
...
...
@@ -3,12 +3,11 @@ package com.ym.userinfo.module.activity
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.widget.CompoundButton
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
import
com.umeng.analytics.MobclickAgent
import
com.ym.admodule.rs.RSADUtils
import
com.ym.library.Constant
import
com.ym.library.config.AdManager
import
com.ym.library.config.ZXADCallback
import
com.ym.library.config.ZXADSizeConfig
import
com.ym.library.down.UpdateVersionManager
import
com.ym.library.listener.ZXADExpressListener
...
...
@@ -17,7 +16,6 @@ import com.ym.library.net.BaseActivity
import
com.ym.library.utils.*
import
com.ym.module.userinfo.R
import
kotlinx.android.synthetic.main.activity_setting.*
import
kotlinx.android.synthetic.main.layout_user_toolbar.*
class
SettingActivity
:
BaseActivity
()
{
...
...
@@ -41,6 +39,18 @@ class SettingActivity : BaseActivity() {
id_iv_copy
.
setOnClickListener
{
copy
()
}
id_notif_check
.
isChecked
=
SettingPreference
.
getNotice
()
//复选框
id_notif_check
.
setOnCheckedChangeListener
(
CompoundButton
.
OnCheckedChangeListener
{
compoundButton
,
b
->
SettingPreference
.
setNotice
(
b
)
//重试设备登录和获取用户信息
if
(
b
){
RxBus
.
get
().
post
(
"refresh_login"
,
"open_notif"
)
}
else
{
RxBus
.
get
().
post
(
"refresh_login"
,
"close_notif"
)
}
})
id_iv_back
.
setOnClickListener
{
finish
()
}
// tv_user_toolbar_title.text = "设置"
//用户协议
...
...
userinfo/src/main/res/drawable-xhdpi/notif_off.png
0 → 100644
View file @
5ee9a3b6
2.59 KB
userinfo/src/main/res/drawable-xhdpi/notif_on.png
0 → 100644
View file @
5ee9a3b6
3.17 KB
userinfo/src/main/res/drawable/checkbox_style.xml
0 → 100644
View file @
5ee9a3b6
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@drawable/notif_on"
android:state_checked=
"true"
/>
<item
android:drawable=
"@drawable/notif_off"
android:state_checked=
"false"
/>
<item
android:drawable=
"@drawable/notif_off"
/>
</selector>
\ No newline at end of file
userinfo/src/main/res/layout/activity_setting.xml
View file @
5ee9a3b6
...
...
@@ -75,6 +75,40 @@
android:src=
"@drawable/icon_user_setting_copy"
/>
</RelativeLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"3dp"
android:layout_marginLeft=
"14dp"
android:layout_marginRight=
"14dp"
android:background=
"@drawable/bg_setting_line"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"17dp"
android:layout_marginBottom=
"17dp"
android:gravity=
"center_vertical"
android:paddingLeft=
"20dp"
android:paddingRight=
"20dp"
>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"通知栏"
android:textColor=
"#664F31"
android:textSize=
"15sp"
/>
<CheckBox
android:id=
"@+id/id_notif_check"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:button=
"@drawable/checkbox_style"
android:checked=
"true"
/>
</LinearLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"3dp"
...
...
@@ -86,10 +120,10 @@
android:id=
"@+id/id_ad_frame_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginLeft=
"15dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"15dp"
android:layout_gravity=
"center_horizontal"
/>
android:layout_marginRight=
"15dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
...
...
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