mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
Merge branch 'develop' into feature/create_file_intent
This commit is contained in:
commit
c5c3592a4c
7 changed files with 73 additions and 66 deletions
|
@ -27,6 +27,7 @@ Build 🧱:
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
- Use Intent.ACTION_CREATE_DOCUMENT to save megolm key or recovery key in a txt file
|
- Use Intent.ACTION_CREATE_DOCUMENT to save megolm key or recovery key in a txt file
|
||||||
|
- Use `Context#withStyledAttributes` extension function (#1546)
|
||||||
|
|
||||||
Changes in Riot.imX 0.91.4 (2020-07-06)
|
Changes in Riot.imX 0.91.4 (2020-07-06)
|
||||||
===================================================
|
===================================================
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 New Vector Ltd
|
* Copyright 2020 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,7 @@ import android.graphics.drawable.ColorDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
@ -67,19 +68,19 @@ class PercentViewBehavior<V : View>(context: Context, attrs: AttributeSet) : Coo
|
||||||
private var isPrepared: Boolean = false
|
private var isPrepared: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val a = context.obtainStyledAttributes(attrs, R.styleable.PercentViewBehavior)
|
context.withStyledAttributes(attrs, R.styleable.PercentViewBehavior) {
|
||||||
dependViewId = a.getResourceId(R.styleable.PercentViewBehavior_behavior_dependsOn, 0)
|
dependViewId = getResourceId(R.styleable.PercentViewBehavior_behavior_dependsOn, 0)
|
||||||
dependType = a.getInt(R.styleable.PercentViewBehavior_behavior_dependType, DEPEND_TYPE_WIDTH)
|
dependType = getInt(R.styleable.PercentViewBehavior_behavior_dependType, DEPEND_TYPE_WIDTH)
|
||||||
dependTarget = a.getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_dependTarget, UNSPECIFIED_INT)
|
dependTarget = getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_dependTarget, UNSPECIFIED_INT)
|
||||||
targetX = a.getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetX, UNSPECIFIED_INT)
|
targetX = getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetX, UNSPECIFIED_INT)
|
||||||
targetY = a.getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetY, UNSPECIFIED_INT)
|
targetY = getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetY, UNSPECIFIED_INT)
|
||||||
targetWidth = a.getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetWidth, UNSPECIFIED_INT)
|
targetWidth = getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetWidth, UNSPECIFIED_INT)
|
||||||
targetHeight = a.getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetHeight, UNSPECIFIED_INT)
|
targetHeight = getDimensionPixelOffset(R.styleable.PercentViewBehavior_behavior_targetHeight, UNSPECIFIED_INT)
|
||||||
targetBackgroundColor = a.getColor(R.styleable.PercentViewBehavior_behavior_targetBackgroundColor, UNSPECIFIED_INT)
|
targetBackgroundColor = getColor(R.styleable.PercentViewBehavior_behavior_targetBackgroundColor, UNSPECIFIED_INT)
|
||||||
targetAlpha = a.getFloat(R.styleable.PercentViewBehavior_behavior_targetAlpha, UNSPECIFIED_FLOAT)
|
targetAlpha = getFloat(R.styleable.PercentViewBehavior_behavior_targetAlpha, UNSPECIFIED_FLOAT)
|
||||||
targetRotateX = a.getFloat(R.styleable.PercentViewBehavior_behavior_targetRotateX, UNSPECIFIED_FLOAT)
|
targetRotateX = getFloat(R.styleable.PercentViewBehavior_behavior_targetRotateX, UNSPECIFIED_FLOAT)
|
||||||
targetRotateY = a.getFloat(R.styleable.PercentViewBehavior_behavior_targetRotateY, UNSPECIFIED_FLOAT)
|
targetRotateY = getFloat(R.styleable.PercentViewBehavior_behavior_targetRotateY, UNSPECIFIED_FLOAT)
|
||||||
a.recycle()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepare(parent: CoordinatorLayout, child: View, dependency: View) {
|
private fun prepare(parent: CoordinatorLayout, child: View, dependency: View) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import android.text.TextUtils.substring
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
@ -71,6 +72,7 @@ class EllipsizingTextView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
private var maxLines = 0
|
private var maxLines = 0
|
||||||
private var lineSpacingMult = 1.0f
|
private var lineSpacingMult = 1.0f
|
||||||
private var lineAddVertPad = 0.0f
|
private var lineAddVertPad = 0.0f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The end punctuation which will be removed when appending [.ELLIPSIS].
|
* The end punctuation which will be removed when appending [.ELLIPSIS].
|
||||||
*/
|
*/
|
||||||
|
@ -408,9 +410,9 @@ class EllipsizingTextView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val a = context.obtainStyledAttributes(attrs, intArrayOf(android.R.attr.maxLines, android.R.attr.ellipsize), defStyle, 0)
|
context.withStyledAttributes(attrs, intArrayOf(android.R.attr.maxLines, android.R.attr.ellipsize), defStyle) {
|
||||||
maxLines = a.getInt(0, Int.MAX_VALUE)
|
maxLines = getInt(0, Int.MAX_VALUE)
|
||||||
a.recycle()
|
}
|
||||||
setEndPunctuationPattern(DEFAULT_END_PUNCTUATION)
|
setEndPunctuationPattern(DEFAULT_END_PUNCTUATION)
|
||||||
val currentTextColor = currentTextColor
|
val currentTextColor = currentTextColor
|
||||||
val ellipsizeColor = Color.argb(ELLIPSIZE_ALPHA, Color.red(currentTextColor), Color.green(currentTextColor), Color.blue(currentTextColor))
|
val ellipsizeColor = Color.argb(ELLIPSIZE_ALPHA, Color.red(currentTextColor), Color.green(currentTextColor), Color.blue(currentTextColor))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 New Vector Ltd
|
* Copyright 2020 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.riotx.core.platform
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
|
||||||
|
@ -34,9 +35,9 @@ class MaxHeightScrollView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MaxHeightScrollView)
|
context.withStyledAttributes(attrs, R.styleable.MaxHeightScrollView) {
|
||||||
maxHeight = styledAttrs.getDimensionPixelSize(R.styleable.MaxHeightScrollView_maxHeight, DEFAULT_MAX_HEIGHT)
|
maxHeight = getDimensionPixelSize(R.styleable.MaxHeightScrollView_maxHeight, DEFAULT_MAX_HEIGHT)
|
||||||
styledAttrs.recycle()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.view.View
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -117,16 +118,15 @@ class BottomSheetActionButton @JvmOverloads constructor(
|
||||||
inflate(context, R.layout.item_verification_action, this)
|
inflate(context, R.layout.item_verification_action, this)
|
||||||
ButterKnife.bind(this)
|
ButterKnife.bind(this)
|
||||||
|
|
||||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetActionButton, 0, 0)
|
context.withStyledAttributes(attrs, R.styleable.BottomSheetActionButton) {
|
||||||
title = typedArray.getString(R.styleable.BottomSheetActionButton_actionTitle) ?: ""
|
title = getString(R.styleable.BottomSheetActionButton_actionTitle) ?: ""
|
||||||
subTitle = typedArray.getString(R.styleable.BottomSheetActionButton_actionDescription) ?: ""
|
subTitle = getString(R.styleable.BottomSheetActionButton_actionDescription) ?: ""
|
||||||
forceStartPadding = typedArray.getBoolean(R.styleable.BottomSheetActionButton_forceStartPadding, false)
|
forceStartPadding = getBoolean(R.styleable.BottomSheetActionButton_forceStartPadding, false)
|
||||||
leftIcon = typedArray.getDrawable(R.styleable.BottomSheetActionButton_leftIcon)
|
leftIcon = getDrawable(R.styleable.BottomSheetActionButton_leftIcon)
|
||||||
|
|
||||||
rightIcon = typedArray.getDrawable(R.styleable.BottomSheetActionButton_rightIcon)
|
rightIcon = getDrawable(R.styleable.BottomSheetActionButton_rightIcon)
|
||||||
|
|
||||||
tint = typedArray.getColor(R.styleable.BottomSheetActionButton_tint, ThemeUtils.getColor(context, android.R.attr.textColor))
|
tint = getColor(R.styleable.BottomSheetActionButton_tint, ThemeUtils.getColor(context, android.R.attr.textColor))
|
||||||
|
}
|
||||||
typedArray.recycle()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
import butterknife.ButterKnife
|
import butterknife.ButterKnife
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
@ -73,11 +74,11 @@ class PollResultLineView @JvmOverloads constructor(
|
||||||
orientation = HORIZONTAL
|
orientation = HORIZONTAL
|
||||||
ButterKnife.bind(this)
|
ButterKnife.bind(this)
|
||||||
|
|
||||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.PollResultLineView, 0, 0)
|
context.withStyledAttributes(attrs, R.styleable.PollResultLineView) {
|
||||||
label = typedArray.getString(R.styleable.PollResultLineView_optionName) ?: ""
|
label = getString(R.styleable.PollResultLineView_optionName) ?: ""
|
||||||
percent = typedArray.getString(R.styleable.PollResultLineView_optionCount) ?: ""
|
percent = getString(R.styleable.PollResultLineView_optionCount) ?: ""
|
||||||
optionSelected = typedArray.getBoolean(R.styleable.PollResultLineView_optionSelected, false)
|
optionSelected = getBoolean(R.styleable.PollResultLineView_optionSelected, false)
|
||||||
isWinner = typedArray.getBoolean(R.styleable.PollResultLineView_optionIsWinner, false)
|
isWinner = getBoolean(R.styleable.PollResultLineView_optionIsWinner, false)
|
||||||
typedArray.recycle()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 New Vector Ltd
|
* Copyright 2020 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -34,6 +34,7 @@ import android.widget.TextView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.withStyledAttributes
|
||||||
import im.vector.riotx.EmojiCompatWrapper
|
import im.vector.riotx.EmojiCompatWrapper
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.HasScreenInjector
|
import im.vector.riotx.core.di.HasScreenInjector
|
||||||
|
@ -44,7 +45,8 @@ import javax.inject.Inject
|
||||||
* An animated reaction button.
|
* An animated reaction button.
|
||||||
* Displays a String reaction (emoji), with a count, and that can be selected or not (toggle)
|
* Displays a String reaction (emoji), with a count, and that can be selected or not (toggle)
|
||||||
*/
|
*/
|
||||||
class ReactionButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null,
|
class ReactionButton @JvmOverloads constructor(context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0)
|
defStyleAttr: Int = 0)
|
||||||
: FrameLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener {
|
: FrameLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener {
|
||||||
|
|
||||||
|
@ -109,42 +111,41 @@ class ReactionButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
countTextView?.text = TextUtils.formatCountToShortDecimal(reactionCount)
|
countTextView?.text = TextUtils.formatCountToShortDecimal(reactionCount)
|
||||||
|
|
||||||
// emojiView?.typeface = this.emojiTypeFace ?: Typeface.DEFAULT
|
// emojiView?.typeface = this.emojiTypeFace ?: Typeface.DEFAULT
|
||||||
|
context.withStyledAttributes(attrs, R.styleable.ReactionButton, defStyleAttr) {
|
||||||
|
onDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape)
|
||||||
|
offDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape_off)
|
||||||
|
|
||||||
val array = context.obtainStyledAttributes(attrs, R.styleable.ReactionButton, defStyleAttr, 0)
|
circleStartColor = getColor(R.styleable.ReactionButton_circle_start_color, 0)
|
||||||
|
|
||||||
onDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape)
|
if (circleStartColor != 0) {
|
||||||
offDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape_off)
|
circleView.startColor = circleStartColor
|
||||||
|
}
|
||||||
|
|
||||||
circleStartColor = array.getColor(R.styleable.ReactionButton_circle_start_color, 0)
|
circleEndColor = getColor(R.styleable.ReactionButton_circle_end_color, 0)
|
||||||
|
|
||||||
if (circleStartColor != 0) {
|
if (circleEndColor != 0) {
|
||||||
circleView.startColor = circleStartColor
|
circleView.endColor = circleEndColor
|
||||||
|
}
|
||||||
|
|
||||||
|
dotPrimaryColor = getColor(R.styleable.ReactionButton_dots_primary_color, 0)
|
||||||
|
dotSecondaryColor = getColor(R.styleable.ReactionButton_dots_secondary_color, 0)
|
||||||
|
|
||||||
|
if (dotPrimaryColor != 0 && dotSecondaryColor != 0) {
|
||||||
|
dotsView.setColors(dotPrimaryColor, dotSecondaryColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
getString(R.styleable.ReactionButton_emoji)?.let {
|
||||||
|
reactionString = it
|
||||||
|
}
|
||||||
|
|
||||||
|
reactionCount = getInt(R.styleable.ReactionButton_reaction_count, 0)
|
||||||
|
|
||||||
|
val status = getBoolean(R.styleable.ReactionButton_toggled, false)
|
||||||
|
setChecked(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
circleEndColor = array.getColor(R.styleable.ReactionButton_circle_end_color, 0)
|
|
||||||
|
|
||||||
if (circleEndColor != 0) {
|
|
||||||
circleView.endColor = circleEndColor
|
|
||||||
}
|
|
||||||
|
|
||||||
dotPrimaryColor = array.getColor(R.styleable.ReactionButton_dots_primary_color, 0)
|
|
||||||
dotSecondaryColor = array.getColor(R.styleable.ReactionButton_dots_secondary_color, 0)
|
|
||||||
|
|
||||||
if (dotPrimaryColor != 0 && dotSecondaryColor != 0) {
|
|
||||||
dotsView.setColors(dotPrimaryColor, dotSecondaryColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
array.getString(R.styleable.ReactionButton_emoji)?.let {
|
|
||||||
reactionString = it
|
|
||||||
}
|
|
||||||
|
|
||||||
reactionCount = array.getInt(R.styleable.ReactionButton_reaction_count, 0)
|
|
||||||
|
|
||||||
val status = array.getBoolean(R.styleable.ReactionButton_toggled, false)
|
|
||||||
setChecked(status)
|
|
||||||
setOnClickListener(this)
|
setOnClickListener(this)
|
||||||
setOnLongClickListener(this)
|
setOnLongClickListener(this)
|
||||||
array.recycle()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDrawableFromResource(array: TypedArray, styleableIndexId: Int): Drawable? {
|
private fun getDrawableFromResource(array: TypedArray, styleableIndexId: Int): Drawable? {
|
||||||
|
|
Loading…
Reference in a new issue