-
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.
Change-Id: I18da92a16da4ac000977e77c3e47a222705e48f1
- Loading branch information
Showing
101 changed files
with
4,827 additions
and
1,106 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
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; | ||
} | ||
} |
152 changes: 152 additions & 0 deletions
152
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,152 @@ | ||
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) | ||
|
||
tip_title?.text = context.getString(R.string.register_agree_2) + context.getString(R.string.rule_title_and) + context.getString(R.string.rule_title_private_protect) | ||
|
||
val agreeContentStrPrefix = context.getString(R.string.rule_content_prefix) | ||
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)}》" | ||
val agreeContentStrMiddle = context.getString(R.string.rule_content_middle) | ||
val partStr4 = "《${context.getString(R.string.rule_content_list)}》" | ||
val agreeContentStrSuffix = context.getString(R.string.rule_content_suffix) | ||
var agreeContentStr = agreeContentStrPrefix + partStr1 + partStr2 + partStr3 + agreeContentStrMiddle + partStr4 + agreeContentStrSuffix | ||
var agreeContentSpannable = SpannableStringBuilder(agreeContentStr) | ||
agreeContentSpannable.setSpan(IndexClickableSpan(context, 1), | ||
agreeContentStrPrefix.length, agreeContentStrPrefix.length + partStr1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
val start1 = agreeContentStrPrefix.length + partStr1.length + partStr2.length | ||
agreeContentSpannable.setSpan(IndexClickableSpan(context, 2), | ||
start1, start1 + partStr3.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | ||
val start2 = agreeContentStrPrefix.length + partStr1.length + partStr2.length + partStr3.length + agreeContentStrMiddle.length | ||
agreeContentSpannable.setSpan(IndexClickableSpan(context, 3), | ||
start2, start2 + partStr4.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 -> { | ||
} | ||
|
||
tv_cancel -> { | ||
onDismisListener?.onDismised() | ||
} | ||
|
||
tv_confirm -> { | ||
readed = true | ||
freshReadState() | ||
onDismisListener?.onOkClicked() | ||
dismiss() | ||
} | ||
} | ||
} | ||
|
||
@Volatile | ||
private var onDismisListener: OnDismisListener? = null | ||
|
||
interface OnDismisListener { | ||
fun onDismised() | ||
fun onOkClicked() | ||
fun onOkClickedUserAgreement() | ||
fun onOkClickedPrivacyPolicy() | ||
fun onOkClickedThirdSDKList() | ||
} | ||
|
||
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() | ||
} else if (index == 3) { | ||
onDismisListener?.onOkClickedThirdSDKList() | ||
} | ||
} | ||
|
||
@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.