Fix warnings in the App
This commit is contained in:
parent
a9c474105a
commit
119e4c0d32
@ -14,6 +14,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("UNUSED_PARAMETER")
|
||||||
|
|
||||||
package im.vector.riotx.push.fcm
|
package im.vector.riotx.push.fcm
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -56,7 +56,7 @@ class TestTokenRegistration @Inject constructor(private val context: AppCompatAc
|
|||||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_token_registration_quick_fix) {
|
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_token_registration_quick_fix) {
|
||||||
override fun doFix() {
|
override fun doFix() {
|
||||||
val workId = pushersManager.registerPusherWithFcmKey(fcmToken)
|
val workId = pushersManager.registerPusherWithFcmKey(fcmToken)
|
||||||
WorkManager.getInstance().getWorkInfoByIdLiveData(workId).observe(context, Observer { workInfo ->
|
WorkManager.getInstance(context).getWorkInfoByIdLiveData(workId).observe(context, Observer { workInfo ->
|
||||||
if (workInfo != null) {
|
if (workInfo != null) {
|
||||||
if (workInfo.state == WorkInfo.State.SUCCEEDED) {
|
if (workInfo.state == WorkInfo.State.SUCCEEDED) {
|
||||||
manager?.retry()
|
manager?.retry()
|
||||||
|
@ -155,7 +155,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## onMessageReceivedInternal() failed : " + e.message)
|
Timber.e(e, "## onMessageReceivedInternal() failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,17 +234,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun findRoomNameBestEffort(data: Map<String, String>, session: Session?): String? {
|
private fun findRoomNameBestEffort(data: Map<String, String>, session: Session?): String? {
|
||||||
val roomName: String? = data["room_name"]
|
var roomName: String? = data["room_name"]
|
||||||
val roomId = data["room_id"]
|
val roomId = data["room_id"]
|
||||||
if (null == roomName && null != roomId) {
|
if (null == roomName && null != roomId) {
|
||||||
// Try to get the room name from our store
|
// Try to get the room name from our store
|
||||||
/*
|
roomName = session?.getRoom(roomId)?.roomSummary()?.displayName
|
||||||
TODO
|
|
||||||
if (session?.dataHandler?.store?.isReady == true) {
|
|
||||||
val room = session.getRoom(roomId)
|
|
||||||
roomName = room?.getRoomDisplayName(this)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
return roomName
|
return roomName
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,9 @@ object FcmHelper {
|
|||||||
storeFcmToken(activity, instanceIdResult.token)
|
storeFcmToken(activity, instanceIdResult.token)
|
||||||
pushersManager.registerPusherWithFcmKey(instanceIdResult.token)
|
pushersManager.registerPusherWithFcmKey(instanceIdResult.token)
|
||||||
}
|
}
|
||||||
.addOnFailureListener(activity) { e -> Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed " + e.message) }
|
.addOnFailureListener(activity) { e -> Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed") }
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed " + e.message)
|
Timber.e(e, "## ensureFcmTokenIsRetrieved() : failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -102,10 +102,12 @@ object FcmHelper {
|
|||||||
return resultCode == ConnectionResult.SUCCESS
|
return resultCode == ConnectionResult.SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun onEnterForeground(context: Context) {
|
fun onEnterForeground(context: Context) {
|
||||||
// No op
|
// No op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun onEnterBackground(context: Context, vectorPreferences: VectorPreferences, activeSessionHolder: ActiveSessionHolder) {
|
fun onEnterBackground(context: Context, vectorPreferences: VectorPreferences, activeSessionHolder: ActiveSessionHolder) {
|
||||||
// TODO FCM fallback
|
// TODO FCM fallback
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
|
|||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
vectorConfiguration.onConfigurationChanged(newConfig)
|
vectorConfiguration.onConfigurationChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFontThreadHandler(): Handler {
|
private fun getFontThreadHandler(): Handler {
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.riotx.core.dialogs
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import im.vector.riotx.R
|
|
||||||
|
|
||||||
internal abstract class DialogAdapter(context: Context) : ArrayAdapter<DialogListItem>(context, R.layout.item_dialog) {
|
|
||||||
|
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
|
||||||
val view: View
|
|
||||||
if (convertView == null) {
|
|
||||||
view = LayoutInflater.from(context).inflate(R.layout.item_dialog, parent, false)
|
|
||||||
view.tag = DialogListItemHolder(view)
|
|
||||||
} else {
|
|
||||||
view = convertView
|
|
||||||
}
|
|
||||||
with(view.tag as DialogListItemHolder) {
|
|
||||||
icon.setImageResource(getItem(position).iconRes)
|
|
||||||
text.setText(getItem(position).titleRes)
|
|
||||||
}
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.riotx.core.dialogs
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
|
|
||||||
internal class DialogCallAdapter(context: Context) : DialogAdapter(context) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
add(DialogListItem.StartVoiceCall)
|
|
||||||
add(DialogListItem.StartVideoCall)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.riotx.core.dialogs
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import im.vector.riotx.R
|
|
||||||
|
|
||||||
internal sealed class DialogListItem(@DrawableRes val iconRes: Int,
|
|
||||||
@StringRes val titleRes: Int) {
|
|
||||||
|
|
||||||
object StartVoiceCall : DialogListItem(R.drawable.voice_call_green, R.string.action_voice_call)
|
|
||||||
object StartVideoCall : DialogListItem(R.drawable.video_call_green, R.string.action_video_call)
|
|
||||||
|
|
||||||
object SendFile : DialogListItem(R.drawable.ic_material_file, R.string.option_send_files)
|
|
||||||
object SendVoice : DialogListItem(R.drawable.vector_micro_green, R.string.option_send_voice)
|
|
||||||
object SendSticker : DialogListItem(R.drawable.ic_send_sticker, R.string.option_send_sticker)
|
|
||||||
object TakePhoto : DialogListItem(R.drawable.ic_material_camera, R.string.option_take_photo)
|
|
||||||
object TakeVideo : DialogListItem(R.drawable.ic_material_videocam, R.string.option_take_video)
|
|
||||||
object TakePhotoVideo : DialogListItem(R.drawable.ic_material_camera, R.string.option_take_photo_video)
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.riotx.core.dialogs
|
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import butterknife.BindView
|
|
||||||
import butterknife.ButterKnife
|
|
||||||
import im.vector.riotx.R
|
|
||||||
|
|
||||||
class DialogListItemHolder(view: View) {
|
|
||||||
|
|
||||||
@BindView(R.id.adapter_item_dialog_icon)
|
|
||||||
lateinit var icon: ImageView
|
|
||||||
|
|
||||||
@BindView(R.id.adapter_item_dialog_text)
|
|
||||||
lateinit var text: TextView
|
|
||||||
|
|
||||||
init {
|
|
||||||
ButterKnife.bind(this, view)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.riotx.core.dialogs
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
|
|
||||||
internal class DialogSendItemAdapter(context: Context, items: MutableList<DialogListItem>) : DialogAdapter(context) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
addAll(items)
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,8 +17,8 @@
|
|||||||
package im.vector.riotx.core.error
|
package im.vector.riotx.core.error
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.Html
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.text.HtmlCompat
|
||||||
import im.vector.matrix.android.api.failure.MatrixError
|
import im.vector.matrix.android.api.failure.MatrixError
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import me.gujun.android.span.span
|
import me.gujun.android.span.span
|
||||||
@ -46,7 +46,7 @@ class ResourceLimitErrorFormatter(private val context: Context) {
|
|||||||
val contact = if (clickable && matrixError.adminUri != null) {
|
val contact = if (clickable && matrixError.adminUri != null) {
|
||||||
val contactSubString = uriAsLink(matrixError.adminUri!!)
|
val contactSubString = uriAsLink(matrixError.adminUri!!)
|
||||||
val contactFullString = context.getString(mode.contactRes, contactSubString)
|
val contactFullString = context.getString(mode.contactRes, contactSubString)
|
||||||
Html.fromHtml(contactFullString)
|
HtmlCompat.fromHtml(contactFullString, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||||
} else {
|
} else {
|
||||||
val contactSubString = context.getString(R.string.resource_limit_contact_admin)
|
val contactSubString = context.getString(R.string.resource_limit_contact_admin)
|
||||||
context.getString(mode.contactRes, contactSubString)
|
context.getString(mode.contactRes, contactSubString)
|
||||||
|
@ -39,7 +39,7 @@ fun EditText.setupAsSearch(@DrawableRes searchIconRes: Int = R.drawable.ic_filte
|
|||||||
maxLines = 1
|
maxLines = 1
|
||||||
inputType = InputType.TYPE_CLASS_TEXT
|
inputType = InputType.TYPE_CLASS_TEXT
|
||||||
imeOptions = EditorInfo.IME_ACTION_SEARCH
|
imeOptions = EditorInfo.IME_ACTION_SEARCH
|
||||||
setOnEditorActionListener { _, actionId, event ->
|
setOnEditorActionListener { _, actionId, _ ->
|
||||||
var consumed = false
|
var consumed = false
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
@ -61,8 +61,11 @@ class ImageTools @Inject constructor(private val context: Context) {
|
|||||||
}
|
}
|
||||||
} else if (uri.scheme == "file") {
|
} else if (uri.scheme == "file") {
|
||||||
try {
|
try {
|
||||||
val exif = ExifInterface(uri.path)
|
val path = uri.path
|
||||||
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)
|
if (path != null) {
|
||||||
|
val exif = ExifInterface(path)
|
||||||
|
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "Cannot get EXIF for file uri $uri")
|
Timber.e(e, "Cannot get EXIF for file uri $uri")
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import androidx.preference.PreferenceViewHolder
|
|||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
|
||||||
// TODO Replace by real Bingrule class, then delete
|
// TODO Replace by real Bingrule class, then delete
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
class BingRule(rule: BingRule) {
|
class BingRule(rule: BingRule) {
|
||||||
fun shouldNotNotify() = false
|
fun shouldNotNotify() = false
|
||||||
fun shouldNotify() = false
|
fun shouldNotify() = false
|
||||||
@ -216,7 +217,7 @@ class BingRulePreference : VectorPreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radioGroup?.setOnCheckedChangeListener { group, checkedId ->
|
radioGroup?.setOnCheckedChangeListener { _, checkedId ->
|
||||||
when (checkedId) {
|
when (checkedId) {
|
||||||
R.id.bingPreferenceRadioBingRuleOff -> {
|
R.id.bingPreferenceRadioBingRuleOff -> {
|
||||||
onPreferenceChangeListener?.onPreferenceChange(this, NOTIFICATION_OFF_INDEX)
|
onPreferenceChangeListener?.onPreferenceChange(this, NOTIFICATION_OFF_INDEX)
|
||||||
|
@ -47,7 +47,7 @@ class VectorEditTextPreference : EditTextPreference {
|
|||||||
try {
|
try {
|
||||||
holder.itemView.findViewById<TextView>(android.R.id.title)?.setSingleLine(false)
|
holder.itemView.findViewById<TextView>(android.R.id.title)?.setSingleLine(false)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "onBindView " + e.message)
|
Timber.e(e, "onBindView")
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onBindViewHolder(holder)
|
super.onBindViewHolder(holder)
|
||||||
|
@ -41,16 +41,8 @@ open class VectorPreference : Preference {
|
|||||||
|
|
||||||
var mTypeface = Typeface.NORMAL
|
var mTypeface = Typeface.NORMAL
|
||||||
|
|
||||||
// long press listener
|
|
||||||
/**
|
/**
|
||||||
* Returns the callback to be invoked when this Preference is long clicked.
|
* Callback to be invoked when this Preference is long clicked.
|
||||||
*
|
|
||||||
* @return The callback to be invoked.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Sets the callback to be invoked when this Preference is long clicked.
|
|
||||||
*
|
|
||||||
* @param onPreferenceLongClickListener The callback to be invoked.
|
|
||||||
*/
|
*/
|
||||||
var onPreferenceLongClickListener: OnPreferenceLongClickListener? = null
|
var onPreferenceLongClickListener: OnPreferenceLongClickListener? = null
|
||||||
|
|
||||||
@ -112,13 +104,13 @@ open class VectorPreference : Preference {
|
|||||||
currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo).apply {
|
currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo).apply {
|
||||||
duration = 250 // milliseconds
|
duration = 250 // milliseconds
|
||||||
addUpdateListener { animator ->
|
addUpdateListener { animator ->
|
||||||
itemView?.setBackgroundColor(animator.animatedValue as Int)
|
itemView.setBackgroundColor(animator.animatedValue as Int)
|
||||||
}
|
}
|
||||||
doOnEnd {
|
doOnEnd {
|
||||||
currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorTo, colorFrom).apply {
|
currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorTo, colorFrom).apply {
|
||||||
duration = 250 // milliseconds
|
duration = 250 // milliseconds
|
||||||
addUpdateListener { animator ->
|
addUpdateListener { animator ->
|
||||||
itemView?.setBackgroundColor(animator.animatedValue as Int)
|
itemView.setBackgroundColor(animator.animatedValue as Int)
|
||||||
}
|
}
|
||||||
doOnEnd {
|
doOnEnd {
|
||||||
isHighlighted = false
|
isHighlighted = false
|
||||||
|
@ -36,7 +36,7 @@ class AppNameProvider @Inject constructor(private val context: Context) {
|
|||||||
}
|
}
|
||||||
return appName
|
return appName
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## AppNameProvider() : failed " + e.message)
|
Timber.e(e, "## AppNameProvider() : failed")
|
||||||
return "RiotXAndroid"
|
return "RiotXAndroid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,14 @@ data class Resource(
|
|||||||
/**
|
/**
|
||||||
* Get a resource stream and metadata about it given its URI returned from onActivityResult.
|
* Get a resource stream and metadata about it given its URI returned from onActivityResult.
|
||||||
*
|
*
|
||||||
* @param context the context.
|
* @param context the context.
|
||||||
* @param uri the URI
|
* @param uri the URI
|
||||||
* @param mimetype the mimetype
|
* @param providedMimetype the mimetype
|
||||||
* @return a [Resource] encapsulating the opened resource stream and associated metadata
|
* @return a [Resource] encapsulating the opened resource stream and associated metadata
|
||||||
* or `null` if opening the resource stream failed.
|
* or `null` if opening the resource stream failed.
|
||||||
*/
|
*/
|
||||||
fun openResource(context: Context, uri: Uri, mimetype: String?): Resource? {
|
fun openResource(context: Context, uri: Uri, providedMimetype: String?): Resource? {
|
||||||
var mimetype = mimetype
|
var mimetype = providedMimetype
|
||||||
try {
|
try {
|
||||||
// if the mime type is not provided, try to find it out
|
// if the mime type is not provided, try to find it out
|
||||||
if (TextUtils.isEmpty(mimetype)) {
|
if (TextUtils.isEmpty(mimetype)) {
|
||||||
@ -86,9 +86,7 @@ fun openResource(context: Context, uri: Uri, mimetype: String?): Resource? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Resource(
|
return Resource(context.contentResolver.openInputStream(uri), mimetype)
|
||||||
context.contentResolver.openInputStream(uri),
|
|
||||||
mimetype)
|
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "Failed to open resource input stream")
|
Timber.e(e, "Failed to open resource input stream")
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UNUSED_PARAMETER")
|
||||||
|
|
||||||
package im.vector.riotx.core.services
|
package im.vector.riotx.core.services
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -243,7 +243,7 @@ fun shareMedia(context: Context, file: File, mediaMimeType: String?) {
|
|||||||
try {
|
try {
|
||||||
mediaUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", file)
|
mediaUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", file)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e("onMediaAction Selected File cannot be shared " + e.message)
|
Timber.e(e, "onMediaAction Selected File cannot be shared")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ import java.util.*
|
|||||||
fun isIgnoringBatteryOptimizations(context: Context): Boolean {
|
fun isIgnoringBatteryOptimizations(context: Context): Boolean {
|
||||||
// no issue before Android M, battery optimisations did not exist
|
// no issue before Android M, battery optimisations did not exist
|
||||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
||||||
|| (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isIgnoringBatteryOptimizations(context.packageName) == true
|
|| (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isIgnoringBatteryOptimizations(context.packageName) == true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ fun requestDisablingBatteryOptimization(activity: Activity, fragment: Fragment?,
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param text the text to copy
|
* @param text the text to copy
|
||||||
*/
|
*/
|
||||||
fun copyToClipboard(context: Context, text: CharSequence, showToast: Boolean = true, @StringRes toastMessage : Int = R.string.copied_to_clipboard) {
|
fun copyToClipboard(context: Context, text: CharSequence, showToast: Boolean = true, @StringRes toastMessage: Int = R.string.copied_to_clipboard) {
|
||||||
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
clipboard.primaryClip = ClipData.newPlainText("", text)
|
clipboard.primaryClip = ClipData.newPlainText("", text)
|
||||||
if (showToast) {
|
if (showToast) {
|
||||||
@ -92,19 +92,16 @@ fun copyToClipboard(context: Context, text: CharSequence, showToast: Boolean = t
|
|||||||
* @return the device locale
|
* @return the device locale
|
||||||
*/
|
*/
|
||||||
fun getDeviceLocale(context: Context): Locale {
|
fun getDeviceLocale(context: Context): Locale {
|
||||||
var locale: Locale
|
return try {
|
||||||
|
|
||||||
locale = try {
|
|
||||||
val packageManager = context.packageManager
|
val packageManager = context.packageManager
|
||||||
val resources = packageManager.getResourcesForApplication("android")
|
val resources = packageManager.getResourcesForApplication("android")
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
resources.configuration.locale
|
resources.configuration.locale
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## getDeviceLocale() failed " + e.message)
|
Timber.e(e, "## getDeviceLocale() failed")
|
||||||
// Fallback to application locale
|
// Fallback to application locale
|
||||||
VectorLocale.applicationLocale
|
VectorLocale.applicationLocale
|
||||||
}
|
}
|
||||||
|
|
||||||
return locale
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UNUSED_PARAMETER")
|
||||||
|
|
||||||
package im.vector.riotx.features.badge
|
package im.vector.riotx.features.badge
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -49,7 +49,7 @@ object CommandParser {
|
|||||||
try {
|
try {
|
||||||
messageParts = textMessage.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }
|
messageParts = textMessage.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## manageSplashCommand() : split failed " + e.message)
|
Timber.e(e, "## manageSplashCommand() : split failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if the string cut fails
|
// test if the string cut fails
|
||||||
|
@ -34,7 +34,7 @@ import javax.inject.Inject
|
|||||||
class VectorConfiguration @Inject constructor(private val context: Context) {
|
class VectorConfiguration @Inject constructor(private val context: Context) {
|
||||||
|
|
||||||
// TODO Import mLanguageReceiver From Riot?
|
// TODO Import mLanguageReceiver From Riot?
|
||||||
fun onConfigurationChanged(newConfig: Configuration?) {
|
fun onConfigurationChanged() {
|
||||||
if (Locale.getDefault().toString() != VectorLocale.applicationLocale.toString()) {
|
if (Locale.getDefault().toString() != VectorLocale.applicationLocale.toString()) {
|
||||||
Timber.v("## onConfigurationChanged() : the locale has been updated to " + Locale.getDefault().toString()
|
Timber.v("## onConfigurationChanged() : the locale has been updated to " + Locale.getDefault().toString()
|
||||||
+ ", restore the expected value " + VectorLocale.applicationLocale.toString())
|
+ ", restore the expected value " + VectorLocale.applicationLocale.toString())
|
||||||
@ -51,8 +51,10 @@ class VectorConfiguration @Inject constructor(private val context: Context) {
|
|||||||
Locale.setDefault(locale)
|
Locale.setDefault(locale)
|
||||||
|
|
||||||
val config = Configuration(context.resources.configuration)
|
val config = Configuration(context.resources.configuration)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
config.locale = locale
|
config.locale = locale
|
||||||
config.fontScale = FontScale.getFontScale(context)
|
config.fontScale = FontScale.getFontScale(context)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
||||||
|
|
||||||
ThemeUtils.setApplicationTheme(context, theme)
|
ThemeUtils.setApplicationTheme(context, theme)
|
||||||
@ -82,8 +84,10 @@ class VectorConfiguration @Inject constructor(private val context: Context) {
|
|||||||
|
|
||||||
Locale.setDefault(locale)
|
Locale.setDefault(locale)
|
||||||
val config = Configuration(context.resources.configuration)
|
val config = Configuration(context.resources.configuration)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
config.locale = locale
|
config.locale = locale
|
||||||
config.fontScale = fontScale
|
config.fontScale = fontScale
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
||||||
|
|
||||||
// init the theme
|
// init the theme
|
||||||
@ -119,10 +123,12 @@ class VectorConfiguration @Inject constructor(private val context: Context) {
|
|||||||
configuration.setLayoutDirection(locale)
|
configuration.setLayoutDirection(locale)
|
||||||
return context.createConfigurationContext(configuration)
|
return context.createConfigurationContext(configuration)
|
||||||
} else {
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
configuration.locale = locale
|
configuration.locale = locale
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
configuration.setLayoutDirection(locale)
|
configuration.setLayoutDirection(locale)
|
||||||
}
|
}
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
resources.updateConfiguration(configuration, resources.displayMetrics)
|
resources.updateConfiguration(configuration, resources.displayMetrics)
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
@ -135,7 +141,6 @@ class VectorConfiguration @Inject constructor(private val context: Context) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the locale status value
|
* Compute the locale status value
|
||||||
* @param activity the activity
|
|
||||||
* @return the local status value
|
* @return the local status value
|
||||||
*/
|
*/
|
||||||
// TODO Create data class for this
|
// TODO Create data class for this
|
||||||
|
@ -84,9 +84,9 @@ class KeysBackupRestoreFromKeyViewModel @Inject constructor() : ViewModel() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
object : MatrixCallback<ImportRoomKeysResult> {
|
object : MatrixCallback<ImportRoomKeysResult> {
|
||||||
override fun onSuccess(info: ImportRoomKeysResult) {
|
override fun onSuccess(data: ImportRoomKeysResult) {
|
||||||
sharedViewModel.loadingEvent.value = null
|
sharedViewModel.loadingEvent.value = null
|
||||||
sharedViewModel.didRecoverSucceed(info)
|
sharedViewModel.didRecoverSucceed(data)
|
||||||
|
|
||||||
KeysBackupBanner.onRecoverDoneForVersion(context, keysVersionResult.version!!)
|
KeysBackupBanner.onRecoverDoneForVersion(context, keysVersionResult.version!!)
|
||||||
trustOnDecrypt(keysBackup, keysVersionResult)
|
trustOnDecrypt(keysBackup, keysVersionResult)
|
||||||
|
@ -148,7 +148,7 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() {
|
|||||||
AlertDialog.Builder(this@KeysBackupSetupActivity)
|
AlertDialog.Builder(this@KeysBackupSetupActivity)
|
||||||
.setMessage(getString(R.string.encryption_export_saved_as, data))
|
.setMessage(getString(R.string.encryption_export_saved_as, data))
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(R.string.ok) { dialog, which ->
|
.setPositiveButton(R.string.ok) { _, _ ->
|
||||||
val resultIntent = Intent()
|
val resultIntent = Intent()
|
||||||
resultIntent.putExtra(MANUAL_EXPORT, true)
|
resultIntent.putExtra(MANUAL_EXPORT, true)
|
||||||
setResult(RESULT_OK, resultIntent)
|
setResult(RESULT_OK, resultIntent)
|
||||||
|
@ -139,7 +139,7 @@ class KeysBackupSetupSharedViewModel @Inject constructor() : ViewModel() {
|
|||||||
loadingStatus.value = null
|
loadingStatus.value = null
|
||||||
|
|
||||||
isCreatingBackupVersion.value = false
|
isCreatingBackupVersion.value = false
|
||||||
prepareRecoverFailError.value = failure ?: Exception()
|
prepareRecoverFailError.value = failure
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent
|
|||||||
import im.vector.matrix.android.api.session.user.model.User
|
import im.vector.matrix.android.api.session.user.model.User
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ScreenComponent
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.dialogs.DialogListItem
|
|
||||||
import im.vector.riotx.core.epoxy.LayoutManagerStateRestorer
|
import im.vector.riotx.core.epoxy.LayoutManagerStateRestorer
|
||||||
import im.vector.riotx.core.error.ErrorFormatter
|
import im.vector.riotx.core.error.ErrorFormatter
|
||||||
import im.vector.riotx.core.extensions.hideKeyboard
|
import im.vector.riotx.core.extensions.hideKeyboard
|
||||||
@ -642,6 +641,7 @@ class RoomDetailFragment :
|
|||||||
inviteView.callback = this
|
inviteView.callback = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private fun onSendChoiceClicked(dialogListItem: DialogListItem) {
|
private fun onSendChoiceClicked(dialogListItem: DialogListItem) {
|
||||||
Timber.v("On send choice clicked: $dialogListItem")
|
Timber.v("On send choice clicked: $dialogListItem")
|
||||||
when (dialogListItem) {
|
when (dialogListItem) {
|
||||||
@ -668,7 +668,7 @@ class RoomDetailFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private fun handleMediaIntent(data: Intent) {
|
private fun handleMediaIntent(data: Intent) {
|
||||||
val files: ArrayList<MediaFile> = data.getParcelableArrayListExtra(FilePickerActivity.MEDIA_FILES)
|
val files: ArrayList<MediaFile> = data.getParcelableArrayListExtra(FilePickerActivity.MEDIA_FILES)
|
||||||
roomDetailViewModel.process(RoomDetailActions.SendMedia(files))
|
roomDetailViewModel.process(RoomDetailActions.SendMedia(files))
|
||||||
|
@ -46,7 +46,6 @@ import im.vector.matrix.android.api.session.room.model.tombstone.RoomTombstoneCo
|
|||||||
import im.vector.matrix.android.api.session.room.send.UserDraft
|
import im.vector.matrix.android.api.session.room.send.UserDraft
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineSettings
|
import im.vector.matrix.android.api.session.room.timeline.TimelineSettings
|
||||||
import im.vector.matrix.android.api.session.room.timeline.getTextEditableContent
|
import im.vector.matrix.android.api.session.room.timeline.getTextEditableContent
|
||||||
import im.vector.matrix.android.api.util.Optional
|
|
||||||
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
|
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
|
||||||
import im.vector.matrix.android.internal.crypto.model.event.EncryptedEventContent
|
import im.vector.matrix.android.internal.crypto.model.event.EncryptedEventContent
|
||||||
import im.vector.matrix.rx.rx
|
import im.vector.matrix.rx.rx
|
||||||
@ -64,8 +63,6 @@ import im.vector.riotx.features.command.CommandParser
|
|||||||
import im.vector.riotx.features.command.ParsedCommand
|
import im.vector.riotx.features.command.ParsedCommand
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineDisplayableEvents
|
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineDisplayableEvents
|
||||||
import im.vector.riotx.features.settings.VectorPreferences
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import io.reactivex.Observable
|
|
||||||
import io.reactivex.functions.BiFunction
|
|
||||||
import io.reactivex.rxkotlin.subscribeBy
|
import io.reactivex.rxkotlin.subscribeBy
|
||||||
import org.commonmark.parser.Parser
|
import org.commonmark.parser.Parser
|
||||||
import org.commonmark.renderer.html.HtmlRenderer
|
import org.commonmark.renderer.html.HtmlRenderer
|
||||||
@ -75,21 +72,28 @@ import java.util.concurrent.TimeUnit
|
|||||||
|
|
||||||
|
|
||||||
class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: RoomDetailViewState,
|
class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: RoomDetailViewState,
|
||||||
private val userPreferencesProvider: UserPreferencesProvider,
|
userPreferencesProvider: UserPreferencesProvider,
|
||||||
private val vectorPreferences: VectorPreferences,
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val imageTools: ImageTools,
|
private val imageTools: ImageTools,
|
||||||
private val session: Session
|
private val session: Session
|
||||||
) : VectorViewModel<RoomDetailViewState>(initialState) {
|
) : VectorViewModel<RoomDetailViewState>(initialState) {
|
||||||
|
|
||||||
private val room = session.getRoom(initialState.roomId)!!
|
private val room = session.getRoom(initialState.roomId)!!
|
||||||
private val roomId = initialState.roomId
|
|
||||||
private val eventId = initialState.eventId
|
private val eventId = initialState.eventId
|
||||||
private val invisibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsInvisible>()
|
private val invisibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsInvisible>()
|
||||||
private val visibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsVisible>()
|
private val visibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsVisible>()
|
||||||
private val timelineSettings = if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
private val timelineSettings = if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
||||||
TimelineSettings(30, false, true, TimelineDisplayableEvents.DEBUG_DISPLAYABLE_TYPES, userPreferencesProvider.shouldShowReadReceipts())
|
TimelineSettings(30,
|
||||||
|
filterEdits = false,
|
||||||
|
filterTypes = true,
|
||||||
|
allowedTypes = TimelineDisplayableEvents.DEBUG_DISPLAYABLE_TYPES,
|
||||||
|
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
||||||
} else {
|
} else {
|
||||||
TimelineSettings(30, true, true, TimelineDisplayableEvents.DISPLAYABLE_TYPES, userPreferencesProvider.shouldShowReadReceipts())
|
TimelineSettings(30,
|
||||||
|
filterEdits = true,
|
||||||
|
filterTypes = true,
|
||||||
|
allowedTypes = TimelineDisplayableEvents.DISPLAYABLE_TYPES,
|
||||||
|
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
|
||||||
}
|
}
|
||||||
|
|
||||||
private var timeline = room.createTimeline(eventId, timelineSettings)
|
private var timeline = room.createTimeline(eventId, timelineSettings)
|
||||||
@ -152,7 +156,6 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
is RoomDetailActions.ResendAll -> handleResendAll()
|
is RoomDetailActions.ResendAll -> handleResendAll()
|
||||||
is RoomDetailActions.SetReadMarkerAction -> handleSetReadMarkerAction(action)
|
is RoomDetailActions.SetReadMarkerAction -> handleSetReadMarkerAction(action)
|
||||||
is RoomDetailActions.MarkAllAsRead -> handleMarkAllAsRead()
|
is RoomDetailActions.MarkAllAsRead -> handleMarkAllAsRead()
|
||||||
else -> Timber.e("Unhandled Action: $action")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,23 +186,23 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
copy(
|
copy(
|
||||||
// Create a sendMode from a draft and retrieve the TimelineEvent
|
// Create a sendMode from a draft and retrieve the TimelineEvent
|
||||||
sendMode = when (draft) {
|
sendMode = when (draft) {
|
||||||
is UserDraft.REGULAR -> SendMode.REGULAR(draft.text)
|
is UserDraft.REGULAR -> SendMode.REGULAR(draft.text)
|
||||||
is UserDraft.QUOTE -> {
|
is UserDraft.QUOTE -> {
|
||||||
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
||||||
SendMode.QUOTE(timelineEvent, draft.text)
|
SendMode.QUOTE(timelineEvent, draft.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is UserDraft.REPLY -> {
|
is UserDraft.REPLY -> {
|
||||||
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
||||||
SendMode.REPLY(timelineEvent, draft.text)
|
SendMode.REPLY(timelineEvent, draft.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is UserDraft.EDIT -> {
|
is UserDraft.EDIT -> {
|
||||||
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
room.getTimeLineEvent(draft.linkedEventId)?.let { timelineEvent ->
|
||||||
SendMode.EDIT(timelineEvent, draft.text)
|
SendMode.EDIT(timelineEvent, draft.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ?: SendMode.REGULAR("")
|
} ?: SendMode.REGULAR("")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +211,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
|
|
||||||
private fun handleTombstoneEvent(action: RoomDetailActions.HandleTombstoneEvent) {
|
private fun handleTombstoneEvent(action: RoomDetailActions.HandleTombstoneEvent) {
|
||||||
val tombstoneContent = action.event.getClearContent().toModel<RoomTombstoneContent>()
|
val tombstoneContent = action.event.getClearContent().toModel<RoomTombstoneContent>()
|
||||||
?: return
|
?: return
|
||||||
|
|
||||||
val roomId = tombstoneContent.replacementRoom ?: ""
|
val roomId = tombstoneContent.replacementRoom ?: ""
|
||||||
val isRoomJoined = session.getRoom(roomId)?.roomSummary()?.membership == Membership.JOIN
|
val isRoomJoined = session.getRoom(roomId)?.roomSummary()?.membership == Membership.JOIN
|
||||||
@ -268,9 +271,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
withState { state ->
|
withState { state ->
|
||||||
when (state.sendMode) {
|
when (state.sendMode) {
|
||||||
is SendMode.REGULAR -> {
|
is SendMode.REGULAR -> {
|
||||||
val slashCommandResult = CommandParser.parseSplashCommand(action.text)
|
when (val slashCommandResult = CommandParser.parseSplashCommand(action.text)) {
|
||||||
|
|
||||||
when (slashCommandResult) {
|
|
||||||
is ParsedCommand.ErrorNotACommand -> {
|
is ParsedCommand.ErrorNotACommand -> {
|
||||||
// Send the text message to the room
|
// Send the text message to the room
|
||||||
room.sendTextMessage(action.text, autoMarkdown = action.autoMarkdown)
|
room.sendTextMessage(action.text, autoMarkdown = action.autoMarkdown)
|
||||||
@ -342,7 +343,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
is SendMode.EDIT -> {
|
is SendMode.EDIT -> {
|
||||||
//is original event a reply?
|
//is original event a reply?
|
||||||
val inReplyTo = state.sendMode.timelineEvent.root.getClearContent().toModel<MessageContent>()?.relatesTo?.inReplyTo?.eventId
|
val inReplyTo = state.sendMode.timelineEvent.root.getClearContent().toModel<MessageContent>()?.relatesTo?.inReplyTo?.eventId
|
||||||
?: state.sendMode.timelineEvent.root.content.toModel<EncryptedEventContent>()?.relatesTo?.inReplyTo?.eventId
|
?: state.sendMode.timelineEvent.root.content.toModel<EncryptedEventContent>()?.relatesTo?.inReplyTo?.eventId
|
||||||
if (inReplyTo != null) {
|
if (inReplyTo != null) {
|
||||||
//TODO check if same content?
|
//TODO check if same content?
|
||||||
room.getTimeLineEvent(inReplyTo)?.let {
|
room.getTimeLineEvent(inReplyTo)?.let {
|
||||||
@ -351,13 +352,13 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
} else {
|
} else {
|
||||||
val messageContent: MessageContent? =
|
val messageContent: MessageContent? =
|
||||||
state.sendMode.timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
state.sendMode.timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
||||||
?: state.sendMode.timelineEvent.root.getClearContent().toModel()
|
?: state.sendMode.timelineEvent.root.getClearContent().toModel()
|
||||||
val existingBody = messageContent?.body ?: ""
|
val existingBody = messageContent?.body ?: ""
|
||||||
if (existingBody != action.text) {
|
if (existingBody != action.text) {
|
||||||
room.editTextMessage(state.sendMode.timelineEvent.root.eventId ?: "",
|
room.editTextMessage(state.sendMode.timelineEvent.root.eventId ?: "",
|
||||||
messageContent?.type ?: MessageType.MSGTYPE_TEXT,
|
messageContent?.type ?: MessageType.MSGTYPE_TEXT,
|
||||||
action.text,
|
action.text,
|
||||||
action.autoMarkdown)
|
action.autoMarkdown)
|
||||||
} else {
|
} else {
|
||||||
Timber.w("Same message content, do not send edition")
|
Timber.w("Same message content, do not send edition")
|
||||||
}
|
}
|
||||||
@ -368,7 +369,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
is SendMode.QUOTE -> {
|
is SendMode.QUOTE -> {
|
||||||
val messageContent: MessageContent? =
|
val messageContent: MessageContent? =
|
||||||
state.sendMode.timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
state.sendMode.timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
||||||
?: state.sendMode.timelineEvent.root.getClearContent().toModel()
|
?: state.sendMode.timelineEvent.root.getClearContent().toModel()
|
||||||
val textMsg = messageContent?.body
|
val textMsg = messageContent?.body
|
||||||
|
|
||||||
val finalText = legacyRiotQuoteText(textMsg, action.text)
|
val finalText = legacyRiotQuoteText(textMsg, action.text)
|
||||||
@ -403,10 +404,10 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
|
|
||||||
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
||||||
val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
|
val messageParagraphs = quotedText?.split("\n\n".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
|
||||||
var quotedTextMsg = StringBuilder()
|
val quotedTextMsg = StringBuilder()
|
||||||
if (messageParagraphs != null) {
|
if (messageParagraphs != null) {
|
||||||
for (i in messageParagraphs.indices) {
|
for (i in messageParagraphs.indices) {
|
||||||
if (messageParagraphs[i].trim({ it <= ' ' }) != "") {
|
if (messageParagraphs[i].trim { it <= ' ' } != "") {
|
||||||
quotedTextMsg.append("> ").append(messageParagraphs[i])
|
quotedTextMsg.append("> ").append(messageParagraphs[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,8 +416,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val finalText = "$quotedTextMsg\n\n$myText"
|
return "$quotedTextMsg\n\n$myText"
|
||||||
return finalText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleChangeTopicSlashCommand(changeTopic: ParsedCommand.ChangeTopic) {
|
private fun handleChangeTopicSlashCommand(changeTopic: ParsedCommand.ChangeTopic) {
|
||||||
@ -654,12 +654,12 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
Timber.e("Cannot resend message, it is not failed, Cancel first")
|
Timber.e("Cannot resend message, it is not failed, Cancel first")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (it.root.isTextMessage()) {
|
when {
|
||||||
room.resendTextMessage(it)
|
it.root.isTextMessage() -> room.resendTextMessage(it)
|
||||||
} else if (it.root.isImageMessage()) {
|
it.root.isImageMessage() -> room.resendMediaMessage(it)
|
||||||
room.resendMediaMessage(it)
|
else -> {
|
||||||
} else {
|
//TODO
|
||||||
//TODO
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +701,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
.disposeOnClear()
|
.disposeOnClear()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSetReadMarkerAction(action: RoomDetailActions.SetReadMarkerAction) = withState { state ->
|
private fun handleSetReadMarkerAction(action: RoomDetailActions.SetReadMarkerAction) = withState {
|
||||||
var readMarkerId = action.eventId
|
var readMarkerId = action.eventId
|
||||||
val indexOfEvent = timeline.getIndexOfEvent(readMarkerId)
|
val indexOfEvent = timeline.getIndexOfEvent(readMarkerId)
|
||||||
// force to set the read marker on the next event
|
// force to set the read marker on the next event
|
||||||
|
@ -32,6 +32,7 @@ import com.airbnb.epoxy.EpoxyModel
|
|||||||
import com.airbnb.epoxy.EpoxyTouchHelperCallback
|
import com.airbnb.epoxy.EpoxyTouchHelperCallback
|
||||||
import com.airbnb.epoxy.EpoxyViewHolder
|
import com.airbnb.epoxy.EpoxyViewHolder
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
|
||||||
class RoomMessageTouchHelperCallback(private val context: Context,
|
class RoomMessageTouchHelperCallback(private val context: Context,
|
||||||
@ -104,6 +105,7 @@ class RoomMessageTouchHelperCallback(private val context: Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun setTouchListener(c: Canvas,
|
private fun setTouchListener(c: Canvas,
|
||||||
recyclerView: RecyclerView,
|
recyclerView: RecyclerView,
|
||||||
@ -112,11 +114,11 @@ class RoomMessageTouchHelperCallback(private val context: Context,
|
|||||||
dY: Float,
|
dY: Float,
|
||||||
actionState: Int,
|
actionState: Int,
|
||||||
isCurrentlyActive: Boolean) {
|
isCurrentlyActive: Boolean) {
|
||||||
//TODO can this interfer with other interactions? should i remove it
|
//TODO can this interfere with other interactions? should i remove it
|
||||||
recyclerView.setOnTouchListener { v, event ->
|
recyclerView.setOnTouchListener { _, event ->
|
||||||
swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP
|
swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP
|
||||||
if (swipeBack) {
|
if (swipeBack) {
|
||||||
if (Math.abs(dX) >= triggerDistance) {
|
if (abs(dX) >= triggerDistance) {
|
||||||
try {
|
try {
|
||||||
viewHolder.model?.let { handler.performQuickReplyOnHolder(it) }
|
viewHolder.model?.let { handler.performQuickReplyOnHolder(it) }
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
|
@ -31,6 +31,8 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
|||||||
import im.vector.riotx.core.date.VectorDateFormatter
|
import im.vector.riotx.core.date.VectorDateFormatter
|
||||||
import im.vector.riotx.core.epoxy.LoadingItem_
|
import im.vector.riotx.core.epoxy.LoadingItem_
|
||||||
import im.vector.riotx.core.extensions.localDateTime
|
import im.vector.riotx.core.extensions.localDateTime
|
||||||
|
import im.vector.riotx.core.utils.DimensionConverter
|
||||||
|
import im.vector.riotx.features.home.AvatarRenderer
|
||||||
import im.vector.riotx.features.home.room.detail.RoomDetailViewState
|
import im.vector.riotx.features.home.room.detail.RoomDetailViewState
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.factory.MergedHeaderItemFactory
|
import im.vector.riotx.features.home.room.detail.timeline.factory.MergedHeaderItemFactory
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.factory.TimelineItemFactory
|
import im.vector.riotx.features.home.room.detail.timeline.factory.TimelineItemFactory
|
||||||
@ -38,8 +40,6 @@ import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineEventDi
|
|||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineEventVisibilityStateChangedListener
|
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineEventVisibilityStateChangedListener
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.nextOrNull
|
import im.vector.riotx.features.home.room.detail.timeline.helper.nextOrNull
|
||||||
import im.vector.riotx.core.utils.DimensionConverter
|
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.item.*
|
import im.vector.riotx.features.home.room.detail.timeline.item.*
|
||||||
import im.vector.riotx.features.media.ImageContentRenderer
|
import im.vector.riotx.features.media.ImageContentRenderer
|
||||||
import im.vector.riotx.features.media.VideoContentRenderer
|
import im.vector.riotx.features.media.VideoContentRenderer
|
||||||
@ -327,7 +327,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||||||
* Return true if added
|
* Return true if added
|
||||||
*/
|
*/
|
||||||
private fun LoadingItem_.setVisibilityStateChangedListener(direction: Timeline.Direction): LoadingItem_ {
|
private fun LoadingItem_.setVisibilityStateChangedListener(direction: Timeline.Direction): LoadingItem_ {
|
||||||
return onVisibilityStateChanged { model, view, visibilityState ->
|
return onVisibilityStateChanged { _, _, visibilityState ->
|
||||||
if (visibilityState == VisibilityState.VISIBLE) {
|
if (visibilityState == VisibilityState.VISIBLE) {
|
||||||
callback?.onLoadMore(direction)
|
callback?.onLoadMore(direction)
|
||||||
}
|
}
|
||||||
|
@ -78,17 +78,13 @@ class MessageMenuFragment : VectorBaseFragment() {
|
|||||||
|
|
||||||
private fun inflateActionView(action: SimpleAction, inflater: LayoutInflater, container: ViewGroup?): View? {
|
private fun inflateActionView(action: SimpleAction, inflater: LayoutInflater, container: ViewGroup?): View? {
|
||||||
return inflater.inflate(R.layout.adapter_item_action, container, false)?.apply {
|
return inflater.inflate(R.layout.adapter_item_action, container, false)?.apply {
|
||||||
if (action.iconResId != null) {
|
findViewById<ImageView>(R.id.action_icon)?.setImageResource(action.iconResId)
|
||||||
findViewById<ImageView>(R.id.action_icon)?.setImageResource(action.iconResId)
|
|
||||||
} else {
|
|
||||||
findViewById<ImageView>(R.id.action_icon)?.setImageDrawable(null)
|
|
||||||
}
|
|
||||||
findViewById<TextView>(R.id.action_title)?.setText(action.titleRes)
|
findViewById<TextView>(R.id.action_title)?.setText(action.titleRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun inflateSeparatorView(): View {
|
private fun inflateSeparatorView(): View {
|
||||||
val frame = FrameLayout(context)
|
val frame = FrameLayout(requireContext())
|
||||||
frame.setBackgroundColor(ThemeUtils.getColor(requireContext(), R.attr.vctr_list_divider_color))
|
frame.setBackgroundColor(ThemeUtils.getColor(requireContext(), R.attr.vctr_list_divider_color))
|
||||||
frame.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, requireContext().resources.displayMetrics.density.toInt())
|
frame.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, requireContext().resources.displayMetrics.density.toInt())
|
||||||
return frame
|
return frame
|
||||||
|
@ -198,7 +198,7 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canCancel(event: TimelineEvent): Boolean {
|
private fun canCancel(@Suppress("UNUSED_PARAMETER") event: TimelineEvent): Boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,15 +28,7 @@ import im.vector.matrix.android.api.permalinks.MatrixLinkify
|
|||||||
import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
||||||
import im.vector.matrix.android.api.session.events.model.RelationType
|
import im.vector.matrix.android.api.session.events.model.RelationType
|
||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageAudioContent
|
import im.vector.matrix.android.api.session.room.model.message.*
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageEmoteContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageFileContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageNoticeContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.getFileUrl
|
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent
|
import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent
|
||||||
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
|
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
|
||||||
@ -47,17 +39,10 @@ import im.vector.riotx.core.linkify.VectorLinkify
|
|||||||
import im.vector.riotx.core.resources.ColorProvider
|
import im.vector.riotx.core.resources.ColorProvider
|
||||||
import im.vector.riotx.core.resources.StringProvider
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import im.vector.riotx.core.utils.DebouncedClickListener
|
import im.vector.riotx.core.utils.DebouncedClickListener
|
||||||
import im.vector.riotx.core.utils.DimensionConverter
|
|
||||||
import im.vector.riotx.core.utils.containsOnlyEmojis
|
|
||||||
import im.vector.riotx.core.utils.isLocalFile
|
import im.vector.riotx.core.utils.isLocalFile
|
||||||
import im.vector.riotx.features.home.AvatarRenderer
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
|
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
|
import im.vector.riotx.features.home.room.detail.timeline.helper.*
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.AvatarSizeProvider
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.item.*
|
import im.vector.riotx.features.home.room.detail.timeline.item.*
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.MessageInformationDataFactory
|
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.MessageItemAttributesFactory
|
|
||||||
import im.vector.riotx.features.html.EventHtmlRenderer
|
import im.vector.riotx.features.html.EventHtmlRenderer
|
||||||
import im.vector.riotx.features.media.ImageContentRenderer
|
import im.vector.riotx.features.media.ImageContentRenderer
|
||||||
import im.vector.riotx.features.media.VideoContentRenderer
|
import im.vector.riotx.features.media.VideoContentRenderer
|
||||||
@ -130,6 +115,7 @@ class MessageItemFactory @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildAudioMessageItem(messageContent: MessageAudioContent,
|
private fun buildAudioMessageItem(messageContent: MessageAudioContent,
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
highlight: Boolean,
|
highlight: Boolean,
|
||||||
callback: TimelineEventController.Callback?,
|
callback: TimelineEventController.Callback?,
|
||||||
@ -162,7 +148,7 @@ class MessageItemFactory @Inject constructor(
|
|||||||
.filename(messageContent.body)
|
.filename(messageContent.body)
|
||||||
.iconRes(R.drawable.filetype_attachment)
|
.iconRes(R.drawable.filetype_attachment)
|
||||||
.clickListener(
|
.clickListener(
|
||||||
DebouncedClickListener(View.OnClickListener { _ ->
|
DebouncedClickListener(View.OnClickListener {
|
||||||
callback?.onFileMessageClicked(informationData.eventId, messageContent)
|
callback?.onFileMessageClicked(informationData.eventId, messageContent)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -176,6 +162,7 @@ class MessageItemFactory @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildImageMessageItem(messageContent: MessageImageContent,
|
private fun buildImageMessageItem(messageContent: MessageImageContent,
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
highlight: Boolean,
|
highlight: Boolean,
|
||||||
callback: TimelineEventController.Callback?,
|
callback: TimelineEventController.Callback?,
|
||||||
@ -305,6 +292,7 @@ class MessageItemFactory @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildNoticeMessageItem(messageContent: MessageNoticeContent,
|
private fun buildNoticeMessageItem(messageContent: MessageNoticeContent,
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
highlight: Boolean,
|
highlight: Boolean,
|
||||||
callback: TimelineEventController.Callback?,
|
callback: TimelineEventController.Callback?,
|
||||||
|
@ -38,7 +38,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
|
|||||||
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
||||||
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderName())
|
EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderName())
|
||||||
EventType.STATE_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
EventType.STATE_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
||||||
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.getDisambiguatedDisplayName())
|
||||||
EventType.CALL_INVITE,
|
EventType.CALL_INVITE,
|
||||||
EventType.CALL_HANGUP,
|
EventType.CALL_HANGUP,
|
||||||
EventType.CALL_ANSWER -> formatCallEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
EventType.CALL_ANSWER -> formatCallEvent(timelineEvent.root, timelineEvent.getDisambiguatedDisplayName())
|
||||||
@ -61,7 +61,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
|
|||||||
EventType.CALL_INVITE,
|
EventType.CALL_INVITE,
|
||||||
EventType.CALL_HANGUP,
|
EventType.CALL_HANGUP,
|
||||||
EventType.CALL_ANSWER -> formatCallEvent(event, senderName)
|
EventType.CALL_ANSWER -> formatCallEvent(event, senderName)
|
||||||
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName)
|
EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(senderName)
|
||||||
else -> {
|
else -> {
|
||||||
Timber.v("Type $type not handled by this formatter")
|
Timber.v("Type $type not handled by this formatter")
|
||||||
null
|
null
|
||||||
@ -82,7 +82,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatRoomTombstoneEvent(event: Event, senderName: String?): CharSequence? {
|
private fun formatRoomTombstoneEvent(senderName: String?): CharSequence? {
|
||||||
return stringProvider.getString(R.string.notice_room_update, senderName)
|
return stringProvider.getString(R.string.notice_room_update, senderName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,17 +67,17 @@ private class ContentMediaProgressUpdater(private val progressLayout: ViewGroup,
|
|||||||
|
|
||||||
override fun onUpdate(state: ContentUploadStateTracker.State) {
|
override fun onUpdate(state: ContentUploadStateTracker.State) {
|
||||||
when (state) {
|
when (state) {
|
||||||
is ContentUploadStateTracker.State.Idle -> handleIdle(state)
|
is ContentUploadStateTracker.State.Idle -> handleIdle()
|
||||||
is ContentUploadStateTracker.State.EncryptingThumbnail -> handleEncryptingThumbnail(state)
|
is ContentUploadStateTracker.State.EncryptingThumbnail -> handleEncryptingThumbnail()
|
||||||
is ContentUploadStateTracker.State.UploadingThumbnail -> handleProgressThumbnail(state)
|
is ContentUploadStateTracker.State.UploadingThumbnail -> handleProgressThumbnail(state)
|
||||||
is ContentUploadStateTracker.State.Encrypting -> handleEncrypting(state)
|
is ContentUploadStateTracker.State.Encrypting -> handleEncrypting()
|
||||||
is ContentUploadStateTracker.State.Uploading -> handleProgress(state)
|
is ContentUploadStateTracker.State.Uploading -> handleProgress(state)
|
||||||
is ContentUploadStateTracker.State.Failure -> handleFailure(state)
|
is ContentUploadStateTracker.State.Failure -> handleFailure(state)
|
||||||
is ContentUploadStateTracker.State.Success -> handleSuccess(state)
|
is ContentUploadStateTracker.State.Success -> handleSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleIdle(state: ContentUploadStateTracker.State.Idle) {
|
private fun handleIdle() {
|
||||||
if (isLocalFile) {
|
if (isLocalFile) {
|
||||||
progressLayout.isVisible = true
|
progressLayout.isVisible = true
|
||||||
val progressBar = progressLayout.findViewById<ProgressBar>(R.id.mediaProgressBar)
|
val progressBar = progressLayout.findViewById<ProgressBar>(R.id.mediaProgressBar)
|
||||||
@ -92,7 +92,7 @@ private class ContentMediaProgressUpdater(private val progressLayout: ViewGroup,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleEncryptingThumbnail(state: ContentUploadStateTracker.State.EncryptingThumbnail) {
|
private fun handleEncryptingThumbnail() {
|
||||||
doHandleEncrypting(R.string.send_file_step_encrypting_thumbnail)
|
doHandleEncrypting(R.string.send_file_step_encrypting_thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ private class ContentMediaProgressUpdater(private val progressLayout: ViewGroup,
|
|||||||
doHandleProgress(R.string.send_file_step_sending_thumbnail, state.current, state.total)
|
doHandleProgress(R.string.send_file_step_sending_thumbnail, state.current, state.total)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleEncrypting(state: ContentUploadStateTracker.State.Encrypting) {
|
private fun handleEncrypting() {
|
||||||
doHandleEncrypting(R.string.send_file_step_encrypting_file)
|
doHandleEncrypting(R.string.send_file_step_encrypting_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ private class ContentMediaProgressUpdater(private val progressLayout: ViewGroup,
|
|||||||
progressTextView?.setTextColor(colorProvider.getMessageTextColor(SendState.UNDELIVERED))
|
progressTextView?.setTextColor(colorProvider.getMessageTextColor(SendState.UNDELIVERED))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSuccess(state: ContentUploadStateTracker.State.Success) {
|
private fun handleSuccess() {
|
||||||
progressLayout.visibility = View.GONE
|
progressLayout.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class MessageItemAttributesFactory @Inject constructor(
|
|||||||
itemClickListener = DebouncedClickListener(View.OnClickListener { view ->
|
itemClickListener = DebouncedClickListener(View.OnClickListener { view ->
|
||||||
callback?.onEventCellClicked(informationData, messageContent, view)
|
callback?.onEventCellClicked(informationData, messageContent, view)
|
||||||
}),
|
}),
|
||||||
memberClickListener = DebouncedClickListener(View.OnClickListener { view ->
|
memberClickListener = DebouncedClickListener(View.OnClickListener {
|
||||||
callback?.onMemberNameClicked(informationData)
|
callback?.onMemberNameClicked(informationData)
|
||||||
}),
|
}),
|
||||||
reactionPillCallback = callback,
|
reactionPillCallback = callback,
|
||||||
|
@ -70,7 +70,7 @@ object ServerUrlsRepository {
|
|||||||
|
|
||||||
return prefs.getString(HOME_SERVER_URL_PREF,
|
return prefs.getString(HOME_SERVER_URL_PREF,
|
||||||
prefs.getString(DEFAULT_REFERRER_HOME_SERVER_URL_PREF,
|
prefs.getString(DEFAULT_REFERRER_HOME_SERVER_URL_PREF,
|
||||||
getDefaultHomeServerUrl(context)))
|
getDefaultHomeServerUrl(context))!!)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package im.vector.riotx.features.html
|
package im.vector.riotx.features.html
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@ -101,7 +103,7 @@ class PillImageSpan(private val glideRequests: GlideRequests,
|
|||||||
private fun createChipDrawable(): ChipDrawable {
|
private fun createChipDrawable(): ChipDrawable {
|
||||||
val textPadding = context.resources.getDimension(R.dimen.pill_text_padding)
|
val textPadding = context.resources.getDimension(R.dimen.pill_text_padding)
|
||||||
return ChipDrawable.createFromResource(context, R.xml.pill_view).apply {
|
return ChipDrawable.createFromResource(context, R.xml.pill_view).apply {
|
||||||
setText(displayName)
|
text = displayName
|
||||||
textEndPadding = textPadding
|
textEndPadding = textPadding
|
||||||
textStartPadding = textPadding
|
textStartPadding = textPadding
|
||||||
setChipMinHeightResource(R.dimen.pill_min_height)
|
setChipMinHeightResource(R.dimen.pill_min_height)
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package im.vector.riotx.features.login
|
package im.vector.riotx.features.login
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
@ -30,6 +32,7 @@ import android.webkit.WebViewClient
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
import im.vector.matrix.android.api.auth.data.Credentials
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
|
import im.vector.matrix.android.api.util.JsonDict
|
||||||
import im.vector.matrix.android.internal.di.MoshiProvider
|
import im.vector.matrix.android.internal.di.MoshiProvider
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ScreenComponent
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
@ -128,8 +131,8 @@ class LoginSsoFallbackFragment : VectorBaseFragment(), OnBackPressed {
|
|||||||
error: SslError) {
|
error: SslError) {
|
||||||
AlertDialog.Builder(requireActivity())
|
AlertDialog.Builder(requireActivity())
|
||||||
.setMessage(R.string.ssl_could_not_verify)
|
.setMessage(R.string.ssl_could_not_verify)
|
||||||
.setPositiveButton(R.string.ssl_trust) { dialog, which -> handler.proceed() }
|
.setPositiveButton(R.string.ssl_trust) { _, _ -> handler.proceed() }
|
||||||
.setNegativeButton(R.string.ssl_do_not_trust) { dialog, which -> handler.cancel() }
|
.setNegativeButton(R.string.ssl_do_not_trust) { _, _ -> handler.cancel() }
|
||||||
.setOnKeyListener(DialogInterface.OnKeyListener { dialog, keyCode, event ->
|
.setOnKeyListener(DialogInterface.OnKeyListener { dialog, keyCode, event ->
|
||||||
if (event.action == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
if (event.action == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
handler.cancel()
|
handler.cancel()
|
||||||
@ -224,7 +227,8 @@ class LoginSsoFallbackFragment : VectorBaseFragment(), OnBackPressed {
|
|||||||
|
|
||||||
val adapter = MoshiProvider.providesMoshi().adapter(Map::class.java)
|
val adapter = MoshiProvider.providesMoshi().adapter(Map::class.java)
|
||||||
|
|
||||||
parameters = adapter.fromJson(json) as Map<String, Any>?
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
parameters = adapter.fromJson(json) as JsonDict?
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## shouldOverrideUrlLoading() : fromJson failed")
|
Timber.e(e, "## shouldOverrideUrlLoading() : fromJson failed")
|
||||||
}
|
}
|
||||||
@ -236,6 +240,7 @@ class LoginSsoFallbackFragment : VectorBaseFragment(), OnBackPressed {
|
|||||||
if (mMode == Mode.MODE_LOGIN) {
|
if (mMode == Mode.MODE_LOGIN) {
|
||||||
try {
|
try {
|
||||||
if (action == "onLogin") {
|
if (action == "onLogin") {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val credentials = parameters["credentials"] as Map<String, String>
|
val credentials = parameters["credentials"] as Map<String, String>
|
||||||
|
|
||||||
val userId = credentials["user_id"]
|
val userId = credentials["user_id"]
|
||||||
@ -245,7 +250,7 @@ class LoginSsoFallbackFragment : VectorBaseFragment(), OnBackPressed {
|
|||||||
|
|
||||||
// check if the parameters are defined
|
// check if the parameters are defined
|
||||||
if (null != homeServer && null != userId && null != accessToken) {
|
if (null != homeServer && null != userId && null != accessToken) {
|
||||||
val credentials = Credentials(
|
val safeCredentials = Credentials(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
accessToken = accessToken,
|
accessToken = accessToken,
|
||||||
homeServer = homeServer,
|
homeServer = homeServer,
|
||||||
@ -253,7 +258,7 @@ class LoginSsoFallbackFragment : VectorBaseFragment(), OnBackPressed {
|
|||||||
refreshToken = null
|
refreshToken = null
|
||||||
)
|
)
|
||||||
|
|
||||||
viewModel.handle(LoginActions.SsoLoginSuccess(credentials))
|
viewModel.handle(LoginActions.SsoLoginSuccess(safeCredentials))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -48,7 +48,7 @@ class ImageMediaViewerActivity : VectorBaseActivity() {
|
|||||||
|
|
||||||
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
||||||
|
|
||||||
lateinit var mediaData: ImageContentRenderer.Data
|
private lateinit var mediaData: ImageContentRenderer.Data
|
||||||
|
|
||||||
override fun injectWith(injector: ScreenComponent) {
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
injector.inject(this)
|
injector.inject(this)
|
||||||
@ -57,8 +57,8 @@ class ImageMediaViewerActivity : VectorBaseActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(im.vector.riotx.R.layout.activity_image_media_viewer)
|
setContentView(im.vector.riotx.R.layout.activity_image_media_viewer)
|
||||||
mediaData = intent.getParcelableExtra<ImageContentRenderer.Data>(EXTRA_MEDIA_DATA)
|
mediaData = intent.getParcelableExtra(EXTRA_MEDIA_DATA)
|
||||||
intent.extras.getString(EXTRA_SHARED_TRANSITION_NAME)?.let {
|
intent.extras?.getString(EXTRA_SHARED_TRANSITION_NAME)?.let {
|
||||||
ViewCompat.setTransitionName(imageTransitionView, it)
|
ViewCompat.setTransitionName(imageTransitionView, it)
|
||||||
}
|
}
|
||||||
if (mediaData.url.isNullOrEmpty()) {
|
if (mediaData.url.isNullOrEmpty()) {
|
||||||
|
@ -80,7 +80,7 @@ class DefaultNavigator @Inject constructor() : Navigator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun openSettings(context: Context) {
|
override fun openSettings(context: Context) {
|
||||||
val intent = VectorSettingsActivity.getIntent(context, "TODO")
|
val intent = VectorSettingsActivity.getIntent(context)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||||||
//Can this happen? should we update notification?
|
//Can this happen? should we update notification?
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val matrixId = intent.getStringExtra(EXTRA_MATRIX_ID)
|
|
||||||
activeSessionHolder.getActiveSession().let { session ->
|
activeSessionHolder.getActiveSession().let { session ->
|
||||||
session.getRoom(roomId)?.let { room ->
|
session.getRoom(roomId)?.let { room ->
|
||||||
sendMatrixEvent(message, session, room, context)
|
sendMatrixEvent(message, session, room, context)
|
||||||
@ -203,6 +202,5 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||||||
companion object {
|
companion object {
|
||||||
const val KEY_ROOM_ID = "roomID"
|
const val KEY_ROOM_ID = "roomID"
|
||||||
const val KEY_TEXT_REPLY = "key_text_reply"
|
const val KEY_TEXT_REPLY = "key_text_reply"
|
||||||
const val EXTRA_MATRIX_ID = "EXTRA_MATRIX_ID"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UNUSED_PARAMETER")
|
||||||
|
|
||||||
package im.vector.riotx.features.notifications
|
package im.vector.riotx.features.notifications
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
@ -713,7 +715,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
|||||||
try {
|
try {
|
||||||
notificationManager.cancelAll()
|
notificationManager.cancelAll()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## cancelAllNotifications() failed " + e.message)
|
Timber.e(e, "## cancelAllNotifications() failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class BugReportActivity : VectorBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## onUploadFailed() : failed to display the toast " + e.message)
|
Timber.e(e, "## onUploadFailed() : failed to display the toast")
|
||||||
}
|
}
|
||||||
|
|
||||||
bug_report_mask_view.isVisible = false
|
bug_report_mask_view.isVisible = false
|
||||||
@ -164,13 +164,13 @@ class BugReportActivity : VectorBaseActivity() {
|
|||||||
Toast.makeText(this@BugReportActivity, R.string.send_bug_report_sent, Toast.LENGTH_LONG).show()
|
Toast.makeText(this@BugReportActivity, R.string.send_bug_report_sent, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## onUploadSucceed() : failed to dismiss the toast " + e.message)
|
Timber.e(e, "## onUploadSucceed() : failed to dismiss the toast")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
finish()
|
finish()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## onUploadSucceed() : failed to dismiss the dialog " + e.message)
|
Timber.e(e, "## onUploadSucceed() : failed to dismiss the dialog")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -36,9 +36,12 @@ import im.vector.riotx.core.utils.getDeviceLocale
|
|||||||
import im.vector.riotx.features.settings.VectorLocale
|
import im.vector.riotx.features.settings.VectorLocale
|
||||||
import im.vector.riotx.features.themes.ThemeUtils
|
import im.vector.riotx.features.themes.ThemeUtils
|
||||||
import im.vector.riotx.features.version.VersionProvider
|
import im.vector.riotx.features.version.VersionProvider
|
||||||
import okhttp3.*
|
import okhttp3.Call
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
import okhttp3.RequestBody.Companion.asRequestBody
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.Response
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -555,10 +558,13 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
// refresh it
|
// refresh it
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
rootView.isDrawingCacheEnabled = false
|
rootView.isDrawingCacheEnabled = false
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
rootView.isDrawingCacheEnabled = true
|
rootView.isDrawingCacheEnabled = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
var bitmap = rootView.drawingCache
|
var bitmap = rootView.drawingCache
|
||||||
|
|
||||||
// Make a copy, because if Activity is destroyed, the bitmap will be recycled
|
// Make a copy, because if Activity is destroyed, the bitmap will be recycled
|
||||||
|
@ -124,7 +124,7 @@ class VectorFileLogger @Inject constructor(val context: Context, private val vec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## addLogFiles() failed : %s", e.message)
|
Timber.e(e, "## addLogFiles() failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
@ -39,7 +39,7 @@ import javax.inject.Inject
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TODO: Loading indicator while getting emoji data source?
|
* TODO: Loading indicator while getting emoji data source?
|
||||||
* TODO: migrate to maverick
|
* TODO: migrate to MvRx
|
||||||
* TODO: Finish Refactor to vector base activity
|
* TODO: Finish Refactor to vector base activity
|
||||||
* TODO: Move font request to app
|
* TODO: Move font request to app
|
||||||
*/
|
*/
|
||||||
@ -58,15 +58,15 @@ class EmojiReactionPickerActivity : VectorBaseActivity(), EmojiCompatFontProvide
|
|||||||
|
|
||||||
@Inject lateinit var emojiCompatFontProvider: EmojiCompatFontProvider
|
@Inject lateinit var emojiCompatFontProvider: EmojiCompatFontProvider
|
||||||
|
|
||||||
private var tabLayoutSelectionListener = object : TabLayout.BaseOnTabSelectedListener<TabLayout.Tab> {
|
private var tabLayoutSelectionListener = object : TabLayout.OnTabSelectedListener {
|
||||||
override fun onTabReselected(p0: TabLayout.Tab) {
|
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTabUnselected(p0: TabLayout.Tab) {
|
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTabSelected(p0: TabLayout.Tab) {
|
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||||
viewModel.scrollToSection(p0.position)
|
viewModel.scrollToSection(tab.position)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ class EmojiRecyclerAdapter(private val dataSource: EmojiDataSource? = null,
|
|||||||
private fun isSection(position: Int): Boolean {
|
private fun isSection(position: Int): Boolean {
|
||||||
dataSource?.rawData?.categories?.let { categories ->
|
dataSource?.rawData?.categories?.let { categories ->
|
||||||
var sectionOffset = 1
|
var sectionOffset = 1
|
||||||
var lastItemInSection = 0
|
var lastItemInSection: Int
|
||||||
for (category in categories) {
|
for (category in categories) {
|
||||||
lastItemInSection = sectionOffset + category.emojis.size - 1
|
lastItemInSection = sectionOffset + category.emojis.size - 1
|
||||||
if (position == sectionOffset - 1) return true
|
if (position == sectionOffset - 1) return true
|
||||||
@ -164,7 +164,7 @@ class EmojiRecyclerAdapter(private val dataSource: EmojiDataSource? = null,
|
|||||||
|
|
||||||
private fun getSectionForAbsoluteIndex(position: Int): Int {
|
private fun getSectionForAbsoluteIndex(position: Int): Int {
|
||||||
var sectionOffset = 1
|
var sectionOffset = 1
|
||||||
var lastItemInSection = 0
|
var lastItemInSection: Int
|
||||||
var index = 0
|
var index = 0
|
||||||
dataSource?.rawData?.categories?.let {
|
dataSource?.rawData?.categories?.let {
|
||||||
for (category in it) {
|
for (category in it) {
|
||||||
@ -180,7 +180,7 @@ class EmojiRecyclerAdapter(private val dataSource: EmojiDataSource? = null,
|
|||||||
private fun getSectionOffset(section: Int): Int {
|
private fun getSectionOffset(section: Int): Int {
|
||||||
//Todo cache this for fast access
|
//Todo cache this for fast access
|
||||||
var sectionOffset = 1
|
var sectionOffset = 1
|
||||||
var lastItemInSection = 0
|
var lastItemInSection: Int
|
||||||
dataSource?.rawData?.categories?.let {
|
dataSource?.rawData?.categories?.let {
|
||||||
for ((index, category) in it.withIndex()) {
|
for ((index, category) in it.withIndex()) {
|
||||||
lastItemInSection = sectionOffset + category.emojis.size - 1
|
lastItemInSection = sectionOffset + category.emojis.size - 1
|
||||||
@ -296,12 +296,18 @@ class EmojiRecyclerAdapter(private val dataSource: EmojiDataSource? = null,
|
|||||||
private val staticLayoutCache = HashMap<String, StaticLayout>()
|
private val staticLayoutCache = HashMap<String, StaticLayout>()
|
||||||
|
|
||||||
private fun getStaticLayoutForEmoji(emoji: String): StaticLayout {
|
private fun getStaticLayoutForEmoji(emoji: String): StaticLayout {
|
||||||
var cachedLayout = staticLayoutCache[emoji]
|
return staticLayoutCache.getOrPut(emoji) {
|
||||||
if (cachedLayout == null) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
cachedLayout = StaticLayout(emoji, EmojiDrawView.tPaint, EmojiDrawView.emojiSize, Layout.Alignment.ALIGN_CENTER, 1f, 0f, true)
|
StaticLayout.Builder.obtain(emoji, 0, emoji.length, EmojiDrawView.tPaint, EmojiDrawView.emojiSize)
|
||||||
staticLayoutCache[emoji] = cachedLayout
|
.setAlignment(Layout.Alignment.ALIGN_CENTER)
|
||||||
|
.setLineSpacing(0f, 1f)
|
||||||
|
.setIncludePad(true)
|
||||||
|
.build()
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
StaticLayout(emoji, EmojiDrawView.tPaint, EmojiDrawView.emojiSize, Layout.Alignment.ALIGN_CENTER, 1f, 0f, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cachedLayout
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +330,7 @@ class EmojiRecyclerAdapter(private val dataSource: EmojiDataSource? = null,
|
|||||||
//TODO better
|
//TODO better
|
||||||
if (scrollState == ScrollState.IDLE) {
|
if (scrollState == ScrollState.IDLE) {
|
||||||
//
|
//
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val toUpdate = toUpdateWhenNotBusy.clone() as ArrayList<Pair<String, EmojiViewHolder>>
|
val toUpdate = toUpdateWhenNotBusy.clone() as ArrayList<Pair<String, EmojiViewHolder>>
|
||||||
toUpdateWhenNotBusy.clear()
|
toUpdateWhenNotBusy.clear()
|
||||||
toUpdate.chunked(8).forEach {
|
toUpdate.chunked(8).forEach {
|
||||||
|
@ -21,6 +21,8 @@ import android.graphics.*
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Property
|
import android.util.Property
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,8 +40,8 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
private val circlePaint = Paint()
|
private val circlePaint = Paint()
|
||||||
private val maskPaint = Paint()
|
private val maskPaint = Paint()
|
||||||
|
|
||||||
private var tempBitmap: Bitmap? = null
|
private lateinit var tempBitmap: Bitmap
|
||||||
private var tempCanvas: Canvas? = null
|
private lateinit var tempCanvas: Canvas
|
||||||
|
|
||||||
var outerCircleRadiusProgress = 0f
|
var outerCircleRadiusProgress = 0f
|
||||||
set(value) {
|
set(value) {
|
||||||
@ -69,9 +71,9 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
tempCanvas!!.drawColor(0xffffff, PorterDuff.Mode.CLEAR)
|
tempCanvas.drawColor(0xffffff, PorterDuff.Mode.CLEAR)
|
||||||
tempCanvas!!.drawCircle(width / 2f, height / 2f, outerCircleRadiusProgress * maxCircleSize, circlePaint)
|
tempCanvas.drawCircle(width / 2f, height / 2f, outerCircleRadiusProgress * maxCircleSize, circlePaint)
|
||||||
tempCanvas!!.drawCircle(width / 2f, height / 2f, innerCircleRadiusProgress * maxCircleSize, maskPaint)
|
tempCanvas.drawCircle(width / 2f, height / 2f, innerCircleRadiusProgress * maxCircleSize, maskPaint)
|
||||||
canvas.drawBitmap(tempBitmap, 0f, 0f, null)
|
canvas.drawBitmap(tempBitmap, 0f, 0f, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +93,7 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private fun updateCircleColor() {
|
private fun updateCircleColor() {
|
||||||
var colorProgress = clamp(outerCircleRadiusProgress, 0.5f, 1f) as Float
|
var colorProgress = clamp(outerCircleRadiusProgress, 0.5f, 1f)
|
||||||
colorProgress = mapValueFromRangeToRange(colorProgress, 0.5f, 1f, 0f, 1f)
|
colorProgress = mapValueFromRangeToRange(colorProgress, 0.5f, 1f, 0f, 1f)
|
||||||
this.circlePaint.color = argbEvaluator.evaluate(colorProgress, startColor, endColor) as Int
|
this.circlePaint.color = argbEvaluator.evaluate(colorProgress, startColor, endColor) as Int
|
||||||
}
|
}
|
||||||
@ -134,7 +136,7 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clamp(value: Float, low: Float, high: Float): Float {
|
fun clamp(value: Float, low: Float, high: Float): Float {
|
||||||
return Math.min(Math.max(value, low), high)
|
return min(max(value, low), high)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,7 +35,12 @@ class DotsView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
private var COLOR_3 = -0xa8de
|
private var COLOR_3 = -0xa8de
|
||||||
private var COLOR_4 = -0xbbcca
|
private var COLOR_4 = -0xbbcca
|
||||||
|
|
||||||
private val circlePaints = arrayOfNulls<Paint>(4)
|
private val circlePaints = listOf(
|
||||||
|
Paint().apply { style = Paint.Style.FILL },
|
||||||
|
Paint().apply { style = Paint.Style.FILL },
|
||||||
|
Paint().apply { style = Paint.Style.FILL },
|
||||||
|
Paint().apply { style = Paint.Style.FILL }
|
||||||
|
)
|
||||||
|
|
||||||
private var centerX: Int = 0
|
private var centerX: Int = 0
|
||||||
private var centerY: Int = 0
|
private var centerY: Int = 0
|
||||||
@ -63,13 +68,6 @@ class DotsView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
|
|
||||||
private val argbEvaluator = ArgbEvaluator()
|
private val argbEvaluator = ArgbEvaluator()
|
||||||
|
|
||||||
init {
|
|
||||||
for (i in circlePaints.indices) {
|
|
||||||
circlePaints[i] = Paint()
|
|
||||||
circlePaints[i]!!.style = Paint.Style.FILL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||||
super.onSizeChanged(w, h, oldw, oldh)
|
super.onSizeChanged(w, h, oldw, oldh)
|
||||||
centerX = w / 2
|
centerX = w / 2
|
||||||
@ -161,32 +159,32 @@ class DotsView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
|||||||
|
|
||||||
private fun updateDotsPaints() {
|
private fun updateDotsPaints() {
|
||||||
if (currentProgress < 0.5f) {
|
if (currentProgress < 0.5f) {
|
||||||
val progress = CircleView.mapValueFromRangeToRange(currentProgress, 0f, 0.5f, 0f, 1f) as Float
|
val progress = CircleView.mapValueFromRangeToRange(currentProgress, 0f, 0.5f, 0f, 1f)
|
||||||
circlePaints[0]?.color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int
|
circlePaints[0].color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int
|
||||||
circlePaints[1]?.color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int
|
circlePaints[1].color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int
|
||||||
circlePaints[2]?.color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int
|
circlePaints[2].color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int
|
||||||
circlePaints[3]?.color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int
|
circlePaints[3].color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int
|
||||||
} else {
|
} else {
|
||||||
val progress = CircleView.mapValueFromRangeToRange(currentProgress, 0.5f, 1f, 0f, 1f) as Float
|
val progress = CircleView.mapValueFromRangeToRange(currentProgress, 0.5f, 1f, 0f, 1f)
|
||||||
circlePaints[0]?.color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int
|
circlePaints[0].color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int
|
||||||
circlePaints[1]?.color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int
|
circlePaints[1].color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int
|
||||||
circlePaints[2]?.color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int
|
circlePaints[2].color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int
|
||||||
circlePaints[3]?.color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int
|
circlePaints[3].color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDotsAlpha() {
|
private fun updateDotsAlpha() {
|
||||||
val progress = CircleView.clamp(currentProgress, 0.6f, 1f) as Float
|
val progress = CircleView.clamp(currentProgress, 0.6f, 1f)
|
||||||
val alpha = (CircleView.mapValueFromRangeToRange(progress, 0.6f, 1f, 255f, 0f) as? Float)?.toInt()
|
val alpha = (CircleView.mapValueFromRangeToRange(progress, 0.6f, 1f, 255f, 0f) as? Float)?.toInt()
|
||||||
?: 0
|
?: 0
|
||||||
circlePaints.forEach { it?.alpha = alpha }
|
circlePaints.forEach { it.alpha = alpha }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val DOTS_COUNT = 7
|
private const val DOTS_COUNT = 7
|
||||||
private val OUTER_DOTS_POSITION_ANGLE = 360 / DOTS_COUNT
|
private const val OUTER_DOTS_POSITION_ANGLE = 360 / DOTS_COUNT
|
||||||
|
|
||||||
val DOTS_PROGRESS: Property<DotsView, Float> = object : Property<DotsView, Float>(Float::class.java, "dotsProgress") {
|
val DOTS_PROGRESS: Property<DotsView, Float> = object : Property<DotsView, Float>(Float::class.java, "dotsProgress") {
|
||||||
override operator fun get(`object`: DotsView): Float? {
|
override operator fun get(`object`: DotsView): Float? {
|
||||||
|
@ -133,6 +133,7 @@ object FontScale {
|
|||||||
|
|
||||||
val config = Configuration(context.resources.configuration)
|
val config = Configuration(context.resources.configuration)
|
||||||
config.fontScale = getFontScale(context)
|
config.fontScale = getFontScale(context)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
context.resources.updateConfiguration(config, context.resources.displayMetrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ import android.preference.PreferenceManager
|
|||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Pair
|
import android.util.Pair
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -128,22 +128,27 @@ object VectorLocale {
|
|||||||
try {
|
try {
|
||||||
result = context.createConfigurationContext(config).getText(resourceId).toString()
|
result = context.createConfigurationContext(config).getText(resourceId).toString()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## getString() failed : " + e.message)
|
Timber.e(e, "## getString() failed")
|
||||||
// use the default one
|
// use the default one
|
||||||
result = context.getString(resourceId)
|
result = context.getString(resourceId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val resources = context.resources
|
val resources = context.resources
|
||||||
val conf = resources.configuration
|
val conf = resources.configuration
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
val savedLocale = conf.locale
|
val savedLocale = conf.locale
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
conf.locale = locale
|
conf.locale = locale
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
resources.updateConfiguration(conf, null)
|
resources.updateConfiguration(conf, null)
|
||||||
|
|
||||||
// retrieve resources from desired locale
|
// retrieve resources from desired locale
|
||||||
result = resources.getString(resourceId)
|
result = resources.getString(resourceId)
|
||||||
|
|
||||||
// restore original locale
|
// restore original locale
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
conf.locale = savedLocale
|
conf.locale = savedLocale
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
resources.updateConfiguration(conf, null)
|
resources.updateConfiguration(conf, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +171,7 @@ object VectorLocale {
|
|||||||
getString(context, locale, R.string.resources_country_code)))
|
getString(context, locale, R.string.resources_country_code)))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## getApplicationLocales() : failed " + e.message)
|
Timber.e(e, "## getApplicationLocales() : failed")
|
||||||
knownLocalesSet.add(Pair(context.getString(R.string.resources_language), context.getString(R.string.resources_country_code)))
|
knownLocalesSet.add(Pair(context.getString(R.string.resources_language), context.getString(R.string.resources_country_code)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||||||
name = name.substring(0, name.lastIndexOf("."))
|
name = name.substring(0, name.lastIndexOf("."))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## getNotificationRingToneName() failed() : " + e.message)
|
Timber.e(e, "## getNotificationRingToneName() failed")
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,9 @@ class VectorSettingsActivity : VectorBaseActivity(),
|
|||||||
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
|
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
|
||||||
val oFragment = when {
|
val oFragment = when {
|
||||||
VectorPreferences.SETTINGS_NOTIFICATION_TROUBLESHOOT_PREFERENCE_KEY == pref.key ->
|
VectorPreferences.SETTINGS_NOTIFICATION_TROUBLESHOOT_PREFERENCE_KEY == pref.key ->
|
||||||
VectorSettingsNotificationsTroubleshootFragment.newInstance(session.myUserId)
|
VectorSettingsNotificationsTroubleshootFragment.newInstance()
|
||||||
VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY == pref.key ->
|
VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY == pref.key ->
|
||||||
VectorSettingsAdvancedNotificationPreferenceFragment.newInstance(session.myUserId)
|
VectorSettingsAdvancedNotificationPreferenceFragment.newInstance()
|
||||||
else ->
|
else ->
|
||||||
try {
|
try {
|
||||||
pref.fragment?.let {
|
pref.fragment?.let {
|
||||||
@ -115,10 +115,7 @@ class VectorSettingsActivity : VectorBaseActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getIntent(context: Context, userId: String) = Intent(context, VectorSettingsActivity::class.java)
|
fun getIntent(context: Context) = Intent(context, VectorSettingsActivity::class.java)
|
||||||
.apply {
|
|
||||||
//putExtra(MXCActionBarActivity.EXTRA_MATRIX_ID, userId)
|
|
||||||
}
|
|
||||||
|
|
||||||
private const val FRAGMENT_TAG = "VectorSettingsPreferencesFragment"
|
private const val FRAGMENT_TAG = "VectorSettingsPreferencesFragment"
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import androidx.preference.Preference
|
|||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ScreenComponent
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.extensions.withArgs
|
|
||||||
import im.vector.riotx.core.preference.BingRule
|
import im.vector.riotx.core.preference.BingRule
|
||||||
import im.vector.riotx.core.preference.BingRulePreference
|
import im.vector.riotx.core.preference.BingRulePreference
|
||||||
import im.vector.riotx.core.preference.VectorPreference
|
import im.vector.riotx.core.preference.VectorPreference
|
||||||
@ -119,8 +118,8 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
|
|||||||
preference.isVisible = true
|
preference.isVisible = true
|
||||||
preference.setBingRule(rule)
|
preference.setBingRule(rule)
|
||||||
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
val rule = preference.createRule(newValue as Int)
|
val rule2 = preference.createRule(newValue as Int)
|
||||||
if (null != rule) {
|
if (null != rule2) {
|
||||||
/*
|
/*
|
||||||
TODO
|
TODO
|
||||||
displayLoadingView()
|
displayLoadingView()
|
||||||
@ -233,9 +232,6 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
|
|||||||
VectorPreferences.SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY to BingRule.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS
|
VectorPreferences.SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY to BingRule.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
fun newInstance(matrixId: String) = VectorSettingsAdvancedNotificationPreferenceFragment()
|
fun newInstance() = VectorSettingsAdvancedNotificationPreferenceFragment()
|
||||||
.withArgs {
|
|
||||||
// putString(MXCActionBarActivity.EXTRA_MATRIX_ID, matrixId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,6 @@ package im.vector.riotx.features.settings
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
@ -134,8 +133,8 @@ abstract class VectorSettingsBaseFragment : PreferenceFragmentCompat(), HasScree
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
if (!TextUtils.isEmpty(errorMessage) && errorMessage != null) {
|
if (errorMessage != null && errorMessage.isNotBlank()) {
|
||||||
activity?.toast(errorMessage!!)
|
activity?.toast(errorMessage)
|
||||||
}
|
}
|
||||||
hideLoadingView()
|
hideLoadingView()
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UNUSED_VARIABLE", "UNUSED_ANONYMOUS_PARAMETER", "UNUSED_PARAMETER")
|
||||||
|
|
||||||
package im.vector.riotx.features.settings
|
package im.vector.riotx.features.settings
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
@ -31,7 +31,6 @@ import butterknife.BindView
|
|||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ScreenComponent
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.extensions.withArgs
|
|
||||||
import im.vector.riotx.core.platform.VectorBaseActivity
|
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||||
import im.vector.riotx.features.rageshake.BugReporter
|
import im.vector.riotx.features.rageshake.BugReporter
|
||||||
@ -175,9 +174,6 @@ class VectorSettingsNotificationsTroubleshootFragment : VectorBaseFragment() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// static constructor
|
// static constructor
|
||||||
fun newInstance(matrixId: String) = VectorSettingsNotificationsTroubleshootFragment()
|
fun newInstance() = VectorSettingsNotificationsTroubleshootFragment()
|
||||||
.withArgs {
|
|
||||||
// TODO putString(MXCActionBarActivity.EXTRA_MATRIX_ID, matrixId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,7 +23,6 @@ import android.content.Intent
|
|||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@ -318,7 +317,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
|
|
||||||
val importDialog = builder.show()
|
val importDialog = builder.show()
|
||||||
|
|
||||||
importButton.setOnClickListener(View.OnClickListener {
|
importButton.setOnClickListener {
|
||||||
val password = passPhraseEditText.text.toString()
|
val password = passPhraseEditText.text.toString()
|
||||||
|
|
||||||
displayLoadingView()
|
displayLoadingView()
|
||||||
@ -351,7 +350,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
importDialog.dismiss()
|
importDialog.dismiss()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +585,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
val lastSeenIp = aDeviceInfo.lastSeenIp?.takeIf { ip -> ip.isNotBlank() } ?: "-"
|
val lastSeenIp = aDeviceInfo.lastSeenIp?.takeIf { ip -> ip.isNotBlank() } ?: "-"
|
||||||
|
|
||||||
val lastSeenTime = aDeviceInfo.lastSeenTs?.let { ts ->
|
val lastSeenTime = aDeviceInfo.lastSeenTs?.let { ts ->
|
||||||
val dateFormatTime = SimpleDateFormat("HH:mm:ss")
|
val dateFormatTime = SimpleDateFormat("HH:mm:ss", Locale.ROOT)
|
||||||
val date = Date(ts)
|
val date = Date(ts)
|
||||||
|
|
||||||
val time = dateFormatTime.format(date)
|
val time = dateFormatTime.format(date)
|
||||||
@ -605,7 +604,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
.setPositiveButton(R.string.rename) { _, _ -> displayDeviceRenameDialog(aDeviceInfo) }
|
.setPositiveButton(R.string.rename) { _, _ -> displayDeviceRenameDialog(aDeviceInfo) }
|
||||||
|
|
||||||
// disable the deletion for our own device
|
// disable the deletion for our own device
|
||||||
if (!TextUtils.equals(session.getMyDevice()?.deviceId, aDeviceInfo.deviceId)) {
|
if (!TextUtils.equals(session.getMyDevice().deviceId, aDeviceInfo.deviceId)) {
|
||||||
builder.setNegativeButton(R.string.delete) { _, _ -> deleteDevice(aDeviceInfo) }
|
builder.setNegativeButton(R.string.delete) { _, _ -> deleteDevice(aDeviceInfo) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,7 +783,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
* Refresh the pushers list
|
* Refresh the pushers list
|
||||||
*/
|
*/
|
||||||
private fun refreshPushersList() {
|
private fun refreshPushersList() {
|
||||||
activity?.let { activity ->
|
activity?.let { _ ->
|
||||||
/* TODO
|
/* TODO
|
||||||
val pushManager = Matrix.getInstance(activity).pushManager
|
val pushManager = Matrix.getInstance(activity).pushManager
|
||||||
val pushersList = ArrayList(pushManager.mPushersList)
|
val pushersList = ArrayList(pushManager.mPushersList)
|
||||||
|
@ -42,32 +42,28 @@ class TestBingRulesSettings @Inject constructor(private val activeSessionHolder:
|
|||||||
override fun perform() {
|
override fun perform() {
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
val pushRules = session.getPushRules()
|
val pushRules = session.getPushRules()
|
||||||
if (pushRules == null) {
|
var oneOrMoreRuleIsOff = false
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_bing_settings_failed_to_load_rules)
|
var oneOrMoreRuleAreSilent = false
|
||||||
status = TestStatus.FAILED
|
testedRules.forEach { ruleId ->
|
||||||
} else {
|
pushRules.find { it.ruleId == ruleId }?.let { rule ->
|
||||||
var oneOrMoreRuleIsOff = false
|
val actions = rule.getActions()
|
||||||
var oneOrMoreRuleAreSilent = false
|
val notifAction = actions.toNotificationAction()
|
||||||
for ((index, ruleId) in testedRules.withIndex()) {
|
if (!rule.enabled || !notifAction.shouldNotify) {
|
||||||
pushRules.find { it.ruleId == ruleId }?.let { rule ->
|
//off
|
||||||
val actions = rule.getActions()
|
oneOrMoreRuleIsOff = true
|
||||||
val notifAction = actions.toNotificationAction()
|
} else if (notifAction.soundName == null) {
|
||||||
if (!rule.enabled || !notifAction.shouldNotify) {
|
//silent
|
||||||
//off
|
oneOrMoreRuleAreSilent = true
|
||||||
oneOrMoreRuleIsOff = true
|
} else {
|
||||||
} else if (notifAction.soundName == null) {
|
//noisy
|
||||||
//silent
|
|
||||||
oneOrMoreRuleAreSilent = true
|
|
||||||
} else {
|
|
||||||
//noisy
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oneOrMoreRuleIsOff) {
|
}
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_bing_settings_failed)
|
|
||||||
//TODO
|
if (oneOrMoreRuleIsOff) {
|
||||||
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_bing_settings_failed)
|
||||||
|
//TODO
|
||||||
// quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_bing_settings_quickfix) {
|
// quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_bing_settings_quickfix) {
|
||||||
// override fun doFix() {
|
// override fun doFix() {
|
||||||
// val activity = fragment.activity
|
// val activity = fragment.activity
|
||||||
@ -77,15 +73,14 @@ class TestBingRulesSettings @Inject constructor(private val activeSessionHolder:
|
|||||||
// activity?.supportFragmentManager?.popBackStack()
|
// activity?.supportFragmentManager?.popBackStack()
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
|
} else {
|
||||||
|
description = if (oneOrMoreRuleAreSilent) {
|
||||||
|
stringProvider.getString(R.string.settings_troubleshoot_test_bing_settings_success_with_warn)
|
||||||
} else {
|
} else {
|
||||||
if (oneOrMoreRuleAreSilent) {
|
null
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_bing_settings_success_with_warn)
|
|
||||||
} else {
|
|
||||||
description = null
|
|
||||||
}
|
|
||||||
status = TestStatus.SUCCESS
|
|
||||||
}
|
}
|
||||||
|
status = TestStatus.SUCCESS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,13 +75,13 @@ class VectorWebViewActivity : VectorBaseActivity() {
|
|||||||
cookieManager.setAcceptThirdPartyCookies(simple_webview, true)
|
cookieManager.setAcceptThirdPartyCookies(simple_webview, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = intent.extras.getString(EXTRA_URL)
|
val url = intent.extras?.getString(EXTRA_URL)
|
||||||
val title = intent.extras.getString(EXTRA_TITLE, USE_TITLE_FROM_WEB_PAGE)
|
val title = intent.extras?.getString(EXTRA_TITLE, USE_TITLE_FROM_WEB_PAGE)
|
||||||
if (title != USE_TITLE_FROM_WEB_PAGE) {
|
if (title != USE_TITLE_FROM_WEB_PAGE) {
|
||||||
setTitle(title)
|
setTitle(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
val webViewMode = intent.extras.getSerializable(EXTRA_MODE) as WebViewMode
|
val webViewMode = intent.extras?.getSerializable(EXTRA_MODE) as WebViewMode
|
||||||
val eventListener = webViewMode.eventListener(this, session)
|
val eventListener = webViewMode.eventListener(this, session)
|
||||||
simple_webview.webViewClient = VectorWebViewClient(eventListener)
|
simple_webview.webViewClient = VectorWebViewClient(eventListener)
|
||||||
simple_webview.webChromeClient = object : WebChromeClient() {
|
simple_webview.webChromeClient = object : WebChromeClient() {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package im.vector.riotx.features.webview
|
package im.vector.riotx.features.webview
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
@ -90,7 +90,7 @@ class SignOutBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
|||||||
var onSignOut: Runnable? = null
|
var onSignOut: Runnable? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(userId: String) = SignOutBottomSheetDialogFragment()
|
fun newInstance() = SignOutBottomSheetDialogFragment()
|
||||||
|
|
||||||
private const val EXPORT_REQ = 0
|
private const val EXPORT_REQ = 0
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class SignOutUiWorker(private val activity: FragmentActivity) {
|
|||||||
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
||||||
val session = activeSessionHolder.getActiveSession()
|
val session = activeSessionHolder.getActiveSession()
|
||||||
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
if (SignOutViewModel.doYouNeedToBeDisplayed(session)) {
|
||||||
val signOutDialog = SignOutBottomSheetDialogFragment.newInstance(session.myUserId)
|
val signOutDialog = SignOutBottomSheetDialogFragment.newInstance()
|
||||||
signOutDialog.onSignOut = Runnable {
|
signOutDialog.onSignOut = Runnable {
|
||||||
doSignOut()
|
doSignOut()
|
||||||
}
|
}
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
~ Copyright 2019 New Vector Ltd
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="48dp"
|
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp">
|
|
||||||
|
|
||||||
<!-- Do not use drawableStart for icon size and for RTL -->
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/adapter_item_dialog_icon"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:rotationY="@integer/rtl_mirror_flip"
|
|
||||||
android:tint="?attr/colorAccent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:src="@drawable/video_call_green" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/adapter_item_dialog_text"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:textSize="20sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/adapter_item_dialog_icon"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
tools:text="@string/action_video_call" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
Loading…
x
Reference in New Issue
Block a user