头像框,空间特效

This commit is contained in:
coldmint 2022-07-26 22:35:13 +08:00
parent 8cbb9274e9
commit e7db8eeedc
23 changed files with 143 additions and 98 deletions

Binary file not shown.

View File

@ -68,6 +68,7 @@ android {
dependencies {
implementation 'com.luolc:emoji-rain:0.1.1'
implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
// https://github.com/getActivity/MultiLanguages
implementation 'com.github.getActivity:MultiLanguages:8.0'

View File

@ -2,6 +2,7 @@ package com.coldmint.rust.pro
import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.os.Environment
@ -31,9 +32,12 @@ import com.coldmint.rust.pro.databinding.ActivityEditModInfoBinding
import com.coldmint.rust.pro.databinding.ActivityEditUserInfoBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod
import com.flask.colorpicker.ColorPickerView
import com.flask.colorpicker.builder.ColorPickerDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.yalantis.ucrop.UCrop
import java.io.File
import java.lang.System.out
class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
lateinit var userId: String
@ -84,8 +88,11 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
viewBinding.signatureView.setText(introduce)
val gender = t.data.gender
if (gender < 0) {
viewBinding.updateSpinner.setSelection(1)
viewBinding.sexView.setText(item[1])
} else {
viewBinding.sexView.setText(item[0])
}
viewBinding.sexView.setSimpleItems(R.array.gender_entries)
viewBinding.button.isVisible = true
} else {
viewBinding.progressBar.isVisible = false
@ -104,6 +111,29 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
}
private fun initAction() {
viewBinding.changeColorButton.setOnClickListener {
ColorPickerDialogBuilder
.with(this)
.setTitle(getString(R.string.choose_color))
.initialColor(Color.WHITE)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(12)
.setOnColorSelectedListener {
//toast("onColorSelected: 0x" + Integer.toHexString(selectedColor));
}
.setPositiveButton(R.string.dialog_ok) { dialog, selectedColor, allColors ->
GlobalMethod.temColor = selectedColor
if (iconLink != null) {
Glide.with(this@EditUserInfoActivity)
.load(iconLink)
.apply(GlobalMethod.getRequestOptions(true, !GlobalMethod.isActive))
.into(viewBinding.iconView)
}
}
.setNegativeButton(R.string.dialog_cancel) { dialog, which -> }
.build()
.show()
}
viewBinding.userNameView.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
@ -234,8 +264,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
getString(R.string.edit_function) -> {
val userName = viewBinding.userNameView.text.toString()
val introduce = viewBinding.signatureView.text.toString()
val genderPosition = viewBinding.updateSpinner.selectedItemPosition
val genderValue = item[genderPosition]
val genderValue = viewBinding.sexView.text.toString()
val boy = getString(R.string.boy)
if (!checkUserName(userName)) {
return@setOnClickListener
@ -248,13 +277,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
} else {
-1
}
viewBinding.button.text = getString(R.string.request_data)
viewBinding.button.setBackgroundColor(
GlobalMethod.getThemeColor(
this,
R.attr.colorPrimaryVariant
)
)
viewBinding.button.hide()
val token =
AppSettings.getInstance(this).getValue(AppSettings.Setting.Token, "")
User.updateSpaceInfo(
@ -269,22 +292,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
Thread {
Glide.get(this@EditUserInfoActivity).clearDiskCache()
runOnUiThread {
viewBinding.button.text =
getString(R.string.edit_function)
viewBinding.button.setBackgroundColor(
GlobalMethod.getColorPrimary(
this@EditUserInfoActivity
)
)
Glide.get(this@EditUserInfoActivity).clearMemory()
// MaterialDialog(this@EditUserInfoActivity).show {
// title(R.string.edit_function).message(R.string.restart_to_take_effect)
// .cancelable(false)
// .positiveButton(R.string.dialog_ok)
// .positiveButton {
// finish()
// }
// }
finish()
}
}.start()
@ -292,12 +300,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
finish()
}
} else {
viewBinding.button.text = getString(R.string.edit_function)
viewBinding.button.setBackgroundColor(
GlobalMethod.getColorPrimary(
this@EditUserInfoActivity
)
)
viewBinding.button.show()
val data = t.data
if (data != null && ServerConfiguration.isEvent(data)) {
when (data) {
@ -320,12 +323,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
}
override fun onFailure(e: Exception) {
viewBinding.button.text = getString(R.string.edit_function)
viewBinding.button.setBackgroundColor(
GlobalMethod.getColorPrimary(
this@EditUserInfoActivity
)
)
viewBinding.button.show()
showInternetError(viewBinding.button, e)
}
@ -400,7 +398,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
val temLink = ServerConfiguration.getRealLink(link)
iconLink = temLink
Glide.with(this@EditUserInfoActivity)
.load(temLink).apply(GlobalMethod.getRequestOptions(true))
.load(temLink).apply(GlobalMethod.getRequestOptions(true, !GlobalMethod.isActive))
.into(viewBinding.iconView)
}
@ -414,7 +412,7 @@ class EditUserInfoActivity : BaseActivity<ActivityEditUserInfoBinding>() {
val temLink = ServerConfiguration.getRealLink(link)
coverLink = temLink
Glide.with(this@EditUserInfoActivity)
.load(temLink).apply(GlobalMethod.getRequestOptions())
.load(temLink).apply(GlobalMethod.getRequestOptions(grayscale = !GlobalMethod.isActive))
.into(viewBinding.coverView)
}

View File

@ -93,7 +93,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
viewBinding.navaiagtion.setupWithNavController(navController)
viewBinding.navaiagtion.addHeaderView(headLayout.root)
//actionbar动画
val actionToggle = ActionBarDrawerToggle(this,viewBinding.drawerlayout,viewBinding.toolbar,R.string.app_name,R.string.app_name)
val actionToggle = ActionBarDrawerToggle(
this,
viewBinding.drawerlayout,
viewBinding.toolbar,
R.string.app_name,
R.string.app_name
)
viewBinding.drawerlayout.addDrawerListener(actionToggle)
actionToggle.syncState()
}
@ -581,8 +587,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater = menuInflater
inflater.inflate(R.menu.menu_main, menu)
// val searchView = menu.findItem(R.id.app_bar_search).actionView as SearchView
// initSearchItem(searchView)
return true
}
@ -608,12 +612,14 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
*/
fun observeStartViewModel() {
startViewModel.userLiveData.observe(this) {
headLayout.nameView.text = it.data.userName
headLayout.emailView.text = it.data.email
val headIcon = it.data.headIcon
if (headIcon != null) {
Glide.with(this).load(ServerConfiguration.getRealLink(headIcon))
.apply(GlobalMethod.getRequestOptions(true)).into(headLayout.imageView)
.apply(GlobalMethod.getRequestOptions(true, !it.data.activation))
.into(headLayout.imageView)
}
val account = it.data.account
headLayout.root.setOnClickListener {

View File

@ -5,6 +5,7 @@ import android.app.ActivityOptions
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.Gravity
import android.view.View
@ -82,7 +83,17 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
openUserList(userId, false)
}
initButton()
// val dlist = ArrayList<Drawable>()
// for (i in 1..30) {
//// dlist.add(getDrawable(R.drawable.emoji_2_3)!!)
// dlist.add(getDrawable(R.drawable.emoji_1_3)!!)
// }
// viewBinding.bubbleView.setDrawableList(dlist)
// viewBinding.bubbleView.startAnimation(5000, 5000,30)
viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_1_3)
viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_2_3)
viewBinding.emojiRainLayout.addEmoji(R.drawable.emoji_3_3)
viewBinding.emojiRainLayout.startDropping()
}

View File

@ -1,45 +1,36 @@
package com.coldmint.rust.pro.tool
import android.Manifest
import android.app.Activity
import android.os.Environment
import android.content.pm.PackageManager
import android.content.pm.PackageInfo
import android.content.Intent
import android.util.TypedValue
import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.R
import android.widget.TextView
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import com.google.android.material.snackbar.Snackbar
import android.graphics.drawable.Drawable
import android.content.res.ColorStateList
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Paint
import android.net.Uri
import android.graphics.drawable.Drawable
import android.os.Build
import android.provider.Settings
import android.util.TypedValue
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.core.graphics.drawable.DrawableCompat
import androidx.fragment.app.FragmentActivity
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.bumptech.glide.Glide
import com.bumptech.glide.load.MultiTransformation
import com.bumptech.glide.request.RequestOptions
import com.coldmint.rust.core.dataBean.mod.WebModUpdateLogData
import com.coldmint.rust.core.interfaces.ApiCallBack
import com.coldmint.rust.core.web.ServerConfiguration
import com.coldmint.rust.core.web.WebMod
import com.coldmint.rust.pro.MainActivity
import com.coldmint.rust.pro.R
import com.flask.colorpicker.ColorPickerView
import com.flask.colorpicker.builder.ColorPickerDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.permissionx.guolindev.PermissionX
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.math.BigInteger
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import jp.wasabeef.glide.transformations.*
import jp.wasabeef.glide.transformations.internal.Utils
/*全局方法类*/
object GlobalMethod {
@ -51,18 +42,33 @@ object GlobalMethod {
const val DEFAULT_GAME_PACKAGE = "com.corrodinggames.rts"
const val DEBUG_SIGN = "963dfd616924b27f9247a35e45bc130a"
const val RELEASE_SIGN = "5320b24894fe7ed449842a81a2dfceda"
var temColor = Color.RED
/**
* 获取Glide请求设置
* @return RequestOptions
*/
fun getRequestOptions(circleCrop: Boolean = false): RequestOptions {
val requestOptions = if (circleCrop) {
RequestOptions.circleCropTransform()
} else {
RequestOptions().placeholder(R.drawable.image).error(R.drawable.image_not_supported)
fun getRequestOptions(circleCrop: Boolean = false, grayscale: Boolean = false): RequestOptions {
//变换列表
val transformations = ArrayList<BitmapTransformation>()
if (circleCrop) {
transformations.add(CropCircleWithBorderTransformation(Utils.toDp(4), temColor))
}
if (grayscale) {
transformations.add(GrayscaleTransformation())
}
//请求设置
val requestOptions = if (transformations.isNotEmpty()) {
val multi = MultiTransformation<Bitmap>(
transformations
)
RequestOptions.bitmapTransform(multi)
} else {
RequestOptions()
}
requestOptions.placeholder(R.drawable.image)
.error(R.drawable.image_not_supported)
return requestOptions
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM19,19L5,19L5,5h11.17L19,7.83L19,19zM12,12c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3zM6,6h9v4L6,10z"/>
</vector>

View File

@ -1,12 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M819.82,83.69L206.99,83.69c-67.7,0 -122.59,54.88 -122.59,122.59v612.83c0,67.7 54.88,122.59 122.59,122.59h612.83c67.7,0 122.59,-54.88 122.59,-122.59L942.41,206.28c-0,-67.7 -54.88,-122.59 -122.59,-122.59zM695.39,147.01v241.14L331.77,388.15L331.77,147.01h363.62zM881.17,819.28c0.03,33.76 -27.32,61.16 -61.09,61.19L207.13,880.47c-16.39,0 -31.86,-6.3 -43.45,-17.89s-18.04,-26.91 -18.04,-43.3v-612.94c0.06,-33.92 27.57,-61.4 61.49,-61.41h61.33v245.29c-0.05,33.77 27.29,61.19 61.06,61.24h367.89c33.85,0 61.3,-27.39 61.3,-61.24L758.7,144.93h61.21c33.87,0.04 61.3,27.52 61.26,61.4L881.18,819.28z"
android:fillColor="?android:attr/textColorPrimary"/>
<path
android:pathData="M574.82,329.94c17.48,0 31.66,-14.17 31.66,-31.66v-61.29c0,-17.48 -14.17,-31.66 -31.66,-31.66s-31.66,14.17 -31.66,31.66v61.29c0,17.48 14.17,31.66 31.66,31.66z"
android:fillColor="?android:attr/textColorPrimary"/>
</vector>

View File

@ -25,6 +25,7 @@
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
@ -52,7 +53,7 @@
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:visibility="gone"
android:visibility="visible"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
@ -121,7 +122,24 @@
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:hint="@string/gender">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/sexView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
app:simpleItems="@array/gender_entries" />
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
@ -129,18 +147,23 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gender" />
android:layout_centerVertical="true"
android:text="@string/profile_picture_box_color" />
<Spinner
android:id="@+id/updateSpinner"
<Button
android:id="@+id/changeColorButton"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/gender_entries" />
</LinearLayout>
android:layout_alignParentEnd="true"
android:text="@string/choose_color" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:gravity="center_vertical">
<TextView
@ -157,18 +180,19 @@
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<Button
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
app:icon="@drawable/ic_outline_save_24"
android:text="@string/edit_function"
android:visibility="gone" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -254,6 +254,11 @@
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
<com.luolc.emojirain.EmojiRainLayout
android:id="@+id/emojiRainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"

View File

@ -14,7 +14,7 @@
<item
android:id="@+id/save_text"
android:icon="@drawable/save"
android:icon="@drawable/ic_outline_save_24"
android:title="@string/edit_function"
app:actionViewClass="view"
app:showAsAction="always" />

View File

@ -359,6 +359,7 @@
<string name="collapse_info">崩溃信息</string>
<string name="load_system_application">显示系统应用</string>
<string name="choose_color">选择颜色</string>
<string name="profile_picture_box_color">头像框颜色</string>
<string name="game_pack">游戏包</string>
<string name="select_the_game_pack">选择游戏包</string>
<string name="enable_the_recovery_station">模组回收站</string>
@ -589,7 +590,7 @@
<string name="defollow_tip">要取消关注\"%1$s\"嘛?</string>
<string name="head_icon">头像:</string>
<string name="signature">个性签名</string>
<string name="gender">性别:</string>
<string name="gender">性别</string>
<string name="cover">空间背景:</string>
<string name="night_mode_auto">深色默认不自动开启</string>
<string name="account_tip">注册后不能修改。</string>

View File

@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jul 25 19:57:10 CST 2022
sdk.dir=D\:\\Android_SDK
#Mon Jul 25 20:47:39 CST 2022
sdk.dir=D\:\\Document\\AndroidSdk