mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Formats entire project
This commit is contained in:
parent
7f3e72b9cb
commit
de899bbb18
224 changed files with 853 additions and 815 deletions
|
@ -37,7 +37,7 @@ interface ImageLoaderTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView) :
|
internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView) :
|
||||||
ImageLoaderTarget {
|
ImageLoaderTarget {
|
||||||
override fun contextView(): ImageView {
|
override fun contextView(): ImageView {
|
||||||
return contextView
|
return contextView
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ import com.airbnb.mvrx.Mavericks
|
||||||
class JSonViewerDialog : DialogFragment() {
|
class JSonViewerDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
return inflater.inflate(R.layout.fragment_dialog_jv, container, false)
|
return inflater.inflate(R.layout.fragment_dialog_jv, container, false)
|
||||||
}
|
}
|
||||||
|
@ -39,15 +39,15 @@ class JSonViewerDialog : DialogFragment() {
|
||||||
val args: JSonViewerFragmentArgs = arguments?.getParcelable(Mavericks.KEY_ARG) ?: return
|
val args: JSonViewerFragmentArgs = arguments?.getParcelable(Mavericks.KEY_ARG) ?: return
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
childFragmentManager.beginTransaction()
|
childFragmentManager.beginTransaction()
|
||||||
.replace(
|
.replace(
|
||||||
R.id.fragmentContainer, JSonViewerFragment.newInstance(
|
R.id.fragmentContainer, JSonViewerFragment.newInstance(
|
||||||
args.jsonString,
|
args.jsonString,
|
||||||
args.defaultOpenDepth,
|
args.defaultOpenDepth,
|
||||||
true,
|
true,
|
||||||
args.styleProvider
|
args.styleProvider
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.commitNow()
|
.commitNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ class JSonViewerDialog : DialogFragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(
|
fun newInstance(
|
||||||
jsonString: String,
|
jsonString: String,
|
||||||
initialOpenDepth: Int = -1,
|
initialOpenDepth: Int = -1,
|
||||||
styleProvider: JSonViewerStyleProvider? = null
|
styleProvider: JSonViewerStyleProvider? = null
|
||||||
): JSonViewerDialog {
|
): JSonViewerDialog {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
val parcelableArgs =
|
val parcelableArgs =
|
||||||
JSonViewerFragmentArgs(jsonString, initialOpenDepth, false, styleProvider)
|
JSonViewerFragmentArgs(jsonString, initialOpenDepth, false, styleProvider)
|
||||||
args.putParcelable(Mavericks.KEY_ARG, parcelableArgs)
|
args.putParcelable(Mavericks.KEY_ARG, parcelableArgs)
|
||||||
return JSonViewerDialog().apply { arguments = args }
|
return JSonViewerDialog().apply { arguments = args }
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
internal data class JSonViewerFragmentArgs(
|
internal data class JSonViewerFragmentArgs(
|
||||||
val jsonString: String,
|
val jsonString: String,
|
||||||
val defaultOpenDepth: Int,
|
val defaultOpenDepth: Int,
|
||||||
val wrap: Boolean,
|
val wrap: Boolean,
|
||||||
val styleProvider: JSonViewerStyleProvider?
|
val styleProvider: JSonViewerStyleProvider?
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
class JSonViewerFragment : Fragment(), MavericksView {
|
class JSonViewerFragment : Fragment(), MavericksView {
|
||||||
|
@ -49,20 +49,20 @@ class JSonViewerFragment : Fragment(), MavericksView {
|
||||||
private lateinit var recyclerView: EpoxyRecyclerView
|
private lateinit var recyclerView: EpoxyRecyclerView
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
val args: JSonViewerFragmentArgs? = arguments?.getParcelable(Mavericks.KEY_ARG)
|
val args: JSonViewerFragmentArgs? = arguments?.getParcelable(Mavericks.KEY_ARG)
|
||||||
val inflate =
|
val inflate =
|
||||||
if (args?.wrap == true) {
|
if (args?.wrap == true) {
|
||||||
inflater.inflate(R.layout.fragment_jv_recycler_view_wrap, container, false)
|
inflater.inflate(R.layout.fragment_jv_recycler_view_wrap, container, false)
|
||||||
} else {
|
} else {
|
||||||
inflater.inflate(R.layout.fragment_jv_recycler_view, container, false)
|
inflater.inflate(R.layout.fragment_jv_recycler_view, container, false)
|
||||||
}
|
}
|
||||||
recyclerView = inflate.findViewById(R.id.jvRecyclerView)
|
recyclerView = inflate.findViewById(R.id.jvRecyclerView)
|
||||||
recyclerView.layoutManager =
|
recyclerView.layoutManager =
|
||||||
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
||||||
recyclerView.setController(epoxyController)
|
recyclerView.setController(epoxyController)
|
||||||
epoxyController.setStyle(args?.styleProvider)
|
epoxyController.setStyle(args?.styleProvider)
|
||||||
registerForContextMenu(recyclerView)
|
registerForContextMenu(recyclerView)
|
||||||
|
@ -79,21 +79,21 @@ class JSonViewerFragment : Fragment(), MavericksView {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(
|
fun newInstance(
|
||||||
jsonString: String,
|
jsonString: String,
|
||||||
initialOpenDepth: Int = -1,
|
initialOpenDepth: Int = -1,
|
||||||
wrap: Boolean = false,
|
wrap: Boolean = false,
|
||||||
styleProvider: JSonViewerStyleProvider? = null
|
styleProvider: JSonViewerStyleProvider? = null
|
||||||
): JSonViewerFragment {
|
): JSonViewerFragment {
|
||||||
return JSonViewerFragment().apply {
|
return JSonViewerFragment().apply {
|
||||||
arguments = Bundle().apply {
|
arguments = Bundle().apply {
|
||||||
putParcelable(
|
putParcelable(
|
||||||
Mavericks.KEY_ARG,
|
Mavericks.KEY_ARG,
|
||||||
JSonViewerFragmentArgs(
|
JSonViewerFragmentArgs(
|
||||||
jsonString,
|
jsonString,
|
||||||
initialOpenDepth,
|
initialOpenDepth,
|
||||||
wrap,
|
wrap,
|
||||||
styleProvider
|
styleProvider
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ internal interface Composed {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class JSonViewerObject(key: String?, index: Int?, jObject: JSONObject) :
|
internal class JSonViewerObject(key: String?, index: Int?, jObject: JSONObject) :
|
||||||
JSonViewerModel(key, index, jObject),
|
JSonViewerModel(key, index, jObject),
|
||||||
Composed {
|
Composed {
|
||||||
|
|
||||||
var keys = LinkedHashMap<String, JSonViewerModel>()
|
var keys = LinkedHashMap<String, JSonViewerModel>()
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ internal class JSonViewerObject(key: String?, index: Int?, jObject: JSONObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class JSonViewerArray(key: String?, index: Int?, jObject: JSONArray) :
|
internal class JSonViewerArray(key: String?, index: Int?, jObject: JSONArray) :
|
||||||
JSonViewerModel(key, index, jObject), Composed {
|
JSonViewerModel(key, index, jObject), Composed {
|
||||||
var items = ArrayList<JSonViewerModel>()
|
var items = ArrayList<JSonViewerModel>()
|
||||||
|
|
||||||
override fun addChild(model: JSonViewerModel) {
|
override fun addChild(model: JSonViewerModel) {
|
||||||
|
@ -50,7 +50,7 @@ internal class JSonViewerArray(key: String?, index: Int?, jObject: JSONArray) :
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class JSonViewerLeaf(key: String?, index: Int?, val stringRes: String, val type: JSONType) :
|
internal class JSonViewerLeaf(key: String?, index: Int?, val stringRes: String, val type: JSONType) :
|
||||||
JSonViewerModel(key, index, stringRes)
|
JSonViewerModel(key, index, stringRes)
|
||||||
|
|
||||||
internal enum class JSONType {
|
internal enum class JSONType {
|
||||||
STRING,
|
STRING,
|
||||||
|
@ -75,41 +75,41 @@ internal object ModelParser {
|
||||||
when (obj) {
|
when (obj) {
|
||||||
is JSONObject -> {
|
is JSONObject -> {
|
||||||
val objectComposed = JSonViewerObject(key, index, obj)
|
val objectComposed = JSonViewerObject(key, index, obj)
|
||||||
.apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth }
|
.apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth }
|
||||||
objectComposed.depth = depth
|
objectComposed.depth = depth
|
||||||
obj.keys().forEach {
|
obj.keys().forEach {
|
||||||
eval(objectComposed, it, null, obj.get(it), depth + 1, initialOpenDepth)
|
eval(objectComposed, it, null, obj.get(it), depth + 1, initialOpenDepth)
|
||||||
}
|
}
|
||||||
parent.addChild(objectComposed)
|
parent.addChild(objectComposed)
|
||||||
}
|
}
|
||||||
is JSONArray -> {
|
is JSONArray -> {
|
||||||
val objectComposed = JSonViewerArray(key, index, obj)
|
val objectComposed = JSonViewerArray(key, index, obj)
|
||||||
.apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth }
|
.apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth }
|
||||||
objectComposed.depth = depth
|
objectComposed.depth = depth
|
||||||
for (i in 0 until obj.length()) {
|
for (i in 0 until obj.length()) {
|
||||||
eval(objectComposed, null, i, obj[i], depth + 1, initialOpenDepth)
|
eval(objectComposed, null, i, obj[i], depth + 1, initialOpenDepth)
|
||||||
}
|
}
|
||||||
parent.addChild(objectComposed)
|
parent.addChild(objectComposed)
|
||||||
}
|
}
|
||||||
is String -> {
|
is String -> {
|
||||||
JSonViewerLeaf(key, index, obj, JSONType.STRING).let {
|
JSonViewerLeaf(key, index, obj, JSONType.STRING).let {
|
||||||
it.depth = depth
|
it.depth = depth
|
||||||
parent.addChild(it)
|
parent.addChild(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Number -> {
|
is Number -> {
|
||||||
JSonViewerLeaf(key, index, obj.toString(), JSONType.NUMBER).let {
|
JSonViewerLeaf(key, index, obj.toString(), JSONType.NUMBER).let {
|
||||||
it.depth = depth
|
it.depth = depth
|
||||||
parent.addChild(it)
|
parent.addChild(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Boolean -> {
|
is Boolean -> {
|
||||||
JSonViewerLeaf(key, index, obj.toString(), JSONType.BOOLEAN).let {
|
JSonViewerLeaf(key, index, obj.toString(), JSONType.BOOLEAN).let {
|
||||||
it.depth = depth
|
it.depth = depth
|
||||||
parent.addChild(it)
|
parent.addChild(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
if (obj == JSONObject.NULL) {
|
if (obj == JSONObject.NULL) {
|
||||||
JSonViewerLeaf(key, index, "null", JSONType.NULL).let {
|
JSonViewerLeaf(key, index, "null", JSONType.NULL).let {
|
||||||
it.depth = depth
|
it.depth = depth
|
||||||
|
|
|
@ -24,22 +24,22 @@ import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class JSonViewerStyleProvider(
|
data class JSonViewerStyleProvider(
|
||||||
@ColorInt val keyColor: Int,
|
@ColorInt val keyColor: Int,
|
||||||
@ColorInt val stringColor: Int,
|
@ColorInt val stringColor: Int,
|
||||||
@ColorInt val booleanColor: Int,
|
@ColorInt val booleanColor: Int,
|
||||||
@ColorInt val numberColor: Int,
|
@ColorInt val numberColor: Int,
|
||||||
@ColorInt val baseColor: Int,
|
@ColorInt val baseColor: Int,
|
||||||
@ColorInt val secondaryColor: Int
|
@ColorInt val secondaryColor: Int
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun default(context: Context) = JSonViewerStyleProvider(
|
fun default(context: Context) = JSonViewerStyleProvider(
|
||||||
keyColor = ContextCompat.getColor(context, R.color.key_color),
|
keyColor = ContextCompat.getColor(context, R.color.key_color),
|
||||||
stringColor = ContextCompat.getColor(context, R.color.string_color),
|
stringColor = ContextCompat.getColor(context, R.color.string_color),
|
||||||
booleanColor = ContextCompat.getColor(context, R.color.bool_color),
|
booleanColor = ContextCompat.getColor(context, R.color.bool_color),
|
||||||
numberColor = ContextCompat.getColor(context, R.color.number_color),
|
numberColor = ContextCompat.getColor(context, R.color.number_color),
|
||||||
baseColor = ContextCompat.getColor(context, R.color.base_color),
|
baseColor = ContextCompat.getColor(context, R.color.base_color),
|
||||||
secondaryColor = ContextCompat.getColor(context, R.color.secondary_color)
|
secondaryColor = ContextCompat.getColor(context, R.color.secondary_color)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ import com.airbnb.mvrx.ViewModelContext
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
internal data class JSonViewerState(
|
internal data class JSonViewerState(
|
||||||
val root: Async<JSonViewerObject> = Uninitialized
|
val root: Async<JSonViewerObject> = Uninitialized
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
|
||||||
internal class JSonViewerViewModel(initialState: JSonViewerState) :
|
internal class JSonViewerViewModel(initialState: JSonViewerState) :
|
||||||
MavericksViewModel<JSonViewerState>(initialState) {
|
MavericksViewModel<JSonViewerState>(initialState) {
|
||||||
|
|
||||||
fun setJsonSource(json: String, initialOpenDepth: Int) {
|
fun setJsonSource(json: String, initialOpenDepth: Int) {
|
||||||
setState {
|
setState {
|
||||||
|
@ -43,14 +43,14 @@ internal class JSonViewerViewModel(initialState: JSonViewerState) :
|
||||||
ModelParser.fromJsonString(json, initialOpenDepth).let {
|
ModelParser.fromJsonString(json, initialOpenDepth).let {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
root = Success(it)
|
root = Success(it)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: Throwable) {
|
} catch (error: Throwable) {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
root = Fail(error)
|
root = Fail(error)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ internal class JSonViewerViewModel(initialState: JSonViewerState) :
|
||||||
val arg: JSonViewerFragmentArgs = viewModelContext.args()
|
val arg: JSonViewerFragmentArgs = viewModelContext.args()
|
||||||
return try {
|
return try {
|
||||||
JSonViewerState(
|
JSonViewerState(
|
||||||
Success(ModelParser.fromJsonString(arg.jsonString, arg.defaultOpenDepth))
|
Success(ModelParser.fromJsonString(arg.jsonString, arg.defaultOpenDepth))
|
||||||
)
|
)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
JSonViewerState(Fail(failure))
|
JSonViewerState(Fail(failure))
|
||||||
|
|
|
@ -22,9 +22,9 @@ import android.util.TypedValue
|
||||||
internal object Utils {
|
internal object Utils {
|
||||||
fun dpToPx(dp: Int, context: Context): Int {
|
fun dpToPx(dp: Int, context: Context): Int {
|
||||||
return TypedValue.applyDimension(
|
return TypedValue.applyDimension(
|
||||||
TypedValue.COMPLEX_UNIT_DIP,
|
TypedValue.COMPLEX_UNIT_DIP,
|
||||||
dp.toFloat(),
|
dp.toFloat(),
|
||||||
context.resources.displayMetrics
|
context.resources.displayMetrics
|
||||||
).toInt()
|
).toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,14 +71,14 @@ internal abstract class ValueItem : EpoxyModelWithHolder<ValueItem.Holder>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateContextMenu(
|
override fun onCreateContextMenu(
|
||||||
menu: ContextMenu?,
|
menu: ContextMenu?,
|
||||||
v: View?,
|
v: View?,
|
||||||
menuInfo: ContextMenu.ContextMenuInfo?
|
menuInfo: ContextMenu.ContextMenuInfo?
|
||||||
) {
|
) {
|
||||||
if (copyValue != null) {
|
if (copyValue != null) {
|
||||||
val menuItem = menu?.add(R.string.copy_value)
|
val menuItem = menu?.add(R.string.copy_value)
|
||||||
val clipService =
|
val clipService =
|
||||||
v?.context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
v?.context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||||
menuItem?.setOnMenuItemClickListener {
|
menuItem?.setOnMenuItemClickListener {
|
||||||
clipService?.setPrimaryClip(ClipData.newPlainText("", copyValue))
|
clipService?.setPrimaryClip(ClipData.newPlainText("", copyValue))
|
||||||
true
|
true
|
||||||
|
|
|
@ -31,15 +31,15 @@ class MultiPicker<T> {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T> get(type: MultiPicker<T>): T {
|
fun <T> get(type: MultiPicker<T>): T {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
IMAGE -> ImagePicker() as T
|
IMAGE -> ImagePicker() as T
|
||||||
VIDEO -> VideoPicker() as T
|
VIDEO -> VideoPicker() as T
|
||||||
MEDIA -> MediaPicker() as T
|
MEDIA -> MediaPicker() as T
|
||||||
FILE -> FilePicker() as T
|
FILE -> FilePicker() as T
|
||||||
AUDIO -> AudioPicker() as T
|
AUDIO -> AudioPicker() as T
|
||||||
CONTACT -> ContactPicker() as T
|
CONTACT -> ContactPicker() as T
|
||||||
CAMERA -> CameraPicker() as T
|
CAMERA -> CameraPicker() as T
|
||||||
CAMERA_VIDEO -> CameraVideoPicker() as T
|
CAMERA_VIDEO -> CameraVideoPicker() as T
|
||||||
else -> throw IllegalArgumentException("Unsupported type $type")
|
else -> throw IllegalArgumentException("Unsupported type $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,12 +108,14 @@ class FlowRoom(private val room: Room) {
|
||||||
room.getAllThreadSummaries()
|
room.getAllThreadSummaries()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveThreadList(): Flow<List<ThreadRootEvent>> {
|
fun liveThreadList(): Flow<List<ThreadRootEvent>> {
|
||||||
return room.getAllThreadsLive().asFlow()
|
return room.getAllThreadsLive().asFlow()
|
||||||
.startWith(room.coroutineDispatchers.io) {
|
.startWith(room.coroutineDispatchers.io) {
|
||||||
room.getAllThreads()
|
room.getAllThreads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> {
|
fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> {
|
||||||
return room.getMarkedThreadNotificationsLive().asFlow()
|
return room.getMarkedThreadNotificationsLive().asFlow()
|
||||||
.startWith(room.coroutineDispatchers.io) {
|
.startWith(room.coroutineDispatchers.io) {
|
||||||
|
|
|
@ -110,11 +110,13 @@ class XSigningTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
}, it)
|
}, it)
|
||||||
}
|
}
|
||||||
testHelper.doSync<Unit> { bobSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
testHelper.doSync<Unit> {
|
||||||
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
bobSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
||||||
promise.resume(bobAuthParams)
|
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
||||||
}
|
promise.resume(bobAuthParams)
|
||||||
}, it) }
|
}
|
||||||
|
}, it)
|
||||||
|
}
|
||||||
|
|
||||||
// Check that alice can see bob keys
|
// Check that alice can see bob keys
|
||||||
testHelper.doSync<MXUsersDevicesMap<CryptoDeviceInfo>> { aliceSession.cryptoService().downloadKeys(listOf(bobSession.myUserId), true, it) }
|
testHelper.doSync<MXUsersDevicesMap<CryptoDeviceInfo>> { aliceSession.cryptoService().downloadKeys(listOf(bobSession.myUserId), true, it) }
|
||||||
|
@ -149,16 +151,20 @@ class XSigningTest : InstrumentedTest {
|
||||||
password = TestConstants.PASSWORD
|
password = TestConstants.PASSWORD
|
||||||
)
|
)
|
||||||
|
|
||||||
testHelper.doSync<Unit> { aliceSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
testHelper.doSync<Unit> {
|
||||||
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
aliceSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
||||||
promise.resume(aliceAuthParams)
|
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
||||||
}
|
promise.resume(aliceAuthParams)
|
||||||
}, it) }
|
}
|
||||||
testHelper.doSync<Unit> { bobSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
}, it)
|
||||||
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
}
|
||||||
promise.resume(bobAuthParams)
|
testHelper.doSync<Unit> {
|
||||||
}
|
bobSession.cryptoService().crossSigningService().initializeCrossSigning(object : UserInteractiveAuthInterceptor {
|
||||||
}, it) }
|
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
||||||
|
promise.resume(bobAuthParams)
|
||||||
|
}
|
||||||
|
}, it)
|
||||||
|
}
|
||||||
|
|
||||||
// Check that alice can see bob keys
|
// Check that alice can see bob keys
|
||||||
val bobUserId = bobSession.myUserId
|
val bobUserId = bobSession.myUserId
|
||||||
|
|
|
@ -155,8 +155,8 @@ class VerificationTest : InstrumentedTest {
|
||||||
bobSupportedMethods: List<VerificationMethod>,
|
bobSupportedMethods: List<VerificationMethod>,
|
||||||
expectedResultForAlice: ExpectedResult,
|
expectedResultForAlice: ExpectedResult,
|
||||||
expectedResultForBob: ExpectedResult) {
|
expectedResultForBob: ExpectedResult) {
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = CommonTestHelper(context())
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||||
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||||
|
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
|
|
|
@ -37,7 +37,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
@MatrixScope
|
@MatrixScope
|
||||||
internal class CurlLoggingInterceptor @Inject constructor() :
|
internal class CurlLoggingInterceptor @Inject constructor() :
|
||||||
Interceptor {
|
Interceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set any additional curl command options (see 'curl --help').
|
* Set any additional curl command options (see 'curl --help').
|
||||||
|
|
|
@ -45,9 +45,9 @@ interface FileService {
|
||||||
* Result will be a decrypted file, stored in the cache folder. url parameter will be used to create unique filename to avoid name collision.
|
* Result will be a decrypted file, stored in the cache folder. url parameter will be used to create unique filename to avoid name collision.
|
||||||
*/
|
*/
|
||||||
suspend fun downloadFile(fileName: String,
|
suspend fun downloadFile(fileName: String,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
url: String?,
|
url: String?,
|
||||||
elementToDecrypt: ElementToDecrypt?): File
|
elementToDecrypt: ElementToDecrypt?): File
|
||||||
|
|
||||||
suspend fun downloadFile(messageContent: MessageWithAttachmentContent): File =
|
suspend fun downloadFile(messageContent: MessageWithAttachmentContent): File =
|
||||||
downloadFile(
|
downloadFile(
|
||||||
|
|
|
@ -43,6 +43,7 @@ interface SyncStatusService {
|
||||||
val rooms: Int,
|
val rooms: Int,
|
||||||
val toDevice: Int
|
val toDevice: Int
|
||||||
) : IncrementalSyncStatus()
|
) : IncrementalSyncStatus()
|
||||||
|
|
||||||
object IncrementalSyncError : IncrementalSyncStatus()
|
object IncrementalSyncError : IncrementalSyncStatus()
|
||||||
object IncrementalSyncDone : IncrementalSyncStatus()
|
object IncrementalSyncDone : IncrementalSyncStatus()
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ object MatrixLinkify {
|
||||||
MatrixPatterns.isRoomId(url) ||
|
MatrixPatterns.isRoomId(url) ||
|
||||||
MatrixPatterns.isGroupId(url) ||
|
MatrixPatterns.isGroupId(url) ||
|
||||||
MatrixPatterns.isEventId(url)) {
|
MatrixPatterns.isEventId(url)) {
|
||||||
url = PermalinkService.MATRIX_TO_URL_BASE + url
|
url = PermalinkService.MATRIX_TO_URL_BASE + url
|
||||||
}
|
}
|
||||||
val span = MatrixPermalinkSpan(url, callback)
|
val span = MatrixPermalinkSpan(url, callback)
|
||||||
spannable.setSpan(span, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
spannable.setSpan(span, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
|
|
|
@ -35,21 +35,21 @@ sealed class PermalinkData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* &room_name=Team2
|
* &room_name=Team2
|
||||||
&room_avatar_url=mxc:
|
&room_avatar_url=mxc:
|
||||||
&inviter_name=bob
|
&inviter_name=bob
|
||||||
*/
|
*/
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class RoomEmailInviteLink(
|
data class RoomEmailInviteLink(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val email: String,
|
val email: String,
|
||||||
val signUrl: String,
|
val signUrl: String,
|
||||||
val roomName: String?,
|
val roomName: String?,
|
||||||
val roomAvatarUrl: String?,
|
val roomAvatarUrl: String?,
|
||||||
val inviterName: String?,
|
val inviterName: String?,
|
||||||
val identityServer: String,
|
val identityServer: String,
|
||||||
val token: String,
|
val token: String,
|
||||||
val privateKey: String,
|
val privateKey: String,
|
||||||
val roomType: String?
|
val roomType: String?
|
||||||
) : PermalinkData(), Parcelable
|
) : PermalinkData(), Parcelable
|
||||||
|
|
||||||
data class UserLink(val userId: String) : PermalinkData()
|
data class UserLink(val userId: String) : PermalinkData()
|
||||||
|
|
|
@ -36,10 +36,10 @@ data class RoomJoinRulesContent(
|
||||||
@Json(name = "allow") val allowList: List<RoomJoinRulesAllowEntry>? = null
|
@Json(name = "allow") val allowList: List<RoomJoinRulesAllowEntry>? = null
|
||||||
) {
|
) {
|
||||||
val joinRules: RoomJoinRules? = when (_joinRules) {
|
val joinRules: RoomJoinRules? = when (_joinRules) {
|
||||||
"public" -> RoomJoinRules.PUBLIC
|
"public" -> RoomJoinRules.PUBLIC
|
||||||
"invite" -> RoomJoinRules.INVITE
|
"invite" -> RoomJoinRules.INVITE
|
||||||
"knock" -> RoomJoinRules.KNOCK
|
"knock" -> RoomJoinRules.KNOCK
|
||||||
"private" -> RoomJoinRules.PRIVATE
|
"private" -> RoomJoinRules.PRIVATE
|
||||||
"restricted" -> RoomJoinRules.RESTRICTED
|
"restricted" -> RoomJoinRules.RESTRICTED
|
||||||
else -> {
|
else -> {
|
||||||
Timber.w("Invalid value for RoomJoinRules: `$_joinRules`")
|
Timber.w("Invalid value for RoomJoinRules: `$_joinRules`")
|
||||||
|
|
|
@ -44,7 +44,7 @@ data class CallAnswerContent(
|
||||||
* Capability advertisement.
|
* Capability advertisement.
|
||||||
*/
|
*/
|
||||||
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
||||||
) : CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Answer(
|
data class Answer(
|
||||||
|
|
|
@ -55,7 +55,7 @@ data class CallInviteContent(
|
||||||
*/
|
*/
|
||||||
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
||||||
|
|
||||||
) : CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Offer(
|
data class Offer(
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,7 +47,7 @@ data class CallNegotiateContent(
|
||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
|
|
||||||
) : CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Description(
|
data class Description(
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,7 @@ data class CallReplacesContent(
|
||||||
* Required. The version of the VoIP specification this messages adheres to.
|
* Required. The version of the VoIP specification this messages adheres to.
|
||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
) : CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class TargetUser(
|
data class TargetUser(
|
||||||
|
|
|
@ -52,5 +52,5 @@ data class FileInfo(
|
||||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||||
*/
|
*/
|
||||||
fun FileInfo.getThumbnailUrl(): String? {
|
fun FileInfo.getThumbnailUrl(): String? {
|
||||||
return thumbnailFile?.url ?: thumbnailUrl
|
return thumbnailFile?.url ?: thumbnailUrl
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,5 +62,5 @@ data class ImageInfo(
|
||||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||||
*/
|
*/
|
||||||
fun ImageInfo.getThumbnailUrl(): String? {
|
fun ImageInfo.getThumbnailUrl(): String? {
|
||||||
return thumbnailFile?.url ?: thumbnailUrl
|
return thumbnailFile?.url ?: thumbnailUrl
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.crypto.verification.VerificationInfoReque
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageVerificationRequestContent(
|
data class MessageVerificationRequestContent(
|
||||||
@Json(name = MessageContent.MSG_TYPE_JSON_KEY)override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
|
@Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
@Json(name = "from_device") override val fromDevice: String?,
|
@Json(name = "from_device") override val fromDevice: String?,
|
||||||
@Json(name = "methods") override val methods: List<String>,
|
@Json(name = "methods") override val methods: List<String>,
|
||||||
|
|
|
@ -27,7 +27,7 @@ data class MessageVideoContent(
|
||||||
/**
|
/**
|
||||||
* Required. Must be 'm.video'.
|
* Required. Must be 'm.video'.
|
||||||
*/
|
*/
|
||||||
@Json(name = MessageContent.MSG_TYPE_JSON_KEY)override val msgType: String,
|
@Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'.
|
* Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'.
|
||||||
|
|
|
@ -67,5 +67,5 @@ data class VideoInfo(
|
||||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||||
*/
|
*/
|
||||||
fun VideoInfo.getThumbnailUrl(): String? {
|
fun VideoInfo.getThumbnailUrl(): String? {
|
||||||
return thumbnailFile?.url ?: thumbnailUrl
|
return thumbnailFile?.url ?: thumbnailUrl
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ sealed class SharedSecretStorageError(message: String?) : Throwable(message) {
|
||||||
data class UnsupportedAlgorithm(val algorithm: String) : SharedSecretStorageError("Unknown algorithm $algorithm")
|
data class UnsupportedAlgorithm(val algorithm: String) : SharedSecretStorageError("Unknown algorithm $algorithm")
|
||||||
data class SecretNotEncrypted(val secretName: String) : SharedSecretStorageError("Missing content for secret $secretName")
|
data class SecretNotEncrypted(val secretName: String) : SharedSecretStorageError("Missing content for secret $secretName")
|
||||||
data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String) :
|
data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String) :
|
||||||
SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
|
SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
|
||||||
|
|
||||||
object BadKeyFormat : SharedSecretStorageError("Bad Key Format")
|
object BadKeyFormat : SharedSecretStorageError("Bad Key Format")
|
||||||
object ParsingError : SharedSecretStorageError("parsing Error")
|
object ParsingError : SharedSecretStorageError("parsing Error")
|
||||||
|
|
|
@ -68,7 +68,7 @@ interface SpaceService {
|
||||||
suggestedOnly: Boolean? = null,
|
suggestedOnly: Boolean? = null,
|
||||||
limit: Int? = null,
|
limit: Int? = null,
|
||||||
from: String? = null,
|
from: String? = null,
|
||||||
// when paginating, pass back the m.space.child state events
|
// when paginating, pass back the m.space.child state events
|
||||||
knownStateList: List<Event>? = null): SpaceHierarchyData
|
knownStateList: List<Event>? = null): SpaceHierarchyData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class CancelGossipRequestWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class CancelGossipRequestWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<CancelGossipRequestWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<CancelGossipRequestWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -48,7 +48,7 @@ internal class CryptoSessionInfoProvider @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* @param allActive if true return joined as well as invited, if false, only joined
|
* @param allActive if true return joined as well as invited, if false, only joined
|
||||||
*/
|
*/
|
||||||
fun getRoomUserIds(roomId: String, allActive: Boolean): List<String> {
|
fun getRoomUserIds(roomId: String, allActive: Boolean): List<String> {
|
||||||
var userIds: List<String> = emptyList()
|
var userIds: List<String> = emptyList()
|
||||||
monarchy.doWithRealm { realm ->
|
monarchy.doWithRealm { realm ->
|
||||||
userIds = if (allActive) {
|
userIds = if (allActive) {
|
||||||
|
|
|
@ -75,15 +75,15 @@ internal class InboundGroupSessionStore @Inject constructor(
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun getInboundGroupSession(sessionId: String, senderKey: String): InboundGroupSessionHolder? {
|
fun getInboundGroupSession(sessionId: String, senderKey: String): InboundGroupSessionHolder? {
|
||||||
val known = sessionCache[CacheKey(sessionId, senderKey)]
|
val known = sessionCache[CacheKey(sessionId, senderKey)]
|
||||||
Timber.tag(loggerTag.value).v("## Inbound: getInboundGroupSession $sessionId in cache ${known != null}")
|
Timber.tag(loggerTag.value).v("## Inbound: getInboundGroupSession $sessionId in cache ${known != null}")
|
||||||
return known
|
return known
|
||||||
?: store.getInboundGroupSession(sessionId, senderKey)?.also {
|
?: store.getInboundGroupSession(sessionId, senderKey)?.also {
|
||||||
Timber.tag(loggerTag.value).v("## Inbound: getInboundGroupSession cache populate ${it.roomId}")
|
Timber.tag(loggerTag.value).v("## Inbound: getInboundGroupSession cache populate ${it.roomId}")
|
||||||
sessionCache.put(CacheKey(sessionId, senderKey), InboundGroupSessionHolder(it))
|
sessionCache.put(CacheKey(sessionId, senderKey), InboundGroupSessionHolder(it))
|
||||||
}?.let {
|
}?.let {
|
||||||
InboundGroupSessionHolder(it)
|
InboundGroupSessionHolder(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
|
|
@ -116,7 +116,7 @@ internal class IncomingGossipingRequestManager @Inject constructor(
|
||||||
Timber.i("## CRYPTO | GOSSIP onGossipingRequestEvent received type ${event.type} from user:${event.senderId}, content:$roomKeyShare")
|
Timber.i("## CRYPTO | GOSSIP onGossipingRequestEvent received type ${event.type} from user:${event.senderId}, content:$roomKeyShare")
|
||||||
// val ageLocalTs = event.unsignedData?.age?.let { System.currentTimeMillis() - it }
|
// val ageLocalTs = event.unsignedData?.age?.let { System.currentTimeMillis() - it }
|
||||||
when (roomKeyShare?.action) {
|
when (roomKeyShare?.action) {
|
||||||
GossipingToDeviceObject.ACTION_SHARE_REQUEST -> {
|
GossipingToDeviceObject.ACTION_SHARE_REQUEST -> {
|
||||||
if (event.getClearType() == EventType.REQUEST_SECRET) {
|
if (event.getClearType() == EventType.REQUEST_SECRET) {
|
||||||
IncomingSecretShareRequest.fromEvent(event)?.let {
|
IncomingSecretShareRequest.fromEvent(event)?.let {
|
||||||
if (event.senderId == credentials.userId && it.deviceId == credentials.deviceId) {
|
if (event.senderId == credentials.userId && it.deviceId == credentials.deviceId) {
|
||||||
|
@ -346,7 +346,7 @@ internal class IncomingGossipingRequestManager @Inject constructor(
|
||||||
val isDeviceLocallyVerified = cryptoStore.getUserDevice(userId, deviceId)?.trustLevel?.isLocallyVerified()
|
val isDeviceLocallyVerified = cryptoStore.getUserDevice(userId, deviceId)?.trustLevel?.isLocallyVerified()
|
||||||
|
|
||||||
when (secretName) {
|
when (secretName) {
|
||||||
MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master
|
MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master
|
||||||
SELF_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.selfSigned
|
SELF_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.selfSigned
|
||||||
USER_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.user
|
USER_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.user
|
||||||
KEYBACKUP_SECRET_SSSS_NAME -> cryptoStore.getKeyBackupRecoveryKeyInfo()?.recoveryKey
|
KEYBACKUP_SECRET_SSSS_NAME -> cryptoStore.getKeyBackupRecoveryKeyInfo()?.recoveryKey
|
||||||
|
|
|
@ -41,7 +41,7 @@ import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class SendGossipRequestWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class SendGossipRequestWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<SendGossipRequestWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<SendGossipRequestWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -33,7 +33,7 @@ internal class MXOlmEncryption(
|
||||||
private val messageEncrypter: MessageEncrypter,
|
private val messageEncrypter: MessageEncrypter,
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction) :
|
private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction) :
|
||||||
IMXEncrypting {
|
IMXEncrypting {
|
||||||
|
|
||||||
override suspend fun encryptEventContent(eventContent: Content, eventType: String, userIds: List<String>): Content {
|
override suspend fun encryptEventContent(eventContent: Content, eventType: String, userIds: List<String>): Content {
|
||||||
// pick the list of recipients based on the membership list.
|
// pick the list of recipients based on the membership list.
|
||||||
|
|
|
@ -174,7 +174,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||||
throw SharedSecretStorageError.UnknownAlgorithm(key.keyInfo.content.algorithm ?: "")
|
throw SharedSecretStorageError.UnknownAlgorithm(key.keyInfo.content.algorithm ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is KeyInfoResult.Error -> throw key.error
|
is KeyInfoResult.Error -> throw key.error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ internal open class CryptoRoomEntity(
|
||||||
// a security to ensure that a room will never revert to not encrypted
|
// a security to ensure that a room will never revert to not encrypted
|
||||||
// even if a new state event with empty encryption, or state is reset somehow
|
// even if a new state event with empty encryption, or state is reset somehow
|
||||||
var wasEncryptedOnce: Boolean? = false
|
var wasEncryptedOnce: Boolean? = false
|
||||||
) :
|
) :
|
||||||
RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ internal open class OlmInboundGroupSessionEntity(
|
||||||
var olmInboundGroupSessionData: String? = null,
|
var olmInboundGroupSessionData: String? = null,
|
||||||
// Indicate if the key has been backed up to the homeserver
|
// Indicate if the key has been backed up to the homeserver
|
||||||
var backedUp: Boolean = false) :
|
var backedUp: Boolean = false) :
|
||||||
RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
fun getInboundGroupSession(): OlmInboundGroupSessionWrapper2? {
|
fun getInboundGroupSession(): OlmInboundGroupSessionWrapper2? {
|
||||||
return try {
|
return try {
|
||||||
|
|
|
@ -30,7 +30,7 @@ internal open class OlmSessionEntity(@PrimaryKey var primaryKey: String = "",
|
||||||
var deviceKey: String? = null,
|
var deviceKey: String? = null,
|
||||||
var olmSessionData: String? = null,
|
var olmSessionData: String? = null,
|
||||||
var lastReceivedMessageTs: Long = 0) :
|
var lastReceivedMessageTs: Long = 0) :
|
||||||
RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
fun getOlmSession(): OlmSession? {
|
fun getOlmSession(): OlmSession? {
|
||||||
return deserializeFromRealm(olmSessionData)
|
return deserializeFromRealm(olmSessionData)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import javax.inject.Inject
|
||||||
* Possible next worker : None
|
* Possible next worker : None
|
||||||
*/
|
*/
|
||||||
internal class SendVerificationMessageWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class SendVerificationMessageWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<SendVerificationMessageWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<SendVerificationMessageWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -296,13 +296,13 @@ internal class VerificationTransportRoomMessage(
|
||||||
messageAuthenticationCode: String,
|
messageAuthenticationCode: String,
|
||||||
shortAuthenticationStrings: List<String>): VerificationInfoAccept =
|
shortAuthenticationStrings: List<String>): VerificationInfoAccept =
|
||||||
MessageVerificationAcceptContent.create(
|
MessageVerificationAcceptContent.create(
|
||||||
tid,
|
tid,
|
||||||
keyAgreementProtocol,
|
keyAgreementProtocol,
|
||||||
hash,
|
hash,
|
||||||
commitment,
|
commitment,
|
||||||
messageAuthenticationCode,
|
messageAuthenticationCode,
|
||||||
shortAuthenticationStrings
|
shortAuthenticationStrings
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = MessageVerificationKeyContent.create(tid, pubKey)
|
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = MessageVerificationKeyContent.create(tid, pubKey)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
internal class EventInsertLiveObserver @Inject constructor(@SessionDatabase realmConfiguration: RealmConfiguration,
|
internal class EventInsertLiveObserver @Inject constructor(@SessionDatabase realmConfiguration: RealmConfiguration,
|
||||||
private val processors: Set<@JvmSuppressWildcards EventInsertLiveProcessor>) :
|
private val processors: Set<@JvmSuppressWildcards EventInsertLiveProcessor>) :
|
||||||
RealmLiveEntityObserver<EventInsertEntity>(realmConfiguration) {
|
RealmLiveEntityObserver<EventInsertEntity>(realmConfiguration) {
|
||||||
|
|
||||||
override val query = Monarchy.Query {
|
override val query = Monarchy.Query {
|
||||||
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicReference
|
||||||
internal interface LiveEntityObserver : SessionLifecycleObserver
|
internal interface LiveEntityObserver : SessionLifecycleObserver
|
||||||
|
|
||||||
internal abstract class RealmLiveEntityObserver<T : RealmObject>(protected val realmConfiguration: RealmConfiguration) :
|
internal abstract class RealmLiveEntityObserver<T : RealmObject>(protected val realmConfiguration: RealmConfiguration) :
|
||||||
LiveEntityObserver, RealmChangeListener<RealmResults<T>> {
|
LiveEntityObserver, RealmChangeListener<RealmResults<T>> {
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
val BACKGROUND_HANDLER = createBackgroundHandler("LIVE_ENTITY_BACKGROUND")
|
val BACKGROUND_HANDLER = createBackgroundHandler("LIVE_ENTITY_BACKGROUND")
|
||||||
|
|
|
@ -33,7 +33,7 @@ import kotlin.concurrent.getOrSet
|
||||||
*/
|
*/
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy) :
|
internal class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy) :
|
||||||
SessionLifecycleObserver {
|
SessionLifecycleObserver {
|
||||||
|
|
||||||
private val realmThreadLocal = ThreadLocal<Realm>()
|
private val realmThreadLocal = ThreadLocal<Realm>()
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.matrix.android.sdk.internal.util.Normalizer
|
||||||
import org.matrix.android.sdk.internal.util.database.RealmMigrator
|
import org.matrix.android.sdk.internal.util.database.RealmMigrator
|
||||||
|
|
||||||
internal class MigrateSessionTo019(realm: DynamicRealm,
|
internal class MigrateSessionTo019(realm: DynamicRealm,
|
||||||
private val normalizer: Normalizer) : RealmMigrator(realm, 19) {
|
private val normalizer: Normalizer) : RealmMigrator(realm, 19) {
|
||||||
|
|
||||||
override fun doMigrate(realm: DynamicRealm) {
|
override fun doMigrate(realm: DynamicRealm) {
|
||||||
realm.schema.get("RoomSummaryEntity")
|
realm.schema.get("RoomSummaryEntity")
|
||||||
|
|
|
@ -24,19 +24,20 @@ import io.realm.annotations.LinkingObjects
|
||||||
import org.matrix.android.sdk.internal.extensions.assertIsManaged
|
import org.matrix.android.sdk.internal.extensions.assertIsManaged
|
||||||
import org.matrix.android.sdk.internal.extensions.clearWith
|
import org.matrix.android.sdk.internal.extensions.clearWith
|
||||||
|
|
||||||
internal open class ChunkEntity(@Index var prevToken: String? = null,
|
internal open class ChunkEntity(
|
||||||
|
@Index var prevToken: String? = null,
|
||||||
// Because of gaps we can have several chunks with nextToken == null
|
// Because of gaps we can have several chunks with nextToken == null
|
||||||
@Index var nextToken: String? = null,
|
@Index var nextToken: String? = null,
|
||||||
var prevChunk: ChunkEntity? = null,
|
var prevChunk: ChunkEntity? = null,
|
||||||
var nextChunk: ChunkEntity? = null,
|
var nextChunk: ChunkEntity? = null,
|
||||||
var stateEvents: RealmList<EventEntity> = RealmList(),
|
var stateEvents: RealmList<EventEntity> = RealmList(),
|
||||||
var timelineEvents: RealmList<TimelineEventEntity> = RealmList(),
|
var timelineEvents: RealmList<TimelineEventEntity> = RealmList(),
|
||||||
// Only one chunk will have isLastForward == true
|
// Only one chunk will have isLastForward == true
|
||||||
@Index var isLastForward: Boolean = false,
|
@Index var isLastForward: Boolean = false,
|
||||||
@Index var isLastBackward: Boolean = false,
|
@Index var isLastBackward: Boolean = false,
|
||||||
// Threads
|
// Threads
|
||||||
@Index var rootThreadEventId: String? = null,
|
@Index var rootThreadEventId: String? = null,
|
||||||
@Index var isLastForwardThread: Boolean = false,
|
@Index var isLastForwardThread: Boolean = false,
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
fun identifier() = "${prevToken}_$nextToken"
|
fun identifier() = "${prevToken}_$nextToken"
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
* Then GetGroupDataTask is called regularly to fetch group information from the homeserver.
|
* Then GetGroupDataTask is called regularly to fetch group information from the homeserver.
|
||||||
*/
|
*/
|
||||||
internal open class GroupEntity(@PrimaryKey var groupId: String = "") :
|
internal open class GroupEntity(@PrimaryKey var groupId: String = "") :
|
||||||
RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
private var membershipStr: String = Membership.NONE.name
|
private var membershipStr: String = Membership.NONE.name
|
||||||
var membership: Membership
|
var membership: Membership
|
||||||
|
|
|
@ -48,8 +48,10 @@ internal open class RoomEntity(@PrimaryKey var roomId: String = "",
|
||||||
set(value) {
|
set(value) {
|
||||||
membersLoadStatusStr = value.name
|
membersLoadStatusStr = value.name
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun RoomEntity.removeThreadSummaryIfNeeded(eventId: String) {
|
internal fun RoomEntity.removeThreadSummaryIfNeeded(eventId: String) {
|
||||||
assertIsManaged()
|
assertIsManaged()
|
||||||
threadSummaries.findRootOrLatest(eventId)?.let {
|
threadSummaries.findRootOrLatest(eventId)?.let {
|
||||||
|
|
|
@ -32,8 +32,8 @@ internal open class TimelineEventEntity(var localId: Long = 0,
|
||||||
var isUniqueDisplayName: Boolean = false,
|
var isUniqueDisplayName: Boolean = false,
|
||||||
var senderAvatar: String? = null,
|
var senderAvatar: String? = null,
|
||||||
var senderMembershipEventId: String? = null,
|
var senderMembershipEventId: String? = null,
|
||||||
// ownedByThreadChunk indicates that the current TimelineEventEntity belongs
|
// ownedByThreadChunk indicates that the current TimelineEventEntity belongs
|
||||||
// to a thread chunk and is a temporarily event.
|
// to a thread chunk and is a temporarily event.
|
||||||
var ownedByThreadChunk: Boolean = false,
|
var ownedByThreadChunk: Boolean = false,
|
||||||
var readReceipts: ReadReceiptsSummaryEntity? = null
|
var readReceipts: ReadReceiptsSummaryEntity? = null
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
|
@ -56,18 +56,21 @@ internal fun ChunkEntity.Companion.findLastForwardChunkOfRoom(realm: Realm, room
|
||||||
.equalTo(ChunkEntityFields.IS_LAST_FORWARD, true)
|
.equalTo(ChunkEntityFields.IS_LAST_FORWARD, true)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ChunkEntity.Companion.findLastForwardChunkOfThread(realm: Realm, roomId: String, rootThreadEventId: String): ChunkEntity? {
|
internal fun ChunkEntity.Companion.findLastForwardChunkOfThread(realm: Realm, roomId: String, rootThreadEventId: String): ChunkEntity? {
|
||||||
return where(realm, roomId)
|
return where(realm, roomId)
|
||||||
.equalTo(ChunkEntityFields.ROOT_THREAD_EVENT_ID, rootThreadEventId)
|
.equalTo(ChunkEntityFields.ROOT_THREAD_EVENT_ID, rootThreadEventId)
|
||||||
.equalTo(ChunkEntityFields.IS_LAST_FORWARD_THREAD, true)
|
.equalTo(ChunkEntityFields.IS_LAST_FORWARD_THREAD, true)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ChunkEntity.Companion.findEventInThreadChunk(realm: Realm, roomId: String, event: String): ChunkEntity? {
|
internal fun ChunkEntity.Companion.findEventInThreadChunk(realm: Realm, roomId: String, event: String): ChunkEntity? {
|
||||||
return where(realm, roomId)
|
return where(realm, roomId)
|
||||||
.`in`(ChunkEntityFields.TIMELINE_EVENTS.EVENT_ID, arrayListOf(event).toTypedArray())
|
.`in`(ChunkEntityFields.TIMELINE_EVENTS.EVENT_ID, arrayListOf(event).toTypedArray())
|
||||||
.equalTo(ChunkEntityFields.IS_LAST_FORWARD_THREAD, true)
|
.equalTo(ChunkEntityFields.IS_LAST_FORWARD_THREAD, true)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ChunkEntity.Companion.findAllIncludingEvents(realm: Realm, eventIds: List<String>): RealmResults<ChunkEntity> {
|
internal fun ChunkEntity.Companion.findAllIncludingEvents(realm: Realm, eventIds: List<String>): RealmResults<ChunkEntity> {
|
||||||
return realm.where<ChunkEntity>()
|
return realm.where<ChunkEntity>()
|
||||||
.`in`(ChunkEntityFields.TIMELINE_EVENTS.EVENT_ID, eventIds.toTypedArray())
|
.`in`(ChunkEntityFields.TIMELINE_EVENTS.EVENT_ID, eventIds.toTypedArray())
|
||||||
|
|
|
@ -39,9 +39,11 @@ internal fun ThreadSummaryEntity.Companion.getOrCreate(realm: Realm, roomId: Str
|
||||||
this.rootThreadEventId = rootThreadEventId
|
this.rootThreadEventId = rootThreadEventId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ThreadSummaryEntity.Companion.getOrNull(realm: Realm, roomId: String, rootThreadEventId: String): ThreadSummaryEntity? {
|
internal fun ThreadSummaryEntity.Companion.getOrNull(realm: Realm, roomId: String, rootThreadEventId: String): ThreadSummaryEntity? {
|
||||||
return where(realm, roomId, rootThreadEventId).findFirst()
|
return where(realm, roomId, rootThreadEventId).findFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun RealmList<ThreadSummaryEntity>.find(rootThreadEventId: String): ThreadSummaryEntity? {
|
internal fun RealmList<ThreadSummaryEntity>.find(rootThreadEventId: String): ThreadSummaryEntity? {
|
||||||
return this.where()
|
return this.where()
|
||||||
.equalTo(ThreadSummaryEntityFields.ROOT_THREAD_EVENT_ID, rootThreadEventId)
|
.equalTo(ThreadSummaryEntityFields.ROOT_THREAD_EVENT_ID, rootThreadEventId)
|
||||||
|
|
|
@ -44,7 +44,7 @@ internal interface NetworkConnectivityChecker {
|
||||||
internal class DefaultNetworkConnectivityChecker @Inject constructor(private val homeServerPinger: HomeServerPinger,
|
internal class DefaultNetworkConnectivityChecker @Inject constructor(private val homeServerPinger: HomeServerPinger,
|
||||||
private val backgroundDetectionObserver: BackgroundDetectionObserver,
|
private val backgroundDetectionObserver: BackgroundDetectionObserver,
|
||||||
private val networkCallbackStrategy: NetworkCallbackStrategy) :
|
private val networkCallbackStrategy: NetworkCallbackStrategy) :
|
||||||
NetworkConnectivityChecker {
|
NetworkConnectivityChecker {
|
||||||
|
|
||||||
private val hasInternetAccess = AtomicBoolean(true)
|
private val hasInternetAccess = AtomicBoolean(true)
|
||||||
private val listeners = Collections.synchronizedSet(LinkedHashSet<NetworkConnectivityChecker.Listener>())
|
private val listeners = Collections.synchronizedSet(LinkedHashSet<NetworkConnectivityChecker.Listener>())
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.network
|
package org.matrix.android.sdk.internal.network
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest as internalExecuteRequest
|
import org.matrix.android.sdk.internal.network.executeRequest as internalExecuteRequest
|
||||||
|
|
||||||
internal interface RequestExecutor {
|
internal interface RequestExecutor {
|
||||||
|
|
|
@ -123,7 +123,7 @@ internal class DefaultFileService @Inject constructor(
|
||||||
val resolvedUrl = contentUrlResolver.resolveForDownload(url, elementToDecrypt) ?: throw IllegalArgumentException("url is null")
|
val resolvedUrl = contentUrlResolver.resolveForDownload(url, elementToDecrypt) ?: throw IllegalArgumentException("url is null")
|
||||||
|
|
||||||
val request = when (resolvedUrl) {
|
val request = when (resolvedUrl) {
|
||||||
is ContentUrlResolver.ResolvedMethod.GET -> {
|
is ContentUrlResolver.ResolvedMethod.GET -> {
|
||||||
Request.Builder()
|
Request.Builder()
|
||||||
.url(resolvedUrl.url)
|
.url(resolvedUrl.url)
|
||||||
.header(DOWNLOAD_PROGRESS_INTERCEPTOR_HEADER, url)
|
.header(DOWNLOAD_PROGRESS_INTERCEPTOR_HEADER, url)
|
||||||
|
|
|
@ -30,7 +30,7 @@ private val loggerTag = LoggerTag("CallEventProcessor", LoggerTag.VOIP)
|
||||||
|
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class CallEventProcessor @Inject constructor(private val callSignalingHandler: CallSignalingHandler) :
|
internal class CallEventProcessor @Inject constructor(private val callSignalingHandler: CallSignalingHandler) :
|
||||||
EventInsertLiveProcessor {
|
EventInsertLiveProcessor {
|
||||||
|
|
||||||
private val allowedTypes = listOf(
|
private val allowedTypes = listOf(
|
||||||
EventType.CALL_ANSWER,
|
EventType.CALL_ANSWER,
|
||||||
|
|
|
@ -148,8 +148,8 @@ internal class FileUploader @Inject constructor(
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return withContext(coroutineDispatchers.io) {
|
return withContext(coroutineDispatchers.io) {
|
||||||
okHttpClient.newCall(request).awaitResponse().use { response ->
|
okHttpClient.newCall(request).awaitResponse().use { response ->
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
throw response.toFailure(globalErrorReceiver)
|
throw response.toFailure(globalErrorReceiver)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,16 +68,16 @@ internal class ImageCompressor @Inject constructor(
|
||||||
val orientation = exifInfo.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
val orientation = exifInfo.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
||||||
val matrix = Matrix()
|
val matrix = Matrix()
|
||||||
when (orientation) {
|
when (orientation) {
|
||||||
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
|
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
|
||||||
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
|
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
|
||||||
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
|
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
|
||||||
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.preScale(-1f, 1f)
|
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.preScale(-1f, 1f)
|
||||||
ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f)
|
ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f)
|
||||||
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
||||||
matrix.preRotate(-90f)
|
matrix.preRotate(-90f)
|
||||||
matrix.preScale(-1f, 1f)
|
matrix.preScale(-1f, 1f)
|
||||||
}
|
}
|
||||||
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
||||||
matrix.preRotate(90f)
|
matrix.preRotate(90f)
|
||||||
matrix.preScale(-1f, 1f)
|
matrix.preScale(-1f, 1f)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class DefaultSyncStatusService @Inject constructor() :
|
internal class DefaultSyncStatusService @Inject constructor() :
|
||||||
SyncStatusService,
|
SyncStatusService,
|
||||||
ProgressReporter {
|
ProgressReporter {
|
||||||
|
|
||||||
private val status = MutableLiveData<SyncStatusService.Status>()
|
private val status = MutableLiveData<SyncStatusService.Status>()
|
||||||
|
|
|
@ -59,7 +59,7 @@ internal class IntegrationManager @Inject constructor(matrixConfiguration: Matri
|
||||||
private val updateUserAccountDataTask: UpdateUserAccountDataTask,
|
private val updateUserAccountDataTask: UpdateUserAccountDataTask,
|
||||||
private val accountDataDataSource: UserAccountDataDataSource,
|
private val accountDataDataSource: UserAccountDataDataSource,
|
||||||
private val widgetFactory: WidgetFactory) :
|
private val widgetFactory: WidgetFactory) :
|
||||||
SessionLifecycleObserver {
|
SessionLifecycleObserver {
|
||||||
|
|
||||||
private val currentConfigs = ArrayList<IntegrationManagerConfig>()
|
private val currentConfigs = ArrayList<IntegrationManagerConfig>()
|
||||||
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
|
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class AddPusherWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class AddPusherWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<AddPusherWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<AddPusherWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -38,18 +38,18 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
|
||||||
) : UpdatePushRuleActionsTask {
|
) : UpdatePushRuleActionsTask {
|
||||||
|
|
||||||
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
|
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
|
||||||
|
executeRequest(globalErrorReceiver) {
|
||||||
|
pushRulesApi.updateEnableRuleStatus(
|
||||||
|
params.kind.value,
|
||||||
|
params.ruleId,
|
||||||
|
EnabledBody(params.enable)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (params.actions != null) {
|
||||||
|
val body = mapOf("actions" to params.actions.toJson())
|
||||||
executeRequest(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
pushRulesApi.updateEnableRuleStatus(
|
pushRulesApi.updateRuleActions(params.kind.value, params.ruleId, body)
|
||||||
params.kind.value,
|
|
||||||
params.ruleId,
|
|
||||||
EnabledBody(params.enable)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (params.actions != null) {
|
|
||||||
val body = mapOf("actions" to params.actions.toJson())
|
|
||||||
executeRequest(globalErrorReceiver) {
|
|
||||||
pushRulesApi.updateRuleActions(params.kind.value, params.ruleId, body)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ internal class DefaultGetRoomIdByAliasTask @Inject constructor(
|
||||||
} else if (!params.searchOnServer) {
|
} else if (!params.searchOnServer) {
|
||||||
Optional.from(null)
|
Optional.from(null)
|
||||||
} else {
|
} else {
|
||||||
val description = tryOrNull("## Failed to get roomId from alias") {
|
val description = tryOrNull("## Failed to get roomId from alias") {
|
||||||
executeRequest(globalErrorReceiver) {
|
executeRequest(globalErrorReceiver) {
|
||||||
directoryAPI.getRoomIdByAlias(params.roomAlias)
|
directoryAPI.getRoomIdByAlias(params.roomAlias)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.matrix.android.sdk.internal.di.SessionDatabase
|
||||||
internal class DefaultRoomPushRuleService @AssistedInject constructor(@Assisted private val roomId: String,
|
internal class DefaultRoomPushRuleService @AssistedInject constructor(@Assisted private val roomId: String,
|
||||||
private val setRoomNotificationStateTask: SetRoomNotificationStateTask,
|
private val setRoomNotificationStateTask: SetRoomNotificationStateTask,
|
||||||
@SessionDatabase private val monarchy: Monarchy) :
|
@SessionDatabase private val monarchy: Monarchy) :
|
||||||
RoomPushRuleService {
|
RoomPushRuleService {
|
||||||
|
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
|
|
|
@ -38,7 +38,7 @@ internal interface SetRoomNotificationStateTask : Task<SetRoomNotificationStateT
|
||||||
internal class DefaultSetRoomNotificationStateTask @Inject constructor(@SessionDatabase private val monarchy: Monarchy,
|
internal class DefaultSetRoomNotificationStateTask @Inject constructor(@SessionDatabase private val monarchy: Monarchy,
|
||||||
private val removePushRuleTask: RemovePushRuleTask,
|
private val removePushRuleTask: RemovePushRuleTask,
|
||||||
private val addPushRuleTask: AddPushRuleTask) :
|
private val addPushRuleTask: AddPushRuleTask) :
|
||||||
SetRoomNotificationStateTask {
|
SetRoomNotificationStateTask {
|
||||||
|
|
||||||
override suspend fun execute(params: SetRoomNotificationStateTask.Params) {
|
override suspend fun execute(params: SetRoomNotificationStateTask.Params) {
|
||||||
val currentRoomPushRule = Realm.getInstance(monarchy.realmConfiguration).use {
|
val currentRoomPushRule = Realm.getInstance(monarchy.realmConfiguration).use {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import javax.inject.Inject
|
||||||
* Possible next worker : None, but it will post new work to send events, encrypted or not
|
* Possible next worker : None, but it will post new work to send events, encrypted or not
|
||||||
*/
|
*/
|
||||||
internal class MultipleEventSendingDispatcherWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class MultipleEventSendingDispatcherWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<MultipleEventSendingDispatcherWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<MultipleEventSendingDispatcherWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
@ -76,10 +76,10 @@ internal class MultipleEventSendingDispatcherWorker(context: Context, params: Wo
|
||||||
params.localEchoIds.forEach { localEchoIds ->
|
params.localEchoIds.forEach { localEchoIds ->
|
||||||
val roomId = localEchoIds.roomId
|
val roomId = localEchoIds.roomId
|
||||||
val eventId = localEchoIds.eventId
|
val eventId = localEchoIds.eventId
|
||||||
localEchoRepository.updateSendState(eventId, roomId, SendState.SENDING)
|
localEchoRepository.updateSendState(eventId, roomId, SendState.SENDING)
|
||||||
Timber.v("## SendEvent: [${System.currentTimeMillis()}] Schedule send event $eventId")
|
Timber.v("## SendEvent: [${System.currentTimeMillis()}] Schedule send event $eventId")
|
||||||
val sendWork = createSendEventWork(params.sessionId, eventId, true)
|
val sendWork = createSendEventWork(params.sessionId, eventId, true)
|
||||||
timelineSendEventWorkCommon.postWork(roomId, sendWork)
|
timelineSendEventWorkCommon.postWork(roomId, sendWork)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success()
|
return Result.success()
|
||||||
|
|
|
@ -34,7 +34,7 @@ import javax.inject.Inject
|
||||||
* Possible next worker : None
|
* Possible next worker : None
|
||||||
*/
|
*/
|
||||||
internal class RedactEventWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class RedactEventWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<RedactEventWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<RedactEventWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -40,7 +40,7 @@ import javax.inject.Inject
|
||||||
* Possible next worker : None
|
* Possible next worker : None
|
||||||
*/
|
*/
|
||||||
internal class SendEventWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
internal class SendEventWorker(context: Context, params: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<SendEventWorker.Params>(context, params, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<SendEventWorker.Params>(context, params, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -74,7 +74,7 @@ internal class QueueMemento @Inject constructor(context: Context,
|
||||||
encrypt = task.encrypt,
|
encrypt = task.encrypt,
|
||||||
order = order
|
order = order
|
||||||
)
|
)
|
||||||
is RedactQueuedTask -> RedactEventTaskInfo(
|
is RedactQueuedTask -> RedactEventTaskInfo(
|
||||||
redactionLocalEcho = task.redactionLocalEchoId,
|
redactionLocalEcho = task.redactionLocalEchoId,
|
||||||
order = order
|
order = order
|
||||||
)
|
)
|
||||||
|
@ -92,7 +92,7 @@ internal class QueueMemento @Inject constructor(context: Context,
|
||||||
?.forEach { info ->
|
?.forEach { info ->
|
||||||
try {
|
try {
|
||||||
when (info) {
|
when (info) {
|
||||||
is SendEventTaskInfo -> {
|
is SendEventTaskInfo -> {
|
||||||
localEchoRepository.getUpToDateEcho(info.localEchoId)?.let {
|
localEchoRepository.getUpToDateEcho(info.localEchoId)?.let {
|
||||||
if (it.sendState.isSending() && it.eventId != null && it.roomId != null) {
|
if (it.sendState.isSending() && it.eventId != null && it.roomId != null) {
|
||||||
localEchoRepository.updateSendState(it.eventId, it.roomId, SendState.UNSENT)
|
localEchoRepository.updateSendState(it.eventId, it.roomId, SendState.UNSENT)
|
||||||
|
|
|
@ -51,7 +51,7 @@ internal fun JsonDict.toSafePowerLevelsContentDict(): JsonDict {
|
||||||
usersDefault = content.usersDefault,
|
usersDefault = content.usersDefault,
|
||||||
users = content.users,
|
users = content.users,
|
||||||
stateDefault = content.stateDefault,
|
stateDefault = content.stateDefault,
|
||||||
notifications = content.notifications?.mapValues { content.notificationLevel(it.key) }
|
notifications = content.notifications?.mapValues { content.notificationLevel(it.key) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
?.toContent()
|
?.toContent()
|
||||||
|
|
|
@ -101,11 +101,11 @@ internal class Graph {
|
||||||
// it's a candidate
|
// it's a candidate
|
||||||
destination = it.destination
|
destination = it.destination
|
||||||
}
|
}
|
||||||
inPath -> {
|
inPath -> {
|
||||||
// Cycle!!
|
// Cycle!!
|
||||||
backwardEdges.add(it)
|
backwardEdges.add(it)
|
||||||
}
|
}
|
||||||
completed -> {
|
completed -> {
|
||||||
// dead end
|
// dead end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ internal class LiveTimelineEvent(private val monarchy: Monarchy,
|
||||||
private val timelineEventMapper: TimelineEventMapper,
|
private val timelineEventMapper: TimelineEventMapper,
|
||||||
private val roomId: String,
|
private val roomId: String,
|
||||||
private val eventId: String) :
|
private val eventId: String) :
|
||||||
MediatorLiveData<Optional<TimelineEvent>>() {
|
MediatorLiveData<Optional<TimelineEvent>>() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
buildAndObserveQuery()
|
buildAndObserveQuery()
|
||||||
|
|
|
@ -49,22 +49,23 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||||
* It does mainly listen to the db timeline events.
|
* It does mainly listen to the db timeline events.
|
||||||
* It also triggers pagination to the server when needed, or dispatch to the prev or next chunk if any.
|
* It also triggers pagination to the server when needed, or dispatch to the prev or next chunk if any.
|
||||||
*/
|
*/
|
||||||
internal class TimelineChunk(private val chunkEntity: ChunkEntity,
|
internal class TimelineChunk(
|
||||||
private val timelineSettings: TimelineSettings,
|
private val chunkEntity: ChunkEntity,
|
||||||
private val roomId: String,
|
private val timelineSettings: TimelineSettings,
|
||||||
private val timelineId: String,
|
private val roomId: String,
|
||||||
private val fetchThreadTimelineTask: FetchThreadTimelineTask,
|
private val timelineId: String,
|
||||||
private val eventDecryptor: TimelineEventDecryptor,
|
private val fetchThreadTimelineTask: FetchThreadTimelineTask,
|
||||||
private val paginationTask: PaginationTask,
|
private val eventDecryptor: TimelineEventDecryptor,
|
||||||
private val realmConfiguration: RealmConfiguration,
|
private val paginationTask: PaginationTask,
|
||||||
private val fetchTokenAndPaginateTask: FetchTokenAndPaginateTask,
|
private val realmConfiguration: RealmConfiguration,
|
||||||
private val timelineEventMapper: TimelineEventMapper,
|
private val fetchTokenAndPaginateTask: FetchTokenAndPaginateTask,
|
||||||
private val uiEchoManager: UIEchoManager?,
|
private val timelineEventMapper: TimelineEventMapper,
|
||||||
private val threadsAwarenessHandler: ThreadsAwarenessHandler,
|
private val uiEchoManager: UIEchoManager?,
|
||||||
private val lightweightSettingsStorage: LightweightSettingsStorage,
|
private val threadsAwarenessHandler: ThreadsAwarenessHandler,
|
||||||
private val initialEventId: String?,
|
private val lightweightSettingsStorage: LightweightSettingsStorage,
|
||||||
private val onBuiltEvents: (Boolean) -> Unit,
|
private val initialEventId: String?,
|
||||||
private val onEventsDeleted: () -> Unit,
|
private val onBuiltEvents: (Boolean) -> Unit,
|
||||||
|
private val onEventsDeleted: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val isLastForward = AtomicBoolean(chunkEntity.isLastForward)
|
private val isLastForward = AtomicBoolean(chunkEntity.isLastForward)
|
||||||
|
|
|
@ -87,7 +87,7 @@ internal class DefaultSearchTask @Inject constructor(
|
||||||
results = searchCategories.roomEvents?.results?.map { searchResponseItem ->
|
results = searchCategories.roomEvents?.results?.map { searchResponseItem ->
|
||||||
|
|
||||||
val localThreadEventDetails = localTimelineEvents
|
val localThreadEventDetails = localTimelineEvents
|
||||||
?.firstOrNull { it.eventId == searchResponseItem.event.eventId }
|
?.firstOrNull { it.eventId == searchResponseItem.event.eventId }
|
||||||
?.root
|
?.root
|
||||||
?.asDomain()
|
?.asDomain()
|
||||||
?.threadDetails
|
?.threadDetails
|
||||||
|
|
|
@ -34,11 +34,12 @@ internal enum class SyncPresence(val value: String) {
|
||||||
companion object {
|
companion object {
|
||||||
fun from(presenceEnum: PresenceEnum): SyncPresence {
|
fun from(presenceEnum: PresenceEnum): SyncPresence {
|
||||||
return when (presenceEnum) {
|
return when (presenceEnum) {
|
||||||
PresenceEnum.ONLINE -> Online
|
PresenceEnum.ONLINE -> Online
|
||||||
PresenceEnum.OFFLINE -> Offline
|
PresenceEnum.OFFLINE -> Offline
|
||||||
PresenceEnum.UNAVAILABLE -> Unavailable
|
PresenceEnum.UNAVAILABLE -> Unavailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun from(s: String?): SyncPresence? = values().find { it.value == s }
|
fun from(s: String?): SyncPresence? = values().find { it.value == s }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ internal class DefaultSyncTask @Inject constructor(
|
||||||
val nbToDevice = syncResponse.toDevice?.events.orEmpty().size
|
val nbToDevice = syncResponse.toDevice?.events.orEmpty().size
|
||||||
val nextBatch = syncResponse.nextBatch
|
val nextBatch = syncResponse.nextBatch
|
||||||
Timber.tag(loggerTag.value).d(
|
Timber.tag(loggerTag.value).d(
|
||||||
"Incremental sync request parsing, $nbRooms room(s) $nbToDevice toDevice(s). Got nextBatch: $nextBatch"
|
"Incremental sync request parsing, $nbRooms room(s) $nbToDevice toDevice(s). Got nextBatch: $nextBatch"
|
||||||
)
|
)
|
||||||
defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncParsing(
|
defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncParsing(
|
||||||
rooms = nbRooms,
|
rooms = nbRooms,
|
||||||
|
|
|
@ -42,7 +42,7 @@ private const val DEFAULT_DELAY_MILLIS = 30_000L
|
||||||
* Possible next worker : None
|
* Possible next worker : None
|
||||||
*/
|
*/
|
||||||
internal class SyncWorker(context: Context, workerParameters: WorkerParameters, sessionManager: SessionManager) :
|
internal class SyncWorker(context: Context, workerParameters: WorkerParameters, sessionManager: SessionManager) :
|
||||||
SessionSafeCoroutineWorker<SyncWorker.Params>(context, workerParameters, sessionManager, Params::class.java) {
|
SessionSafeCoroutineWorker<SyncWorker.Params>(context, workerParameters, sessionManager, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
|
|
@ -23,7 +23,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultThirdPartyService @Inject constructor(private val getThirdPartyProtocolTask: GetThirdPartyProtocolsTask,
|
internal class DefaultThirdPartyService @Inject constructor(private val getThirdPartyProtocolTask: GetThirdPartyProtocolsTask,
|
||||||
private val getThirdPartyUserTask: GetThirdPartyUserTask) :
|
private val getThirdPartyUserTask: GetThirdPartyUserTask) :
|
||||||
ThirdPartyService {
|
ThirdPartyService {
|
||||||
|
|
||||||
override suspend fun getThirdPartyProtocols(): Map<String, ThirdPartyProtocol> {
|
override suspend fun getThirdPartyProtocols(): Map<String, ThirdPartyProtocol> {
|
||||||
return getThirdPartyProtocolTask.execute(Unit)
|
return getThirdPartyProtocolTask.execute(Unit)
|
||||||
|
|
|
@ -29,7 +29,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultWidgetPostAPIMediator @Inject constructor(private val moshi: Moshi,
|
internal class DefaultWidgetPostAPIMediator @Inject constructor(private val moshi: Moshi,
|
||||||
private val widgetPostMessageAPIProvider: WidgetPostMessageAPIProvider) :
|
private val widgetPostMessageAPIProvider: WidgetPostMessageAPIProvider) :
|
||||||
WidgetPostAPIMediator {
|
WidgetPostAPIMediator {
|
||||||
|
|
||||||
private val jsonAdapter = moshi.adapter<JsonDict>(JSON_DICT_PARAMETERIZED_TYPE)
|
private val jsonAdapter = moshi.adapter<JsonDict>(JSON_DICT_PARAMETERIZED_TYPE)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import javax.inject.Provider
|
||||||
internal class DefaultWidgetService @Inject constructor(private val widgetManager: WidgetManager,
|
internal class DefaultWidgetService @Inject constructor(private val widgetManager: WidgetManager,
|
||||||
private val widgetURLFormatter: WidgetURLFormatter,
|
private val widgetURLFormatter: WidgetURLFormatter,
|
||||||
private val widgetPostAPIMediator: Provider<WidgetPostAPIMediator>) :
|
private val widgetPostAPIMediator: Provider<WidgetPostAPIMediator>) :
|
||||||
WidgetService {
|
WidgetService {
|
||||||
|
|
||||||
override fun getWidgetURLFormatter(): WidgetURLFormatter {
|
override fun getWidgetURLFormatter(): WidgetURLFormatter {
|
||||||
return widgetURLFormatter
|
return widgetURLFormatter
|
||||||
|
@ -52,7 +52,7 @@ internal class DefaultWidgetService @Inject constructor(private val widgetManage
|
||||||
return widgetManager.getWidgetComputedUrl(widget, isLightTheme)
|
return widgetManager.getWidgetComputedUrl(widget, isLightTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRoomWidgetsLive(
|
override fun getRoomWidgetsLive(
|
||||||
roomId: String,
|
roomId: String,
|
||||||
widgetId: QueryStringValue,
|
widgetId: QueryStringValue,
|
||||||
widgetTypes: Set<String>?,
|
widgetTypes: Set<String>?,
|
||||||
|
|
|
@ -52,7 +52,7 @@ internal class WidgetManager @Inject constructor(private val integrationManager:
|
||||||
private val widgetFactory: WidgetFactory,
|
private val widgetFactory: WidgetFactory,
|
||||||
@UserId private val userId: String) :
|
@UserId private val userId: String) :
|
||||||
|
|
||||||
IntegrationManagerService.Listener, SessionLifecycleObserver {
|
IntegrationManagerService.Listener, SessionLifecycleObserver {
|
||||||
|
|
||||||
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
|
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
|
||||||
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(lifecycleOwner)
|
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(lifecycleOwner)
|
||||||
|
|
|
@ -21,7 +21,7 @@ import io.realm.RealmObjectSchema
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
internal abstract class RealmMigrator(private val realm: DynamicRealm,
|
internal abstract class RealmMigrator(private val realm: DynamicRealm,
|
||||||
private val targetSchemaVersion: Int) {
|
private val targetSchemaVersion: Int) {
|
||||||
fun perform() {
|
fun perform() {
|
||||||
Timber.d("Migrate ${realm.configuration.realmFileName} to $targetSchemaVersion")
|
Timber.d("Migrate ${realm.configuration.realmFileName} to $targetSchemaVersion")
|
||||||
doMigrate(realm)
|
doMigrate(realm)
|
||||||
|
|
|
@ -20,6 +20,6 @@ import android.os.Build
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultBuildVersionSdkIntProvider @Inject constructor() :
|
internal class DefaultBuildVersionSdkIntProvider @Inject constructor() :
|
||||||
BuildVersionSdkIntProvider {
|
BuildVersionSdkIntProvider {
|
||||||
override fun get() = Build.VERSION.SDK_INT
|
override fun get() = Build.VERSION.SDK_INT
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import androidx.work.Worker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
|
|
||||||
internal class AlwaysSuccessfulWorker(context: Context, params: WorkerParameters) :
|
internal class AlwaysSuccessfulWorker(context: Context, params: WorkerParameters) :
|
||||||
Worker(context, params) {
|
Worker(context, params) {
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
return Result.success()
|
return Result.success()
|
||||||
|
|
|
@ -93,7 +93,7 @@ internal class MatrixWorkerFactory @Inject constructor(private val sessionManage
|
||||||
class CheckFactoryWorker(context: Context,
|
class CheckFactoryWorker(context: Context,
|
||||||
workerParameters: WorkerParameters,
|
workerParameters: WorkerParameters,
|
||||||
private val isCreatedByMatrixWorkerFactory: Boolean) :
|
private val isCreatedByMatrixWorkerFactory: Boolean) :
|
||||||
CoroutineWorker(context, workerParameters) {
|
CoroutineWorker(context, workerParameters) {
|
||||||
|
|
||||||
// Called by WorkManager if there is no MatrixWorkerFactory
|
// Called by WorkManager if there is no MatrixWorkerFactory
|
||||||
constructor(context: Context, workerParameters: WorkerParameters) : this(context,
|
constructor(context: Context, workerParameters: WorkerParameters) : this(context,
|
||||||
|
|
|
@ -27,7 +27,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
@MatrixScope
|
@MatrixScope
|
||||||
internal class CurlLoggingInterceptor @Inject constructor() :
|
internal class CurlLoggingInterceptor @Inject constructor() :
|
||||||
Interceptor {
|
Interceptor {
|
||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
|
|
@ -198,7 +198,7 @@ fun activityIdlingResource(activityClass: Class<*>): IdlingResource {
|
||||||
println("*** [$name] onActivityLifecycleChanged callback: $callback")
|
println("*** [$name] onActivityLifecycleChanged callback: $callback")
|
||||||
callback?.onTransitionToIdle()
|
callback?.onTransitionToIdle()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// do nothing, we're blocking until the activity resumes
|
// do nothing, we're blocking until the activity resumes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ class MessageMenuRobot(
|
||||||
clickOn(R.string.reply_in_thread)
|
clickOn(R.string.reply_in_thread)
|
||||||
autoClosed = true
|
autoClosed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun viewInRoom() {
|
fun viewInRoom() {
|
||||||
clickOn(R.string.view_in_room)
|
clickOn(R.string.view_in_room)
|
||||||
autoClosed = true
|
autoClosed = true
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SettingsRobot {
|
||||||
clickOnAndGoBack(R.string.settings_security_and_privacy) { block(SettingsSecurityRobot()) }
|
clickOnAndGoBack(R.string.settings_security_and_privacy) { block(SettingsSecurityRobot()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun labs(shouldGoBack: Boolean = true, block: () -> Unit = {}) {
|
fun labs(shouldGoBack: Boolean = true, block: () -> Unit = {}) {
|
||||||
if (shouldGoBack) {
|
if (shouldGoBack) {
|
||||||
clickOnAndGoBack(R.string.room_settings_labs_pref_title) { block() }
|
clickOnAndGoBack(R.string.room_settings_labs_pref_title) { block() }
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -32,6 +32,7 @@ abstract class SasEmojiItem : VectorEpoxyModel<SasEmojiItem.Holder>() {
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var index: Int = 0
|
var index: Int = 0
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
lateinit var emojiRepresentation: EmojiRepresentation
|
lateinit var emojiRepresentation: EmojiRepresentation
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
class TestAutoStartBoot @Inject constructor(private val vectorPreferences: VectorPreferences,
|
class TestAutoStartBoot @Inject constructor(private val vectorPreferences: VectorPreferences,
|
||||||
private val stringProvider: StringProvider) :
|
private val stringProvider: StringProvider) :
|
||||||
TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
||||||
|
|
||||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||||
if (vectorPreferences.autoStartOnBoot()) {
|
if (vectorPreferences.autoStartOnBoot()) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class TestBackgroundRestrictions @Inject constructor(private val context: FragmentActivity,
|
class TestBackgroundRestrictions @Inject constructor(private val context: FragmentActivity,
|
||||||
private val stringProvider: StringProvider) :
|
private val stringProvider: StringProvider) :
|
||||||
TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
|
TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
|
||||||
|
|
||||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||||
context.getSystemService<ConnectivityManager>()!!.apply {
|
context.getSystemService<ConnectivityManager>()!!.apply {
|
||||||
|
|
|
@ -29,10 +29,10 @@ class OnApplicationUpgradeOrRebootReceiver : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
Timber.v("## onReceive() ${intent.action}")
|
Timber.v("## onReceive() ${intent.action}")
|
||||||
val singletonEntryPoint = context.singletonEntryPoint()
|
val singletonEntryPoint = context.singletonEntryPoint()
|
||||||
BackgroundSyncStarter.start(
|
BackgroundSyncStarter.start(
|
||||||
context,
|
context,
|
||||||
singletonEntryPoint.vectorPreferences(),
|
singletonEntryPoint.vectorPreferences(),
|
||||||
singletonEntryPoint.activeSessionHolder()
|
singletonEntryPoint.activeSessionHolder()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
class TestPlayServices @Inject constructor(private val context: FragmentActivity,
|
class TestPlayServices @Inject constructor(private val context: FragmentActivity,
|
||||||
private val stringProvider: StringProvider) :
|
private val stringProvider: StringProvider) :
|
||||||
TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) {
|
TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) {
|
||||||
|
|
||||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||||
val apiAvailability = GoogleApiAvailability.getInstance()
|
val apiAvailability = GoogleApiAvailability.getInstance()
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestPushFromPushGateway @Inject constructor(private val context: FragmentA
|
||||||
private val errorFormatter: ErrorFormatter,
|
private val errorFormatter: ErrorFormatter,
|
||||||
private val pushersManager: PushersManager,
|
private val pushersManager: PushersManager,
|
||||||
private val activeSessionHolder: ActiveSessionHolder) :
|
private val activeSessionHolder: ActiveSessionHolder) :
|
||||||
TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
|
TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
|
||||||
|
|
||||||
private var action: Job? = null
|
private var action: Job? = null
|
||||||
private var pushReceived: Boolean = false
|
private var pushReceived: Boolean = false
|
||||||
|
|
|
@ -37,7 +37,7 @@ class TestTokenRegistration @Inject constructor(private val context: FragmentAct
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val pushersManager: PushersManager,
|
private val pushersManager: PushersManager,
|
||||||
private val activeSessionHolder: ActiveSessionHolder) :
|
private val activeSessionHolder: ActiveSessionHolder) :
|
||||||
TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) {
|
TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) {
|
||||||
|
|
||||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||||
// Check if we have a registered pusher for this token
|
// Check if we have a registered pusher for this token
|
||||||
|
|
|
@ -34,7 +34,7 @@ data class E2EMessageDetected(
|
||||||
val senderDeviceId: String,
|
val senderDeviceId: String,
|
||||||
val senderKey: String,
|
val senderKey: String,
|
||||||
val sessionId: String
|
val sessionId: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromEvent(event: Event, roomId: String): E2EMessageDetected {
|
fun fromEvent(event: Event, roomId: String): E2EMessageDetected {
|
||||||
|
@ -109,9 +109,9 @@ class UISIDetector : LiveEventListener {
|
||||||
timer.schedule(timeoutTask, timeoutMillis)
|
timer.schedule(timeoutTask, timeoutMillis)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLiveEvent(roomId: String, event: Event) { }
|
override fun onLiveEvent(roomId: String, event: Event) {}
|
||||||
|
|
||||||
override fun onPaginatedEvent(roomId: String, event: Event) { }
|
override fun onPaginatedEvent(roomId: String, event: Event) {}
|
||||||
|
|
||||||
private fun trackerId(eventId: String, roomId: String): String = "$roomId-$eventId"
|
private fun trackerId(eventId: String, roomId: String): String = "$roomId-$eventId"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class DefaultDateFormatterProvider @Inject constructor(private val context: Context,
|
class DefaultDateFormatterProvider @Inject constructor(private val context: Context,
|
||||||
private val localeProvider: LocaleProvider) :
|
private val localeProvider: LocaleProvider) :
|
||||||
DateFormatterProvider {
|
DateFormatterProvider {
|
||||||
|
|
||||||
override val dateWithMonthFormatter: DateTimeFormatter by lazy {
|
override val dateWithMonthFormatter: DateTimeFormatter by lazy {
|
||||||
val pattern = DateFormat.getBestDateTimePattern(localeProvider.current(), "d MMMMM")
|
val pattern = DateFormat.getBestDateTimePattern(localeProvider.current(), "d MMMMM")
|
||||||
|
|
|
@ -45,7 +45,7 @@ import dagger.hilt.components.SingletonComponent
|
||||||
inline fun <reified VM : MavericksViewModel<S>, S : MavericksState> hiltMavericksViewModelFactory() = HiltMavericksViewModelFactory<VM, S>(VM::class.java)
|
inline fun <reified VM : MavericksViewModel<S>, S : MavericksState> hiltMavericksViewModelFactory() = HiltMavericksViewModelFactory<VM, S>(VM::class.java)
|
||||||
|
|
||||||
class HiltMavericksViewModelFactory<VM : MavericksViewModel<S>, S : MavericksState>(
|
class HiltMavericksViewModelFactory<VM : MavericksViewModel<S>, S : MavericksState>(
|
||||||
private val viewModelClass: Class<out MavericksViewModel<S>>
|
private val viewModelClass: Class<out MavericksViewModel<S>>
|
||||||
) : MavericksViewModelFactory<VM, S> {
|
) : MavericksViewModelFactory<VM, S> {
|
||||||
|
|
||||||
override fun create(viewModelContext: ViewModelContext, state: S): VM {
|
override fun create(viewModelContext: ViewModelContext, state: S): VM {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ExportKeysDialog {
|
||||||
val textWatcher = object : SimpleTextWatcher() {
|
val textWatcher = object : SimpleTextWatcher() {
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
when {
|
when {
|
||||||
views.exportDialogEt.text.isNullOrEmpty() -> {
|
views.exportDialogEt.text.isNullOrEmpty() -> {
|
||||||
views.exportDialogSubmit.isEnabled = false
|
views.exportDialogSubmit.isEnabled = false
|
||||||
views.exportDialogTilConfirm.error = null
|
views.exportDialogTilConfirm.error = null
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class ExportKeysDialog {
|
||||||
views.exportDialogSubmit.isEnabled = true
|
views.exportDialogSubmit.isEnabled = true
|
||||||
views.exportDialogTilConfirm.error = null
|
views.exportDialogTilConfirm.error = null
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
views.exportDialogSubmit.isEnabled = false
|
views.exportDialogSubmit.isEnabled = false
|
||||||
views.exportDialogTilConfirm.error = activity.getString(R.string.passphrase_passphrase_does_not_match)
|
views.exportDialogTilConfirm.error = activity.getString(R.string.passphrase_passphrase_does_not_match)
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,8 @@ fun Session.cannotLogoutSafely(): Boolean {
|
||||||
return hasUnsavedKeys() ||
|
return hasUnsavedKeys() ||
|
||||||
// has local cross signing keys
|
// has local cross signing keys
|
||||||
(cryptoService().crossSigningService().allPrivateKeysKnown() &&
|
(cryptoService().crossSigningService().allPrivateKeysKnown() &&
|
||||||
// That are not backed up
|
// That are not backed up
|
||||||
!sharedSecretStorageService.isRecoverySetup())
|
!sharedSecretStorageService.isRecoverySetup())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Session.vectorStore(context: Context) = VectorSessionStore(context, myUserId)
|
fun Session.vectorStore(context: Context) = VectorSessionStore(context, myUserId)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue