Use colorProvider instead of context
This commit is contained in:
parent
7bebd6151e
commit
1555c06b21
@ -87,6 +87,7 @@ import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment
|
|||||||
import im.vector.app.features.roomprofile.uploads.files.RoomUploadsFilesFragment
|
import im.vector.app.features.roomprofile.uploads.files.RoomUploadsFilesFragment
|
||||||
import im.vector.app.features.roomprofile.uploads.media.RoomUploadsMediaFragment
|
import im.vector.app.features.roomprofile.uploads.media.RoomUploadsMediaFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsAdvancedNotificationPreferenceFragment
|
import im.vector.app.features.settings.VectorSettingsAdvancedNotificationPreferenceFragment
|
||||||
|
import im.vector.app.features.settings.VectorSettingsGeneralFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsHelpAboutFragment
|
import im.vector.app.features.settings.VectorSettingsHelpAboutFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsLabsFragment
|
import im.vector.app.features.settings.VectorSettingsLabsFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsNotificationPreferenceFragment
|
import im.vector.app.features.settings.VectorSettingsNotificationPreferenceFragment
|
||||||
@ -292,6 +293,11 @@ interface FragmentModule {
|
|||||||
@FragmentKey(VectorSettingsPinFragment::class)
|
@FragmentKey(VectorSettingsPinFragment::class)
|
||||||
fun bindVectorSettingsPinFragment(fragment: VectorSettingsPinFragment): Fragment
|
fun bindVectorSettingsPinFragment(fragment: VectorSettingsPinFragment): Fragment
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@FragmentKey(VectorSettingsGeneralFragment::class)
|
||||||
|
fun bindVectorSettingsGeneralFragment(fragment: VectorSettingsGeneralFragment): Fragment
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@FragmentKey(PushRulesFragment::class)
|
@FragmentKey(PushRulesFragment::class)
|
||||||
|
@ -187,7 +187,7 @@ class AttachmentsPreviewFragment @Inject constructor(
|
|||||||
val currentAttachment = it.attachments.getOrNull(it.currentAttachmentIndex) ?: return@withState
|
val currentAttachment = it.attachments.getOrNull(it.currentAttachmentIndex) ?: return@withState
|
||||||
val destinationFile = File(requireContext().cacheDir, "${currentAttachment.name}_edited_image_${System.currentTimeMillis()}")
|
val destinationFile = File(requireContext().cacheDir, "${currentAttachment.name}_edited_image_${System.currentTimeMillis()}")
|
||||||
val uri = currentAttachment.queryUri
|
val uri = currentAttachment.queryUri
|
||||||
createUCropWithDefaultSettings(requireContext(), uri, destinationFile.toUri(), currentAttachment.name)
|
createUCropWithDefaultSettings(colorProvider, uri, destinationFile.toUri(), currentAttachment.name)
|
||||||
.start(requireContext(), this)
|
.start(requireContext(), this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import im.vector.app.R
|
|||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.di.ScreenComponent
|
import im.vector.app.core.di.ScreenComponent
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.resources.ColorProvider
|
|
||||||
import kotlinx.android.synthetic.main.activity_big_image_viewer.*
|
import kotlinx.android.synthetic.main.activity_big_image_viewer.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
class BigImageViewerActivity : VectorBaseActivity() {
|
class BigImageViewerActivity : VectorBaseActivity() {
|
||||||
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
@Inject lateinit var sessionHolder: ActiveSessionHolder
|
||||||
@Inject lateinit var colorProvider: ColorProvider
|
|
||||||
|
|
||||||
override fun injectWith(injector: ScreenComponent) {
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
injector.inject(this)
|
injector.inject(this)
|
||||||
|
@ -16,16 +16,17 @@
|
|||||||
|
|
||||||
package im.vector.app.features.media
|
package im.vector.app.features.media
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.yalantis.ucrop.UCrop
|
import com.yalantis.ucrop.UCrop
|
||||||
import com.yalantis.ucrop.UCropActivity
|
import com.yalantis.ucrop.UCropActivity
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.core.resources.ColorProvider
|
||||||
|
|
||||||
fun createUCropWithDefaultSettings(context: Context, source: Uri, destination: Uri, toolbarTitle: String?): UCrop {
|
fun createUCropWithDefaultSettings(colorProvider: ColorProvider,
|
||||||
|
source: Uri,
|
||||||
|
destination: Uri,
|
||||||
|
toolbarTitle: String?): UCrop {
|
||||||
return UCrop.of(source, destination)
|
return UCrop.of(source, destination)
|
||||||
.withOptions(
|
.withOptions(
|
||||||
UCrop.Options()
|
UCrop.Options()
|
||||||
@ -39,15 +40,15 @@ fun createUCropWithDefaultSettings(context: Context, source: Uri, destination: U
|
|||||||
// Disable freestyle crop, usability was not easy
|
// Disable freestyle crop, usability was not easy
|
||||||
// setFreeStyleCropEnabled(true)
|
// setFreeStyleCropEnabled(true)
|
||||||
// Color used for toolbar icon and text
|
// Color used for toolbar icon and text
|
||||||
setToolbarColor(ThemeUtils.getColor(context, R.attr.riotx_background))
|
setToolbarColor(colorProvider.getColorFromAttribute(R.attr.riotx_background))
|
||||||
setToolbarWidgetColor(ThemeUtils.getColor(context, R.attr.vctr_toolbar_primary_text_color))
|
setToolbarWidgetColor(colorProvider.getColorFromAttribute(R.attr.vctr_toolbar_primary_text_color))
|
||||||
// Background
|
// Background
|
||||||
setRootViewBackgroundColor(ThemeUtils.getColor(context, R.attr.riotx_background))
|
setRootViewBackgroundColor(colorProvider.getColorFromAttribute(R.attr.riotx_background))
|
||||||
// Status bar color (pb in dark mode, icon of the status bar are dark)
|
// Status bar color (pb in dark mode, icon of the status bar are dark)
|
||||||
setStatusBarColor(ThemeUtils.getColor(context, R.attr.riotx_header_panel_background))
|
setStatusBarColor(colorProvider.getColorFromAttribute(R.attr.riotx_header_panel_background))
|
||||||
// Known issue: there is still orange color used by the lib
|
// Known issue: there is still orange color used by the lib
|
||||||
// https://github.com/Yalantis/uCrop/issues/602
|
// https://github.com/Yalantis/uCrop/issues/602
|
||||||
setActiveControlsWidgetColor(ContextCompat.getColor(context, R.color.riotx_accent))
|
setActiveControlsWidgetColor(colorProvider.getColor(R.color.riotx_accent))
|
||||||
// Hide the logo (does not work)
|
// Hide the logo (does not work)
|
||||||
setLogoColor(Color.TRANSPARENT)
|
setLogoColor(Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import im.vector.app.core.extensions.cleanup
|
|||||||
import im.vector.app.core.extensions.configureWith
|
import im.vector.app.core.extensions.configureWith
|
||||||
import im.vector.app.core.platform.OnBackPressed
|
import im.vector.app.core.platform.OnBackPressed
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
|
import im.vector.app.core.resources.ColorProvider
|
||||||
import im.vector.app.features.media.createUCropWithDefaultSettings
|
import im.vector.app.features.media.createUCropWithDefaultSettings
|
||||||
import im.vector.app.features.roomdirectory.RoomDirectorySharedAction
|
import im.vector.app.features.roomdirectory.RoomDirectorySharedAction
|
||||||
import im.vector.app.features.roomdirectory.RoomDirectorySharedActionViewModel
|
import im.vector.app.features.roomdirectory.RoomDirectorySharedActionViewModel
|
||||||
@ -41,7 +42,8 @@ import java.io.File
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class CreateRoomFragment @Inject constructor(
|
class CreateRoomFragment @Inject constructor(
|
||||||
private val createRoomController: CreateRoomController
|
private val createRoomController: CreateRoomController,
|
||||||
|
private val colorProvider: ColorProvider
|
||||||
) : VectorBaseFragment(),
|
) : VectorBaseFragment(),
|
||||||
CreateRoomController.Listener,
|
CreateRoomController.Listener,
|
||||||
GalleryOrCameraDialogHelper.Listener,
|
GalleryOrCameraDialogHelper.Listener,
|
||||||
@ -86,7 +88,7 @@ class CreateRoomFragment @Inject constructor(
|
|||||||
override fun onImageReady(image: MultiPickerImageType) {
|
override fun onImageReady(image: MultiPickerImageType) {
|
||||||
val destinationFile = File(requireContext().cacheDir, "${image.displayName}_edited_image_${System.currentTimeMillis()}")
|
val destinationFile = File(requireContext().cacheDir, "${image.displayName}_edited_image_${System.currentTimeMillis()}")
|
||||||
val uri = image.contentUri
|
val uri = image.contentUri
|
||||||
createUCropWithDefaultSettings(requireContext(), uri, destinationFile.toUri(), image.displayName)
|
createUCropWithDefaultSettings(colorProvider, uri, destinationFile.toUri(), image.displayName)
|
||||||
.withAspectRatio(1f, 1f)
|
.withAspectRatio(1f, 1f)
|
||||||
.start(requireContext(), this)
|
.start(requireContext(), this)
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import im.vector.app.core.platform.SimpleTextWatcher
|
|||||||
import im.vector.app.core.preference.UserAvatarPreference
|
import im.vector.app.core.preference.UserAvatarPreference
|
||||||
import im.vector.app.core.preference.VectorPreference
|
import im.vector.app.core.preference.VectorPreference
|
||||||
import im.vector.app.core.preference.VectorSwitchPreference
|
import im.vector.app.core.preference.VectorSwitchPreference
|
||||||
|
import im.vector.app.core.resources.ColorProvider
|
||||||
import im.vector.app.core.utils.TextUtils
|
import im.vector.app.core.utils.TextUtils
|
||||||
import im.vector.app.core.utils.getSizeOfFiles
|
import im.vector.app.core.utils.getSizeOfFiles
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
@ -70,8 +71,11 @@ import org.matrix.android.sdk.rx.rx
|
|||||||
import org.matrix.android.sdk.rx.unwrap
|
import org.matrix.android.sdk.rx.unwrap
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsGeneralFragment :
|
class VectorSettingsGeneralFragment @Inject constructor(
|
||||||
|
private val colorProvider: ColorProvider
|
||||||
|
):
|
||||||
VectorSettingsBaseFragment(),
|
VectorSettingsBaseFragment(),
|
||||||
GalleryOrCameraDialogHelper.Listener {
|
GalleryOrCameraDialogHelper.Listener {
|
||||||
|
|
||||||
@ -311,7 +315,7 @@ class VectorSettingsGeneralFragment :
|
|||||||
override fun onImageReady(image: MultiPickerImageType) {
|
override fun onImageReady(image: MultiPickerImageType) {
|
||||||
val destinationFile = File(requireContext().cacheDir, "${image.displayName}_edited_image_${System.currentTimeMillis()}")
|
val destinationFile = File(requireContext().cacheDir, "${image.displayName}_edited_image_${System.currentTimeMillis()}")
|
||||||
val uri = image.contentUri
|
val uri = image.contentUri
|
||||||
createUCropWithDefaultSettings(requireContext(), uri, destinationFile.toUri(), image.displayName)
|
createUCropWithDefaultSettings(colorProvider, uri, destinationFile.toUri(), image.displayName)
|
||||||
.withAspectRatio(1f, 1f)
|
.withAspectRatio(1f, 1f)
|
||||||
.start(requireContext(), this)
|
.start(requireContext(), this)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user