新增用户协议更新弹窗
This commit is contained in:
@@ -58,6 +58,7 @@ import com.yizhuan.erban.community.im.WorldDynamicShareViewHolder;
|
||||
import com.yizhuan.erban.community.publish.view.PublishActivity;
|
||||
import com.yizhuan.erban.community.square.SquareFragment;
|
||||
import com.yizhuan.erban.family.view.activity.FamilyHomeActivity;
|
||||
import com.yizhuan.erban.home.dialog.ProtocolUpdateDialog;
|
||||
import com.yizhuan.erban.flutter.RouterConstants;
|
||||
import com.yizhuan.erban.home.fragment.ContactsListFragment;
|
||||
import com.yizhuan.erban.home.fragment.GameFragment;
|
||||
@@ -117,6 +118,7 @@ import com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel;
|
||||
import com.yizhuan.xchat_android_core.community.attachment.DynamicSysAttachment;
|
||||
import com.yizhuan.xchat_android_core.community.event.SquareTaskEvent;
|
||||
import com.yizhuan.xchat_android_core.community.event.UnReadCountEvent;
|
||||
import com.yizhuan.xchat_android_core.user.bean.ProtocolInfo;
|
||||
import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment;
|
||||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||||
import com.yizhuan.xchat_android_core.home.model.HomeModel;
|
||||
@@ -192,6 +194,7 @@ import java.util.List;
|
||||
import io.flutter.embedding.android.FlutterFragment;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
import static com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel.KEY_FLAG_VALID_CHANNEL_PAGE;
|
||||
|
||||
@@ -848,6 +851,8 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
handleChannelPageInfo();
|
||||
|
||||
checkProtocolUpdate();
|
||||
|
||||
// 互动消息未读数量
|
||||
HomeModel.get().getUnreadCount(AuthModel.get().getCurrentUid())
|
||||
.compose(bindToLifecycle())
|
||||
@@ -859,6 +864,22 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void checkProtocolUpdate() {
|
||||
UserModel.get()
|
||||
.getProtocolInfo()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(protocolInfo -> {
|
||||
int version = (int) SharedPreferenceUtils.get(ProtocolUpdateDialog.SP_KEY, 0);
|
||||
//第一次打开APP不弹,因为闪屏页已经弹了!
|
||||
if (version == 0) {
|
||||
SharedPreferenceUtils.put(ProtocolUpdateDialog.SP_KEY, protocolInfo.getVer());
|
||||
} else if (version < protocolInfo.getVer()) {
|
||||
new ProtocolUpdateDialog(MainActivity.this, protocolInfo).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//闪屏→linkedme→渠道指定房间→邀请码
|
||||
@SuppressLint("CheckResult")
|
||||
private void handleChannelPageInfo() {
|
||||
|
@@ -0,0 +1,104 @@
|
||||
package com.yizhuan.erban.home.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseSdDialog;
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.ui.patriarch.PatriarchModeActivity;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.user.bean.ProtocolInfo;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* 家长模式 提醒框
|
||||
* create by lvzebiao @2019/7/27
|
||||
*/
|
||||
public class ProtocolUpdateDialog extends BaseSdDialog {
|
||||
|
||||
@BindView(R.id.tv_title)
|
||||
TextView tvTitle;
|
||||
@BindView(R.id.tv_content)
|
||||
TextView tvContent;
|
||||
|
||||
@NonNull
|
||||
private final ProtocolInfo protocolInfo;
|
||||
|
||||
public static final String SP_KEY = "ProtocolUpdate";
|
||||
|
||||
public ProtocolUpdateDialog(Context context, @NonNull ProtocolInfo protocolInfo) {
|
||||
super(context);
|
||||
this.protocolInfo = protocolInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.dialog_protocol_update);
|
||||
ButterKnife.bind(this);
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.width = UIUtil.dip2px(getContext(), 300);
|
||||
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
windowParams.dimAmount = 0.5f;
|
||||
windowParams.gravity = Gravity.CENTER;
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
|
||||
tvContent.setText(protocolInfo.getContent());
|
||||
tvTitle.setText(protocolInfo.getTitle());
|
||||
String privacyAgreementTip = protocolInfo.getLinkText();
|
||||
int privacyAgreementTipIndex = protocolInfo.getContent().indexOf(privacyAgreementTip);
|
||||
SpannableString ss = new SpannableString(protocolInfo.getContent());
|
||||
ss.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_7154EE)), privacyAgreementTipIndex, privacyAgreementTipIndex + privacyAgreementTip.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
CommonWebViewActivity.start(getContext(), protocolInfo.getLinkUrl());
|
||||
}
|
||||
}, privacyAgreementTipIndex, privacyAgreementTipIndex + privacyAgreementTip.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
tvContent.setText(ss);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
|
||||
@OnClick({R.id.tv_cancel, R.id.tv_confirm})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.tv_cancel:
|
||||
dismiss();
|
||||
((Activity) context).finish();
|
||||
break;
|
||||
case R.id.tv_confirm:
|
||||
dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
81
app/src/main/res/layout/dialog_protocol_update.xml
Normal file
81
app/src/main/res/layout/dialog_protocol_update.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_white_corner_8dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textStyle="bold"
|
||||
tools:text="用户协议" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="34dp"
|
||||
android:layout_marginTop="@dimen/dp_15"
|
||||
android:layout_marginEnd="34dp"
|
||||
android:lineSpacingExtra="@dimen/dp_5"
|
||||
android:textColor="@color/color_666666"
|
||||
android:textSize="@dimen/sp_13"
|
||||
tools:text="@string/text_dialog_pm_notice" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_common_cancel"
|
||||
android:gravity="center"
|
||||
android:text="不同意"
|
||||
android:textColor="@color/color_7154EE"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_common_confirm_normal_22r"
|
||||
android:gravity="center"
|
||||
android:text="同意"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
@@ -8,6 +8,7 @@ import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.user.bean.GiftAchievementInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.GiftWallInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.NewUserInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.ProtocolInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserDetailInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserGameInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
@@ -220,4 +221,5 @@ public interface IUserModel extends IModel {
|
||||
@Nullable
|
||||
String getPreFillInviteCode();
|
||||
|
||||
Single<ProtocolInfo> getProtocolInfo();
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.yizhuan.xchat_android_core.noble.NobleUtil;
|
||||
import com.yizhuan.xchat_android_core.user.bean.GiftAchievementInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.GiftWallInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.NewUserInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.ProtocolInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserDetailInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserGameInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
@@ -792,6 +793,14 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
return preFillInviteCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<ProtocolInfo> getProtocolInfo() {
|
||||
return api.getProtocolInfo()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
|
||||
private interface Api {
|
||||
/**
|
||||
* 获取某个用户的用户信息
|
||||
@@ -1003,5 +1012,14 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
*/
|
||||
@GET("user/gold/give/recent")
|
||||
Single<ServiceResult<List<UserInfo>>> getGiveUserList();
|
||||
|
||||
|
||||
/**
|
||||
* 用户协议更新弹窗
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("/user/latestPrivacyPolicy")
|
||||
Single<ServiceResult<ProtocolInfo>> getProtocolInfo();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package com.yizhuan.xchat_android_core.user.bean
|
||||
|
||||
data class ProtocolInfo(
|
||||
val content: String = "",
|
||||
val linkText: String = "",
|
||||
val linkUrl: String = "",
|
||||
val title: String = "",
|
||||
val ver: Int = 0
|
||||
)
|
@@ -54,7 +54,7 @@ public class SharedPreferenceUtils {
|
||||
} else if (defaultValue instanceof Long) {
|
||||
return preferences.getLong(key, (Long) defaultValue);
|
||||
}
|
||||
return null;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static void put(String key, Object value) {
|
||||
|
Reference in New Issue
Block a user