feat:完成发红包UI国际化
This commit is contained in:
@@ -9,6 +9,7 @@ import com.yizhuan.erban.databinding.RedPackagePrivateFragmentBinding
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.ColorDecoration
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.utils.keyboard.KeyboardUtil
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
|
@@ -4,6 +4,8 @@ package com.yizhuan.erban.avroom.redpackage.send
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import com.chuhai.utils.ktx.dp
|
||||
import com.chuhai.utils.ktx.toStringRes
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageEvent
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
@@ -31,8 +33,8 @@ class RedPackageSendDialog2 : BaseDialog<DialogRedPackageSend2Binding>() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
val tabTitles = arrayListOf("厅内红包", "全服红包")
|
||||
val topMagicIndicatorAdapter = ContactsIndicatorAdapter(context, tabTitles, 1)
|
||||
val tabTitles = arrayListOf(R.string.red_package_room.toStringRes(), R.string.red_package_public.toStringRes())
|
||||
val topMagicIndicatorAdapter = TabIndicatorAdapter(context, tabTitles)
|
||||
topMagicIndicatorAdapter.setOnItemSelectListener {
|
||||
binding.viewPager.currentItem = it
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.chuhai.utils.UiUtils;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
@@ -26,12 +27,10 @@ import java.util.List;
|
||||
public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private List<String> mTitleList;
|
||||
private Context mContext;
|
||||
private int mBottomMargin;
|
||||
|
||||
public TabIndicatorAdapter(Context mContext, List<String> mTitleList, int bottomMargin) {
|
||||
public TabIndicatorAdapter(Context mContext, List<String> mTitleList ) {
|
||||
this.mTitleList = mTitleList;
|
||||
this.mContext = mContext;
|
||||
mBottomMargin = bottomMargin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,12 +56,12 @@ public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 9));
|
||||
indicator.setColors(context.getResources().getColor(R.color.app_248cfe));
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 12));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_FF285C));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
lp.bottomMargin = mBottomMargin;
|
||||
lp.topMargin = UIUtil.dip2px(mContext, 2);
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
@@ -82,8 +81,8 @@ public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
|
||||
public ContactsPagerTitleView(Context context, String tabInfo) {
|
||||
super(context);
|
||||
setHeight(Utils.dip2px(getContext(), 30));
|
||||
setTextSize(16);
|
||||
setHeight(Utils.dip2px(getContext(), 25));
|
||||
setTextSize(18);
|
||||
setText(tabInfo);
|
||||
setGravity(Gravity.CENTER);
|
||||
|
||||
@@ -93,13 +92,13 @@ public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
@Override
|
||||
public void onSelected(int index, int totalCount) {
|
||||
// setBackgroundResource(R.drawable.shape_bg_contact_indicator_item);
|
||||
setTextColor(getResources().getColor(R.color.color_333333));
|
||||
setTextColor(getResources().getColor(R.color.color_FF285C));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeselected(int index, int totalCount) {
|
||||
// setBackgroundDrawable(null);
|
||||
setTextColor(getResources().getColor(R.color.color_666666));
|
||||
setTextColor(getResources().getColor(R.color.color_767585));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -57,10 +57,10 @@ public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 12));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_FF285C));
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 5));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 9));
|
||||
indicator.setColors(context.getResources().getColor(R.color.app_248cfe));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
@@ -82,8 +82,8 @@ public class ContactsIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
|
||||
public ContactsPagerTitleView(Context context, String tabInfo) {
|
||||
super(context);
|
||||
setHeight(Utils.dip2px(getContext(), 25));
|
||||
setTextSize(18);
|
||||
setHeight(Utils.dip2px(getContext(), 30));
|
||||
setTextSize(16);
|
||||
setText(tabInfo);
|
||||
setGravity(Gravity.CENTER);
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:text="红包金额"
|
||||
android:text="@string/red_package_money"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
@@ -52,7 +52,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="钻"
|
||||
android:text="@string/red_package_money_unit"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
@@ -91,7 +91,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="红包数量"
|
||||
android:text="@string/red_package_num"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
@@ -103,7 +103,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="个"
|
||||
android:text="@string/red_package_num_unit"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
@@ -125,7 +125,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="抢红包条件"
|
||||
android:text="@string/red_package_type"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
@@ -158,7 +158,7 @@
|
||||
android:layout_marginStart="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:text="立即生效"
|
||||
android:text="@string/red_package_now"
|
||||
android:textColor="@color/color_FF285C"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_delay"
|
||||
@@ -173,7 +173,7 @@
|
||||
android:layout_marginEnd="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:text="即时生效"
|
||||
android:text="@string/red_package_delay"
|
||||
android:textColor="@color/color_FF285C"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -187,7 +187,7 @@
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:background="@drawable/shape_f8f8fa_8"
|
||||
android:gravity="center"
|
||||
android:hint="輸入指定彈幕內容(最多10個字符)"
|
||||
android:hint="@string/red_package_msg_hint"
|
||||
android:maxLength="10"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textColorHint="@color/color_B3B3C3"
|
||||
@@ -197,13 +197,6 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier_send_top"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="et_text,tv_now,tv_delay" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_send"
|
||||
android:layout_width="match_parent"
|
||||
@@ -212,7 +205,7 @@
|
||||
android:layout_marginTop="28dp"
|
||||
android:background="@drawable/shape_g_ff6060_ff225c_26_lr"
|
||||
android:gravity="center"
|
||||
android:text="发红包"
|
||||
android:text="@string/red_package_send"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_parameter" />
|
||||
@@ -221,7 +214,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="未搶完的紅包將在12小時後返還你的錢包"
|
||||
android:text="@string/red_package_tips"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@@ -40,7 +40,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:text="红包金额"
|
||||
android:text="@string/red_package_money"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
@@ -52,7 +52,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="钻"
|
||||
android:text="@string/red_package_money_unit"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_money"
|
||||
@@ -91,7 +91,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="红包数量"
|
||||
android:text="@string/red_package_num"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
@@ -103,7 +103,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="个"
|
||||
android:text="@string/red_package_num_unit"
|
||||
android:textColor="@color/color_767585"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/et_num"
|
||||
@@ -130,7 +130,7 @@
|
||||
android:maxLength="20"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:text="恭喜發財,大吉大利!"
|
||||
android:text="@string/red_package_msg_def"
|
||||
android:textColor="@color/color_322F4D"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_num" />
|
||||
@@ -155,7 +155,7 @@
|
||||
android:layout_marginTop="28dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_g_ff6060_ff225c_26_lr"
|
||||
android:text="发红包"
|
||||
android:text="@string/red_package_send"
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/et_text" />
|
||||
@@ -164,7 +164,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="未搶完的紅包將在12小時後返還你的錢包"
|
||||
android:text="@string/red_package_tips"
|
||||
android:textColor="@color/color_94959C"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
@@ -5152,4 +5152,18 @@
|
||||
<string name="red_package_type_msg_name">發彈幕紅包</string>
|
||||
<string name="red_package_type_msg_tips">發指定彈幕內容</string>
|
||||
|
||||
<string name="red_package_room">廳內紅包</string>
|
||||
<string name="red_package_public">全服紅包</string>
|
||||
<string name="red_package_money">紅包金額</string>
|
||||
<string name="red_package_num">紅包數量</string>
|
||||
<string name="red_package_money_unit">鉆</string>
|
||||
<string name="red_package_num_unit">個</string>
|
||||
<string name="red_package_type">搶紅包條件</string>
|
||||
<string name="red_package_msg_hint">輸入指定彈幕內容(最多10個字符)</string>
|
||||
<string name="red_package_send">發紅包</string>
|
||||
<string name="red_package_tips">未搶完的紅包將在12小時後返還你的錢包</string>
|
||||
<string name="red_package_now">立即生效</string>
|
||||
<string name="red_package_delay">即時生效</string>
|
||||
<string name="red_package_msg_def">恭喜發財,大吉大利!</string>
|
||||
|
||||
</resources>
|
86
library/src/module_utils/java/com/chuhai/utils/UiUtils.kt
Normal file
86
library/src/module_utils/java/com/chuhai/utils/UiUtils.kt
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.chuhai.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.core.text.TextUtilsCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Max
|
||||
* @date 2019-12-10.
|
||||
*/
|
||||
|
||||
|
||||
object UiUtils {
|
||||
fun getScreenWidth(context: Context): Int {
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as? WindowManager
|
||||
val outMetrics = DisplayMetrics()
|
||||
wm?.defaultDisplay?.getMetrics(outMetrics)
|
||||
return outMetrics.widthPixels
|
||||
}
|
||||
|
||||
fun getScreenHeight(context: Context): Int {
|
||||
val wm = context.getSystemService(Context.WINDOW_SERVICE) as? WindowManager
|
||||
val outMetrics = DisplayMetrics()
|
||||
wm?.defaultDisplay?.getMetrics(outMetrics)
|
||||
return outMetrics.heightPixels
|
||||
}
|
||||
|
||||
fun getScreenRatio(context: Context): Float {
|
||||
return getScreenWidth(context) * 1.0f / getScreenHeight(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||
*/
|
||||
fun dip2px(dpValue: Float): Int {
|
||||
return dip2px(AppUtils.getApp(), dpValue)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
|
||||
*/
|
||||
fun px2dip(pxValue: Float): Float {
|
||||
return px2dip(AppUtils.getApp(), pxValue)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||
*/
|
||||
fun dip2px(context: Context, dpValue: Float): Int {
|
||||
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, context.resources.displayMetrics) + 0.5f).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
|
||||
*/
|
||||
fun px2dip(context: Context, pxValue: Float): Float {
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, pxValue, context.resources.displayMetrics)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否从右到左布局
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
fun isRtl(view: View): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
View.LAYOUT_DIRECTION_RTL == view.layoutDirection
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否从右到左布局
|
||||
*/
|
||||
fun isRtl(context: Context): Boolean {
|
||||
return TextUtilsCompat.getLayoutDirectionFromLocale(context.resources.configuration.locale) == ViewCompat.LAYOUT_DIRECTION_RTL
|
||||
}
|
||||
}
|
53
library/src/module_utils/java/com/chuhai/utils/ktx/UiKtx.kt
Normal file
53
library/src/module_utils/java/com/chuhai/utils/ktx/UiKtx.kt
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.chuhai.utils.ktx
|
||||
|
||||
import com.chuhai.utils.UiUtils
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* UI
|
||||
* @author Max
|
||||
* @date 2020-01-10.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 转换为PX值
|
||||
*/
|
||||
val Float.dp: Int get() = this.toPX()
|
||||
val Int.dp: Int get() = this.toPX()
|
||||
|
||||
/**
|
||||
* 转换为DP值
|
||||
*/
|
||||
val Float.px: Int get() = this.toDP().roundToInt()
|
||||
val Int.px: Int get() = this.toDP().roundToInt()
|
||||
|
||||
|
||||
fun Long.toDP(): Float {
|
||||
return UiUtils.px2dip(this.toFloat())
|
||||
}
|
||||
|
||||
|
||||
fun Float.toDP(): Float {
|
||||
return UiUtils.px2dip(this)
|
||||
}
|
||||
|
||||
|
||||
fun Int.toDP(): Float {
|
||||
return UiUtils.px2dip(this.toFloat())
|
||||
}
|
||||
|
||||
|
||||
fun Long.toPX(): Int {
|
||||
return UiUtils.dip2px(this.toFloat())
|
||||
}
|
||||
|
||||
|
||||
fun Float.toPX(): Int {
|
||||
return UiUtils.dip2px(this)
|
||||
}
|
||||
|
||||
|
||||
fun Int.toPX(): Int {
|
||||
return UiUtils.dip2px(this.toFloat())
|
||||
}
|
Reference in New Issue
Block a user