Commit 00a90f23 by 刘鹏

Merge branch 'feat/wjy/合规' into 'd/v4.4.08'

Feat/wjy/合规

See merge request app_android_lib/YDL-Component!335
parents 218bbcc6 e5b75397
package com.yidianling.consultant.adapter
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Typeface
import android.text.SpannableStringBuilder
......@@ -19,10 +20,11 @@ import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.consultant.IExpertSearchView
import com.yidianling.consultant.R
import com.yidianling.consultant.constants.ConsultBIConstants
......@@ -30,6 +32,7 @@ import com.yidianling.consultant.listener.OnExpertClickListener
import com.yidianling.consultant.model.bean.ExpertServiceItem
import com.yidianling.consultant.modular.utils.TempH5RouteUtils
import com.yidianling.consultant.router.ConsultantIn
import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.main.consultant_expert_search_feedbackrate.view.*
import kotlinx.android.synthetic.main.consultant_expert_search_header_view.view.*
import kotlinx.android.synthetic.main.consultant_expert_search_item_view.view.*
......@@ -581,6 +584,18 @@ class ExpertSearchAdapter(
if (!TextUtils.isEmpty(doctor.uid)) {
val userService = findRouteService(IUserService::class.java)
if (!userService.isBindPhone() && context is Activity) {
CommonDialog(context)
.setMessage("为了及时接收消息通知,请立即绑定手机")
.setLeftOnclick("忍痛放弃") {}
.setRightClick("果断绑定") {
userService.wxBindToInputhonePage(context) // 跳转绑定手机号页面
}
.setCancelAble(false)
.show()
return@setOnClickListener
}
//跳转私聊
ConsultantIn.startP2PSession(context as AppCompatActivity, doctor.uid!!)
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_PRIVATE_CHAT_CLICK)
......
......@@ -32,7 +32,7 @@ class CourseListDialog : BaseDialogFragment() {
private lateinit var recycler_list: RecyclerView
override fun getLayoutResourceId(): Int = R.layout.dialog_course_list
override fun getGravity(): Int = Gravity.BOTTOM
override fun setGravity(): Int = Gravity.BOTTOM
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
context?.let { ctx ->
......
......@@ -26,7 +26,7 @@ class CourseSpeedDialog : BaseDialogFragment() {
private lateinit var tv_cancel: TextView
override fun getLayoutResourceId(): Int = R.layout.dialog_course_speed
override fun getGravity(): Int = Gravity.BOTTOM
override fun setGravity(): Int = Gravity.BOTTOM
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
context?.let {
......
......@@ -20,11 +20,11 @@ public class MemberFragment extends DynamicFragment {
private View view;
private Context context;
private TextView member_age_tv,member_emotional_state_tv,member_job_tv,member_address_tv,member_introduction_tv;
private TextView member_age_tv,member_emotional_state_tv,member_job_tv,member_address_tv,member_introduction_tv,member_ip_tv;
String age,emotional_state,job,address,introduction;
String age,emotional_state,job,address,introduction,ipProvince;
public static MemberFragment newInstance(String age, String emotional_state, String job, String address, String introduction){
public static MemberFragment newInstance(String age, String emotional_state, String job, String address, String introduction, String ipProvince){
MemberFragment memberFragment=new MemberFragment();
Bundle args = new Bundle();
args.putString("age", age);
......@@ -32,6 +32,7 @@ public class MemberFragment extends DynamicFragment {
args.putString("job", job);
args.putString("address", address);
args.putString("introduction", introduction);
args.putString("ipProvince", ipProvince);
memberFragment.setArguments(args);
return memberFragment;
}
......@@ -46,18 +47,21 @@ public class MemberFragment extends DynamicFragment {
member_job_tv=(TextView)view.findViewById(R.id.member_job_tv);
member_address_tv=(TextView)view.findViewById(R.id.member_address_tv);
member_introduction_tv=(TextView)view.findViewById(R.id.member_introduction_tv);
member_ip_tv = view.findViewById(R.id.member_ip_tv);
age=getArguments().getString("age");
emotional_state=getArguments().getString("emotional_state");
job=getArguments().getString("job");
address=getArguments().getString("address");
introduction=getArguments().getString("introduction");
ipProvince=getArguments().getString("ipProvince");
member_age_tv.setText(age);
member_emotional_state_tv.setText(emotional_state);
member_job_tv.setText(job);
member_address_tv.setText(address);
member_introduction_tv.setText(introduction);
member_ip_tv.setText(ipProvince);
return view;
}
}
......@@ -24,7 +24,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.alibaba.android.arouter.launcher.ARouter;
import com.google.gson.internal.LinkedTreeMap;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseActivity;
......@@ -83,7 +83,7 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
List<String> reportReasons;//举报内容列表
private FragmentManager fragmentManager;
String age, emotional_state, job, address, introduction;
String age, emotional_state, job, address, introduction, ipProvince;
String focus_state;//关注状态
boolean zan_state;
......@@ -239,6 +239,7 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
job = person.profession;
address = person.address;
introduction = person.description;
ipProvince = person.ipProvince;
String bg = person.bg;
GlideApp.with(MembersActivity.this)
.load(head)
......@@ -477,12 +478,13 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
private void RightSet() {
final List<String> dialog_datas = new ArrayList<String>();
if (shielding == false) {
if (!shielding) {
dialog_datas.add("屏蔽ta");
} else {
dialog_datas.add("解除屏蔽");
}
dialog_datas.add("举报");
dialog_datas.add("投诉与反馈");
int itemTextColor = getResources().getColor(R.color.dynamic_black);
ListDialog.Builder builder1 = new ListDialog.Builder(MembersActivity.this, dialog_datas, itemTextColor);
builder1.SetLastStr("取消");
......@@ -495,19 +497,20 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
builder1.SetOnItemClickLister(new ListDialog.Builder.OnItemClickLister() {
@Override
public void onItemClick(Dialog dialog, View view, int position) {
if (dialog_datas.size() == 2) {//不含取消关注
switch (position) {
case 0:
if (shielding == false) {
shieldHint();
} else {
RemoveShielding();
}
break;
case 1:
report();
break;
}
switch (position) {
case 0:
if (!shielding) {
shieldHint();
} else {
RemoveShielding();
}
break;
case 1:
report();
break;
case 2:
ARouter.getInstance().build("/mine/FeedBackActivity").navigation();
break;
}
dialog.dismiss();
}
......@@ -728,7 +731,7 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
members_information_tv.setTextColor(getResources().getColor(R.color.platform_main_theme));
members_information_hint_tv.setBackgroundColor(getResources().getColor(R.color.platform_main_theme));
if (memberfragment == null) {
memberfragment = MemberFragment.newInstance(age, emotional_state, job, address, introduction);
memberfragment = MemberFragment.newInstance(age, emotional_state, job, address, introduction, ipProvince);
transaction.add(R.id.members_content_frm, memberfragment);
} else {
transaction.show(memberfragment);
......
......@@ -35,6 +35,7 @@ public class CommentBean {
private ShareData share_data;
private int isAvailable; //是否空闲 0-否 1-是
private int isOpenListen; //是否开通倾诉 0-否 1-是
private String ipProvince;
private String listenLinkUrl; //统一路由url
......@@ -52,6 +53,14 @@ public class CommentBean {
return isOpenListen;
}
public String getIpProvince() {
return ipProvince;
}
public void setIpProvince(String ipProvince) {
this.ipProvince = ipProvince;
}
public ShareData getShare_data() {
return share_data;
}
......
......@@ -24,5 +24,7 @@ public class MemberInfoBean {
public String description;
public String address;
public String bg;
public String ipProvince;
}
}
......@@ -76,6 +76,7 @@ public class TrendsDetailInfoBean {
public String uid;
public String multitextType;//动态类型
public ExtAd ext;
public String ipProvince;
}
//图片
......
......@@ -948,6 +948,7 @@ public class TrendsDetailActivity extends BaseMvpActivity<ITrendsDetailView, ITr
holder.setHeadImageWithUrl(R.id.item_recommend_trend_user_head_iv, data.getHeader()); //头像
holder.setText(R.id.text_userName, data.getName()); //用户名
holder.setText(R.id.text_time, data.getTime_str()); //发布时间
holder.setText(R.id.tv_ip, "IP属地: " + data.getIpProvince()); // IP属地
holder.setImageResource(R.id.img_comment_sex, data.getGender() == 1 ? R.drawable.dynamic_male : R.drawable.dynamic_female);
holder.setImageResource(R.id.img_comment_zan, data.getIs_zan() == 1 ? R.drawable.dynamic_reply_zan_sel : R.drawable.dynamic_reply_zan);
showCommentItemContent(holder, data);
......@@ -1406,6 +1407,7 @@ public class TrendsDetailActivity extends BaseMvpActivity<ITrendsDetailView, ITr
return commentCount > commentListAdapter.getDatas().size();
}
@SuppressLint("SetTextI18n")
private void fillContent() {
linComment.setVisibility(VISIBLE);
linContent.setVisibility(View.VISIBLE);
......@@ -1420,8 +1422,8 @@ public class TrendsDetailActivity extends BaseMvpActivity<ITrendsDetailView, ITr
tvContent.setVisibility(View.GONE);
}
tvUserName.setText(mTrendBody.name);
tvTime.setText(mTrendBody.timeStr + "-"); //发布时间
tvFrom.setText(mTrendBody.from); //来源
tvTime.setText(mTrendBody.timeStr); //发布时间
tvFrom.setText("IP属地: " + mTrendBody.ipProvince); // IP属地
if (TextUtils.isEmpty(mTrendBody.title)) {
tvTrendInfoTitle.setVisibility(GONE);
......
......@@ -309,15 +309,15 @@
android:layout_weight="1">
<TextView
android:id="@+id/members_information_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="个人资料"
android:textColor="@color/dynamic_text_gray"
android:textSize="18sp" />
android:id="@+id/members_information_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="个人资料"
android:textColor="@color/dynamic_text_gray"
android:textSize="18sp" />
<TextView
android:id="@+id/members_information_hint_tv"
......
......@@ -61,6 +61,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:visibility="visible"
android:visibility="gone">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
......@@ -148,7 +149,6 @@
</RelativeLayout>
<TextView
android:id="@+id/text_time"
android:layout_width="wrap_content"
......@@ -166,11 +166,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_userName_rel"
android:layout_marginStart="10dp"
android:layout_marginTop="7dp"
android:layout_toRightOf="@id/text_time"
android:textColor="@color/dynamic_text_trend_defult"
android:textSize="12sp"
tools:text=" - 来自安卓客户端" />
tools:text="IP属地: XX" />
<TextView
android:id="@+id/text_guanzhu"
......@@ -498,6 +499,7 @@
<com.ydl.ydlcommon.ui.LogoLoadingView
android:id="@+id/v_loading"
tools:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
......
......@@ -114,4 +114,25 @@
android:text=""
android:textSize="18sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/dynamic_black"
android:text="IP属地"
android:textSize="18sp"
android:layout_marginRight="15dp"/>
<TextView
android:id="@+id/member_ip_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/dynamic_black"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
......@@ -112,6 +112,17 @@
tools:text="23分钟前" />
<TextView
android:id="@+id/tv_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/color_9d9ea7"
android:layout_toEndOf="@id/text_time"
android:layout_marginStart="10dp"
android:textSize="12sp"
android:layout_alignBaseline="@id/text_time"
tools:text="IP属地: XX"/>
<TextView
android:id="@+id/text_chat"
android:layout_width="60dp"
android:layout_height="30dp"
......
......@@ -9,15 +9,18 @@ import android.widget.FrameLayout
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.StringUtils
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.home.R
import com.yidianling.home.constants.HomeBIConstants
import com.yidianling.home.event.IHomeBaseEvent
import com.yidianling.home.model.bean.HomeConsultBean
import com.yidianling.user.api.service.IUserService
import kotlinx.android.synthetic.ydl.home_consult_item_view.view.*
/**
......@@ -72,7 +75,6 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
)*/
//补充点击事件埋点
ActionCountUtils.count(HomeBIConstants.YDL_USER_EXPERT_INTRODUCTION_CLICK, bean.uid.toString())
val url = URLUtils.appendParmas(bean.linkUrl,"cateId",cateId)
ModularServiceManager.provide(IConsultantService::class.java).dueToTypeJumpAutoOrGuide(
mContext as Activity,
11,
......@@ -134,6 +136,18 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
*/
private fun setConfideButton(bodyBean: HomeConsultBean.ListBean) {
tv_consult_chat.setOnClickListener {
val userService = findRouteService(IUserService::class.java)
if (!userService.isBindPhone() && context is Activity) {
CommonDialog(context)
.setMessage("为了及时接收消息通知,请立即绑定手机")
.setLeftOnclick("忍痛放弃") {}
.setRightClick("果断绑定") {
userService.wxBindToInputhonePage(context as Activity) // 跳转绑定手机号页面
}
.setCancelAble(false)
.show()
return@setOnClickListener
}
ModularServiceManager.provide(IConsultantService::class.java).dueToTypeJumpAutoOrGuide(
mContext as Activity,
11,
......
......@@ -17,8 +17,8 @@
android:id="@+id/tv_consult_chat"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/img_consult_head"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/platform_dp_13"
android:layout_marginEnd="@dimen/platform_dp_15"
android:background="@drawable/home_consult_chat_bg"
......
......@@ -15,7 +15,6 @@ import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.ListNoCancelDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.param.RmHistoryParam
import com.yidianling.im.api.param.RmTalkParam
import com.yidianling.im.api.param.TopMessageParam
......@@ -24,15 +23,11 @@ import com.yidianling.im.event.UpdateTabUnreadNumEvent
import com.yidianling.im.helper.IMChatUtil
import com.yidianling.im.helper.MsgReceiveHelper
import com.yidianling.im.http.ImHttpImpl
import com.yidianling.im.router.ImIn
import com.yidianling.im.session.SessionHelper
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import com.yidianling.im.ui.page.fragment.bean.ChatModelBean
import com.yidianling.im.ui.page.fragment.view.ChatItemView
import com.yidianling.im.ui.page.fragment.view.ChatTimeItemView
import com.yidianling.im.ui.param.ChatParam
import de.greenrobot.event.EventBus
import kotlinx.android.synthetic.main.im_chat_fragment_layout.*
/**
* 互动列表适配器
......@@ -94,7 +89,7 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
name.add("标记为已读")
}
val builder = ListNoCancelDialog.Builder(context, name, 0)
builder.SetOnItemClickLister(object : ListNoCancelDialog.Builder.OnItemClickLister {
builder.setOnItemClickLister(object : ListNoCancelDialog.Builder.OnItemClickLister {
override fun onItemClick(dialog: Dialog, view: View, position1: Int) {
val tag = name[position1]
when (tag) {
......
package com.ydl.js
import android.app.Activity
import android.content.Context
import android.webkit.JavascriptInterface
import androidx.fragment.app.FragmentActivity
import com.google.gson.Gson
......@@ -18,6 +20,7 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil
import com.yidianling.user.api.service.IUserService
......@@ -56,14 +59,15 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
wvEnventPro?.jumpLogin(jsData.cmd?.params)
return
}
val userService = findRouteService(IUserService::class.java)
if (jsData.url.equals("http")) {
if (jsData.cmd?.params?.toUid != 0) {
wvEnventPro?.chat(
findRouteService(IUserService::class.java).getUserInfo()?.uid?.toInt() ?: 0,
userService.getUserInfo()?.uid?.toInt() ?: 0,
jsData.cmd?.params?.toUid ?: 0,
0,
findRouteService(IUserService::class.java).getUserInfo()?.accessToken,
userService.getUserInfo()?.accessToken,
jsData.cmd?.params?.isFromQingShu ?: 0,
jsData.cmd?.params?.closeReplaceChat ?: false
)
......@@ -72,11 +76,11 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
}
} else if (jsData.url.equals("ydl_app")) {
wvEnventPro?.ydlNative(jsData.cmd)
jumpAction(jsData)
jumpAction(jsData, userService)
}
}
fun jumpAction(jsData: H5JsBean) {
private fun jumpAction(jsData: H5JsBean, userService: IUserService) {
LogUtil.d("jumpAction")
when (jsData.cmd!!.action_name) {
"fm" -> if (jsData.cmd!!.params!!.id > 0) {
......@@ -126,23 +130,24 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"chat" ->
//私聊
if (wvEnventPro != null) {
wvEnventPro?.chat(findRouteService(IUserService::class.java).getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid, 0,
JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu,
jsData.cmd!!.params!!.closeReplaceChat
wvEnventPro.chat(userService.getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid, 0,
JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu,
jsData.cmd!!.params!!.closeReplaceChat
)
// 埋点
ActionCountUtils.count("ydl_user_main_page|private_chat_click")
}
"chat_send_message" ->
"chat_send_message" -> {
//跳转私聊:并发送消息
if (wvEnventPro != null) {
wvEnventPro!!.chatSendMessage(findRouteService(IUserService::class.java).getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid,
0, JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu)
}
wvEnventPro?.chatSendMessage(
userService.getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid,
0, JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu
)
}
"chat_team" ->
//群聊
if (wvEnventPro != null) {
......@@ -169,7 +174,7 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"set_time_warn" ->
//提醒专家设置时间
if (wvEnventPro != null) {
wvEnventPro!!.sendSubscriptionTimeMessage("" + jsData.cmd?.params?.toUid)
wvEnventPro.sendSubscriptionTimeMessage("" + jsData.cmd?.params?.toUid)
}
"user_home" -> if (wvEnventPro != null) {
wvEnventPro!!.openMember("" + jsData.cmd?.params?.uid)
......@@ -507,4 +512,5 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
}
}
}
......@@ -39,6 +39,8 @@ import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlinx.android.synthetic.main.activity_play_meditation.iv_close
import kotlinx.android.synthetic.main.activity_play_meditation.tv_title
import kotlinx.android.synthetic.main.player_control_view.*
import java.util.*
import java.util.concurrent.TimeUnit
......
......@@ -32,10 +32,6 @@
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".ui.FillInfoActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".safePrivate.CheckPasswordActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
......@@ -126,19 +122,19 @@
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".mine.PersonalDesActivity"
android:name=".mine.PersonalInfoActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".mine.PersonalInfoActivity"
android:name=".mine.RechargeActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".mine.RechargeActivity"
android:name=".mine.ModifyInfoActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
android:name=".mine.SetInfoActivity"
android:name=".mine.ModifyAvatarActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<activity
......
......@@ -7,9 +7,11 @@ import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.bean.CollectFocusItemBean
import com.yidianling.user.http.LoginApiRequestUtil.Companion.LOGIN_USER_PORT
import com.yidianling.user.http.request.UserModifyAuditRespDto
import com.yidianling.user.http.response.*
import com.yidianling.user.mine.bean.RedPacketId
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*
......@@ -67,16 +69,6 @@ interface UserApi {
@POST("user/set-info")
fun setUserInfo(@FieldMap params: Map<String, String>): Observable<BaseResponse<Any>>
//上传头像
@Multipart
@POST("user/set-info")
fun uploadHeadImg(@PartMap params: MutableMap<String, RequestBody>): Observable<BaseResponse<Any>>
//上传头像
@Multipart
@POST("user/set-info")
fun uploadHeadImg(@Part("type") param: RequestBody): Observable<BaseResponse<Any>>
//验证账号密码
@FormUrlEncoded
@POST("user/chkin-pass")
......@@ -251,4 +243,27 @@ interface UserApi {
@POST("login/v2/is_need_strong_bind")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_LOGIN_BASE_URL, LOGIN_USER_PORT)
fun isNeedForceBindPhone(@Body map: Map<String,String>): Observable<BaseAPIResponse<Boolean>>
/**
* 修改昵称、头像、简介等基本信息
*/
@POST("user/v1/baseInfo/modify")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun modifyUserBaseInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<Boolean>>
/**
* 获取用户审核信息
*/
@POST("user/v1/getUserAuditInfo")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getUserAuditInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
/**
* 上传图片
*/
@Multipart
@POST("file/upload")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun uploadFile(@Part file: MultipartBody.Part): Observable<BaseAPIResponse<String>>
}
\ No newline at end of file
......@@ -9,15 +9,11 @@ import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.bean.CheckPhonePassBean
import com.yidianling.user.bean.CollectFocusItemBean
import com.yidianling.user.http.request.*
import com.yidianling.user.http.response.CheckPassword
import com.yidianling.user.http.response.CountryResponse
import com.yidianling.user.http.response.ExistResponse
import com.yidianling.user.http.response.SecretResponse
import com.yidianling.user.mine.bean.RedPackDataForRegister
import com.yidianling.user.http.response.*
import com.yidianling.user.mine.bean.RedPacketId
import com.yidianling.user.mine.bean.RedPacketIdCmd
import com.yidianling.user.http.response.*
import io.reactivex.Observable
import java.io.File
/**
* author : Zhangwenchao
......@@ -46,8 +42,6 @@ interface UserHttp {
fun setUserInfo(param: UserInfoParam): Observable<BaseResponse<Any>>
fun uploadHead(param: HeadParam): Observable<BaseResponse<Any>>
fun checkPhonePass(cmd: CheckPhonePassBean): Observable<BaseResponse<CheckPassword>>
fun bindQQ(param: BindQQ): Observable<BaseResponse<Any>>
......@@ -84,4 +78,10 @@ interface UserHttp {
/**用户注销账号*/
fun accountLogOff(param: UserForbidLoginParam):Observable<BaseAPIResponse<Boolean>>
fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>>
fun getUserAuditInfo(type: BaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>>
}
\ No newline at end of file
......@@ -4,16 +4,11 @@ import android.app.Activity
import com.google.gson.Gson
import com.google.gson.internal.LinkedTreeMap
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseCommand
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.user.UserHelper
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.bean.CheckPhonePassBean
import com.yidianling.user.bean.CollectFocusItemBean
......@@ -21,14 +16,14 @@ import com.yidianling.user.http.request.*
import com.yidianling.user.http.response.CheckPassword
import com.yidianling.user.http.response.CountryResponse
import com.yidianling.user.http.response.ExistResponse
import com.yidianling.user.http.response.SecretResponse
import com.yidianling.user.mine.bean.RedPacketId
import com.yidianling.user.mine.bean.RedPacketIdCmd
import com.yidianling.user.rxlogin.LoginObservable
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import java.io.File
/**
* author : Zhangwenchao
......@@ -117,49 +112,40 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().setUserInfo(it) }
}
//验证账号密码
override fun checkPhonePass(cmd: CheckPhonePassBean): Observable<BaseResponse<CheckPassword>> {
return RxUtils.mapObservable(cmd)
.flatMap { getUserApi().checkPhonePass(it) }
override fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().modifyUserBaseInfo(it) }
}
override fun getUserAuditInfo(type: BaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
return RxUtils.mapObservable(type)
.flatMap { getUserApi().getUserAuditInfo(it) }
}
override fun uploadHead(param: HeadParam): Observable<BaseResponse<Any>> {
return Observable.just(param)
override fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>> {
return Observable.just(true)
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.map {
val map = HashMap<String, RequestBody>()
val mediaType = MediaType.parse("text/plain")
map["type"] = RequestBody.create(mediaType, it.type)
map["value"] = RequestBody.create(mediaType, it.value)
map["ffrom"] = RequestBody.create(mediaType, YdlCommonOut.getChannelName())
map["isFromApp"] = RequestBody.create(mediaType, "1")
map["osBuild"] = RequestBody.create(
mediaType,
"""${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()},${
RxAppTool.getAppVersionName(
BaseApp.getApp()
)
}"""
)
map["ts"] =
RequestBody.create(mediaType, (System.currentTimeMillis() / 1000).toString())
map["version"] =
RequestBody.create(mediaType, RxAppTool.getAppVersionName(BaseApp.getApp()))
val userInfo = UserHelper.getUserInfo()
if (userInfo != null) {
map["uid"] = RequestBody.create(mediaType, userInfo.uid)
map["accessToken"] = RequestBody.create(mediaType, userInfo.accessToken)
}
val fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), it.file)
map.put("""head"; filename="${it.file.name}""", fileBody)
map
}
.flatMap {
getUserApi().uploadHeadImg(it)
getUserApi().uploadFile(
MultipartBody.Part.createFormData(
"file", file.name,
RequestBody.create(MediaType.parse("multipart/form-data"), file)
)
)
}.flatMap {
if (it.code == "200")
modifyUserBaseInfo(ModifyBaseInfo(it.data, 102))
else
Observable.just(BaseAPIResponse())
}
}
//验证账号密码
override fun checkPhonePass(cmd: CheckPhonePassBean): Observable<BaseResponse<CheckPassword>> {
return RxUtils.mapObservable(cmd)
.flatMap { getUserApi().checkPhonePass(it) }
}
override fun bindQQ(param: BindQQ): Observable<BaseResponse<Any>> {
return RxUtils.mapObservable(param)
.flatMap { getUserApi().bindQQ(it) }
......
package com.yidianling.user.http.request
data class ModifyBaseInfo(val modifyValue: String?,
val type: Int // 101:用户昵称 102:用户头像 103:用户简介
)
data class BaseInfo(val type: Int)
\ No newline at end of file
package com.yidianling.user.http.request
import com.ydl.ydlcommon.data.http.BaseCommand
data class UserModifyAuditRespDto(
val auditReason: String?, // 审核原因
val auditStatus: Int, // 审核状态 1:审核中,2:审核失败,3:已审核 || 提交审核
val auditTime: String?, // 审核时间
val auditor: String?, // 审核人
val auditorId: String?, // 审核人id
val createTime: String?, // 申请时间
val id: Int,
val last7Day: Boolean, // 最近7天申请修改
val modifyAfter: String?, // 变更后
val modifyBefore: String?, // 变更前
val modifyField: String? // 变更字段
) : BaseCommand()
\ No newline at end of file
package com.yidianling.user.mine
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import com.ydl.ydlcommon.base.BaseDialogFragment
import com.yidianling.user.R
/**
* 修改头像dialog
*/
class AvaterDialog : BaseDialogFragment() {
override fun getLayoutResourceId(): Int = R.layout.dialog_album_photo
override fun setGravity(): Int = Gravity.BOTTOM
lateinit var listener: (Int, DialogFragment) -> Unit
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val tv_album = view.findViewById<TextView>(R.id.tv_album)
tv_album.setOnClickListener {
listener.invoke(0, this)
}
val tv_photo = view.findViewById<TextView>(R.id.tv_photo)
tv_photo.setOnClickListener {
listener.invoke(1, this)
}
val tv_cancel = view.findViewById<TextView>(R.id.tv_cancel)
tv_cancel.setOnClickListener {
listener.invoke(2, this)
}
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@ class ChooseAccountActivity : BaseActivity() {
list.add("编辑")
list.add("删除")
val builder = ListNoCancelDialog.Builder(this, list, 0)
builder.SetOnItemClickLister(object : ListNoCancelDialog.Builder.OnItemClickLister {
builder.setOnItemClickLister(object : ListNoCancelDialog.Builder.OnItemClickLister {
override fun onItemClick(dialog: Dialog?, view: View?, index: Int) {
val name = list[index]
when (name) {
......
......@@ -59,8 +59,8 @@ class FeedBackActivity : BaseActivity(), View.OnClickListener {
private var isPhoneNull = true
private var imgFiles: MutableList<File>? = null
internal var work_time = if (PlatformDataManager.getRam().getGlobalInfo() == null) "早8:30-凌晨2:00" else PlatformDataManager.getRam().getGlobalInfo()?.info?.work_time
internal var tel = if (PlatformDataManager.getRam().getGlobalInfo() == null) "400-765-1010" else PlatformDataManager.getRam().getGlobalInfo()?.info?.tel
private var work_time = if (PlatformDataManager.getRam().getGlobalInfo() == null) "早8:30-凌晨2:00" else PlatformDataManager.getRam().getGlobalInfo()?.info?.work_time
private var tel = if (PlatformDataManager.getRam().getGlobalInfo() == null) "400-765-1010" else PlatformDataManager.getRam().getGlobalInfo()?.info?.tel
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(true, true)
}
......
......@@ -29,7 +29,6 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils.Companion.count
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.ydl.ydlcommon.view.dialog.YDLShareDialog.Companion.style4
import com.yidianling.dynamic.api.IDynamicService
import com.yidianling.im.api.service.IImService
import com.yidianling.im.message.param.MsgListParam
import com.yidianling.user.BuildConfig
import com.yidianling.user.R
......@@ -324,7 +323,7 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
.compose(resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { response: UserResponseBean ->
.subscribe({ response: UserResponseBean ->
swipe_refresh_layout.isRefreshing = false
try {
//此处后端返回信息,只有userinfo,其它数据为空,切勿整体赋值
......@@ -625,30 +624,14 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
mShareDialog?.show(activity?.fragmentManager, "lose")
}
/**
* 收到照片选取事件
*/
fun onEventBackgroundThread(event: UserResponseBean?) {
if (event?.userInfo != null) {
userInfoData = event.userInfo
}
}
fun onEvent(event: RefreshRecentContactListEvent?) {
refreshCouponData()
}
fun onEvent(event: UserChangeEvent) {
val changeFlag = event.isChange_flag
if (changeFlag) {
if (event.isChange_flag) {
initdata()
refreshCouponData()
try {
provide(
IImService::class.java
).updateUserHead(getUserInfo()?.userInfo?.head)
} catch (e: Exception) {
}
}
}
}
\ No newline at end of file
package com.yidianling.user.mine import android.annotation.SuppressLintimport android.content.Intentimport android.graphics.Bitmapimport android.graphics.BitmapFactoryimport android.hardware.Cameraimport android.net.Uriimport android.os.Buildimport android.provider.MediaStoreimport android.text.Spannableimport android.text.SpannableStringimport android.text.style.ForegroundColorSpanimport android.widget.ImageViewimport android.widget.TextViewimport com.alibaba.android.arouter.launcher.ARouterimport com.bumptech.glide.Glideimport com.hjq.permissions.OnPermissionCallbackimport com.hjq.permissions.Permissionimport com.hjq.permissions.XXPermissionsimport com.ydl.ydlcommon.base.BaseActivityimport com.ydl.ydlcommon.bean.StatusBarOptionsimport com.ydl.ydlcommon.data.http.BaseAPIResponseimport com.ydl.ydlcommon.modular.findRouteServiceimport com.ydl.ydlcommon.utils.FileUtilsimport com.ydl.ydlcommon.utils.extend.visibleimport com.ydl.ydlcommon.view.TitleBarimport com.yidianling.common.tools.ToastUtilimport com.yidianling.im.api.service.IImServiceimport com.yidianling.user.Rimport com.yidianling.user.api.service.IUserServiceimport com.yidianling.user.http.UserHttpImplimport com.yidianling.user.http.request.BaseInfoimport com.yidianling.user.http.request.UserModifyAuditRespDtoimport de.greenrobot.event.EventBusimport io.reactivex.android.schedulers.AndroidSchedulersimport io.reactivex.schedulers.Schedulersimport java.io.Fileimport java.io.IOException class ModifyAvatarActivity : BaseActivity() { override fun getStatusViewOptions(): StatusBarOptions { return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = false).apply { statusColor = "#E6000000" } } private val ALBUM = 0x0 // 相册 private val CAMERA = 0x1 // 照相 private val CROP = 0x2 // 裁剪m private val mAvatarDir = "${FileUtils.getStorageDirectory()}/img/head_img/" // 头像目录 private val mAvatarPath = "${mAvatarDir}avatar_camera.jpg" // 头像 private val mAvatarFile = File(mAvatarPath) // 头像文件 private val mUserInfo = findRouteService(IUserService::class.java).getUserInfo() override fun layoutResId(): Int = R.layout.activity_modify_avatar private lateinit var tip_bar: TitleBar private lateinit var tv_tip1: TextView private lateinit var iv_avatar: ImageView private lateinit var iv_warn: ImageView private lateinit var tv_tip2: TextView private lateinit var tv_modify: TextView private fun findView() { tip_bar = findViewById(R.id.tip_bar) tv_tip1 = findViewById(R.id.tv_tip1) iv_avatar = findViewById(R.id.iv_avatar) iv_warn = findViewById(R.id.iv_warn) tv_tip2 = findViewById(R.id.tv_tip2) tv_modify = findViewById(R.id.tv_modify) } @SuppressLint("SetTextI18n") override fun initDataAndEvent() { findView() tip_bar.setOnLeftTextClick { _, _ -> setResult(RESULT_OK) // 刷新个人资料页 finish() } mUserInfo ?: return mDisposables.add( UserHttpImpl.getInstance() .getUserAuditInfo(BaseInfo(102)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> -> if (response.code != "200") return@subscribe val (auditReason, auditStatus, _, _, _, _, _, last7Day, modifyAfter) = response.data when (auditStatus) { 1 -> { // 审核中 underReview() Glide.with(this) .load(modifyAfter) .into(iv_avatar) } 2 -> { // 审核失败 tv_tip1.text = "七天内可修改一次头像" Glide.with(this) .load(mUserInfo.head) .into(iv_avatar) iv_warn.visible() tv_tip2.text = SpannableString("审核失败,$auditReason。如有疑问联系客服小壹").also { it.setSpan( ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)), it.lastIndexOf("客服"), it.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) } tv_tip2.setOnClickListener { // 客服 ARouter.getInstance().navigation( IImService::class.java ).startKefuChat(this, "", 0, 0) } setModifyAvatar() } 3 -> { // 审核成功 || 提交审核 modifyAfter?.let { mUserInfo.head = it Glide.with(this) .load(it) .error(R.drawable.platform_head_place_hold_pic) .into(iv_avatar) } findRouteService(IImService::class.java).updateUserHead(modifyAfter) // 更新用户头像到云信 EventBus.getDefault().post(UserChangeEvent(true)) // 更新MineFragment if (last7Day) { tv_tip1.text = "抱歉,七天内只能修改一次头像" tv_modify.isEnabled = false tv_modify.setBackgroundResource(R.drawable.bg_c3c4ca_corner_8) } else { tv_tip1.text = "七天内可修改一次头像" setModifyAvatar() } } } }) } private fun setModifyAvatar() { tv_modify.setOnClickListener { requestPermissions { optionDialog() } } } private fun requestPermissions(block: () -> Unit) { if (XXPermissions.isGrantedPermission(this, Permission.CAMERA)) { block.invoke() } else { XXPermissions.with(this) .permission(Permission.CAMERA) .request(object : OnPermissionCallback { override fun onGranted(permissions: MutableList<String>?, all: Boolean) { block.invoke() } override fun onDenied(permissions: MutableList<String>?, never: Boolean) { ToastUtil.toastLong(this@ModifyAvatarActivity, "缺少使用相机和读取存储权限,无法获取图片") } }) } } private fun optionDialog() { showFragment(AvaterDialog().apply { listener = { position, dialog -> val file = File(mAvatarDir) if (!file.exists()) file.mkdirs() when (position) { 0 -> { // 相册 val intent = Intent(Intent.ACTION_PICK, null) intent.setDataAndType( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*" ) this@ModifyAvatarActivity.startActivityForResult(intent, ALBUM) } 1 -> { // 拍照 callCamera() } } dialog.dismiss() } }, "avater") } /** * 调用相机 */ private fun callCamera() { val intent = Intent() packageManager.getLaunchIntentForPackage("com.android.camera")?.run { intent.setPackage("com.android.camera") } intent.action = MediaStore.ACTION_IMAGE_CAPTURE if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { // api 24 intent.putExtra( "android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT ) // 调用前置摄像头 intent.putExtra("autofocus", true) // 自动对焦 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mAvatarFile)) intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()) startActivityForResult(intent, CAMERA) } else { try { mAvatarFile.createNewFile() } catch (e: IOException) { e.printStackTrace() } val uri: Uri = FileUtils.getImageContentUri(this, mAvatarFile) intent.putExtra( "android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT ) // 调用前置摄像头 intent.putExtra("autofocus", true) // 自动对焦 intent.putExtra(MediaStore.EXTRA_OUTPUT, uri) intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()) startActivityForResult(intent, CAMERA) } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (resultCode == RESULT_OK) { when (requestCode) { ALBUM -> { // 相册 data?.let { startPhotoZoom(it.data) } } CAMERA -> { // 拍照 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { // api 24 if (mAvatarFile.exists()) { startPhotoZoom(Uri.fromFile(mAvatarFile)) } } else { startPhotoZoom(FileUtils.getImageContentUri(this, mAvatarFile)) } } CROP -> { mUserInfo ?: return showProgressDialog("保存中...") val path = FileUtils.getPathByUri4kitkat(this, Uri.fromFile(mAvatarFile)) var bitmap = BitmapFactory.decodeFile(path) bitmap = FileUtils.getZoomImage(bitmap, 200.0) val outPutFile = FileUtils.saveBitmap(bitmap, path) mDisposables.add( UserHttpImpl.getInstance().uploadFile(outPutFile) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe { dismissProgressDialog() if (it.code != "200") { ToastUtil.toastShort(it.msg) return@subscribe } ToastUtil.toastShort("头像审核中,预计24小时内审核完成") underReview() iv_avatar.setImageBitmap(bitmap) } ) } } } } /** * 审核中 */ @SuppressLint("SetTextI18n") private fun underReview() { tv_tip1.text = "抱歉,七天内只能修改一次头像" tv_tip2.text = "审核中,预计24小时内审核完成,暂无法修改。" tv_modify.setBackgroundResource(R.drawable.bg_c3c4ca_corner_8) tv_modify.isEnabled = false } /** * 裁剪图片方法实现 */ private fun startPhotoZoom(uri: Uri?) { val intent = Intent("com.android.camera.action.CROP").apply { setDataAndType(uri, "image/*") putExtra("crop", "true") // 设置裁剪 putExtra("scaleUpIfNeeded", true) // 图片拉伸,就不会出现黑框了 //宽高的比例 putExtra("aspectX", 1) putExtra("aspectY", 1) //裁剪图片宽高 putExtra("outputX", 200) putExtra("outputY", 200) } intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mAvatarFile)) intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString())// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败 intent.putExtra("return-data", false)// intent.putExtra("noFaceDetection", false) // 是否需要人脸识别 startActivityForResult(intent, CROP) }}
\ No newline at end of file
package com.yidianling.user.mine
import android.annotation.SuppressLint
import android.text.Editable
import android.text.Spannable
import android.text.SpannableString
import android.text.TextWatcher
import android.text.style.ForegroundColorSpan
import android.util.TypedValue.COMPLEX_UNIT_SP
import android.view.Gravity
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.TextView
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.extend.visible
import com.ydl.ydlcommon.view.DeleteEditTextView
import com.ydl.ydlcommon.view.TitleBar
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService
import com.yidianling.user.R
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.http.UserHttpImpl.Companion.getInstance
import com.yidianling.user.http.request.BaseInfo
import com.yidianling.user.http.request.ModifyBaseInfo
import com.yidianling.user.http.request.UserModifyAuditRespDto
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* 昵称修改
* 简介修改
*/
const val NICKNAME = 1
const val INTRODUCTION = 2
class ModifyInfoActivity : BaseActivity() {
override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = true)
}
private val mShake: Animation by lazy {
AnimationUtils.loadAnimation(this, R.anim.user_mine_shake)
}
private lateinit var det_set_info: DeleteEditTextView
private lateinit var tv_tip1: TextView
private lateinit var tv_tip2: TextView
private lateinit var tb_title_bar: TitleBar
private lateinit var iv_warn: ImageView
override fun layoutResId(): Int = R.layout.activity_modify_info
private fun findView() {
det_set_info = findViewById(R.id.det_set_info)
tv_tip1 = findViewById(R.id.tv_tip1)
tv_tip2 = findViewById(R.id.tv_tip2)
tb_title_bar = findViewById(R.id.tb_title_bar)
iv_warn = findViewById(R.id.iv_warn)
}
@SuppressLint("SetTextI18n")
override fun initDataAndEvent() {
findView()
val from = intent.getIntExtra("from", 0)
val userInfo = findRouteService(IUserService::class.java).getUserInfo()
userInfo ?: return
if (INTRODUCTION == from) {
tb_title_bar.title = "简介"
det_set_info.layoutParams.height = RxImageTool.dp2px(180f)
det_set_info.hint = "一句话介绍下自己"
det_set_info.setShowDelete(false)
det_set_info.setTextSize(COMPLEX_UNIT_SP, 14f)
det_set_info.gravity = Gravity.START
}
tb_title_bar.setOnLeftTextClick { _, _ ->
setResult(RESULT_OK) // 刷新个人资料页
finish()
}
mDisposables.add(
getInstance().getUserAuditInfo(BaseInfo(if (NICKNAME == from) 101 else 103))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
if (response.code != "200") return@subscribe
val (auditReason, auditStatus, _, _, _, _, _, last7Day, modifyAfter) = response.data
if (NICKNAME == from) {
when (auditStatus) {
1 -> { // 审核中
tv_tip1.visible()
tv_tip1.text = "抱歉,七天内只能修改一次昵称"
setCanNotSave()
setEditText(modifyAfter, "昵称审核中,预计24小时内审核完成")
tv_tip2.visible()
tv_tip2.text = "昵称审核中,预计24小时内审核完成,暂无法修改。"
}
2 -> { // 审核失败
tv_tip1.visible()
tv_tip1.text = "七天内可修改一次昵称"
checkNickSaveButton(userInfo)
det_set_info.setText(userInfo.nick_name)
iv_warn.visible()
customerService("审核失败 ,$auditReason。如有疑问联系客服小壹")
}
3 -> { // 审核成功 || 提交审核
modifyAfter?.let { nick ->
userInfo.nick_name = nick
findRouteService(IImService::class.java).updateUserName(nick) // 更新用户昵称到云信
}
if (last7Day) {
tv_tip1.visible()
tv_tip1.text = "抱歉,七天内只能修改一次昵称"
setCanNotSave()
setEditText(modifyAfter, "抱歉,七天内只能修改一次")
} else {
tv_tip1.visible()
tv_tip1.text = "七天内可修改一次昵称"
checkNickSaveButton(userInfo)
det_set_info.setText(modifyAfter)
}
}
}
} else if (INTRODUCTION == from) {
when (auditStatus) {
1 -> { // 审核中
setCanNotSave()
setEditText(modifyAfter, "简介审核中,预计24小时内审核完成")
tv_tip2.visible()
tv_tip2.text = "审核中 预计24小时内审核完成,暂无法修改"
}
2 -> { // 审核失败
setCanSave()
det_set_info.setText(userInfo.description)
iv_warn.visible()
customerService("审核失败,$auditReason。如有疑问联系客服小壹")
}
3 -> { // 审核成功 || 提交审核
modifyAfter?.let {
det_set_info.setText(it)
userInfo.description = it
}
setCanSave()
}
}
}
})
}
/**
* 客服提示
*/
private fun customerService(tip: String) {
tv_tip2.visible()
tv_tip2.text = SpannableString(tip).also {
it.setSpan(
ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)),
it.lastIndexOf("客服"),
it.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
tv_tip2.setOnClickListener { // 客服
ARouter.getInstance().navigation(
IImService::class.java
).startKefuChat(this, "", 0, 0)
}
}
private fun setCanSave() {
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnRightTextClick { _, _ ->
modifyUserBaseInfo(103) {
ToastUtil.toastShort("提交成功,简介审核中,预计24小时内审核完成")
finish()
}
}
}
private fun setCanNotSave() {
tb_title_bar.setRightTextEnable(false)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
}
private fun setEditText(text: String?, tip: String) {
det_set_info.setText(text)
det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setOnClickListener {
ToastUtil.toastShort(tip)
}
}
private fun checkNickSaveButton(userInfo: UserResponseBean.UserInfo) {
tb_title_bar.setOnRightTextClick { _: View?, _: Boolean ->
modifyUserBaseInfo(101) {
ToastUtil.toastShort("提交成功,昵称审核中,预计24小时内审核完成")
finish()
}
}
det_set_info.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (s?.isEmpty() == true || s?.toString() == userInfo.nick_name) {
tb_title_bar.setRightTextEnable(false)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
} else {
tb_title_bar.setRightTextEnable(true)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
}
}
override fun afterTextChanged(s: Editable?) {}
})
}
private fun modifyUserBaseInfo(type: Int, block: () -> Unit) {
mDisposables.add(
getInstance().modifyUserBaseInfo(
ModifyBaseInfo(
det_set_info.text.toString(),
type
)
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.code == "200") block.invoke()
else ToastUtil.toastShort(it.msg)
}
)
}
}
\ No newline at end of file
package com.yidianling.user.mine;
import android.annotation.SuppressLint;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.data.http.RxUtils;
import com.ydl.ydlcommon.data.http.ThrowableConsumer;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.utils.remind.ToastHelper;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.api.service.IImService;
import com.yidianling.user.R;
import com.yidianling.user.UserHelper;
import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl;
import com.yidianling.user.http.request.UserInfoParam;
import org.jetbrains.annotations.NotNull;
import io.reactivex.android.schedulers.AndroidSchedulers;
/**
* 个人资料--个人简介
* Created by hgw on 2017/3/24.
*/
public class PersonalDesActivity extends BaseActivity {
ImageView imageBack;
TextView tvCenterTitle;
TextView textSave;
RelativeLayout relaToolBar;
EditText editDes;
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true);
}
@Override
protected int layoutResId() {
return R.layout.user_mine_activity_personal_des;
}
@Override
protected void initDataAndEvent() {
imageBack = findViewById(R.id.image_back);
tvCenterTitle = findViewById(R.id.tv_center_title);
editDes = findViewById(R.id.edit_des);
textSave = findViewById(R.id.text_save);
imageBack.setOnClickListener(v -> {
finish();
});
textSave.setOnClickListener(v -> {
updateInfo("home_desc", editDes.getText().toString());
});
init();
}
private void init() {
String desc = "";
try {
desc = ModularServiceManager.INSTANCE.provide(IImService.class).getUserInfoDescription();
} catch (Exception e) {}
editDes.setText(desc);
}
@SuppressLint("CheckResult")
private void updateInfo(final String changType, final String value) {
showProgressDialog("保存中");
UserHttp userHttp = UserHttpImpl.Companion.getInstance();
userHttp.setUserInfo(new UserInfoParam(changType, value))
.filter(objectBaseResponse -> changType.equals("home_desc"))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(o -> {
dismissProgressDialog();
UserHelper.INSTANCE.getUserInfo().getUserInfo().setDescription(value);
ToastUtil.toastShort("保存成功");
finish();
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
dismissProgressDialog();
ToastHelper.Companion.show(msg);
}
});
}
}
package com.yidianling.user.mine;
import android.Manifest;
import static com.yidianling.user.mine.ModifyInfoActivityKt.NICKNAME;
import static com.yidianling.user.mine.ModifyInfoActivityKt.INTRODUCTION;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.View;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.bumptech.glide.Glide;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydl_image.transform.GlideCircleTransform;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.data.http.RxUtils;
import com.ydl.ydlcommon.data.http.ThrowableConsumer;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.utils.FileUtils;
import com.ydl.ydlcommon.utils.PopUtils;
import com.ydl.ydlcommon.utils.remind.ToastHelper;
import com.ydl.ydlcommon.view.JumpTextView;
......@@ -36,22 +27,17 @@ import com.ydl.ydlcommon.view.ListNoCancelDialog;
import com.ydl.ydlcommon.view.TitleBar;
import com.ydl.ydlcommon.view.dialog.ListDialog;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.api.service.IImService;
import com.yidianling.user.R;
import com.yidianling.user.UserHelper;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl;
import com.yidianling.user.http.request.HeadParam;
import com.yidianling.user.http.request.UserInfoParam;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.greenrobot.event.EventBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
......@@ -64,13 +50,11 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
@Route(path = "/user/personInfo")
public class PersonalInfoActivity extends BaseActivity implements View.OnClickListener {
public static final int REQUEST_NAME = 1;
private final int AVATAR = 0x0; // 头像
private final int NICK = 0x1; // 昵称
UserResponseBean.UserInfo userInfoData;
private static final int REQUEST_IMAGE = 2;
TitleBar tb_title;
ImageView persion_head_iv;
ImageView person_head_hint_iv;
......@@ -82,23 +66,8 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
JumpTextView jtv_career;
JumpTextView jtv_jianjie;
private ArrayList<String> mSelectPath = new ArrayList<>();
List<String> name = new ArrayList<String>();
DatePickerDialogFragment datePickerDialogFragment = new DatePickerDialogFragment();
private PopupWindow popupWindow;
private Uri imgUri;
private final DatePickerDialogFragment datePickerDialogFragment = new DatePickerDialogFragment();
FileUtils fileUtils;
private String head_dir;//目录
private String head_path;//路径
File head_filec;
private RxPermissions rxPermissions;
public static Intent newIntent(Activity activity) {
return new Intent(activity, PersonalInfoActivity.class);
}
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
......@@ -135,11 +104,10 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
void init() {
rxPermissions = new RxPermissions(this);
tb_title.setRightImageListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow = PopUtils.showMoreItem(PersonalInfoActivity.this,
PopUtils.showMoreItem(PersonalInfoActivity.this,
tb_title.getRootView(),
0,
0);
......@@ -157,13 +125,10 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
}
});
fileUtils = new FileUtils(this);
head_dir = fileUtils.getStorageDirectory() + "/img/head_img/";
}
private void setData() {
if (userInfoData == null || userInfoData == null)
return;
if (userInfoData == null) return;
String head_url = UserHelper.INSTANCE.getUserInfo().getUserInfo().getHead();
GlideApp.with(PersonalInfoActivity.this)
......@@ -196,60 +161,18 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.persion_head_rel) {
rxPermissions.request(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(granted -> {
if (granted) {
List<String> name = new ArrayList<>();
name.add("相册");
name.add("拍照");
ListNoCancelDialog.Builder builders = new ListNoCancelDialog.Builder(PersonalInfoActivity.this, name, 0);
builders.SetOnItemClickLister(new ListNoCancelDialog.Builder.OnItemClickLister() {
@Override
public void onItemClick(Dialog dialog, View view, int position) {
File file_dir = new File(head_dir);
if (file_dir.exists()) {
fileUtils.deleteAllFiles(file_dir);
file_dir.mkdirs();
}
switch (position) {
case 0://相册
Intent intent1 = new Intent(Intent.ACTION_PICK, null);
intent1.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(intent1, 21001);
dialog.dismiss();
break;
case 1://拍照
head_path = head_dir + System.currentTimeMillis() + "hand_carmer.jpg";
showCameraAction(21002, head_path);
dialog.dismiss();
break;
}
}
@Override
public void onItemLongClick(Dialog dialog, View view, int position) {
}
});
if (!PersonalInfoActivity.this.isFinishing()) {
builders.create().show();
}
} else {
ToastUtil.toastLong(this, "缺少使用相机和读取存储权限,无法获取图片");
}
});
if (id == R.id.persion_head_rel) { // 头像
startActivityForResult(new Intent(this, ModifyAvatarActivity.class), AVATAR);
} else if (id == R.id.jtv_nick) {//昵称
Intent intent = new Intent(this, SetInfoActivity.class);
intent.putExtra("mOldString", jtv_nick.getRightText());
intent.putExtra("mTitle", "修改昵称");
startActivityForResult(intent, REQUEST_NAME);
Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", NICKNAME);
startActivityForResult(intent, NICK);
} else if (id == R.id.jtv_sex) {//性别
List<String> sexs = new ArrayList<String>();
sexs.add("男");
sexs.add("女");
ListNoCancelDialog.Builder builder1 = new ListNoCancelDialog.Builder(PersonalInfoActivity.this, sexs, 0);
builder1.SetOnItemClickLister(new ListNoCancelDialog.Builder.OnItemClickLister() {
builder1.setOnItemClickLister(new ListNoCancelDialog.Builder.OnItemClickLister() {
@Override
public void onItemClick(Dialog dialog, View view, int position) {
switch (position) {
......@@ -347,61 +270,10 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
});
builderm.create().show();
} else if (id == R.id.jtv_jianjie) {//个人简介
Intent intent1 = new Intent(this, PersonalDesActivity.class);
startActivity(intent1);
}
}
/**
* 调用系统拍照
*/
private void showCameraAction(int type_code, String file_path) {
File file_dir = new File(head_dir);
if (file_dir.exists()) {
fileUtils.deleteAllFiles(file_dir);
}
file_dir.mkdirs();
head_filec = new File(file_path);
// fileUtils.isFilleExit(head_dir);
// BigHeadFile = new File(file_path);
// try {
// if (BigHeadFile.exists()) {
// BigHeadFile.delete();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
final Intent intent = new Intent();
final Intent intent_camera = getPackageManager()
.getLaunchIntentForPackage("com.android.camera");
if (intent_camera != null) {
intent.setPackage("com.android.camera");
}
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
// Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
/*获取当前系统的android版本号*/
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT); // 调用前置摄像头
intent.putExtra("autofocus", true); // 自动对焦
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(head_filec));
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(intent, type_code);
} else {
try {
head_filec.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Uri uri = fileUtils.getImageContentUri(PersonalInfoActivity.this, new File(file_path));
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT); // 调用前置摄像头
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
intent.putExtra("autofocus", true); // 自动对焦
startActivityForResult(intent, type_code);
Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", INTRODUCTION);
startActivity(intent);
}
}
@Override
......@@ -409,95 +281,22 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 21001:
if (data != null) {
imgUri = data.getData();
startPhotoZoom(data.getData());
}
break;
case 21002:
imgUri = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
if (head_filec.exists()) {
startPhotoZoom(Uri.fromFile(head_filec));
}
} else {
Uri uri = fileUtils.getImageContentUri(PersonalInfoActivity.this, head_filec);
if (uri != null) {
startPhotoZoom(uri);
}
}
break;
case 21003:
if (imgUri != null) {
showProgressDialog("保存中...");
String path = fileUtils.getPathByUri4kitkat(this, imgUri);
Bitmap bitmap = BitmapFactory.decodeFile(path);
bitmap = fileUtils.getZoomImage(bitmap, 200);
try {
File out_file = fileUtils.SaveBitmap(bitmap, path);
uploadImage(out_file.getAbsolutePath(), 1001);
} catch (IOException e) {
e.printStackTrace();
}
imgUri = null;
}
break;
case REQUEST_NAME: {
updateInfo("nickName", SetInfoActivity.getInput(data));
case AVATAR: {
Glide.with(PersonalInfoActivity.this)
.load(userInfoData.getHead())
.override(100, 100)
.transform(new GlideCircleTransform(PersonalInfoActivity.this))
.error(R.drawable.platform_head_place_hold_pic)
.into(persion_head_iv);
}
case NICK: {
jtv_nick.setRightText(userInfoData.getNick_name());
break;
}
}
}
}
/**
* 裁剪图片方法实现
*/
public void startPhotoZoom(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
// 设置裁剪
intent.putExtra("crop", "true");
// 图片拉伸,就不会出现黑框了
intent.putExtra("scaleUpIfNeeded", true);
//宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
//裁剪图片宽高
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 200);
if (imgUri != null) {
// 输出路径
fileUtils.isFilleExit(head_dir);
imgUri = Uri.fromFile(new File(head_dir + System.currentTimeMillis() + "my_head1.jpg"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败
intent.putExtra("return-data", false);
// 是否需要人脸识别
// intent.putExtra("noFaceDetection", false);
startActivityForResult(intent, 21003);
} else {
File bigfile = new File(head_path);
imgUri = Uri.fromFile(bigfile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败
intent.putExtra("return-data", false);
// 是否需要人脸识别
intent.putExtra("noFaceDetection", false);
startActivityForResult(intent, 21003);
}
}
@SuppressLint("CheckResult")
void updateInfo(final String changType, final String value) {
showProgressDialog("保存中...");
......@@ -526,14 +325,6 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
break;
}
break;
case "nickName":
jtv_nick.setRightText(value);
userInfo.setNick_name(value);
//更新用户昵称到云信
try {
ModularServiceManager.INSTANCE.provide(IImService.class).updateUserName(value);
}catch (Exception e) {}
break;
case "profession":
setCareer(Integer.valueOf(value));
userInfo.setProfession(Integer.valueOf(value));
......@@ -550,75 +341,20 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
//封面背景
userInfo.setHome_bg(value);
break;
case "home_desc":
//简介
userInfo.setDescription(value);
break;
}
EventBus.getDefault().post(userInfoData);
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
ToastHelper.Companion.show(msg);
}
});
}
/**
* 上传图片
*/
@SuppressLint("CheckResult")
void uploadImage(final String path, final int requestCode) {
UserHttp userHttp = UserHttpImpl.Companion.getInstance();
userHttp.uploadHead(new HeadParam(new File(path)))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(o -> {
Map map = (Map) o;
String head_url = (String) map.get("url");
userInfoData.setHead(head_url);
// 跟新本地云信数据库信息
try {
ModularServiceManager.INSTANCE.provide(IImService.class).updateUserHead(userInfoData.getHead());
}catch (Exception e) {}
UserResponseBean.UserInfo userInfo = UserHelper.INSTANCE.getUserInfo().getUserInfo();
if (userInfo != null) {
userInfo.setHead(head_url);
// case "home_desc": // 简介
// userInfo.setDescription(value);
// break;
}
UserChangeEvent changeEvent = new UserChangeEvent(true);
EventBus.getDefault().post(changeEvent);
EventBus.getDefault().post(userInfoData);
if (head_url != null && !"".equals(head_url)) {
GlideApp.with(PersonalInfoActivity.this)
.load(userInfoData.getHead())
.override(100, 100)
.transform(new GlideCircleTransform(PersonalInfoActivity.this))
.error(R.drawable.platform_head_place_hold_pic)
.into(persion_head_iv);
} else {
GlideApp.with(PersonalInfoActivity.this)
.load(R.drawable.platform_head_place_hold_pic)
.transform(new GlideCircleTransform(PersonalInfoActivity.this))
.into(persion_head_iv);
}
dismissProgressDialog();
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
ToastHelper.Companion.show(msg);
dismissProgressDialog();
}
});
}
private void setCareer(int select) {
switch (select) {
case 0:
......
package com.yidianling.user.mine;
import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.view.DeleteEditTextView;
import com.ydl.ydlcommon.view.TitleBar;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.R;
import org.jetbrains.annotations.NotNull;
/**
* 短信息填写
* Created by softrice on 15/9/29.
*/
public class SetInfoActivity extends BaseActivity {
public static final String INPUT = "INPUT";
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true);
}
public static Intent getIntent(String input) {
Intent intent = new Intent();
intent.putExtra(INPUT, input);
return intent;
}
public static String getInput(Intent intent) {
if (intent == null) {
return null;
}
return intent.getStringExtra(INPUT);
}
String mTitle;
String mOldString;
DeleteEditTextView det_set_info;
TitleBar tb_title_bar;
Animation shake;
@Override
protected int layoutResId() {
return R.layout.user_mine_activity_set_info;
}
@Override
protected void initDataAndEvent() {
det_set_info = findViewById(R.id.det_set_info);
tb_title_bar = findViewById(R.id.tb_title_bar);
mTitle = getIntent().getStringExtra("mTitle");
mOldString = getIntent().getStringExtra("mOldString");
init();
}
void init() {
shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.user_mine_shake);
tb_title_bar.setTitle(mTitle);
det_set_info.setText(mOldString);
tb_title_bar.setOnRightTextClick(new TitleBar.OnTitleBarTextClick() {
@Override
public void onClick(View view, boolean isActive) {
if (checkInput()) {
ToastUtil.toastShort("保存成功");
setResult(RESULT_OK, getIntent(det_set_info.getText().toString()));
finish();
}
}
});
}
boolean checkInput() {
if (det_set_info.getText().length() == 0) {
ToastUtil.toastShort("请输入昵称");
det_set_info.startAnimation(shake);
return false;
}
if (det_set_info.getText().length() > 6) {
ToastUtil.toastShort("昵称最多6个字哦");
det_set_info.startAnimation(shake);
return false;
}
return true;
}
}
package com.yidianling.user.ui;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.miracle.view.imageeditor.utils.FileUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.webview.RefreshWebEvent;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.data.http.RxUtils;
import com.ydl.ydlcommon.data.http.ThrowableConsumer;
import com.ydl.ydlcommon.utils.ActivityManager;
import com.ydl.ydlcommon.utils.log.LogHelper;
import com.ydl.ydlcommon.utils.remind.ToastHelper;
import com.ydl.ydlcommon.view.CircleImageView;
import com.ydl.ydlcommon.view.ListNoCancelDialog;
import com.ydl.ydlcommon.view.RoundCornerButton;
import com.ydl.ydlcommon.view.TitleBar;
import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.yidianling.common.tools.RxFileTool;
import com.yidianling.common.tools.RxImageTool;
import com.yidianling.user.LoginHelper;
import com.yidianling.user.R;
import com.yidianling.user.UserConstants;
import com.yidianling.user.UserHelper;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.http.UserHttp;
import com.yidianling.user.http.UserHttpImpl;
import com.yidianling.user.http.request.HeadParam;
import com.yidianling.user.http.request.UserInfoParam;
import com.yidianling.user.route.UserIn;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.greenrobot.event.EventBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* 完善信息
* Created by softrice on 15/12/9.
*/
public class FillInfoActivity extends BaseActivity implements View.OnClickListener {
String icon;
String name;
String sex;
int type = 0;//0 normal 1 第三方登录模式
boolean isSelected;//是否上传了头像
TitleBar tb_title;
CircleImageView sdv_head;
TextView tv_sex;
EditText et_nick;
RoundCornerButton rcb_submit;
String head = "";
private int finishNum = 0;
private int gender = -1;
String path;
private Uri imgUri;
// FileUtils fileUtils;
private String head_dir;//目录
private String head_path;//路径
File head_filec;
private RxPermissions rxPermissions;
private boolean isFromSplash;
private boolean isRegisterFromRedPacket;
@Override
protected int layoutResId() {
return R.layout.user_activity_fill_info;
}
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true,true);
}
@Override
protected void initDataAndEvent() {
tb_title = findViewById(R.id.tb_title);
sdv_head = findViewById(R.id.sdv_head);
tv_sex = findViewById(R.id.tv_sex);
et_nick = findViewById(R.id.et_nick);
rcb_submit = findViewById(R.id.rcb_submit);
sdv_head.setOnClickListener(this);
tv_sex.setOnClickListener(this);
rcb_submit.setOnClickListener(this);
icon = getIntent().getStringExtra("icon");
name = getIntent().getStringExtra("name");
sex = getIntent().getStringExtra("sex");
type = getIntent().getIntExtra("type", 0);
isFromSplash = getIntent().getBooleanExtra("isFromSplash", false);
isRegisterFromRedPacket = getIntent().getBooleanExtra(UserConstants.IS_REGISTER_FROM_PACKET, false);
init();
}
void init() {
rxPermissions = new RxPermissions(this);
head_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/yidianling/img/head_img/";
if (!TextUtils.isEmpty(icon)) {
GlideApp.with(FillInfoActivity.this)
.load(icon)
.fitCenter()
.error(R.drawable.user_regist_photo)
.into(sdv_head);
}
if (!TextUtils.isEmpty(name)) {
et_nick.setText(name);
}
if (!TextUtils.isEmpty(sex)) {
if (sex.equals("1")) {
tv_sex.setText("男");
gender = 1;
} else {
tv_sex.setText("女");
gender = 2;
}
}
tb_title.setOnLeftTextClick((view, isActive) -> {
showExitDialog();
});
}
@Override
public void onBackPressed() {
showExitDialog();
}
private void showExitDialog() {
CommonDialog.create(this)
.setTitle("提示")
.setMessage("确定退出完善资料?")
.setLeftOnclick("退出", (view1) -> {
if (isFromSplash) {
UserIn.INSTANCE.mainIntent(this);
ActivityManager.Companion.finishActivity(InputPhoneActivity.class);
ActivityManager.Companion.finishActivity(LoginActivity.class);
finish();
} else if (isRegisterFromRedPacket) {
EventBus.getDefault().post(new RefreshWebEvent());
UserIn.INSTANCE.mainIntent(this);
finish();
} else {
EventBus.getDefault().post(new RefreshWebEvent());
ActivityManager.Companion.finishActivity(InputPhoneActivity.class);
ActivityManager.Companion.finishActivity(LoginActivity.class);
finish();
}
ToastHelper.Companion.show(R.string.platform_register_success);
LogHelper.Companion.getInstance().writeLogSync("完善资料页退出");
})
.setRightClick("继续", (view1 -> {
}))
.show();
}
private static final int REQUEST_CODE_FILL_CAMER_HEAD = 21012;
private static final int IMAGE_PICKER=32001;
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.sdv_head) {
YDLImagePicker.INSTANCE.startPicker(FillInfoActivity.this, new OnResultCallbackListener() {
@Override
public void onResult(List<LocalMedia> list) {
if (list.isEmpty()) {
return;
}
for (int i = 0; i < list.size(); i++) {
uploadImage(list.get(0).getPath(), 1002);
}
}
@Override
public void onCancel() {
}
});
} else if (id == R.id.tv_sex) {
List<String> name = new ArrayList<String>();
name.add("男");
name.add("女");
ListNoCancelDialog.Builder builders = new ListNoCancelDialog.Builder(FillInfoActivity.this, name, 0);
builders.SetOnItemClickLister(new ListNoCancelDialog.Builder.OnItemClickLister() {
@Override
public void onItemClick(Dialog dialog, View view, int position) {
switch (position) {
case 0:
tv_sex.setText("男");
gender = 1;
dialog.dismiss();
break;
case 1:
tv_sex.setText("女");
gender = 2;
dialog.dismiss();
break;
}
}
@Override
public void onItemLongClick(Dialog dialog, View view, int position) {
}
});
builders.create().show();
} else if (id == R.id.rcb_submit) {
if (judge()) {
setInfo();
}
}
}
/**
* 调用系统拍照
*/
private void showCameraAction(int type_code, String file_path) {
File file_dir = new File(head_dir);
if (file_dir.exists()) {
RxFileTool.deleteFilesInDir(file_dir);
}
file_dir.mkdirs();
head_filec = new File(file_path);
final Intent intent = new Intent();
final Intent intent_camera = getPackageManager()
.getLaunchIntentForPackage("com.android.camera");
if (intent_camera != null) {
intent.setPackage("com.android.camera");
}
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT); // 调用前置摄像头
intent.putExtra("autofocus", true); // 自动对焦
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(head_filec));
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(intent, type_code);
} else {
try {
head_filec.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Uri uri = RxFileTool.getImageContentUri(FillInfoActivity.this, new File(file_path));
intent.putExtra("android.intent.extras.CAMERA_FACING", Camera.CameraInfo.CAMERA_FACING_FRONT); // 调用前置摄像头
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
intent.putExtra("autofocus", true); // 自动对焦
startActivityForResult(intent, type_code);
}
}
private void setInfo() {
showProgressDialog("");
updateInfo("gender", gender + "");
}
@Override
protected void onResume() {
super.onResume();
if (LoginHelper.isRegister) {
UserIn.INSTANCE.setChattingAccountAll();
}
}
@Override
protected void onPause() {
super.onPause();
if (LoginHelper.isRegister) {
UserIn.INSTANCE.setChattingAccountNone();
}
}
private void updateInfo(String changType, String value) {
UserHttp userHttp = UserHttpImpl.Companion.getInstance();
userHttp.setUserInfo(new UserInfoParam(changType, value))
.subscribeOn(Schedulers.io())
.compose(RxUtils.resultData())
.flatMap(o->{
return userHttp.setUserInfo(new UserInfoParam("nickName", et_nick.getText().toString()))
.compose(RxUtils.resultData());
})
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(this::dismissProgressDialog)
.subscribe(o -> {
UserResponseBean userInfo = UserHelper.INSTANCE.getUserInfo();
if (userInfo != null) {
userInfo.getUserInfo().setHead(head);
userInfo.getUserInfo().setGender(gender);
userInfo.getUserInfo().setNick_name(et_nick.getText().toString());
}
if (isFromSplash) {
UserIn.INSTANCE.mainIntent(this);
ActivityManager.Companion.finishActivity(InputPhoneActivity.class);
ActivityManager.Companion.finishActivity(LoginActivity.class);
finish();
} else if (isRegisterFromRedPacket) {
EventBus.getDefault().post(new RefreshWebEvent());
UserIn.INSTANCE.mainIntent(this);
finish();
} else {
EventBus.getDefault().post(new RefreshWebEvent());
ActivityManager.Companion.finishActivity(InputPhoneActivity.class);
ActivityManager.Companion.finishActivity(LoginActivity.class);
finish();
}
ToastHelper.Companion.show(R.string.platform_register_success);
LogHelper.Companion.getInstance().writeLogSync("完善资料成功");
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
ToastHelper.Companion.show(msg);
LogHelper.Companion.getInstance().writeLogSync(String.format("完善资料失败%s", msg));
}
});
}
private boolean judge() {
if (!isSelected && TextUtils.isEmpty(icon)) {
ToastHelper.Companion.show("选个头像吧");
return false;
}
if (gender == -1) {
ToastHelper.Companion.show("设置下性别哦");
return false;
}
if (TextUtils.isEmpty(et_nick.getText().toString())) {
ToastHelper.Companion.show("大侠,请留个名");
return false;
}
if (TextUtils.isEmpty(et_nick.getText().toString())) {
ToastHelper.Companion.show("昵称最多5个字哦");
return false;
}
return true;
}
private static final int REQUEST_CODE_CUT = 21003;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_CODE_FILL_CAMER_HEAD:
imgUri = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
if (head_filec.exists()) {
startPhotoZoom(Uri.fromFile(head_filec));
}
} else {
Uri uri = RxFileTool.getImageContentUri(FillInfoActivity.this, head_filec);
if (uri != null) {
startPhotoZoom(uri);
}
}
break;
case REQUEST_CODE_CUT:
if (imgUri != null) {
String path = RxFileTool.getPathFromUri(this, imgUri);
Bitmap bitmap = BitmapFactory.decodeFile(path);
bitmap = RxImageTool.compressByQuality(bitmap, 200);
RxImageTool.save(bitmap, path, Bitmap.CompressFormat.PNG);
File out_file = new File(path);
uploadImage(out_file.getAbsolutePath(), 1002);
imgUri = null;
}
break;
}
}
}
/**
* 裁剪图片方法实现
*/
public void startPhotoZoom(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
// 设置裁剪
intent.putExtra("crop", "true");
// 图片拉伸,就不会出现黑框了
intent.putExtra("scaleUpIfNeeded", true);
//宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
//裁剪图片宽高
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 200);
if (imgUri != null) {
// 输出路径
RxFileTool.isFileExists(head_dir);
imgUri = Uri.fromFile(new File(head_dir + System.currentTimeMillis() + "my_head1.jpg"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败
intent.putExtra("return-data", false);
// 是否需要人脸识别
// intent.putExtra("noFaceDetection", false);
startActivityForResult(intent, REQUEST_CODE_CUT);
} else {
File bigfile = new File(head_path);
imgUri = Uri.fromFile(bigfile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
// return-data=true传递的为缩略图,小米手机默认传递大图,所以会导致onActivityResult调用失败
intent.putExtra("return-data", false);
// 是否需要人脸识别
intent.putExtra("noFaceDetection", false);
startActivityForResult(intent, REQUEST_CODE_CUT);
}
}
/**
* 上传图片
*/
void uploadImage(final String path, final int requestCode) {
UserHttp userHttp = UserHttpImpl.Companion.getInstance();
File outputFile = FileUtils.INSTANCE.getFileByUri(FillInfoActivity.this,path);
userHttp.uploadHead(new HeadParam(outputFile))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(disposable -> {
dismissProgressDialog();
GlideApp.with(FillInfoActivity.this).load(R.drawable.user_loading2).into(sdv_head);
})
.subscribe(o -> {
Map map = (Map) o;
String head_url = (String) map.get("url");
isSelected = true;
GlideApp.with(FillInfoActivity.this)
.load(path)
.fitCenter()
.error(R.drawable.user_regist_photo)
.into(sdv_head);
head = head_url;
}, new ThrowableConsumer() {
@Override
public void accept(@NotNull String msg) {
ToastHelper.Companion.show(msg);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@color/color_1DA1F2"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@color/color_C3C4CA"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@android:color/white"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
<solid android:color="@android:color/white"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
android:layout_height="match_parent"
android:background="#E6000000">
<com.ydl.ydlcommon.view.TitleBar
android:id="@+id/tip_bar"
android:layout_width="match_parent"
android:layout_height="44dp"
app:layout_constraintTop_toTopOf="parent"
app:pa_divide_visibility="false"
app:pa_left_start_icon="@drawable/platform_common_back_un"
app:pa_title_bar_text_color="@android:color/white"
app:pa_title_text="头像" />
<TextView
android:id="@id/tv_tip1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:gravity="center"
android:textColor="@color/color_62636F"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@id/iv_avatar"
tools:text="抱歉,七天内只能修改一次头像" />
<ImageView
android:id="@+id/iv_avatar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toTopOf="parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center_horizontal"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
app:layout_constraintTop_toBottomOf="@id/iv_avatar">
<ImageView
android:id="@+id/iv_warn"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="2.5dp"
android:layout_marginEnd="3dp"
android:src="@drawable/modify_warn"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/tv_tip2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/iv_warn"
android:gravity="center_horizontal"
android:textColor="@color/color_C3C4CA"
android:lineSpacingExtra="5dp"
android:textSize="12sp"
tools:text="审核失败,XXX先休息休息寻寻寻寻小地方付付付付。如有疑问联系客服小壹" />
</RelativeLayout>
<TextView
android:id="@+id/tv_modify"
android:layout_width="333dp"
android:layout_height="54dp"
android:layout_marginBottom="50dp"
android:background="@drawable/bg_1da1f2_corner_8"
android:gravity="center"
android:text="修改头像"
android:textColor="@android:color/white"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:layout_height="match_parent"
android:background="@color/color_F7F7FA"
android:orientation="vertical">
<com.ydl.ydlcommon.view.TitleBar
android:id="@+id/tb_title_bar"
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="@color/platform_white"
app:pa_left_start_icon="@drawable/platform_common_back"
android:layout_marginBottom="16dp"
app:pa_right_text="保存"
app:pa_title_text="修改昵称" />
<TextView
android:id="@+id/tv_tip1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:layout_marginBottom="12dp"
android:textColor="@color/color_C3C4CA"
android:textSize="14sp"
android:visibility="gone"
tools:text="七天内可修改一次昵称"
tools:visibility="visible"/>
<com.ydl.ydlcommon.view.DeleteEditTextView
android:id="@+id/det_set_info"
android:layout_width="match_parent"
android:layout_height="55dp"
android:textColorHint="@color/color_C3C4CA"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/bg_corner_8_white"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="12dp"
android:gravity="center_vertical"
android:textSize="18sp"
android:textColor="@color/color_1C1F28"
android:paddingBottom="15dp" />
<LinearLayout
android:layout_marginTop="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="26dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_warn"
android:visibility="gone"
tools:visibility="visible"
android:layout_width="12dp"
android:layout_marginTop="2dp"
android:layout_height="12dp"
android:layout_marginEnd="4dp"
android:src="@drawable/modify_warn"/>
<TextView
android:id="@+id/tv_tip2"
android:layout_marginEnd="26dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="5dp"
android:textColor="@color/color_9d9ea7"
android:textSize="12sp"
android:visibility="gone"
tools:text="审核失败,简介有风险词。如有疑问联系客服小壹"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_top_corner_8_white">
<TextView
android:id="@+id/tv_album"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="相册"
android:textColor="@color/color_1C1F28"
android:textSize="16sp"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/divide_1"
android:layout_width="match_parent"
android:layout_height="0.5dp"
app:layout_constraintTop_toBottomOf="@id/tv_album"
android:background="@color/color_EFEFF1"/>
<TextView
android:id="@+id/tv_photo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="拍照"
android:textColor="@color/color_1C1F28"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/divide_1" />
<View
android:id="@+id/divide_2"
android:layout_width="match_parent"
android:layout_height="0.5dp"
app:layout_constraintTop_toBottomOf="@id/tv_photo"
android:background="@color/color_EFEFF1"/>
<TextView
android:id="@+id/tv_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="取消"
android:textColor="@color/color_1C1F28"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/divide_2" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<com.ydl.ydlcommon.view.TitleBar
android:id="@+id/tb_title"
android:layout_width="match_parent"
android:layout_height="@dimen/title_bar_height"
app:pa_left_text="退出"
android:background="@color/platform_white"
app:pa_title_text="完善资料" />
<com.ydl.ydlcommon.view.CircleImageView
android:id="@+id/sdv_head"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="30dp"
android:src="@drawable/user_regist_photo" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/user_divide_line_stroke_width"
android:layout_marginTop="36dp"
android:background="@color/platform_divide_color" />
<TextView
android:id="@+id/tv_sex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/platform_white"
android:gravity="center"
android:hint="@string/platform_please_select_gender"
android:padding="@dimen/platform_default_dis_size_huge"
android:textColorHint="#777777" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/user_divide_line_stroke_width"
android:background="@color/platform_divide_color" />
<EditText
android:id="@+id/et_nick"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/platform_white"
android:gravity="center"
android:hint="@string/platform_nickname_hint"
android:maxLength="10"
android:padding="@dimen/platform_default_dis_size_huge"
android:singleLine="true"
android:textColorHint="#777777" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/user_divide_line_stroke_width"
android:background="@color/platform_divide_color" />
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/rcb_submit"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/platform_default_dis_size_big"
android:layout_marginRight="@dimen/platform_default_dis_size_big"
android:layout_marginTop="@dimen/platform_default_dis_size_huge"
android:text="@string/platform_finish"
android:textColor="@color/platform_white"
android:textSize="@dimen/platform_default_text_size_big"
app:pa_round_btn_active_bg="@color/platform_white"
app:pa_round_btn_bg="@color/platform_main_theme"
app:pa_round_btn_radio_size="5dp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#f5f5f5"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rela_toolBar"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="45dp">
<ImageView
android:id="@+id/image_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:gravity="center_vertical"
android:src="@drawable/platform_common_back" />
<TextView
android:id="@+id/tv_center_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:ellipsize="end"
android:gravity="center"
android:maxEms="12"
android:maxLines="1"
android:text="简介"
android:textColor="#555555"
android:textSize="16sp" />
<TextView
android:id="@+id/text_save"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_alignParentRight="true"
android:paddingRight="20dp"
android:text="保存"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:layout_alignParentBottom="true"
android:background="#EDEDED" />
</RelativeLayout>
<EditText
android:id="@+id/edit_des"
android:layout_width="match_parent"
android:layout_height="300dp"
android:gravity="start"
android:maxLength="150"
android:padding="10dp"
android:background="@color/white"
android:textColorHint="#cbd0d8"
android:hint="一句话介绍下自己"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.ydl.ydlcommon.view.TitleBar
android:id="@+id/tb_title_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/title_bar_height"
app:pa_left_text="取消"
app:pa_right_text="保存"
android:background="@color/platform_white"
app:pa_title_text="title" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:layout_marginTop="14dp"
android:background="#EDEDED" />
<com.ydl.ydlcommon.view.DeleteEditTextView
android:id="@+id/det_set_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:padding="@dimen/platform_default_dis_size"
android:singleLine="true" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="#EDEDED" />
</LinearLayout>
......@@ -20,6 +20,7 @@ import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.AndroidSystemHelper
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.statusBar.StatusBarUtil
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject
import kotlin.properties.Delegates
......@@ -37,6 +38,9 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
var statusView: View? = null
private var loadingDialogFragment: LoadingDialogFragment? = null
@JvmField
val mDisposables = CompositeDisposable()
override fun provideLifecycleSubject(): Subject<ActivityEvent> {
return mLifecycleSubject;
}
......@@ -157,6 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
override fun onDestroy() {
super.onDestroy()
mDisposables.takeIf { !it.isDisposed }?.dispose()
ActivityManager.getInstance().removeStack(this)
AndroidSystemHelper.fixInputMethodManagerLeak(this)
}
......
......@@ -8,6 +8,7 @@ import android.view.ViewDebug.ExportedProperty
import android.view.ViewDebug.IntToString
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.annotation.StyleRes
import androidx.fragment.app.DialogFragment
import com.ydl.ydlcommon.R
......@@ -18,7 +19,7 @@ abstract class BaseDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.bottomUpDialog)
setStyle(STYLE_NO_TITLE, setTheme())
}
override fun onCreateView(
......@@ -33,7 +34,7 @@ abstract class BaseDialogFragment : DialogFragment() {
super.onStart()
dialog?.window?.run {
attributes = attributes?.apply {
gravity = getGravity()
gravity = setGravity()
width = getWidth()
height = getHeight()
}
......@@ -42,7 +43,9 @@ abstract class BaseDialogFragment : DialogFragment() {
@LayoutRes
abstract fun getLayoutResourceId(): Int
open fun getGravity(): Int = Gravity.NO_GRAVITY
open fun setGravity(): Int = Gravity.NO_GRAVITY
@StyleRes
open fun setTheme(): Int = R.style.bottomUpDialog
@ExportedProperty(
category = "layout",
......
......@@ -38,7 +38,7 @@ public class FileUtils {
/**
* sd卡的根目录
*/
private static String mSdRootPath = Environment.getExternalStorageDirectory().getPath();
private static final String mSdRootPath = Environment.getExternalStorageDirectory().getPath();
/**
* 手机的缓存根目录
*/
......@@ -48,12 +48,8 @@ public class FileUtils {
*/
private final static String FOLDER_NAME = "/yidianling";
private static Context mContext;
public FileUtils(Context context) {
mDataRootPath = context.getCacheDir().getPath();
mContext = context;
}
......@@ -77,9 +73,9 @@ public class FileUtils {
mSdRootPath : mDataRootPath;
}
public File SaveBitmap(Bitmap mBitmap, String path) throws IOException {
public static File saveBitmap(Bitmap mBitmap, String path) throws IOException {
File file;
isFilleExit(path);
isFileExit(path);
File f = new File(path);
try {
f.createNewFile();
......@@ -100,7 +96,7 @@ public class FileUtils {
}
public void SaveBitmap(Bitmap mBitmap, String path, String filen_name) throws IOException {
isFilleExit(path);
isFileExit(path);
File f = new File(path + filen_name);
try {
f.createNewFile();
......@@ -174,13 +170,12 @@ public class FileUtils {
* @param path
* @return
*/
public static boolean isFilleExit(String path) {
Boolean isexit = false;
public static boolean isFileExit(String path) {
boolean isexit = false;
File f = new File(path);
if (f.exists()) {
isexit = true;
} else {
isexit = false;
if (!f.exists()) {
try {
f.mkdirs();
......@@ -196,7 +191,7 @@ public class FileUtils {
* 删除该目录下所有文件
* @param root
*/
public void deleteAllFiles(File root) {
public static void deleteAllFiles(File root) {
File files[] = root.listFiles();
if (files != null)
for (File f : files) {
......@@ -224,7 +219,7 @@ public class FileUtils {
* @param imageFile
* @return
*/
public Uri getImageContentUri(Context context, File imageFile) {
public static Uri getImageContentUri(Context context, File imageFile) {
String filePath = imageFile.getAbsolutePath();
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
......@@ -235,9 +230,11 @@ public class FileUtils {
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor
.getColumnIndex(MediaStore.MediaColumns._ID));
cursor.close();
Uri baseUri = Uri.parse("content://media/external/images/media");
return Uri.withAppendedPath(baseUri, "" + id);
} else {
if (cursor != null) cursor.close();
if (imageFile.exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, filePath);
......
......@@ -21,6 +21,7 @@ import com.ydl.ydlcommon.R;
public class DeleteEditTextView extends EditText {
int mCloseAreaSize;
private boolean mShowDelete = true;
public DeleteEditTextView(Context context) {
super(context);
......@@ -43,6 +44,10 @@ public class DeleteEditTextView extends EditText {
setSelection(text.length());
}
public void setShowDelete(boolean showDelete) {
this.mShowDelete = showDelete;
}
/**
* 初始化视图
*/
......@@ -77,6 +82,7 @@ public class DeleteEditTextView extends EditText {
}
void setEditTextDrawable() {
if (!mShowDelete) return;
if (getText().length() == 0 || !isFocused()) {
setCompoundDrawablesWithIntrinsicBounds(getCompoundDrawables()[0], null, null, null);
} else {
......@@ -87,7 +93,7 @@ public class DeleteEditTextView extends EditText {
@Override
public boolean onTouchEvent(MotionEvent event) {
if ((event.getAction() == 1) && isFocused()) {
if (mShowDelete && (event.getAction() == 1) && isFocused()) {
int i = (int) event.getRawX();
if (i > getRight() - mCloseAreaSize) {
setText("");
......
......@@ -63,15 +63,11 @@ public class ListNoCancelDialog extends Dialog {
return this;
}
public ListNoCancelDialog.Builder SetOnItemClickLister(ListNoCancelDialog.Builder.OnItemClickLister lister) {
public ListNoCancelDialog.Builder setOnItemClickLister(ListNoCancelDialog.Builder.OnItemClickLister lister) {
this.mOnItemClickLister = lister;
return this;
}
public ListNoCancelDialog create() {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
......
......@@ -38,6 +38,8 @@ public class TitleBar extends RelativeLayout {
int buttom_color;
//左侧图标颜色
int mLeftStartIconColor ;
//下划线是否可见
private boolean mDividerVisibility;
//文字内容
String mLeftText, mTitle, mRightText;
......@@ -196,26 +198,27 @@ public class TitleBar extends RelativeLayout {
void initRoot(AttributeSet attrs, int defStyleAttr) {
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.Platform_TitleBar, defStyleAttr, 0);
attrs, R.styleable.TitleBar, defStyleAttr, 0);
mLeftText = a.getString(R.styleable.Platform_TitleBar_pa_left_text);
mLeftStartIcon = a.getDrawable(R.styleable.Platform_TitleBar_pa_left_start_icon);
mLeftEndIcon = a.getDrawable(R.styleable.Platform_TitleBar_pa_left_end_icon);
mRight = a.getDrawable(R.styleable.Platform_TitleBar_pa_right_iv);
mLeftText = a.getString(R.styleable.TitleBar_pa_left_text);
mLeftStartIcon = a.getDrawable(R.styleable.TitleBar_pa_left_start_icon);
mLeftEndIcon = a.getDrawable(R.styleable.TitleBar_pa_left_end_icon);
mRight = a.getDrawable(R.styleable.TitleBar_pa_right_iv);
mTitle = a.getString(R.styleable.Platform_TitleBar_pa_title_text);
mTitle = a.getString(R.styleable.TitleBar_pa_title_text);
mRightText = a.getString(R.styleable.Platform_TitleBar_pa_right_text);
mRightStartIcon = a.getDrawable(R.styleable.Platform_TitleBar_pa_right_start_icon);
mRightEndIcon = a.getDrawable(R.styleable.Platform_TitleBar_pa_right_end_icon);
mRightText = a.getString(R.styleable.TitleBar_pa_right_text);
mRightStartIcon = a.getDrawable(R.styleable.TitleBar_pa_right_start_icon);
mRightEndIcon = a.getDrawable(R.styleable.TitleBar_pa_right_end_icon);
mTextColor = a.getColor(R.styleable.Platform_TitleBar_pa_title_bar_text_color, 0xff3c3c3c);
mSideTextColor = a.getColor(R.styleable.Platform_TitleBar_pa_side_text_color, 0xff3c3c3c);
mTextColor = a.getColor(R.styleable.TitleBar_pa_title_bar_text_color, 0xff3c3c3c);
mSideTextColor = a.getColor(R.styleable.TitleBar_pa_side_text_color, 0xff3c3c3c);
//底部线颜色
buttom_color = a.getColor(R.styleable.Platform_TitleBar_pa_bm_line_color, getResources().getColor(R.color.platform_divide_color));
buttom_color = a.getColor(R.styleable.TitleBar_pa_bm_line_color, getResources().getColor(R.color.platform_divide_color));
//左侧图标颜色
mLeftStartIconColor = a.getColor(R.styleable.Platform_TitleBar_pa_left_start_icon_color, 0xffffff);
mLeftStartIconColor = a.getColor(R.styleable.TitleBar_pa_left_start_icon_color, 0xffffff);
mDividerVisibility = a.getBoolean(R.styleable.TitleBar_pa_divide_visibility, true);
a.recycle();
setGravity(Gravity.CENTER_VERTICAL);
......@@ -256,6 +259,7 @@ public class TitleBar extends RelativeLayout {
//底部线
iv_title_divide.setBackgroundColor(buttom_color);
iv_title_divide.setVisibility(mDividerVisibility ? View.VISIBLE : View.GONE);
//设置点击事件
setupTextClick();
......
......@@ -2,7 +2,7 @@
<resources>
<!--头部bar-->
<declare-styleable name="Platform_TitleBar">
<declare-styleable name="TitleBar">
<attr name="pa_left_text" />
<attr name="pa_left_start_icon" format="reference" />
<attr name="pa_left_end_icon" format="reference" />
......@@ -15,6 +15,7 @@
<attr name="pa_bm_line_color" format="color" />
<attr name="pa_right_iv" format="reference" />
<attr name="pa_left_start_icon_color" format="color" />
<attr name="pa_divide_visibility" format="boolean" />
</declare-styleable>
<attr name="pa_left_text" format="string" />
<attr name="pa_right_text" format="string" />
......
......@@ -127,9 +127,14 @@
<color name="color_1C1F28">#1C1F28</color>
<color name="color_1DA1F2">#1DA1F2</color>
<color name="color_EB892C">#EB892C</color>
<color name="color_9D9EA7">#9D9EA7</color>
<color name="color_EFEFF1">#EFEFF1</color>
<color name="color_FAFAFF">#FAFAFF</color>
<color name="color_242424">#242424</color>
<color name="color_9d9ea7">#9D9EA7</color>
<color name="color_C3C4CA">#C3C4CA</color>
<color name="color_2E2E30">#2E2E30</color>
<color name="color_191919">#191919</color>
<color name="color_E5E5E5">#E5E5E5</color>
<color name="color_F7F7FA">#F7F7FA</color>
<color name="color_62636F">#62636F</color>
</resources>
package com.ydl.utils;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
import com.ydl.view.MoreClickView;
import com.ydl.webview.IJavascriptHandler;
/**
* Created by Wi1ls on 2016/10/17;
*/
public class PopUtils {
public static PopupWindow showMoreItem(Context context, View view, IJavascriptHandler jtoJHandle){
MoreClickView v= new MoreClickView(context,jtoJHandle);
WindowManager windowManager= (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final PopupWindow popupWindow=new PopupWindow(v, windowManager.getDefaultDisplay().getWidth(),
windowManager.getDefaultDisplay().getHeight());
v.setPopupWindow(popupWindow);
popupWindow.setFocusable(false);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.showAtLocation(view, Gravity.CENTER,0,0);
return popupWindow;
}
}
......@@ -7,6 +7,7 @@ import android.text.TextUtils
import android.view.View
import android.widget.PopupWindow
import android.widget.RelativeLayout
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.webview.IJavascriptHandler
import com.ydl.webview.R
import com.ydl.ydlcommon.base.config.ChannelConfig
......@@ -20,12 +21,17 @@ import kotlinx.android.synthetic.main.web_ui_new_more.view.*
/**
* Created by Wi1ls on 2016/10/17;
*/
class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : RelativeLayout(context), View.OnClickListener {
private var mJtoJHandle: IJavascriptHandler?= jtoJHandle
class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : RelativeLayout(context),
View.OnClickListener {
private var mJtoJHandle: IJavascriptHandler? = jtoJHandle
private var mPopupWindow: PopupWindow? = null
private val work_time = if (PlatformDataManager.getRam().getGlobalInfo() == null) "早8:30-凌晨2:00" else PlatformDataManager.getRam().getGlobalInfo()?.info?.work_time
private val tel = if (PlatformDataManager.getRam().getGlobalInfo() == null) "400-765-1010" else PlatformDataManager.getRam().getGlobalInfo()?.info?.tel
private val work_time = if (PlatformDataManager.getRam()
.getGlobalInfo() == null
) "早8:30-凌晨2:00" else PlatformDataManager.getRam().getGlobalInfo()?.info?.work_time
private val tel = if (PlatformDataManager.getRam()
.getGlobalInfo() == null
) "400-765-1010" else PlatformDataManager.getRam().getGlobalInfo()?.info?.tel
init {
View.inflate(context, R.layout.web_ui_new_more, this)
......@@ -33,38 +39,37 @@ class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : Relative
}
internal fun init() {
fl_main.setOnClickListener(this)
if(mJtoJHandle?.setMoreMsg()!=null){
if (mJtoJHandle?.setMoreMsg() != null) {
more_msg.setOnClickListener(mJtoJHandle?.setMoreMsg())
}else{
} else {
more_msg.setOnClickListener(this)
}
if(mJtoJHandle?.setMoreHomePage()!=null){
if (mJtoJHandle?.setMoreHomePage() != null) {
more_homepage.setOnClickListener(mJtoJHandle?.setMoreHomePage())
}else{
} else {
more_homepage.setOnClickListener(this)
}
if(mJtoJHandle?.setMoreService()!=null){
if (mJtoJHandle?.setMoreService() != null) {
more_service.setOnClickListener(mJtoJHandle?.setMoreService())
}else{
} else {
more_service.setOnClickListener(this)
}
if(mJtoJHandle?.setMoreCall()!=null){
if (mJtoJHandle?.setMoreCall() != null) {
more_ray.setOnClickListener(mJtoJHandle?.setMoreCall())
}else{
} else {
more_ray.setOnClickListener(this)
}
more_feed.setOnClickListener(this)
/* if (YdlCommonRouterManager.getYdlCommonRoute().isHasUnread()) {
msg_new.setVisibility(View.VISIBLE)
} else {
msg_new.setVisibility(View.INVISIBLE)
}*/
var unreadNum = ModularServiceManager.provide(IImService::class.java).getAllUnReadNum()
val unreadNum = ModularServiceManager.provide(IImService::class.java).getAllUnReadNum()
if (unreadNum <= 0) {
un_read_num.visibility = View.GONE
}
else {
} else {
if (unreadNum > 99) {
un_read_num.text = "${unreadNum}+"
} else {
......@@ -80,8 +85,6 @@ class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : Relative
mPopupWindow!!.dismiss()
}
when (view.id) {
R.id.fl_main -> {
}
R.id.more_msg -> {
setMoreMsg()
}
......@@ -92,7 +95,10 @@ class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : Relative
setMoreService()
}
R.id.more_ray -> {
setMoreRay()
setMoreRay()
}
R.id.more_feed -> {
ARouter.getInstance().build("/mine/FeedBackActivity").navigation()
}
}
......@@ -116,24 +122,14 @@ class MoreClickView(context: Context, jtoJHandle: IJavascriptHandler) : Relative
private fun setMoreRay() {
CommonDialog(context)
.setMessage("欢迎致电壹点灵客服热线\n$tel\n服务时间:$work_time")
.setLeftOnclick("取消", null)
.setRightClick("拨打") {
if (null != tel && !TextUtils.isEmpty(tel)) {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$tel"))
context.startActivity(phoneIntent)
}
}.show()
}
private var callBack: CallPhoneCallBack? = null
fun setCallPhoneCallBack(callBack: CallPhoneCallBack) {
this.callBack = callBack
}
interface CallPhoneCallBack {
fun call(tel: String, action: String)
.setMessage("欢迎致电壹点灵客服热线\n$tel\n服务时间:$work_time")
.setLeftOnclick("取消", null)
.setRightClick("拨打") {
if (null != tel && !TextUtils.isEmpty(tel)) {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$tel"))
context.startActivity(phoneIntent)
}
}.show()
}
fun setPopupWindow(popupWindow: PopupWindow) {
......
......@@ -18,8 +18,10 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
......@@ -37,10 +39,10 @@ import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.utils.PopUtils;
import com.ydl.utils.ProxyCheckUtils;
import com.ydl.utils.WebUrlParamsUtils;
import com.ydl.view.ArticleDialogFragment;
import com.ydl.view.MoreClickView;
import com.ydl.view.ShareMeditationDialog;
import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydlcommon.base.BaseActivity;
......@@ -131,8 +133,6 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
private ShareMeditationDialog shareMeditationDialog;
private ArticleDialogFragment commentArticleDialog;
protected PopupWindow popupWindow;
protected ValueCallback<Uri> uploadMessage;
protected ValueCallback<Uri[]> uploadMessageAboveL;
private boolean shouldClearHistory = false;
......@@ -536,8 +536,12 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
public void openRightTopMenu() {
popupWindow = PopUtils.showMoreItem(this,
tb_title.getRootView(), jtoJHandle);
MoreClickView moreView = new MoreClickView(this, jtoJHandle);
PopupWindow popupWindow = new PopupWindow(moreView, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
moreView.setPopupWindow(popupWindow);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true); // 防止外部点击事件穿透
popupWindow.showAtLocation(tb_title, Gravity.TOP | Gravity.END, 0, 0);
}
public void openShareMenu(H5JsBean.H5JsCmd.Params params) {
......@@ -641,8 +645,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
purl = intent.getStringExtra("purl");
//要加"more"按钮
if (h5Params.isShowMenu()) {
tb_title.setRightImageListener(v -> popupWindow = PopUtils.showMoreItem(this,
tb_title.getRootView(), jtoJHandle));
tb_title.setRightImageListener(v -> openRightTopMenu());
tb_title.setRightImageIfShouldSee();
} else {
tb_title.setRightImageIfNoSee();
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@android:color/white"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fl_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_corner_8_white"
android:elevation="4dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="right"
android:elevation="4dp"
android:background="@color/platform_white"
android:layout_marginTop="55dp"
android:layout_marginRight="5dp">
<LinearLayout
android:id="@+id/more_msg"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="15dp"
android:src="@drawable/platform_ic_pop_news"/>
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="消息"
android:textColor="#333333"/>
<TextView
android:id="@+id/un_read_num"
android:layout_width="wrap_content"
android:layout_height="14dp"
android:minWidth="14dp"
android:textSize="10dp"
tools:text="10"
android:textColor="#ffffff"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:gravity="center"
android:background="@drawable/web_message_num_bg"
android:layout_marginLeft="5dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e5e5e5"
android:layout_marginRight="2dp"/>
<LinearLayout
android:id="@+id/more_homepage"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="15dp"
android:src="@drawable/platform_ic_pop_home"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="首页"
android:textColor="#333333"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e5e5e5"
android:layout_marginRight="2dp"/>
<LinearLayout
android:id="@+id/more_service"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="15dp"
android:src="@drawable/platform_ic_pop_kefu"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="在线客服"
android:textColor="#333333"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e5e5e5"
android:layout_marginRight="2dp"/>
<LinearLayout
android:id="@+id/more_ray"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginRight="15dp"
android:src="@drawable/platform_ic_pop_phone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="免费热线"
android:textColor="#333333"/>
</LinearLayout>
android:id="@+id/more_msg"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="17dp"
android:src="@drawable/platform_ic_pop_news" />
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="消息"
android:textColor="@color/platform_color_333333"
android:textSize="14sp" />
<TextView
android:id="@+id/un_read_num"
android:layout_width="wrap_content"
android:layout_height="14dp"
android:layout_marginStart="5dp"
android:background="@drawable/web_message_num_bg"
android:gravity="center"
android:minWidth="14dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:textColor="#ffffff"
android:textSize="11sp"
tools:text="10" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/color_E5E5E5" />
<LinearLayout
android:id="@+id/more_homepage"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="17dp"
android:src="@drawable/platform_ic_pop_home" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="首页"
android:textColor="@color/platform_color_333333"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/color_E5E5E5" />
<LinearLayout
android:id="@+id/more_service"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="17dp"
android:src="@drawable/platform_ic_pop_kefu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="在线客服"
android:textColor="@color/platform_color_333333"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/color_E5E5E5" />
<LinearLayout
android:id="@+id/more_ray"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="17dp"
android:src="@drawable/platform_ic_pop_phone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="免费热线"
android:textColor="@color/platform_color_333333"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/color_E5E5E5" />
<LinearLayout
android:id="@+id/more_feed"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginEnd="19dp"
android:src="@drawable/platform_ic_pop_feed" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="投诉与反馈"
android:textColor="@color/platform_color_333333"
android:textSize="14sp" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
</LinearLayout>
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