Commit f890568a authored by jyx's avatar jyx

青少年模式添加密码页面

parent 966d068c
...@@ -66,12 +66,8 @@ class PswActivity : BaseActivity(), View.OnClickListener { ...@@ -66,12 +66,8 @@ class PswActivity : BaseActivity(), View.OnClickListener {
} else { } else {
if (TextUtils.equals(str, inputPsw)) { if (TextUtils.equals(str, inputPsw)) {
AppPreferencesManager.get().put(Constant.PSW_FLAG, inputPsw) AppPreferencesManager.get().put(Constant.PSW_FLAG, inputPsw)
showToast("暂无青少年内容推荐,请在成年人监护下观看!") showToast("青少年内容开启成功!")
Handler(Looper.getMainLooper()).postDelayed( Handler(Looper.getMainLooper()).postDelayed({ finish() }, 1000)
{
finish()
}, 1000
)
} else { } else {
isFirstSet = true isFirstSet = true
tv_psw.text = "设置密码" tv_psw.text = "设置密码"
...@@ -81,16 +77,12 @@ class PswActivity : BaseActivity(), View.OnClickListener { ...@@ -81,16 +77,12 @@ class PswActivity : BaseActivity(), View.OnClickListener {
} }
} else { } else {
if (TextUtils.equals(str, realPsw)) { if (TextUtils.equals(str, realPsw)) {
Handler(Looper.getMainLooper()).postDelayed( AppPreferencesManager.get().put(Constant.PSW_FLAG, "")
{ showToast("青少年内容关闭成功!")
showToast("暂无青少年内容推荐,请在成年人监护下观看!") Handler(Looper.getMainLooper()).postDelayed({ finish() }, 1000)
finish()
}, 1000
)
} else { } else {
showToast("密码输入错误!") showToast("密码输入错误!")
finish() autoIdentify.initIdentifyBoxKeyboard(this)
} }
} }
......
...@@ -2,8 +2,6 @@ package com.duben.heliapp.ui.activitys ...@@ -2,8 +2,6 @@ package com.duben.heliapp.ui.activitys
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
...@@ -51,6 +49,12 @@ class SettingsActivity : BaseActivity(), View.OnClickListener { ...@@ -51,6 +49,12 @@ class SettingsActivity : BaseActivity(), View.OnClickListener {
} else { } else {
btn_switch.visibility = View.GONE btn_switch.visibility = View.GONE
} }
if (TextUtils.isEmpty(AppPreferencesManager.get().getString(Constant.PSW_FLAG, ""))) {
yangView!!.text = "去开启"
} else {
yangView!!.text = "去关闭"
}
} }
@SuppressLint("CutPasteId") @SuppressLint("CutPasteId")
...@@ -70,8 +74,6 @@ class SettingsActivity : BaseActivity(), View.OnClickListener { ...@@ -70,8 +74,6 @@ class SettingsActivity : BaseActivity(), View.OnClickListener {
item_phone.setOnClickListener(this) item_phone.setOnClickListener(this)
item_yang.setOnClickListener(this) item_yang.setOnClickListener(this)
item_invitedCode.findViewById<TextView>(R.id.tv_title).text = "河狸刷剧ID" item_invitedCode.findViewById<TextView>(R.id.tv_title).text = "河狸刷剧ID"
val invitedCode = ContextCompat.getDrawable(this, R.mipmap.icon_settings_invite) val invitedCode = ContextCompat.getDrawable(this, R.mipmap.icon_settings_invite)
invitedCode?.setBounds(0, 0, 56, 56) invitedCode?.setBounds(0, 0, 56, 56)
...@@ -90,14 +92,11 @@ class SettingsActivity : BaseActivity(), View.OnClickListener { ...@@ -90,14 +92,11 @@ class SettingsActivity : BaseActivity(), View.OnClickListener {
.setCompoundDrawables(itemYang, null, null, null) .setCompoundDrawables(itemYang, null, null, null)
yangView!!.visibility = View.VISIBLE yangView!!.visibility = View.VISIBLE
item_yang.findViewById<ImageView>(R.id.iv_right).visibility = View.GONE item_yang.findViewById<ImageView>(R.id.iv_right).visibility = View.GONE
if (TextUtils.isEmpty( // if (TextUtils.isEmpty(AppPreferencesManager.get().getString(Constant.PSW_FLAG, ""))) {
AppPreferencesManager.get().getString(Constant.PSW_FLAG, "") // yangView!!.text = "去开启"
) // } else {
) { // yangView!!.text = "去关闭"
yangView!!.text = "去关闭" // }
} else {
yangView!!.text = "去开启"
}
item_phone.findViewById<TextView>(R.id.tv_title).text = "手机号" item_phone.findViewById<TextView>(R.id.tv_title).text = "手机号"
val phone = ContextCompat.getDrawable(this, R.mipmap.icon_settings_tel) val phone = ContextCompat.getDrawable(this, R.mipmap.icon_settings_tel)
......
package com.duben.heliapp.ui.widgets; package com.duben.heliapp.ui.widgets;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
...@@ -45,6 +49,7 @@ public class AutoIdentifyView extends RelativeLayout { ...@@ -45,6 +49,7 @@ public class AutoIdentifyView extends RelativeLayout {
//让后三个失去焦点,第一个得到焦点 //让后三个失去焦点,第一个得到焦点
setThirdlyLoseFocusable(); setThirdlyLoseFocusable();
new Handler(Looper.getMainLooper()).postDelayed(() -> showSoftInput(), 500);
} }
/** /**
...@@ -131,7 +136,7 @@ public class AutoIdentifyView extends RelativeLayout { ...@@ -131,7 +136,7 @@ public class AutoIdentifyView extends RelativeLayout {
/** /**
* 清除验证码,初始化验证码框状态,弹出键盘 * 清除验证码,初始化验证码框状态,弹出键盘
*/ */
public void initIdentifyBoxKeyboard(Activity activity){ public void initIdentifyBoxKeyboard(Activity activity) {
clearContent(); clearContent();
setThirdlyLoseFocusable(); setThirdlyLoseFocusable();
setShowKeyboard(activity); setShowKeyboard(activity);
...@@ -185,7 +190,6 @@ public class AutoIdentifyView extends RelativeLayout { ...@@ -185,7 +190,6 @@ public class AutoIdentifyView extends RelativeLayout {
// //第一个获取焦点 // //第一个获取焦点
// loseFocusable(identify1, true); // loseFocusable(identify1, true);
// } // }
private void clearContent() { private void clearContent() {
currentCode = ""; currentCode = "";
identify1.setText(""); identify1.setText("");
...@@ -213,12 +217,16 @@ public class AutoIdentifyView extends RelativeLayout { ...@@ -213,12 +217,16 @@ public class AutoIdentifyView extends RelativeLayout {
// identify3.setInputType(InputType.TYPE_CLASS_TEXT); // identify3.setInputType(InputType.TYPE_CLASS_TEXT);
// identify4.setInputType(InputType.TYPE_CLASS_TEXT); // identify4.setInputType(InputType.TYPE_CLASS_TEXT);
// } // }
public String getCurrentCode() { public String getCurrentCode() {
return currentCode; return currentCode;
} }
public void showSoftInput() {
identify1.requestFocus();
InputMethodManager inputManager = (InputMethodManager) identify1.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(identify1, 0);
}
private void setCurrentCode(String currentCode) { private void setCurrentCode(String currentCode) {
this.currentCode = currentCode; this.currentCode = currentCode;
} }
......
...@@ -2,11 +2,15 @@ package com.duben.heliapp.ui.widgets ...@@ -2,11 +2,15 @@ package com.duben.heliapp.ui.widgets
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.text.TextUtils
import android.view.Gravity import android.view.Gravity
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.widget.TextView
import com.duben.heliapp.R import com.duben.heliapp.R
import com.duben.heliapp.common.Constant
import com.duben.heliapp.utils.AppPreferencesManager
class JuniorDialog( class JuniorDialog(
private val context: Context, private val listener: DialogListener private val context: Context, private val listener: DialogListener
...@@ -15,7 +19,7 @@ class JuniorDialog( ...@@ -15,7 +19,7 @@ class JuniorDialog(
private val lp: WindowManager.LayoutParams private val lp: WindowManager.LayoutParams
private val view_close: View private val view_close: View
private val view_done: View private val view_done: View
private val view_open: View private val view_open: TextView
init { init {
setContentView(R.layout.dialog_junior) setContentView(R.layout.dialog_junior)
...@@ -38,6 +42,12 @@ class JuniorDialog( ...@@ -38,6 +42,12 @@ class JuniorDialog(
view_done = findViewById(R.id.view_done) view_done = findViewById(R.id.view_done)
view_open = findViewById(R.id.view_open) view_open = findViewById(R.id.view_open)
if (TextUtils.isEmpty(AppPreferencesManager.get().getString(Constant.PSW_FLAG, ""))) {
view_open.text = "开启青少年模式 >"
} else {
view_open.text = "关闭青少年模式 >"
}
listener.setDialog(this) listener.setDialog(this)
view_open.setOnClickListener { view_open.setOnClickListener {
listener.onClick(this@JuniorDialog, view_open) listener.onClick(this@JuniorDialog, view_open)
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <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_width="match_parent"
android:layout_height="match_parent"> android:layout_height="380dp"
android:background="@mipmap/bg_junior"
android:orientation="horizontal">
<LinearLayout <LinearLayout
android:id="@+id/ll_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:gravity="center_horizontal"
android:background="@drawable/shape_banner_write" android:orientation="vertical"
android:orientation="vertical"> app:layout_constraintBottom_toBottomOf="parent">
<RelativeLayout <TextView
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:text="青少年模式"
android:textColor="#0C0D19"
android:textSize="22sp"
android:textStyle="bold" />
<ImageView <TextView
android:id="@+id/view_close" android:id="@+id/tv_phone_dialog_phone"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_gravity="center_horizontal"
android:padding="10dp" android:layout_marginStart="20dp"
android:src="@mipmap/ic_activity_quit" /> android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
<LinearLayout android:text="1、开启青年少模式后,将自动开始时间锁,每天使用时长最多为40分钟\n2、根据年龄段分级,更精细地推荐更多丰富内容,帮助青少年健康成长"
android:layout_width="wrap_content" android:textColor="@color/gray"
android:layout_height="wrap_content" android:textSize="14sp"
android:layout_marginTop="60dp" android:textStyle="bold" />
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="青少年模式"
android:textColor="#0C0D19"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_phone_dialog_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:text="1、开启青年少模式后,将自动开始时间锁,每天使用时长最多为40分钟\n2、根据年龄段分级,更精细地推荐更多丰富内容,帮助青少年健康成长"
android:textColor="@color/gray"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/view_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="开启青少年模式 >"
android:textColor="#0C0D19"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/view_done"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="30dp"
android:background="@drawable/shape_red"
android:gravity="center"
android:text="我知道了"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/view_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="开启青少年模式 >"
android:textColor="#0C0D19"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/view_done"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="30dp"
android:background="@drawable/shape_red"
android:gravity="center"
android:text="我知道了"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout> </LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/view_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/ll_content"
android:layout_alignParentEnd="true"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:src="@mipmap/ic_activity_quit"
app:layout_constraintBottom_toTopOf="@id/ll_content"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
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