Skip to content

Commit

Permalink
Merge branch 'main' into Migrate-Feedback-Module-from-java-to-kt
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii authored Dec 4, 2024
2 parents 034c1ba + 33548fa commit 6e7c1cc
Show file tree
Hide file tree
Showing 48 changed files with 2,619 additions and 3,359 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package fr.free.nrw.commons.LocationPicker

import android.app.Activity
import android.content.Intent
import fr.free.nrw.commons.CameraPosition
import fr.free.nrw.commons.Media


/**
* Helper class for starting the activity
*/
object LocationPicker {

/**
* Getting camera position from the intent using constants
*
* @param data intent
* @return CameraPosition
*/
@JvmStatic
fun getCameraPosition(data: Intent): CameraPosition? {
return data.getParcelableExtra(LocationPickerConstants.MAP_CAMERA_POSITION)
}

class IntentBuilder
/**
* Creates a new builder that creates an intent to launch the place picker activity.
*/() {

private val intent: Intent = Intent()

/**
* Gets and puts location in intent
* @param position CameraPosition
* @return LocationPicker.IntentBuilder
*/
fun defaultLocation(position: CameraPosition): IntentBuilder {
intent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION, position)
return this
}

/**
* Gets and puts activity name in intent
* @param activity activity key
* @return LocationPicker.IntentBuilder
*/
fun activityKey(activity: String): IntentBuilder {
intent.putExtra(LocationPickerConstants.ACTIVITY_KEY, activity)
return this
}

/**
* Gets and puts media in intent
* @param media Media
* @return LocationPicker.IntentBuilder
*/
fun media(media: Media): IntentBuilder {
intent.putExtra(LocationPickerConstants.MEDIA, media)
return this
}

/**
* Gets and sets the activity
* @param activity Activity
* @return Intent
*/
fun build(activity: Activity): Intent {
intent.setClass(activity, LocationPickerActivity::class.java)
return intent
}
}
}
Loading

0 comments on commit 6e7c1cc

Please sign in to comment.