Filters

Hide filters
Platform
Content Type
Difficulty

All Tutorials · 9 Results

Contained in: Swift SDK for Android strings
Multiple Domains

Lesson in Swift SDK for Android

Data Persistence & Testing

…minTitleLength = 3 private static let maxTitleLength = 50 private static let minDescriptionLength = 10 private static let maxDescriptionLength = 200 // 2 public static func validateTitle(_ title: String) -> Bool { let trimmed = title.trimmingCharacters(in: .whitespacesAndNewlines) return trimmed.count >= minTitleLength && trimmed.count <= maxTitleLength } // 3 public static func validateDescription(_ description: String) -> Bool…
Multiple Domains

Lesson in Swift SDK for Android

Swift-Java Interoperability: Building the Task Manager Core

…contents: // swift-tools-version: 6.2 import CompilerPluginSupport import PackageDescription import class Foundation.FileManager import class Foundation.ProcessInfo // 1: Helper to find Java installation func findJavaHome() -> String { if let home = ProcessInfo.processInfo.environment["JAVA_HOME"] { return home } // Fallback: read from ~/.java_home file let path = "\(FileManager.default.homeDirectoryForCurrentUser.path()).java_home" if let home = try? String(contentsOfFile: path…
Multiple Domains

Lesson in Swift SDK for Android

Data Persistence & Testing

…afterward. Implementing savePhotoViaPath() Open TaskRepository.kt and add this private helper method after the init block and before other methods: private fun savePhotoViaPath(taskId: String, photoUri: String, context: Context): String? { try { // 1 val sourceFile = when { photoUri.startsWith("file://") -> File(photoUri.removePrefix("file://")) photoUri.startsWith("/") -> File(photoUri) else -> { println("Invalid photo…
Multiple Domains

Lesson in Swift SDK for Android

Data Persistence & Testing

Model Review Your Task struct is already set up for JSON serialization. Open Task.swift and you’ll see: public struct Task: Codable { let id: String let title: String let description: String let priority: Priority var isCompleted: Bool let photoFilename: String? } Notice the Codable conformance after the struct name. Because…
Multiple Domains

Lesson in Swift SDK for Android

Platform Integration: Camera & Image Processing

…stored as files in the app’s directory. Open taskmanager-lib/Sources/TaskManagerKit/Task.swift and update the Task struct: public struct Task: Codable { public let id: String public let title: String public let description: String public let priority: Priority public var isCompleted: Bool // 1 public let photoUri: String? // 2 public init…
Multiple Domains

Lesson in Swift SDK for Android

Swift-Java Interoperability: Building the Task Manager Core

…because it’s shorter than 10 characters. Test Case 5: Description Too Long Create a task with: Title: “Valid task” Description: A 250-character string (exceeds 200) Priority: Medium Expected result: Error: “Description must be between 10 and 200 characters” Swift rejected the description for being too long. Test Case…
Multiple Domains

Lesson in Swift SDK for Android

Swift-Java Interoperability: Building the Task Manager Core

…compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } } dependencies { implementation("org.swift.swiftkit:swiftkit-core:1.0-SNAPSHOT") } // Helper function to get swiftly executable path fun getSwiftlyPath(): String { val fromConfig = project.findProperty("swiftly.path")?.toString() ?: System.getenv("SWIFTLY_PATH") if (fromConfig != null) { return fromConfig } // Try to find swiftly in common locations val homeDir = System.getProperty("user.home") val possiblePaths…
Multiple Domains

Lesson in Swift SDK for Android

Platform Integration: Camera & Image Processing

…same taskmanager-lib/Sources/TaskManagerKit/ImageProcessor.swift file, add the processImageFile function at the end of the struct (after the adjustBrightness function): public static func processImageFile( inputPath: String, outputPath: String, filterType: String, amount: Float = 0 ) -> Bool { // 1 let inputURL = URL(fileURLWithPath: inputPath) guard let fileData = try? Data(contentsOf: inputURL), fileData.count…
Multiple Domains

Lesson in Swift SDK for Android

Platform Integration: Camera & Image Processing

…file app/src/main/java/com/kodeco/android/swiftsdkforandroid/taskmanager/repository/ImageProcessingRepository.kt: package com.kodeco.android.swiftsdkforandroid.taskmanager.repository import android.content.Context import android.graphics.Bitmap import com.kodeco.android.taskmanagerkit.ImageProcessor import java.io.File import java.io.FileOutputStream // 1 object ImageProcessingRepository { // 2 enum class FilterType(val swiftName: String) { GRAYSCALE("grayscale"), BLUR("blur"), BRIGHTER("brighter"), DARKER("darker") } // 3 fun applyFilter( bitmap: Bitmap, filterType: FilterType, context: Context, amount: Float = 0f ): Bitmap? { try { // 4 val scaledBitmap = downscaleForProcessing…