Skip to content

Commit

Permalink
fix for ipads
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Manrique committed Dec 1, 2024
1 parent 689346f commit e49c44c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.jmp.wayback.presentation.app.platform

import kotlinx.cinterop.ExperimentalForeignApi
import platform.CoreLocation.CLLocationCoordinate2DMake
import platform.MapKit.MKMapItem
import platform.MapKit.MKPlacemark
import platform.Foundation.NSURL
import platform.UIKit.UIApplication

@OptIn(ExperimentalForeignApi::class)
actual fun openMap(latitude: Double, longitude: Double) {
val coordinate = CLLocationCoordinate2DMake(latitude, longitude)
val placemark = MKPlacemark(coordinate)
val mapItem = MKMapItem(placemark = placemark)
mapItem.name = "Wayback pin"
mapItem.openInMapsWithLaunchOptions(null)
val urlString = "http://maps.apple.com/?ll=${latitude},${longitude}&q=${"Wayback pin"}"
val url = NSURL.URLWithString(urlString) ?: return

if (UIApplication.sharedApplication.canOpenURL(url)) {
UIApplication.sharedApplication.openURL(
url = url,
options = emptyMap<Any?, Any>(),
completionHandler = null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ import com.jmp.wayback.common.ParkingInformation
import com.jmp.wayback.presentation.app.platform.ShareStrings.shareLocationTitle
import com.jmp.wayback.presentation.app.platform.ShareStrings.shareNoteTitle
import com.jmp.wayback.presentation.app.util.localized
import kotlinx.cinterop.ExperimentalForeignApi
import platform.CoreGraphics.CGRectMake
import platform.UIKit.UIActivityTypePostToFacebook
import platform.UIKit.UIActivityTypePostToTwitter
import platform.UIKit.UIActivityViewController
import platform.UIKit.UIApplication
import platform.UIKit.UIDevice
import platform.UIKit.UIImage
import platform.UIKit.UIUserInterfaceIdiomPad
import platform.UIKit.popoverPresentationController

@OptIn(ExperimentalForeignApi::class)
actual fun shareParkingInformation(parkingInformation: ParkingInformation) {
val currentController = UIApplication.sharedApplication.keyWindow?.rootViewController

Expand All @@ -36,6 +42,14 @@ actual fun shareParkingInformation(parkingInformation: ParkingInformation) {
applicationActivities = null
)

// Check if the current device is an iPad
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
activityViewController.popoverPresentationController?.apply {
sourceView = currentController?.view
sourceRect = CGRectMake(0.0, 0.0, 0.0, 0.0)
}
}

activityViewController.excludedActivityTypes = listOf(
UIActivityTypePostToFacebook,
UIActivityTypePostToTwitter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package com.jmp.wayback.presentation.app.provider.camera

import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.ObjCObjectVar
import kotlinx.cinterop.objcPtr
import kotlinx.cinterop.ptr
import kotlinx.cinterop.value
import platform.Foundation.NSDate
import platform.Foundation.NSDocumentDirectory
import platform.Foundation.NSError
import platform.Foundation.NSFileManager
import platform.Foundation.NSSearchPathForDirectoriesInDomains
import platform.Foundation.NSUserDomainMask
import platform.Foundation.timeIntervalSince1970
Expand All @@ -23,7 +15,6 @@ import platform.UIKit.UIImagePickerControllerOriginalImage
import platform.UIKit.UINavigationControllerDelegateProtocol
import platform.UIKit.UIViewController
import platform.darwin.NSObject
import kotlin.concurrent.AtomicReference

class IosCameraManager : NSObject(), UIImagePickerControllerDelegateProtocol, UINavigationControllerDelegateProtocol {

Expand Down
2 changes: 1 addition & 1 deletion translator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import json
import os
import requests
import json
import xml.etree.ElementTree as ElementTree

# MIT License
Expand Down

0 comments on commit e49c44c

Please sign in to comment.