-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192868776255 Change-Id: Ic4512e90df9361582f2f4a8d78e63f7559466955
- Loading branch information
1 parent
89899f5
commit 03fa80e
Showing
36 changed files
with
2,371 additions
and
975 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/PermissionDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.tencent.iot.explorer.link.customview.dialog; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import androidx.constraintlayout.widget.ConstraintLayout; | ||
|
||
import com.tencent.iot.explorer.link.R; | ||
import com.tencent.iot.explorer.link.customview.dialog.entity.UpgradeInfo; | ||
|
||
public class PermissionDialog extends IosCenterStyleDialog implements View.OnClickListener { | ||
|
||
private TextView detail; | ||
private TextView detailLips; | ||
private TextView btnRefuse; | ||
private TextView btnOK; | ||
private ConstraintLayout outLayout; | ||
private String detailString; | ||
private String detailLipsString; | ||
|
||
public PermissionDialog(Context context, String detail, String detailLips) { | ||
super(context, R.layout.popup_permission_layout); | ||
this.detailString = detail; | ||
this.detailLipsString = detailLips; | ||
} | ||
|
||
@Override | ||
public void initView() { | ||
outLayout = view.findViewById(R.id.permission_dialog_layout); | ||
detail = view.findViewById(R.id.tv_detail); | ||
detailLips = view.findViewById(R.id.tv_detail_lips); | ||
btnRefuse = view.findViewById(R.id.tv_refuse); | ||
btnOK = view.findViewById(R.id.tv_ok); | ||
|
||
btnRefuse.setOnClickListener(this); | ||
btnOK.setOnClickListener(this); | ||
|
||
detail.setText(detailString); | ||
detailLips.setText(detailLipsString); | ||
outLayout.setBackgroundColor(getContext().getResources().getColor(R.color.dialog_background)); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.tv_refuse: | ||
dismiss(); | ||
if (onDismisListener != null) { | ||
onDismisListener.OnClickRefuse(); | ||
} | ||
break; | ||
case R.id.tv_ok: | ||
dismiss(); | ||
if (onDismisListener != null) { | ||
onDismisListener.OnClickOK(); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
private volatile OnDismisListener onDismisListener; | ||
|
||
public interface OnDismisListener { | ||
void OnClickRefuse(); | ||
void OnClickOK(); | ||
} | ||
|
||
public void setOnDismisListener(OnDismisListener onDismisListener) { | ||
this.onDismisListener = onDismisListener; | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/UserAgreeDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package com.tencent.iot.explorer.link.customview.dialog | ||
|
||
import android.content.Context | ||
import android.content.DialogInterface | ||
import android.os.Build | ||
import android.text.Spannable | ||
import android.text.SpannableStringBuilder | ||
import android.text.TextPaint | ||
import android.text.method.LinkMovementMethod | ||
import android.text.style.ClickableSpan | ||
import android.util.Log | ||
import android.view.KeyEvent | ||
import android.view.View | ||
import android.widget.ImageView | ||
import android.widget.RelativeLayout | ||
import android.widget.TextView | ||
import androidx.annotation.RequiresApi | ||
import com.tencent.iot.explorer.link.R | ||
|
||
class UserAgreeDialog(context: Context) : IosCenterStyleDialog(context, R.layout.popup_user_agree_layout), View.OnClickListener, DialogInterface.OnKeyListener { | ||
private var tip_title: TextView? = null | ||
private var tv_tip_content: TextView? = null | ||
private var tv_register_tip: TextView? = null | ||
private var tv_confirm: TextView? = null | ||
private var tv_cancel: TextView? = null | ||
private var select_tag_layout: RelativeLayout? = null | ||
private var iv_agreement: ImageView? = null | ||
private var iv_agreement_status: ImageView? = null | ||
@Volatile | ||
private var readed = false | ||
|
||
private fun freshReadState() { | ||
if (readed) { | ||
iv_agreement?.setImageResource(R.mipmap.dev_mode_sel) | ||
iv_agreement_status?.visibility = View.VISIBLE | ||
} else { | ||
iv_agreement?.setImageResource(R.mipmap.dev_mode_unsel) | ||
iv_agreement_status?.visibility = View.GONE | ||
} | ||
} | ||
|
||
override fun initView() { | ||
tip_title = view.findViewById(R.id.tip_title) | ||
tv_tip_content = view.findViewById(R.id.tv_tip_content) | ||
tv_register_tip = view.findViewById(R.id.tv_register_tip) | ||
tv_confirm = view.findViewById(R.id.tv_confirm) | ||
tv_cancel = view.findViewById(R.id.tv_cancel) | ||
select_tag_layout = view.findViewById(R.id.select_tag_layout) | ||
iv_agreement = view.findViewById(R.id.iv_agreement) | ||
iv_agreement_status = view.findViewById(R.id.iv_agreement_status) | ||
|
||
val partStr0 = context.getString(R.string.register_agree_1) | ||
val partStr1 = context.getString(R.string.register_agree_2) | ||
val partStr2 = context.getString(R.string.register_agree_3) | ||
val partStr3 = context.getString(R.string.register_agree_4) | ||
var showStr = partStr1 + partStr2 + partStr3 | ||
tip_title?.text = showStr | ||
|
||
var agreeStr = partStr0 + showStr | ||
var spannable = SpannableStringBuilder(agreeStr) | ||
spannable.setSpan(IndexClickableSpan(context, 1), | ||
partStr0.length, partStr0.length + partStr1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
spannable.setSpan(IndexClickableSpan(context, 2), | ||
agreeStr.length - partStr1.length, agreeStr.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
tv_register_tip?.movementMethod = LinkMovementMethod.getInstance() | ||
tv_register_tip?.text = spannable | ||
|
||
val agreeContentStrPrefix = context.getString(R.string.rule_content_prefix) | ||
val agreeContentStrSuffix = context.getString(R.string.rule_content_suffix) | ||
var agreeContentStr = agreeContentStrPrefix + showStr + agreeContentStrSuffix | ||
var agreeContentSpannable = SpannableStringBuilder(agreeContentStr) | ||
agreeContentSpannable.setSpan(IndexClickableSpan(context, 1), | ||
agreeContentStrPrefix.length, agreeContentStrPrefix.length + partStr1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
val start = agreeContentStrPrefix.length + partStr1.length + partStr2.length | ||
agreeContentSpannable.setSpan(IndexClickableSpan(context, 2), | ||
start, start + partStr3.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
tv_tip_content?.movementMethod = LinkMovementMethod.getInstance() | ||
tv_tip_content?.text = agreeContentSpannable | ||
|
||
select_tag_layout?.setOnClickListener(this) | ||
tv_cancel?.setOnClickListener(this) | ||
tv_confirm?.setOnClickListener(this) | ||
this.setOnKeyListener(this) | ||
freshReadState() | ||
} | ||
|
||
override fun onClick(v: View?) { | ||
when(v) { | ||
select_tag_layout -> { | ||
readed =! readed | ||
freshReadState() | ||
} | ||
|
||
tv_cancel -> { | ||
onDismisListener?.onDismised() | ||
} | ||
|
||
tv_confirm -> { | ||
if (!readed) return | ||
onDismisListener?.onOkClicked() | ||
dismiss() | ||
} | ||
} | ||
} | ||
|
||
@Volatile | ||
private var onDismisListener: OnDismisListener? = null | ||
|
||
interface OnDismisListener { | ||
fun onDismised() | ||
fun onOkClicked() | ||
fun onOkClickedUserAgreement() | ||
fun onOkClickedPrivacyPolicy() | ||
} | ||
|
||
fun setOnDismisListener(onDismisListener: OnDismisListener?) { | ||
this.onDismisListener = onDismisListener | ||
} | ||
|
||
inner class IndexClickableSpan(context: Context, index: Int): ClickableSpan() { | ||
private var index = 0 | ||
private var context: Context? = null | ||
|
||
init { | ||
this.index = index | ||
this.context = context | ||
} | ||
|
||
@RequiresApi(Build.VERSION_CODES.M) | ||
override fun onClick(widget: View) { | ||
context?.let { | ||
tv_tip_content?.highlightColor = it.getColor(android.R.color.transparent) | ||
tv_register_tip?.highlightColor = it.getColor(android.R.color.transparent) | ||
} | ||
if (index == 1) { | ||
onDismisListener?.onOkClickedUserAgreement() | ||
} else if (index == 2) { | ||
onDismisListener?.onOkClickedPrivacyPolicy() | ||
} | ||
} | ||
|
||
@RequiresApi(Build.VERSION_CODES.M) | ||
override fun updateDrawState(ds: TextPaint) { | ||
super.updateDrawState(ds) | ||
context?.let { | ||
ds.color = it.getColor(R.color.blue_0066FF) | ||
} | ||
ds.isUnderlineText = false | ||
} | ||
} | ||
|
||
override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean { | ||
if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
onDismisListener?.onDismised() | ||
} | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.