Commit d2fa0ae6 by 霍志良

feat:UI和对话框修改

parent a7018484
......@@ -9,9 +9,7 @@ import android.net.Uri
import android.os.Handler
import android.provider.Settings
import android.text.*
import android.text.method.LinkMovementMethod
import android.text.style.AbsoluteSizeSpan
import android.text.style.ClickableSpan
import android.util.Log
import android.view.View
import android.view.animation.AnimationUtils
......@@ -25,14 +23,11 @@ import com.mobile.auth.gatewayauth.model.InitResult
import com.mobile.auth.gatewayauth.model.VendorConfig
import com.tbruyelle.rxpermissions2.RxPermissions
import com.umeng.socialize.UMShareAPI
import com.umeng.socialize.UMShareConfig
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.data.PlatformRamImpl
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil
......@@ -52,9 +47,9 @@ import com.yidianling.user.route.UserIn
import com.yidianling.user.safePrivate.FingerPrintCheckActivity
import com.yidianling.user.safePrivate.FingerPrintUtil
import com.yidianling.user.safePrivate.HandUnlockCheckActivity
import com.yidianling.user.ui.CountryListActivity
import com.yidianling.user.ui.login.contract.ILoginContract
import com.yidianling.user.ui.login.presenter.LoginPresenterImpl
import com.yidianling.user.widget.ZDialog
import kotlinx.android.synthetic.main.user_activity_register_and_login.*
/**
......@@ -122,7 +117,7 @@ class testLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginContract.Pr
}
override fun layoutResId(): Int {
return R.layout.user_activity_verfication_code_new
return R.layout.user_activity_input_password_new
}
override fun initDataAndEvent() {
......@@ -288,12 +283,44 @@ class testLoginActivity : BaseMvpActivity<ILoginContract.View, ILoginContract.Pr
/**
* 设置点击事件
*/
private var mKeFuDialog: ZDialog? = null
private fun setClickEvent() {
// tv_skip.setOnClickListener {
// ActionCountUtils.count(uid = "", partId = UserBIConstants.PART_ID_LOGIN_MAIN, position = UserBIConstants.POSITION_LOOK_AROUND_CLICK, url = "无url",api = "无api", sign1 = "")
// RxKeyboardTool.hideSoftInput(this)
// onBackPressed()
// }
img_reg_back.postDelayed(Runnable {
// KeFuTipDialog(this).show()
if (mKeFuDialog==null){
mKeFuDialog= ZDialog.Builder(this)
.setContentView(R.layout.user_kefu_tipdialog)
.setOnClickListener(R.id.cancel_dialog) {
mKeFuDialog?.dismiss()
}
.setAnimation(0)//取消动画
.setOnClickListener(R.id.dial_right_now) {
val dialIntent =
Intent(
Intent.ACTION_DIAL,
Uri.parse(String.format("tel:" + "400-765-1010"))
)
startActivity(dialIntent)
}
.show()
}
},2000)
/*
*
* val dialIntent =
Intent(
Intent.ACTION_DIAL,
Uri.parse(String.format("tel:" + getString(R.string.service_hotline)))
)
startActivity(dialIntent)
* */
img_reg_back.setOnClickListener {
RxKeyboardTool.hideSoftInput(this)
onBackPressed()
......
package com.yidianling.user.widget;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import com.yidianling.user.R;
/**
* Created on 2018/1/18 11:24
*
* @author Z
* @version : 1.0.0
* 利用Builder模式构建一个通用的Dialog,现在暂时不支持在ZDialog中自定义加载图片
* use like this:
* new ZDialog.Builder(this)
* .setContentView(R.layout.zdialog_normal)
* .setFullScreen()
* .setCancelAble(true)
* .setGravity(ZDialogDirection.FROM_BOTTOM)
* .setText(R.id.tv_normal_test,"哈哈哈哈")
* .setOnClickListener(R.id.btn_normal, ...)
*
*/
public class ZDialog extends Dialog {
private ZDialogController mDialogController;
public ZDialog( Context context) {
super(context, R.style.user_ZDialogDefaultStyle);
init();
}
private void init() {
mDialogController = new ZDialogController(this, getWindow());
}
public ZDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
init();
}
public void setOnClickListener(int viewId, View.OnClickListener listener) {
mDialogController.setOnClickListener(viewId, listener);
}
public EditText getEditText(int viewId) {
return mDialogController.getEditText(viewId);
}
public View findDialogView(int viewId) {
return mDialogController.findView(viewId);
}
public static class Builder {
private ZDialogController.ZDialogParams mDialogParams;
public Builder(Context context) {
this(context, R.style.user_ZDialogDefaultStyle);
}
public Builder(Context context, int themeResId) {
mDialogParams = new ZDialogController.ZDialogParams(context, themeResId);
//设置一个默认的动画
mDialogParams.animation = R.style.user_ZDialogDefaultAnimation;
}
public Builder setContentView(View contentView) {
mDialogParams.contentView = contentView;
mDialogParams.contentResId = 0;
return this;
}
public Builder setContentView(int contentViewResId) {
mDialogParams.contentResId = contentViewResId;
mDialogParams.contentView = null;
return this;
}
public Builder setText(int viewId, CharSequence charSequence) {
mDialogParams.textArray.put(viewId, charSequence);
return this;
}
public Builder setText(int viewId, int strId) {
mDialogParams.textArray.put(viewId, mDialogParams.context.get().getResources().getString(strId));
return this;
}
public Builder setOnClickListener(int viewId, View.OnClickListener onClickListener) {
mDialogParams.clickViewArray.put(viewId, onClickListener);
return this;
}
public Builder setOnDismissListener(OnDismissListener onDismissListener) {
mDialogParams.onDismissListener = onDismissListener;
return this;
}
public Builder setOnCancelListener(OnCancelListener onCancelListener) {
mDialogParams.onCancelListener = onCancelListener;
return this;
}
public Builder setOnKeyListener(OnKeyListener onKeyListener) {
mDialogParams.onKeyListener = onKeyListener;
return this;
}
public Builder setFullScreen() {
mDialogParams.defaultWidth = ViewGroup.LayoutParams.MATCH_PARENT;
return this;
}
public Builder setGravity(@ZDialogDirection.ZGravity int direction) {
switch (direction) {
case ZDialogDirection.FROM_TOP:
mDialogParams.direction = Gravity.TOP;
break;
case ZDialogDirection.FROM_BOTTOM:
mDialogParams.direction = Gravity.BOTTOM;
default:
break;
}
return this;
}
public Builder setAnimation(int animationRes) {
mDialogParams.animation = animationRes;
return this;
}
public Builder setCancelAble(boolean cancelAble) {
mDialogParams.cancelable = cancelAble;
return this;
}
public ZDialog show() {
ZDialog zDialog = create();
zDialog.show();
return zDialog;
}
private ZDialog create() {
ZDialog dialog = new ZDialog(mDialogParams.context.get(), mDialogParams.themeResId);
mDialogParams.apply(dialog.mDialogController);
dialog.setCancelable(mDialogParams.cancelable);
dialog.setOnCancelListener(mDialogParams.onCancelListener);
dialog.setOnDismissListener(mDialogParams.onDismissListener);
return dialog;
}
}
}
package com.yidianling.user.widget;
import android.content.Context;
import android.content.DialogInterface;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import java.lang.ref.WeakReference;
/**
* Created on 2018/1/18 11:32
*
* @author Z
* @version : 1.0.0
*/
public class ZDialogController {
private ZDialog mZDialog;
private Window mWindow;
private ZDialogViewHelper mZDialogViewHelper;
public ZDialogController(ZDialog ZDialog, Window window) {
mZDialog = ZDialog;
mWindow = window;
}
public ZDialog getZDialog() {
return mZDialog;
}
public Window getWindow() {
return mWindow;
}
public void setZDialogViewHelper(ZDialogViewHelper ZDialogViewHelper) {
mZDialogViewHelper = ZDialogViewHelper;
}
public void setText(int viewId, CharSequence charSequence) {
mZDialogViewHelper.setText(viewId, charSequence);
}
public EditText getEditText(int viewId) {
return mZDialogViewHelper.getEditText(viewId);
}
public View findView(int viewId) {
return mZDialogViewHelper.findView(viewId);
}
public void setOnClickListener(int viewId, View.OnClickListener onClickListener) {
mZDialogViewHelper.setOnClickListener(viewId, onClickListener);
}
/**
* ZDialog 显示出来可能需要的一些参数
*/
public static class ZDialogParams {
public WeakReference<Context> context;
public int themeResId;// dialog 的style
public boolean cancelable;
public View contentView;
public int contentResId;
public int defaultWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
public int defaultHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
public int direction = Gravity.CENTER;
public int animation = 0;
public SparseArray<CharSequence> textArray = new SparseArray<>();
public SparseArray<View.OnClickListener> clickViewArray = new SparseArray<>();
public DialogInterface.OnCancelListener onCancelListener;
public DialogInterface.OnDismissListener onDismissListener;
public DialogInterface.OnKeyListener onKeyListener;
public ZDialogParams(Context context, int themeResId) {
this.context = new WeakReference<>(context);
this.themeResId = themeResId;
}
public void apply(ZDialogController controller) {
//创建ZDialogViewHelper
ZDialogViewHelper viewHelper = null;
if (contentResId != 0) {
viewHelper = new ZDialogViewHelper(context.get(), contentResId);
}
if (contentView != null) {
viewHelper = new ZDialogViewHelper();
viewHelper.setContentView(contentView);
}
if (viewHelper == null) {
throw new IllegalArgumentException("please do setContentView() first");
}
//添加布局到dialog
if (viewHelper.getContentView() != null) {
controller.getZDialog().setContentView(viewHelper.getContentView());
}
controller.setZDialogViewHelper(viewHelper);
for (int i = 0; i < textArray.size(); i++) {
controller.setText(textArray.keyAt(i), textArray.valueAt(i));
}
for (int i = 0; i < clickViewArray.size(); i++) {
controller.setOnClickListener(clickViewArray.keyAt(i), clickViewArray.valueAt(i));
}
Window window = controller.getWindow();
window.setGravity(direction);
if (animation != 0) {
window.setWindowAnimations(animation);
}
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.width = defaultWidth;
attributes.height = defaultHeight;
window.setAttributes(attributes);
}
}
}
package com.yidianling.user.widget;
import android.support.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Created on 2018/1/18 16:34
*
* @author Z
* @version : 1.0.0
* ZDialog的方向
*/
public class ZDialogDirection {
@IntDef({FROM_TOP, FROM_BOTTOM})
@Retention(RetentionPolicy.SOURCE)
public @interface ZGravity {
}
public static final int FROM_TOP = 0;
public static final int FROM_BOTTOM = 1;
}
package com.yidianling.user.widget;
import android.content.Context;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import java.lang.ref.WeakReference;
/**
* Created on 2018/1/18 13:02
*
* @author Z
* @version : 1.0.0
* 辅助给ZDialog的布局文件设置属性
*/
public class ZDialogViewHelper {
private View mContentView;
private SparseArray<WeakReference<View>> mViews;
private Context mContext;
public ZDialogViewHelper(Context context, int contentResId) {
this();
mContext = context;
mContentView = LayoutInflater.from(mContext).inflate(contentResId, null);
}
public ZDialogViewHelper() {
mViews = new SparseArray<>();
}
public View getContentView() {
return mContentView;
}
public void setContentView(View contentView) {
this.mContentView = contentView;
}
/**
* @param viewId viewId
* @param strId strId
*/
public void setText(int viewId, int strId) {
setText(viewId, mContext.getResources().getString(strId));
}
/**
* 通过id 给控件设置文本
*
* @param viewId viewId
* @param charSequence 文本类容
*/
public void setText(int viewId, CharSequence charSequence) {
TextView view = getView(viewId);
if (charSequence != null && charSequence.length() > 0) {
view.setText(charSequence);
}
}
/**
* 通过id 找到相应的控件
*
* @param viewId viewId
* @param <T> 具体的类型
* @return view
*/
@SuppressWarnings("unchecked")
private <T extends View> T getView(int viewId) {
WeakReference<View> weakReference = mViews.get(viewId);
View view = null;
if (weakReference != null) {
view = weakReference.get();
}
if (view == null) {
view = mContentView.findViewById(viewId);
if (view != null) {
mViews.put(viewId, new WeakReference<>(view));
}
}
return (T) view;
}
public EditText getEditText(int viewId) {
return getView(viewId);
}
public View findView(int viewId) {
return getView(viewId);
}
/**
* 设置点击事件
*
* @param viewId viewId
* @param onClickListener onClickListener
*/
public void setOnClickListener(int viewId, View.OnClickListener onClickListener) {
View view = getView(viewId);
if (view != null) {
view.setOnClickListener(onClickListener);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="600"
/>
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:duration="600"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>
<!--
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:duration="500"/>
-->
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
......@@ -62,6 +62,18 @@
>
</ImageView>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@id/view_lin"
app:layout_constraintTop_toBottomOf="@id/view_lin"
android:layout_marginTop="@dimen/platform_dp_10"
android:text="密码须包含数字、字母、符号中至少2种元素,长度需6-16位"
app:layout_constraintEnd_toEndOf="@id/view_lin"
android:layout_marginEnd="@dimen/platform_dp_27"
android:id="@+id/forget_password_hint"
>
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="验证码登录"
......@@ -83,7 +95,30 @@
android:id="@+id/tv_forget"
>
</TextView>
<TextView
<!-- <android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_msm_login"
app:layout_constraintStart_toStartOf="@id/tv_msm_login"
app:layout_constraintEnd_toEndOf="@id/tv_forget"
app:cardBackgroundColor="#a5dafa"
android:layout_marginTop="@dimen/platform_dp_40"
app:cardCornerRadius="@dimen/platform_dp_24"
app:cardElevation="3dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white"
android:text="登录"
android:textSize="15sp"
android:id="@+id/login_password"
android:paddingTop="@dimen/platform_dp_14"
android:paddingBottom="@dimen/platform_dp_14"
/>
</android.support.v7.widget.CardView>-->
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
......@@ -99,5 +134,6 @@
app:layout_constraintEnd_toEndOf="@id/tv_forget"
android:layout_marginTop="@dimen/platform_dp_40"
/>
<include layout="@layout/user_activity_register_and_login_bottom" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="38dp"
android:layout_marginEnd="38dp"
android:background="@drawable/shape_bg_white_fillet8"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="联系客服"
android:textSize="18sp"
android:textColor="@color/platform_color_242424"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/platform_dp_28"
android:id="@+id/title"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="400-765-1010"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/user_text_size_15"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="@dimen/platform_dp_12"
android:id="@+id/second_title"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(服务时间早8:00-次日凌晨2:00)"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/user_text_size_15"
app:layout_constraintTop_toBottomOf="@id/second_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="@dimen/platform_dp_5"
android:id="@+id/third_title"
/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/platform_color_D8D8D8"
app:layout_constraintTop_toBottomOf="@id/third_title"
android:layout_marginTop="@dimen/platform_dp_28"
android:id="@+id/line"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@id/line"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="取消"
android:textSize="17sp"
android:paddingTop="@dimen/platform_dp_15"
android:paddingBottom="@dimen/platform_dp_15"
android:gravity="center"
android:textColor="@color/platform_color_666666"
android:id="@+id/cancel_dialog"
/>
<View
android:layout_width="0.5dp"
android:background="@color/platform_color_D8D8D8"
android:layout_height="match_parent"
/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="立即拨打"
android:textSize="17sp"
android:gravity="center"
android:textColor="@color/platform_color_1DA1F2"
android:id="@+id/dial_right_now"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -5,4 +5,27 @@
<item name="android:layout_height">0.5dp</item>
<item name="android:background">@color/platform_color_F0F0F0</item>
</style>
<!-- 仿ios普通对话框 -->
<style name="user_normaldialog_style" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="user_ZDialogDefaultStyle" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<!--显示区域以外是否使用黑色半透明-->
<item name="android:backgroundDimEnabled">true</item>
<!--用来控制dialog显示区域以外的灰度值,默认是0.5,值为1是,完全看不到dialog以外的内容-->
<item name="android:backgroundDimAmount">0.6</item>
</style>
<!--ZDialog的默认动画效果-->
<style name="user_ZDialogDefaultAnimation">
<item name="android:windowEnterAnimation">@anim/common_dialog_default_in</item>
<item name="android:windowExitAnimation">@anim/common_dialog_default_out</item>
</style>
</resources>
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