forked from jbvincey/InstantAppSample
-
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.
- Loading branch information
1 parent
d42a46a
commit ed4ea57
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/jbvincey/instantappssample/helper/IntentHelper1.java
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,68 @@ | ||
package com.jbvincey.instantappssample.helper; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
|
||
import com.jbvincey.instantappssample.BuildConfig; | ||
import com.jbvincey.instantappssample.constants.Constants; | ||
import com.jbvincey.instantappssample.model.Coordinates; | ||
|
||
/** | ||
* Created by jean-baptistevincey on 24/06/2017. | ||
*/ | ||
|
||
public final class hfhfhdashldhgklhslgr { | ||
|
||
private static final String PLAYSTORE_BASE_URL = "market://details?id="; | ||
|
||
private static final String PACKAGE_MAPS = "com.google.android.apps.maps"; | ||
|
||
private static final String COORDINATES_PREFIX = "geo:0,0?q="; | ||
|
||
private static final String COORDINATES_SEPARATOR = ","; | ||
|
||
private static final String SHARE_INTENT_TYPE = "text/plain"; | ||
|
||
private static final String MAILTO_URI = "mailto:"; | ||
|
||
public static Intent getMapsLocationItent(Coordinates coordinates) { | ||
Uri mapsUri = Uri.parse(buildCoordinatesUri(coordinates)); | ||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapsUri); | ||
mapIntent.setPackage(PACKAGE_MAPS); | ||
return mapIntent; | ||
} | ||
|
||
private static String buildCoordinatesUri(Coordinates coordinates) { | ||
return COORDINATES_PREFIX | ||
+ coordinates.getLatitude() | ||
+ COORDINATES_SEPARATOR | ||
+ coordinates.getLongitude(); | ||
} | ||
|
||
public static Intent getContactIntent(String contact) { | ||
Intent intent = new Intent(Intent.ACTION_SENDTO); | ||
intent.setData(Uri.parse(MAILTO_URI)); | ||
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{contact}); | ||
return intent; | ||
} | ||
|
||
public static Intent getShareDetailUrlIntent(String tripId) { | ||
Intent shareIntent = new Intent(Intent.ACTION_SEND); | ||
shareIntent.setType(SHARE_INTENT_TYPE); | ||
shareIntent.putExtra(Intent.EXTRA_TEXT, buildDetailUrl(tripId)); | ||
return shareIntent; | ||
} | ||
|
||
private static String buildDetailUrl(String tripId) { | ||
return Constants.BASE_URL + "/" + tripId; | ||
} | ||
|
||
public static Intent getInstantTripPlayStoreIntent() { | ||
return new Intent(Intent.ACTION_VIEW, buildPlayStoreUrl()); | ||
} | ||
|
||
private static Uri buildPlayStoreUrl() { | ||
return Uri.parse(PLAYSTORE_BASE_URL + BuildConfig.APPLICATION_ID); | ||
} | ||
|
||
} |