Bluesky app fork with some witchin' additions 💫

run `lint-native:fix` (#8836)

authored by samuel.fm and committed by GitHub d5cc19f2 edd20548

Changed files
+110 -104
modules
BlueskyClip
bottom-sheet
android
src
main
java
expo
expo-bluesky-gif-view
android
src
main
java
expo
modules
blueskygifview
expo-emoji-picker
android
src
main
java
expo
community
+7 -7
modules/BlueskyClip/ViewController.swift
··· 43 43 let payload = try? JSONDecoder().decode(WebViewActionPayload.self, from: data) else { 44 44 return 45 45 } 46 - 46 + 47 47 switch payload.action { 48 48 case .present: 49 49 self.presentAppStoreOverlay() ··· 65 65 guard let url = navigationAction.request.url else { 66 66 return .allow 67 67 } 68 - 68 + 69 69 // Store the previous one to compare later, but only set starterPackUrl when we find the right one 70 70 prevUrl = url 71 71 // pathComponents starts with "/" as the first component, then each path name. so... 72 72 // ["/", "start", "name", "rkey"] 73 - if isStarterPackUrl(url){ 73 + if isStarterPackUrl(url) { 74 74 self.starterPackUrl = url 75 75 } 76 - 76 + 77 77 return .allow 78 78 } 79 - 79 + 80 80 func isStarterPackUrl(_ url: URL) -> Bool { 81 81 var host: String? 82 82 if #available(iOS 16.0, *) { ··· 84 84 } else { 85 85 host = url.host 86 86 } 87 - 87 + 88 88 switch host { 89 89 case "bsky.app": 90 90 if url.pathComponents.count == 4, 91 - (url.pathComponents[1] == "start" || url.pathComponents[1] == "starter-pack") { 91 + url.pathComponents[1] == "start" || url.pathComponents[1] == "starter-pack" { 92 92 return true 93 93 } 94 94 return false
+8 -8
modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/BottomSheetView.kt
··· 19 19 import expo.modules.kotlin.viewevent.EventDispatcher 20 20 import expo.modules.kotlin.views.ExpoView 21 21 22 - 23 22 class BottomSheetView( 24 23 context: Context, 25 24 appContext: AppContext, ··· 31 30 private lateinit var dialogRootViewGroup: DialogRootViewGroup 32 31 private var eventDispatcher: EventDispatcher? = null 33 32 34 - private val rawScreenHeight = context.resources.displayMetrics.heightPixels.toFloat() 33 + private val rawScreenHeight = 34 + context.resources.displayMetrics.heightPixels 35 + .toFloat() 35 36 private val safeScreenHeight = (rawScreenHeight - getNavigationBarHeight()).toFloat() 36 37 37 38 private fun getNavigationBarHeight(): Int { 38 - val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") 39 - return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0 39 + val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") 40 + return if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0 40 41 } 41 42 42 43 private val onAttemptDismiss by EventDispatcher() ··· 45 46 46 47 // Props 47 48 var disableDrag = false 48 - set (value) { 49 + set(value) { 49 50 field = value 50 51 this.setDraggable(!value) 51 52 } ··· 157 158 158 159 // Presentation 159 160 160 - private fun getHalfExpandedRatio(contentHeight: Float): Float { 161 - return when { 161 + private fun getHalfExpandedRatio(contentHeight: Float): Float = 162 + when { 162 163 // Full height sheets 163 164 contentHeight >= safeScreenHeight -> 0.99f 164 165 // Medium height sheets (>50% but <100%) ··· 168 169 else -> 169 170 this.clampRatio(this.getTargetHeight() / rawScreenHeight) 170 171 } 171 - } 172 172 173 173 private fun present() { 174 174 if (this.isOpen || this.isOpening || this.isClosing) return
+4 -1
modules/bottom-sheet/android/src/main/java/expo/modules/bottomsheet/DialogRootViewGroup.kt
··· 139 139 return super.onHoverEvent(event) 140 140 } 141 141 142 - override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) { 142 + override fun onChildStartedNativeGesture( 143 + childView: View?, 144 + ev: MotionEvent, 145 + ) { 143 146 eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) } 144 147 jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher) 145 148 }
+60 -60
modules/expo-bluesky-gif-view/android/src/main/java/expo/modules/blueskygifview/GifView.kt
··· 16 16 import expo.modules.kotlin.views.ExpoView 17 17 18 18 class GifView( 19 - context: Context, 20 - appContext: AppContext, 19 + context: Context, 20 + appContext: AppContext, 21 21 ) : ExpoView(context, appContext) { 22 22 // Events 23 23 private val onPlayerStateChange by EventDispatcher() ··· 82 82 } 83 83 84 84 this.webpRequest = 85 - glide.load(source) 86 - .diskCacheStrategy(DiskCacheStrategy.DATA) 87 - .skipMemoryCache(false) 88 - .listener( 89 - object : RequestListener<Drawable> { 90 - override fun onResourceReady( 91 - resource: Drawable, 92 - model: Any, 93 - target: Target<Drawable>?, 94 - dataSource: DataSource, 95 - isFirstResource: Boolean 96 - ): Boolean { 97 - placeholderRequest?.let { glide.clear(it) } 98 - return false 99 - } 85 + glide 86 + .load(source) 87 + .diskCacheStrategy(DiskCacheStrategy.DATA) 88 + .skipMemoryCache(false) 89 + .listener( 90 + object : RequestListener<Drawable> { 91 + override fun onResourceReady( 92 + resource: Drawable, 93 + model: Any, 94 + target: Target<Drawable>?, 95 + dataSource: DataSource, 96 + isFirstResource: Boolean, 97 + ): Boolean { 98 + placeholderRequest?.let { glide.clear(it) } 99 + return false 100 + } 100 101 101 - override fun onLoadFailed( 102 - e: GlideException?, 103 - model: Any?, 104 - target: Target<Drawable>, 105 - isFirstResource: Boolean 106 - ): Boolean = true 107 - } 108 - ) 109 - .into(this.imageView) 102 + override fun onLoadFailed( 103 + e: GlideException?, 104 + model: Any?, 105 + target: Target<Drawable>, 106 + isFirstResource: Boolean, 107 + ): Boolean = true 108 + }, 109 + ).into(this.imageView) 110 110 111 111 if (this.imageView.drawable == null || this.imageView.drawable !is Animatable) { 112 112 this.placeholderRequest = 113 - glide.load(placeholderSource) 114 - .diskCacheStrategy(DiskCacheStrategy.DATA) 115 - // Let's not bloat the memory cache with placeholders 116 - .skipMemoryCache(true) 117 - .listener( 118 - object : RequestListener<Drawable> { 119 - override fun onResourceReady( 120 - resource: Drawable, 121 - model: Any, 122 - target: Target<Drawable>?, 123 - dataSource: DataSource, 124 - isFirstResource: Boolean 125 - ): Boolean { 126 - // Incase this request finishes after the webp, let's just not set 127 - // the drawable. This shouldn't happen because the request should 128 - // get cancelled 129 - if (imageView.drawable == null) { 130 - imageView.setImageDrawable(resource) 131 - } 132 - return true 133 - } 113 + glide 114 + .load(placeholderSource) 115 + .diskCacheStrategy(DiskCacheStrategy.DATA) 116 + // Let's not bloat the memory cache with placeholders 117 + .skipMemoryCache(true) 118 + .listener( 119 + object : RequestListener<Drawable> { 120 + override fun onResourceReady( 121 + resource: Drawable, 122 + model: Any, 123 + target: Target<Drawable>?, 124 + dataSource: DataSource, 125 + isFirstResource: Boolean, 126 + ): Boolean { 127 + // Incase this request finishes after the webp, let's just not set 128 + // the drawable. This shouldn't happen because the request should 129 + // get cancelled 130 + if (imageView.drawable == null) { 131 + imageView.setImageDrawable(resource) 132 + } 133 + return true 134 + } 134 135 135 - override fun onLoadFailed( 136 - e: GlideException?, 137 - model: Any?, 138 - target: Target<Drawable>, 139 - isFirstResource: Boolean 140 - ): Boolean = true 141 - }, 142 - ) 143 - .submit() 136 + override fun onLoadFailed( 137 + e: GlideException?, 138 + model: Any?, 139 + target: Target<Drawable>, 140 + isFirstResource: Boolean, 141 + ): Boolean = true 142 + }, 143 + ).submit() 144 144 } 145 145 } 146 146 ··· 174 174 175 175 fun firePlayerStateChange() { 176 176 onPlayerStateChange( 177 - mapOf( 178 - "isPlaying" to this.isPlaying, 179 - "isLoaded" to this.isLoaded, 180 - ), 177 + mapOf( 178 + "isPlaying" to this.isPlaying, 179 + "isLoaded" to this.isLoaded, 180 + ), 181 181 ) 182 182 } 183 183
+6 -5
modules/expo-emoji-picker/android/src/main/java/expo/community/modules/emojipicker/EmojiPickerModule.kt
··· 5 5 import java.net.URL 6 6 7 7 class EmojiPickerModule : Module() { 8 - override fun definition() = ModuleDefinition { 9 - Name("EmojiPicker") 8 + override fun definition() = 9 + ModuleDefinition { 10 + Name("EmojiPicker") 10 11 11 - View(EmojiPickerModuleView::class) { 12 - Events("onEmojiSelected") 13 - } 12 + View(EmojiPickerModuleView::class) { 13 + Events("onEmojiSelected") 14 + } 14 15 } 15 16 }
+25 -23
modules/expo-emoji-picker/android/src/main/java/expo/community/modules/emojipicker/EmojiPickerModuleView.kt
··· 8 8 import expo.modules.kotlin.viewevent.EventDispatcher 9 9 import expo.modules.kotlin.views.ExpoView 10 10 11 - 12 11 @SuppressLint("ViewConstructor") 13 - class EmojiPickerModuleView(context: Context, appContext: AppContext) : 14 - ExpoView(context, appContext) { 15 - private var emojiView: EmojiPickerView = EmojiPickerView(context) 16 - private val onEmojiSelected by EventDispatcher() 12 + class EmojiPickerModuleView( 13 + context: Context, 14 + appContext: AppContext, 15 + ) : ExpoView(context, appContext) { 16 + private var emojiView: EmojiPickerView = EmojiPickerView(context) 17 + private val onEmojiSelected by EventDispatcher() 17 18 18 - init { 19 - setupView() 20 - } 19 + init { 20 + setupView() 21 + } 21 22 22 - private fun setupView() { 23 - addView( 24 - emojiView, LayoutParams( 25 - LayoutParams.MATCH_PARENT, 26 - LayoutParams.MATCH_PARENT 27 - ) 28 - ) 23 + private fun setupView() { 24 + addView( 25 + emojiView, 26 + LayoutParams( 27 + LayoutParams.MATCH_PARENT, 28 + LayoutParams.MATCH_PARENT, 29 + ), 30 + ) 29 31 30 - emojiView.setOnEmojiPickedListener { emoji -> 31 - onEmojiSelected(mapOf("emoji" to emoji.emoji)) 32 - } 32 + emojiView.setOnEmojiPickedListener { emoji -> 33 + onEmojiSelected(mapOf("emoji" to emoji.emoji)) 33 34 } 35 + } 34 36 35 - override fun onConfigurationChanged(newConfig: Configuration?) { 36 - super.onConfigurationChanged(newConfig) 37 - removeView(emojiView) 38 - setupView() 39 - } 37 + override fun onConfigurationChanged(newConfig: Configuration?) { 38 + super.onConfigurationChanged(newConfig) 39 + removeView(emojiView) 40 + setupView() 41 + } 40 42 }