Added mapillary install dialog
This commit is contained in:
parent
c2663b3caa
commit
a74c813694
6 changed files with 107 additions and 8 deletions
45
OsmAnd/res/layout/mapillary_install_dialog.xml
Normal file
45
OsmAnd/res/layout/mapillary_install_dialog.xml
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/ic_logo_mapillary"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/improve_coverage_mapillary"
|
||||
android:gravity="center"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="22dp"
|
||||
android:text="@string/improve_coverage_install_mapillary_desc"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,6 +9,9 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="shared_string_install">Install</string>
|
||||
<string name="improve_coverage_mapillary">Improve coverage with Mapillary</string>
|
||||
<string name="improve_coverage_install_mapillary_desc">You can take your own photos or series of photos and add it to this map location.\n\nTo do this you need install Mapillary app from Google Play.</string>
|
||||
<string name="online_photos">Online photos</string>
|
||||
<string name="shared_string_add_photos">Add photos</string>
|
||||
<string name="no_photos_descr">We don\'t have photos for this location</string>
|
||||
|
|
|
@ -23,7 +23,7 @@ public class NoImagesCard extends AbstractCard {
|
|||
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapillaryPlugin.openMapillary(getMyApplication());
|
||||
MapillaryPlugin.openMapillary(getMapActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MapillaryContributeCard extends ImageCard {
|
|||
view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapillaryPlugin.openMapillary(getMyApplication());
|
||||
MapillaryPlugin.openMapillary(getMapActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package net.osmand.plus.mapillary;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class MapillaryInstallDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String TAG = "MapillaryInstallDialogFragment";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(mapActivity.getString(R.string.shared_string_cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(mapActivity.getString(R.string.shared_string_install), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
MapillaryPlugin.installMapillary(mapActivity.getMyApplication());
|
||||
}
|
||||
});
|
||||
|
||||
builder.setView(mapActivity.getLayoutInflater().inflate(R.layout.mapillary_install_dialog, null));
|
||||
return builder.create();
|
||||
}
|
||||
}
|
|
@ -174,7 +174,7 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
mapillaryControl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openMapillary(app);
|
||||
openMapillary(map);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -195,8 +195,9 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean openMapillary(OsmandApplication app) {
|
||||
public static boolean openMapillary(FragmentActivity activity) {
|
||||
boolean success = false;
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
|
||||
Intent launchIntent = app.getPackageManager().getLaunchIntentForPackage(MAPILLARY_PACKAGE_ID);
|
||||
if (launchIntent != null) {
|
||||
|
@ -204,10 +205,15 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
success = true;
|
||||
}
|
||||
} else {
|
||||
success = execInstall(app, "market://search?q=pname:" + MAPILLARY_PACKAGE_ID);
|
||||
if (!success) {
|
||||
success = execInstall(app, "https://play.google.com/store/apps/details?id=" + MAPILLARY_PACKAGE_ID);
|
||||
}
|
||||
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public static boolean installMapillary(OsmandApplication app) {
|
||||
boolean success = execInstall(app, "market://search?q=pname:" + MAPILLARY_PACKAGE_ID);
|
||||
if (!success) {
|
||||
success = execInstall(app, "https://play.google.com/store/apps/details?id=" + MAPILLARY_PACKAGE_ID);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue