Commit 5ee9a3b6 authored by wangxuewei's avatar wangxuewei

[提交人]:王雪伟

[提交简述] :幸运农场1.0.6
[实现方案] :设置加入通知开关
parent 0bb05f53
...@@ -45,29 +45,36 @@ import java.lang.reflect.Method ...@@ -45,29 +45,36 @@ import java.lang.reflect.Method
class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback { class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
private var mOrderString = ""; private var mOrderString = "";
private val mContext = AppliContext.get() private val mContext = AppliContext.get()
private var mRefreshLoginObservable: Observable<Boolean>? = null private var mRefreshLoginObservable: Observable<String>? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
EventUtils.onEvent("tab_imp", "幸运农场") EventUtils.onEvent("tab_imp", "幸运农场")
if (SettingPreference.getIsShowGuide()) { if (SettingPreference.getIsShowGuide()) {
SettingPreference.setIsShowGuide(false) SettingPreference.setIsShowGuide(false)
} }
mRefreshLoginObservable = RxBus.get().register("refresh_login", Boolean::class.java) mRefreshLoginObservable = RxBus.get().register("refresh_login", String::class.java)
TurntableDialog.initTurntableAnim() TurntableDialog.initTurntableAnim()
getUserInfo() getUserInfo()
getRankReceive() getRankReceive()
checkUpdateApp() checkUpdateApp()
mRefreshLoginObservable?.observeOn(AndroidSchedulers.mainThread())?.subscribe({ mRefreshLoginObservable?.observeOn(AndroidSchedulers.mainThread())?.subscribe({
SettingPreference.setToken("") when (it) {
try { "not_login" -> {
val intent = Intent(this@GameActivity, WxLoginActivity::class.java) SettingPreference.setToken("")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) try {
AppliContext.get().startActivity(intent) val intent = Intent(this, WxLoginActivity::class.java)
} catch (e: java.lang.Exception) { 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 { ...@@ -86,7 +93,6 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
if (mRefreshLoginObservable != null) { if (mRefreshLoginObservable != null) {
RxBus.get().unregister("refresh_login", mRefreshLoginObservable!!)//页面销毁的时候要执行 反注册 RxBus.get().unregister("refresh_login", mRefreshLoginObservable!!)//页面销毁的时候要执行 反注册
} }
} }
private fun checkUpdateApp() { private fun checkUpdateApp() {
...@@ -990,6 +996,24 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback { ...@@ -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) { fun GameEvent(keyName: String, valueName: String) {
EventUtils.onEvent(keyName, valueName); EventUtils.onEvent(keyName, valueName);
} }
...@@ -1024,18 +1048,22 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback { ...@@ -1024,18 +1048,22 @@ class GameActivity : UnityPlayerActivity(), IDialogViewCloseCallback {
private var myNotifService: NotificationService? = null private var myNotifService: NotificationService? = null
private var scc: ServiceConnection? = null private var scc: ServiceConnection? = null
//打开通知栏 //打开通知栏
private fun openNotif() { private fun openNotif() {
val intent = Intent(this, NotificationService::class.java) if (SettingPreference.getNotice()) {
scc = object : ServiceConnection { val intent = Intent(this, NotificationService::class.java)
override fun onServiceConnected(name: ComponentName, service: IBinder) { scc = object : ServiceConnection {
val myBinder: NotificationService.MyBinder = service as NotificationService.MyBinder override fun onServiceConnected(name: ComponentName, service: IBinder) {
myNotifService = myBinder.getService() 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
...@@ -44,4 +44,7 @@ interface IUnitySendMessageCallback { ...@@ -44,4 +44,7 @@ interface IUnitySendMessageCallback {
//红包列表成功 //红包列表成功
fun onRedPackListSuccess(isSuccess: Boolean, result: String) fun onRedPackListSuccess(isSuccess: Boolean, result: String)
//判断是否云朵加速
fun onGetCheckCloud(isSuccess: Boolean, result: String)
} }
\ No newline at end of file
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;
}
}
...@@ -23,6 +23,15 @@ interface IGameApi { ...@@ -23,6 +23,15 @@ interface IGameApi {
*/ */
@GET(NetConfig.Game.URL_GAME_HOME_INFO) @GET(NetConfig.Game.URL_GAME_HOME_INFO)
fun getGameHomeInfo(): Observable<Response<HomeInfoEntity>> fun getGameHomeInfo(): Observable<Response<HomeInfoEntity>>
/**
* 云朵加速判断
* @param
* @param
* @return
*/
@GET(NetConfig.Game.URL_GAME_CLOUD_CHECK)
fun getGameCloudCheck(): Observable<Response<GuideEntity>>
/** /**
* 地块列表 * 地块列表
......
...@@ -17,8 +17,10 @@ import android.os.IBinder; ...@@ -17,8 +17,10 @@ import android.os.IBinder;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import com.ym.game.GameActivity; import com.ym.game.GameActivity;
import com.ym.library.utils.LogUtils; import com.ym.library.utils.LogUtils;
import com.ym.library.utils.SettingPreference;
import com.ym.xync.R; import com.ym.xync.R;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -132,7 +134,8 @@ public class NotificationService extends Service { ...@@ -132,7 +134,8 @@ public class NotificationService extends Service {
} }
// startForeground(ID_FOR_CUSTOM_VIEW, notification); // startForeground(ID_FOR_CUSTOM_VIEW, notification);
// Boolean isOpen = (Boolean) SPUtils.get(context, SPUtils.SP_LONG_NOTICATION, true); // Boolean isOpen = (Boolean) SPUtils.get(context, SPUtils.SP_LONG_NOTICATION, true);
Boolean isOpen = true;
Boolean isOpen = SettingPreference.getNotice();
try { try {
if (isOpen) { if (isOpen) {
if (notification != null) { if (notification != null) {
...@@ -217,8 +220,8 @@ public class NotificationService extends Service { ...@@ -217,8 +220,8 @@ public class NotificationService extends Service {
} }
} }
public void collapseStatusBar() { public void collapseStatusBar() {
@SuppressLint("WrongConstant") Object service =getSystemService("statusbar"); @SuppressLint("WrongConstant") Object service = getSystemService("statusbar");
if (null == service) if (null == service)
return; return;
try { try {
......
...@@ -27,7 +27,7 @@ public abstract class BaseObserver<T> implements Observer<Response<T>> { ...@@ -27,7 +27,7 @@ public abstract class BaseObserver<T> implements Observer<Response<T>> {
onSuccess(null); onSuccess(null);
} }
} else if (TextUtils.equals(result.status, "101")) {//重试设备登录和获取用户信息 } 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")) { } else if (TextUtils.equals(result.status, "160")) {
onFailure(null, "160", "请重试");//该异常可以汇报服务端 onFailure(null, "160", "请重试");//该异常可以汇报服务端
} else { } else {
......
...@@ -241,5 +241,6 @@ public class NetConfig { ...@@ -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_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_RED_PACK_AWARD_RECEIVE="app/v3/common/award/multiple";//翻倍领取接口
public static final String URL_GAME_CLOUD_CHECK = "app/v1/game/farm/cloud_check";//云朵加速判断
} }
} }
...@@ -129,6 +129,8 @@ public class SettingPreference { ...@@ -129,6 +129,8 @@ public class SettingPreference {
private static final String SHOW_PRIVACY_PROTOCOL = "show_privacy_protocol";//是否同意隐私协议 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_FIVE_WITHDRAW = "show_five_withdraw";//5首提现
private static final String SHOW_NOTIFICATION = "show_notification";//通知栏
/** /**
* 是否第一次进入APP * 是否第一次进入APP
* *
...@@ -147,6 +149,7 @@ public class SettingPreference { ...@@ -147,6 +149,7 @@ public class SettingPreference {
editor.commit(); editor.commit();
} }
/** /**
* 是否第一次进入APP * 是否第一次进入APP
* *
...@@ -221,8 +224,6 @@ public class SettingPreference { ...@@ -221,8 +224,6 @@ public class SettingPreference {
} }
public static void setH5Data(String key, String value) { public static void setH5Data(String key, String value) {
SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0); SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
...@@ -236,6 +237,22 @@ public class SettingPreference { ...@@ -236,6 +237,22 @@ public class SettingPreference {
return ad; 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 { ...@@ -1891,6 +1908,7 @@ public class SettingPreference {
SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0); SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
return settings.getString(USER_INFRO_NAME, ""); return settings.getString(USER_INFRO_NAME, "");
} }
// 保存任务页签到日期 // 保存任务页签到日期
public static void saveSignInDate() { public static void saveSignInDate() {
String currentDD = DateUtils.getStringByFormat(System.currentTimeMillis(), "dd"); String currentDD = DateUtils.getStringByFormat(System.currentTimeMillis(), "dd");
...@@ -1902,6 +1920,7 @@ public class SettingPreference { ...@@ -1902,6 +1920,7 @@ public class SettingPreference {
} }
} }
private static final String SIGN_IN_ISTODAY = "sign_in_istoDay"; private static final String SIGN_IN_ISTODAY = "sign_in_istoDay";
// 获取任务页签到日期 // 获取任务页签到日期
......
...@@ -3,12 +3,11 @@ package com.ym.userinfo.module.activity ...@@ -3,12 +3,11 @@ package com.ym.userinfo.module.activity
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.widget.CompoundButton
import com.bytedance.sdk.openadsdk.TTNativeExpressAd import com.bytedance.sdk.openadsdk.TTNativeExpressAd
import com.umeng.analytics.MobclickAgent import com.umeng.analytics.MobclickAgent
import com.ym.admodule.rs.RSADUtils
import com.ym.library.Constant import com.ym.library.Constant
import com.ym.library.config.AdManager import com.ym.library.config.AdManager
import com.ym.library.config.ZXADCallback
import com.ym.library.config.ZXADSizeConfig import com.ym.library.config.ZXADSizeConfig
import com.ym.library.down.UpdateVersionManager import com.ym.library.down.UpdateVersionManager
import com.ym.library.listener.ZXADExpressListener import com.ym.library.listener.ZXADExpressListener
...@@ -17,7 +16,6 @@ import com.ym.library.net.BaseActivity ...@@ -17,7 +16,6 @@ import com.ym.library.net.BaseActivity
import com.ym.library.utils.* import com.ym.library.utils.*
import com.ym.module.userinfo.R import com.ym.module.userinfo.R
import kotlinx.android.synthetic.main.activity_setting.* import kotlinx.android.synthetic.main.activity_setting.*
import kotlinx.android.synthetic.main.layout_user_toolbar.*
class SettingActivity : BaseActivity() { class SettingActivity : BaseActivity() {
...@@ -41,6 +39,18 @@ class SettingActivity : BaseActivity() { ...@@ -41,6 +39,18 @@ class SettingActivity : BaseActivity() {
id_iv_copy.setOnClickListener { id_iv_copy.setOnClickListener {
copy() 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() } id_iv_back.setOnClickListener { finish() }
// tv_user_toolbar_title.text = "设置" // tv_user_toolbar_title.text = "设置"
//用户协议 //用户协议
......
<?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
...@@ -75,6 +75,40 @@ ...@@ -75,6 +75,40 @@
android:src="@drawable/icon_user_setting_copy" /> android:src="@drawable/icon_user_setting_copy" />
</RelativeLayout> </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 <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="3dp" android:layout_height="3dp"
...@@ -86,10 +120,10 @@ ...@@ -86,10 +120,10 @@
android:id="@+id/id_ad_frame_view" android:id="@+id/id_ad_frame_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp" />
android:layout_gravity="center_horizontal"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment