diff --git a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUIAnimationUtils.java b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUIAnimationUtils.java new file mode 100644 index 0000000..64f9031 --- /dev/null +++ b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/ChatUIAnimationUtils.java @@ -0,0 +1,31 @@ +package com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore; + +import android.animation.ArgbEvaluator; +import android.animation.ValueAnimator; +import android.content.Context; +import android.content.res.ColorStateList; + +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +public class ChatUIAnimationUtils { + // 定义静态全局变量来管理时间 + public static final long DURATION_SHORT = 1000; // 1秒渐变 + public static final double DURATION_LONG = 2022.1104; // 2秒左右渐变,星闪规范发布日 + + public static void animateBackgroundColorChange(Context context, FloatingActionButton button, int startColorRes, int endColorRes) { + int startColor = context.getResources().getColor(startColorRes); + int endColor = context.getResources().getColor(endColorRes); + + ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor); + colorAnimation.setDuration((long) DURATION_LONG); // 动画持续时间,单位为毫秒 + colorAnimation.setRepeatCount(ValueAnimator.INFINITE); // 无限循环 + colorAnimation.setRepeatMode(ValueAnimator.REVERSE); // 反转颜色渐变 + colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animator) { + button.setBackgroundTintList(ColorStateList.valueOf((int) animator.getAnimatedValue())); + } + }); + colorAnimation.start(); + } +} diff --git a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java index 8248358..992b9a7 100644 --- a/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java +++ b/app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/MainActivity.java @@ -8,6 +8,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.database.Cursor; import android.hardware.usb.UsbManager; @@ -53,6 +54,7 @@ import com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.ChatMessageQueueUpdater; import com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.ChatProcessorForExtract; import com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.ChatSaveMessageDatabaseManager; +import com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.ChatUIAnimationUtils; import com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.ChatUtils; import com.haohanyh.linmengjia.nearlink.nlchat.fun.Premission.NearLinkChatGetSomePermission; import com.haohanyh.linmengjia.nearlink.nlchat.fun.R.array; @@ -639,6 +641,8 @@ public void onClick(View view) { if (view.getId() == id.btnGO) { MainAPP.Vibrate(this); btnGO.setEnabled(false);//一次点击后不可再次点击,因为已经把星闪网络给启动了 + btnGO.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(color.nearlinkgreen_deep))); + ChatUIAnimationUtils.animateBackgroundColorChange(MainActivity.this, btnGO, color.nearlinkgreen_deep, color.nearlinkgreen_light); InitToOpen(); } else if (view.getId() == id.menu_labels_right_btn_nearlink) { MainAPP.Vibrate(this); diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 6c0ba15..8665e7e 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -17,6 +17,8 @@ #4500CEFC #00C08B + #FF00C08B + #7C00C08B #330033 #0099FF diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a3765bc..73d0f7e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ NLChat com.haohanyh.linmengjia.nearlink.nlchat.fun - 1.3.56.2024.0706 + 1.3.57.2024.0706 NLChat,浩瀚银河宗旨为用爱和魔法创造Android APP。 友情感谢