Move fun to a dedicated file.
This commit is contained in:
parent
d125cb5c01
commit
3fea2173f4
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2020 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.core.utils
|
||||
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerStyleProvider
|
||||
|
||||
fun createJSonViewerStyleProvider(colorProvider: ColorProvider): JSonViewerStyleProvider {
|
||||
return JSonViewerStyleProvider(
|
||||
keyColor = colorProvider.getColor(R.color.riotx_accent),
|
||||
secondaryColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary),
|
||||
stringColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
|
||||
baseColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_primary),
|
||||
booleanColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
|
||||
numberColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color)
|
||||
)
|
||||
}
|
|
@ -18,8 +18,6 @@ package im.vector.riotx.core.utils
|
|||
|
||||
import androidx.annotation.ColorRes
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerStyleProvider
|
||||
import kotlin.math.abs
|
||||
|
||||
@ColorRes
|
||||
|
@ -39,14 +37,3 @@ fun getColorFromUserId(userId: String?): Int {
|
|||
else -> R.color.riotx_username_1
|
||||
}
|
||||
}
|
||||
|
||||
fun jsonViewerStyler(colorProvider: ColorProvider): JSonViewerStyleProvider {
|
||||
return JSonViewerStyleProvider(
|
||||
keyColor = colorProvider.getColor(R.color.riotx_accent),
|
||||
secondaryColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary),
|
||||
stringColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
|
||||
baseColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_primary),
|
||||
booleanColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color),
|
||||
numberColor = colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -110,10 +110,10 @@ import im.vector.riotx.core.utils.allGranted
|
|||
import im.vector.riotx.core.utils.checkPermissions
|
||||
import im.vector.riotx.core.utils.colorizeMatchingText
|
||||
import im.vector.riotx.core.utils.copyToClipboard
|
||||
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
|
||||
import im.vector.riotx.core.utils.createUIHandler
|
||||
import im.vector.riotx.core.utils.getColorFromUserId
|
||||
import im.vector.riotx.core.utils.isValidUrl
|
||||
import im.vector.riotx.core.utils.jsonViewerStyler
|
||||
import im.vector.riotx.core.utils.openUrlInExternalBrowser
|
||||
import im.vector.riotx.core.utils.saveMedia
|
||||
import im.vector.riotx.core.utils.shareMedia
|
||||
|
@ -1207,14 +1207,14 @@ class RoomDetailFragment @Inject constructor(
|
|||
JSonViewerDialog.newInstance(
|
||||
action.content,
|
||||
-1,
|
||||
jsonViewerStyler(colorProvider)
|
||||
createJSonViewerStyleProvider(colorProvider)
|
||||
).show(childFragmentManager, "JSON_VIEWER")
|
||||
}
|
||||
is EventSharedAction.ViewDecryptedSource -> {
|
||||
JSonViewerDialog.newInstance(
|
||||
action.content,
|
||||
-1,
|
||||
jsonViewerStyler(colorProvider)
|
||||
createJSonViewerStyleProvider(colorProvider)
|
||||
).show(childFragmentManager, "JSON_VIEWER")
|
||||
}
|
||||
is EventSharedAction.QuickReact -> {
|
||||
|
|
|
@ -29,7 +29,7 @@ import im.vector.riotx.core.extensions.configureWith
|
|||
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import im.vector.riotx.core.utils.jsonViewerStyler
|
||||
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
|
||||
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerDialog
|
||||
import javax.inject.Inject
|
||||
|
@ -73,7 +73,7 @@ class AccountDataFragment @Inject constructor(
|
|||
JSonViewerDialog.newInstance(
|
||||
jsonString,
|
||||
-1, // open All
|
||||
jsonViewerStyler(colorProvider)
|
||||
createJSonViewerStyleProvider(colorProvider)
|
||||
).show(childFragmentManager, "JSON_VIEWER")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import im.vector.riotx.core.extensions.cleanup
|
|||
import im.vector.riotx.core.extensions.configureWith
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
import im.vector.riotx.core.resources.ColorProvider
|
||||
import im.vector.riotx.core.utils.jsonViewerStyler
|
||||
import im.vector.riotx.core.utils.createJSonViewerStyleProvider
|
||||
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
||||
import org.billcarsonfr.jsonviewer.JSonViewerDialog
|
||||
import javax.inject.Inject
|
||||
|
@ -66,7 +66,7 @@ class GossipingEventsPaperTrailFragment @Inject constructor(
|
|||
JSonViewerDialog.newInstance(
|
||||
it,
|
||||
-1,
|
||||
jsonViewerStyler(colorProvider)
|
||||
createJSonViewerStyleProvider(colorProvider)
|
||||
).show(childFragmentManager, "JSON_VIEWER")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue