mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3110 Release 7.1 | Sentry issues (#1850)
This commit is contained in:
parent
d78c269c98
commit
d80f57e9b6
9 changed files with 78 additions and 39 deletions
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_utils.ext.FilePickerUtils.hasPermission
|
|||
import com.anytypeio.anytype.core_utils.ext.Mimetype
|
||||
import com.anytypeio.anytype.core_utils.ext.msg
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
import timber.log.Timber
|
||||
|
||||
class MediaPermissionHelper(
|
||||
private val fragment: Fragment,
|
||||
|
@ -16,36 +17,67 @@ class MediaPermissionHelper(
|
|||
) {
|
||||
private var mimeType: Mimetype? = null
|
||||
private var requestCode: Int? = null
|
||||
private var isRequestInProgress: Boolean = false
|
||||
|
||||
private val permissionReadStorage: ActivityResultLauncher<Array<String>> =
|
||||
fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { grantResults ->
|
||||
grantResults.entries.forEach {
|
||||
val isGranted = it.value
|
||||
if (isGranted) {
|
||||
val type = requireNotNull(mimeType) {
|
||||
"mimeType should be initialized"
|
||||
}
|
||||
onPermissionSuccess(type, requestCode)
|
||||
} else {
|
||||
onPermissionDenied()
|
||||
}
|
||||
Timber.d("Permission callback: $grantResults")
|
||||
|
||||
if (mimeType == null) {
|
||||
Timber.e("mimeType is null in permission callback")
|
||||
onPermissionDenied()
|
||||
isRequestInProgress = false
|
||||
return@registerForActivityResult
|
||||
}
|
||||
|
||||
val allGranted = grantResults.values.all { it }
|
||||
if (allGranted) {
|
||||
onPermissionSuccess(mimeType!!, requestCode)
|
||||
} else {
|
||||
onPermissionDenied()
|
||||
}
|
||||
|
||||
// Reset state
|
||||
mimeType = null
|
||||
requestCode = null
|
||||
isRequestInProgress = false
|
||||
}
|
||||
|
||||
fun openFilePicker(mimeType: Mimetype, requestCode: Int?) {
|
||||
if (isRequestInProgress) {
|
||||
Timber.w("Permission request already in progress")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.mimeType = mimeType
|
||||
this.requestCode = requestCode
|
||||
val context = fragment.context ?: return
|
||||
isRequestInProgress = true
|
||||
|
||||
val context = fragment.context ?: run {
|
||||
onPermissionDenied()
|
||||
isRequestInProgress = false
|
||||
return
|
||||
}
|
||||
|
||||
val hasPermission = mimeType.hasPermission(context)
|
||||
if (hasPermission) {
|
||||
onPermissionSuccess(mimeType, requestCode)
|
||||
isRequestInProgress = false
|
||||
} else {
|
||||
val permission = mimeType.getPermissionToRequestByMime()
|
||||
permissionReadStorage.launch(permission)
|
||||
val permissions = mimeType.getPermissionToRequestByMime()
|
||||
if (permissions.isNotEmpty()) {
|
||||
permissionReadStorage.launch(permissions)
|
||||
} else {
|
||||
// No permissions to request
|
||||
onPermissionDenied()
|
||||
isRequestInProgress = false
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
fragment.toast(e.msg())
|
||||
onPermissionDenied()
|
||||
isRequestInProgress = false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -144,14 +144,18 @@ class DragAndDropDelegate {
|
|||
is Code -> TextInputDragShadow(vh.content.id, vh.itemView, event)
|
||||
else -> DefaultEditorDragShadow(vh.itemView, event)
|
||||
}
|
||||
vh.itemView.startDragAndDrop(
|
||||
dragData,
|
||||
shadow,
|
||||
null,
|
||||
0
|
||||
)
|
||||
blockAdapter.selectDraggedViewHolder(dndTargetPos)
|
||||
blockAdapter.notifyItemChanged(dndTargetPos)
|
||||
try {
|
||||
vh.itemView.startDragAndDrop(
|
||||
dragData,
|
||||
shadow,
|
||||
null,
|
||||
0
|
||||
)
|
||||
blockAdapter.selectDraggedViewHolder(dndTargetPos)
|
||||
blockAdapter.notifyItemChanged(dndTargetPos)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Failed to start drag and drop")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val pos = vh.bindingAdapterPosition
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:hint="@string/search"
|
||||
android:maxLines="1"
|
||||
android:imeOptions="actionDone"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textColorHint="@color/text_secondary"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.anytypeio.anytype.middleware.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.DurationUnit
|
||||
import timber.log.Timber
|
||||
|
||||
interface MiddlewareProtobufLogger {
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ fun List<BlockView>.enterSAM(
|
|||
)
|
||||
else -> view.also {
|
||||
if(view !is BlockView.Permission) {
|
||||
Timber.w("Attempts to enter SAM for block which does not support read / write mode")
|
||||
Timber.w("Attempts to enter SAM for block which does not support read / write mode : ${view.getViewType()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.anytypeio.anytype.presentation.editor.editor.styling
|
|||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.Alignment
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -13,7 +13,7 @@ fun Editor.Mode.getIds(): List<Id>? = when (this) {
|
|||
is Editor.Mode.Styling.Single -> listOf(target)
|
||||
is Editor.Mode.Table -> targets.toList()
|
||||
else -> {
|
||||
Timber.e("Couldn't get ids of selected blocks, wrong Editor Mode : $this")
|
||||
Timber.w("Couldn't get ids of selected blocks, wrong Editor Mode : $this")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@ import com.anytypeio.anytype.core_models.ObjectType
|
|||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_utils.const.DateConst
|
||||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.presentation.extension.MAX_SNIPPET_SIZE
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.relations.model.DefaultObjectRelationValueView
|
||||
import com.anytypeio.anytype.presentation.sets.model.FileView
|
||||
import com.anytypeio.anytype.presentation.sets.model.ObjectView
|
||||
|
@ -351,7 +351,9 @@ suspend fun ObjectWrapper.Basic.objects(
|
|||
}
|
||||
ids.forEach { id ->
|
||||
val wrapper = storeOfObjects.get(id) ?: return@forEach
|
||||
result.add(wrapper.toObjectView(urlBuilder))
|
||||
if (wrapper.isValid) {
|
||||
result.add(wrapper.toObjectView(urlBuilder))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
|||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.getProperName
|
||||
import com.anytypeio.anytype.presentation.relations.BasicObjectCoverWrapper
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationView
|
||||
|
@ -168,13 +167,14 @@ private fun ObjectState.DataView.mapFeaturedRelations(
|
|||
val sourceMap = source?.let { details.details[it]?.map }
|
||||
|
||||
val isSourceMapValid = !sourceMap.isNullOrEmpty()
|
||||
val wrapper = if (isSourceMapValid) ObjectWrapper.Basic(sourceMap!!) else null
|
||||
val wrapper = if (isSourceMapValid) ObjectWrapper.Basic(sourceMap) else null
|
||||
|
||||
val isValid = wrapper?.isValid == true
|
||||
val isDeleted = wrapper?.isDeleted == true
|
||||
val isReadOnly = wrapper?.relationReadonlyValue ?: false
|
||||
val isReadOnly = wrapper?.relationReadonlyValue == true
|
||||
|
||||
val sources = if (!isDeleted && isSourceMapValid) {
|
||||
listOf(wrapper!!.toObjectViewDefault(urlBuilder = urlBuilder))
|
||||
val sources = if (isValid && !isDeleted) {
|
||||
listOf(wrapper.toObjectViewDefault(urlBuilder = urlBuilder))
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.getProperName
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.relations.getDateRelationFormat
|
||||
import com.anytypeio.anytype.presentation.sets.model.CellView
|
||||
import com.anytypeio.anytype.presentation.sets.model.ColumnView
|
||||
|
@ -292,14 +292,14 @@ fun Struct.buildRelationValueObjectViews(
|
|||
val objects = mutableListOf<ObjectView>()
|
||||
val value = this.getOrDefault(relationKey, null)
|
||||
if (value is Id) {
|
||||
val wrapper = ObjectWrapper.Basic(details[value]?.map ?: emptyMap())
|
||||
if (!wrapper.isEmpty()) {
|
||||
val wrapper = ObjectWrapper.Basic(details[value]?.map.orEmpty())
|
||||
if (wrapper.isValid) {
|
||||
objects.add(wrapper.toObjectView(urlBuilder = builder))
|
||||
}
|
||||
} else if (value is List<*>) {
|
||||
value.typeOf<Id>().forEach { id ->
|
||||
val wrapper = ObjectWrapper.Basic(details[id]?.map ?: emptyMap())
|
||||
if (!wrapper.isEmpty()) {
|
||||
val wrapper = ObjectWrapper.Basic(details[id]?.map.orEmpty())
|
||||
if (wrapper.isValid) {
|
||||
objects.add(wrapper.toObjectView(urlBuilder = builder))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue