forked from commons-app/apps-android-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Migrate-Feedback-Module-from-
java
-to-kt
- Loading branch information
Showing
48 changed files
with
2,619 additions
and
3,359 deletions.
There are no files selected for viewing
77 changes: 0 additions & 77 deletions
77
app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPicker.java
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPicker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
Oops, something went wrong.