conflict resolved
This commit is contained in:
parent
4035885842
commit
5a91901eee
4 changed files with 183 additions and 180 deletions
|
@ -1,114 +1,105 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/color_white"
|
|
||||||
android:clickable="true"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_marginTop="@dimen/dialog_content_margin">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/back_button"
|
|
||||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:contentDescription="@string/shared_string_back"
|
|
||||||
app:srcCompat="@drawable/ic_arrow_back"
|
|
||||||
app:tint="@color/icon_color_default_light" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/opr_img"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:contentDescription="@string/shared_string_back"
|
|
||||||
app:srcCompat="@drawable/ic_img_logo_openplacereview" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginTop="@dimen/content_padding"
|
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
|
||||||
android:layout_marginBottom="@dimen/dashPadding"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:lineSpacingExtra="5sp"
|
|
||||||
android:text="@string/register_on_openplacereviews"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textColor="@color/color_black"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/start_opr_description"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginTop="@dimen/dashPadding"
|
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
|
||||||
android:lineSpacingExtra="5sp"
|
|
||||||
android:text="@string/register_on_openplacereviews_desc"
|
|
||||||
android:textColor="@color/color_black"
|
|
||||||
android:textColorLink="@color/icon_color_active_light" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbar_height"
|
||||||
|
android:layout_marginTop="@dimen/dialog_content_margin">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/back_button"
|
||||||
|
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:contentDescription="@string/shared_string_back"
|
||||||
|
app:srcCompat="@drawable/ic_arrow_back"
|
||||||
|
app:tint="@color/icon_color_default_light" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/toolbar"
|
||||||
|
android:layout_above="@id/buttons">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/opr_img"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="@string/shared_string_back"
|
||||||
|
app:srcCompat="@drawable/ic_img_logo_openplacereview" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/dashPadding"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||||
|
android:text="@string/register_on_openplacereviews"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/start_opr_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginTop="@dimen/dashPadding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
|
||||||
|
app:typeface="@string/font_roboto_regular"
|
||||||
|
android:text="@string/register_on_openplacereviews_desc"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
android:textColorLink="@color/icon_color_active_light" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/buttons"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:layout_marginBottom="@dimen/content_padding_small"
|
android:layout_marginBottom="@dimen/content_padding_small"
|
||||||
android:gravity="bottom"
|
android:layout_alignParentBottom="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/register_opr_create_account"
|
android:id="@+id/register_opr_create_account"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/dialog_button_height"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginBottom="@dimen/content_padding_small" />
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
|
||||||
android:layout_marginBottom="@dimen/dashPadding"
|
|
||||||
android:background="@color/icon_color_active_light"
|
|
||||||
android:text="@string/register_opr_create_new_account"
|
|
||||||
android:textColor="@color/color_white" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/register_opr_have_account"
|
android:id="@+id/register_opr_have_account"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/dialog_button_height" />
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginTop="@dimen/dashPadding"
|
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
|
||||||
android:background="@color/activity_background_color_light"
|
|
||||||
android:text="@string/register_opr_have_account"
|
|
||||||
android:textColor="@color/icon_color_active_light" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
</RelativeLayout>
|
|
@ -11,6 +11,19 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="add_photos_descr">OsmAnd shows photos from several sources:\nOpenPlaceReviews - POI photos;\nMapillary - street-level imagery;\nWeb / Wikimedia - POI photos specified in OpenStreetMap data.</string>
|
||||||
|
<string name="use_dev_url">Use dev.openstreetmap.org</string>
|
||||||
|
<string name="use_dev_url_descr">Switch to use "dev.openstreetmap.org" instead of "openstreetmap.org" to testing uploading OSM Note / POI / GPX.</string>
|
||||||
|
<string name="add_to_opr">Add to OpenPlaceReviews</string>
|
||||||
|
<string name="add_to_mapillary">Add to Mapillary</string>
|
||||||
|
<string name="select_items_for_import">Select items that will be imported.</string>
|
||||||
|
<string name="select_groups_for_import">Select groups that will be imported.</string>
|
||||||
|
<string name="export_not_enough_space">There is not enough space</string>
|
||||||
|
<string name="export_not_enough_space_descr">Your device only has %1$s free. Please free up some space or unselect some items to export.</string>
|
||||||
|
<string name="file_size_needed_for_import">Needed for import</string>
|
||||||
|
<string name="select_data_to_export">Select the data to be exported to the file.</string>
|
||||||
|
<string name="approximate_file_size">Approximate file size</string>
|
||||||
|
<string name="shared_string_resources">Resources</string>
|
||||||
<string name="select_picture">Select picture</string>
|
<string name="select_picture">Select picture</string>
|
||||||
<string name="cannot_upload_image">Cannot upload image, please, try again later</string>
|
<string name="cannot_upload_image">Cannot upload image, please, try again later</string>
|
||||||
<string name="app_mode_motorboat">Motorboat</string>
|
<string name="app_mode_motorboat">Motorboat</string>
|
||||||
|
@ -18,10 +31,10 @@
|
||||||
<string name="shared_string_search_history">Search history</string>
|
<string name="shared_string_search_history">Search history</string>
|
||||||
<string name="register_opr_have_account">I already have an account</string>
|
<string name="register_opr_have_account">I already have an account</string>
|
||||||
<string name="register_opr_create_new_account">Create new account</string>
|
<string name="register_opr_create_new_account">Create new account</string>
|
||||||
<string name="register_on_openplacereviews_desc">Log in on the open data project website OpenPlaceReviews.org to upload even more photos.</string>
|
<string name="register_on_openplacereviews_desc">Photos are provided by open data project OpenPlaceReviews.org. In order to upload your photos you need to sign up on website.</string>
|
||||||
<string name="register_on_openplacereviews">Register on\nOpenPlaceReviews.org</string>
|
<string name="register_on_openplacereviews">Register on\nOpenPlaceReviews.org</string>
|
||||||
<string name="shared_string_add_photo">Add photo</string>
|
<string name="shared_string_add_photo">Add photo</string>
|
||||||
<string name="osm_login_descr">Log in using the safe OAuth method or use your username and password.</string>
|
<string name="osm_login_descr">You can log in using the safe OAuth method or use your login and password.</string>
|
||||||
<string name="osm_edit_comment_note">Comment OSM Note</string>
|
<string name="osm_edit_comment_note">Comment OSM Note</string>
|
||||||
<string name="osm_edit_close_note">Close OSM Note</string>
|
<string name="osm_edit_close_note">Close OSM Note</string>
|
||||||
<string name="gpx_upload_trackable_visibility_descr">\"Trackable\" means the trace does not show up in any public listings, but processed trackpoints with timestamps from it (that can\'t be associated with you directly) do through downloads from the public GPS API.</string>
|
<string name="gpx_upload_trackable_visibility_descr">\"Trackable\" means the trace does not show up in any public listings, but processed trackpoints with timestamps from it (that can\'t be associated with you directly) do through downloads from the public GPS API.</string>
|
||||||
|
@ -36,15 +49,15 @@
|
||||||
<string name="subscription_expired_title">OsmAnd Live subscription has been expired</string>
|
<string name="subscription_expired_title">OsmAnd Live subscription has been expired</string>
|
||||||
<string name="subscription_payment_issue_title">There is a problem with your subscription. Click the button to go to the Google Play subscription settings to fix your payment method.</string>
|
<string name="subscription_payment_issue_title">There is a problem with your subscription. Click the button to go to the Google Play subscription settings to fix your payment method.</string>
|
||||||
<string name="manage_subscription">Manage subscription</string>
|
<string name="manage_subscription">Manage subscription</string>
|
||||||
<string name="user_login">Username</string>
|
<string name="user_login">Login</string>
|
||||||
<string name="user_password">Password</string>
|
<string name="user_password">Password</string>
|
||||||
<string name="login_account">Account</string>
|
<string name="login_account">Account</string>
|
||||||
<string name="use_login_password">Log in with username and password</string>
|
<string name="use_login_password">Use login and password</string>
|
||||||
<string name="open_street_map_login_mode">Log in to upload new or modified changes,\n\neither with OAuth or using your username and password.</string>
|
<string name="open_street_map_login_mode">You need to login to upload new or modified changes. \n\nYou can log in using the safe OAuth method or use your login and password.</string>
|
||||||
<string name="osm_edits_view_descr">You can view all your not yet uploaded edits or OSM bugs in %1$s. Uploaded points don’t show in OsmAnd.</string>
|
<string name="osm_edits_view_descr">You can view all your not yet uploaded edits or OSM bugs in %1$s. Uploaded points don’t show in OsmAnd.</string>
|
||||||
<string name="sign_in_with_open_street_map">Log in with OpenStreetMap</string>
|
<string name="sign_in_with_open_street_map">Sign in with OpenStreetMap</string>
|
||||||
<string name="login_open_street_map_org">Login for OpenStreetMap.org</string>
|
<string name="login_open_street_map_org">Login to OpenStreetMap.org</string>
|
||||||
<string name="login_open_street_map">Login for OpenStreetMap</string>
|
<string name="login_open_street_map">Login to OpenStreetMap</string>
|
||||||
<string name="plugin_global_prefs_info">These plugin setting are global, and apply to all profiles</string>
|
<string name="plugin_global_prefs_info">These plugin setting are global, and apply to all profiles</string>
|
||||||
<string name="message_you_need_add_two_points_to_show_graphs">You need to add at least two points</string>
|
<string name="message_you_need_add_two_points_to_show_graphs">You need to add at least two points</string>
|
||||||
<string name="icon_group_travel">Travel</string>
|
<string name="icon_group_travel">Travel</string>
|
||||||
|
|
|
@ -51,6 +51,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
|
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
|
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
||||||
|
import net.osmand.plus.openplacereviews.AddPhotosBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.openplacereviews.OPRWebviewActivity;
|
import net.osmand.plus.openplacereviews.OPRWebviewActivity;
|
||||||
import net.osmand.plus.openplacereviews.OprStartFragment;
|
import net.osmand.plus.openplacereviews.OprStartFragment;
|
||||||
import net.osmand.plus.osmedit.opr.OpenDBAPI;
|
import net.osmand.plus.osmedit.opr.OpenDBAPI;
|
||||||
|
@ -78,6 +79,8 @@ import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCa
|
||||||
|
|
||||||
public class MenuBuilder {
|
public class MenuBuilder {
|
||||||
|
|
||||||
|
private static final int PICK_IMAGE = 1231;
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class);
|
||||||
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
|
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
|
||||||
public static final int TITLE_LIMIT = 60;
|
public static final int TITLE_LIMIT = 60;
|
||||||
protected static final String[] arrowChars = new String[] {"=>", " - "};
|
protected static final String[] arrowChars = new String[] {"=>", " - "};
|
||||||
|
@ -107,10 +110,7 @@ public class MenuBuilder {
|
||||||
private String preferredMapAppLang;
|
private String preferredMapAppLang;
|
||||||
private boolean transliterateNames;
|
private boolean transliterateNames;
|
||||||
|
|
||||||
private static final int PICK_IMAGE = 1231;
|
private final OpenDBAPI openDBAPI = new OpenDBAPI();
|
||||||
private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class);
|
|
||||||
private View view;
|
|
||||||
private OpenDBAPI openDBAPI = new OpenDBAPI();
|
|
||||||
private String[] placeId = new String[0];
|
private String[] placeId = new String[0];
|
||||||
private GetImageCardsListener imageCardListener = new GetImageCardsListener() {
|
private GetImageCardsListener imageCardListener = new GetImageCardsListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,8 +126,7 @@ public class MenuBuilder {
|
||||||
@Override
|
@Override
|
||||||
public void onFinish(List<ImageCard> cardList) {
|
public void onFinish(List<ImageCard> cardList) {
|
||||||
if (!isHidden()) {
|
if (!isHidden()) {
|
||||||
List<AbstractCard> cards = new ArrayList<>();
|
List<AbstractCard> cards = new ArrayList<AbstractCard>(cardList);
|
||||||
cards.addAll(cardList);
|
|
||||||
if (cardList.size() == 0) {
|
if (cardList.size() == 0) {
|
||||||
cards.add(new NoImagesCard(mapActivity));
|
cards.add(new NoImagesCard(mapActivity));
|
||||||
}
|
}
|
||||||
|
@ -386,19 +385,7 @@ public class MenuBuilder {
|
||||||
b.setOnClickListener(new OnClickListener() {
|
b.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View view) {
|
public void onClick(final View view) {
|
||||||
mapActivity.registerActivityResultListener(new ActivityResultListener(PICK_IMAGE,
|
registerResultListener(view);
|
||||||
new ActivityResultListener.OnActivityResultListener() {
|
|
||||||
@Override
|
|
||||||
public void onResult(int resultCode, Intent resultData) {
|
|
||||||
InputStream inputStream = null;
|
|
||||||
try {
|
|
||||||
inputStream = mapActivity.getContentResolver().openInputStream(resultData.getData());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error(e);
|
|
||||||
}
|
|
||||||
handleSelectedImage(view, inputStream);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
final String privateKey = OPRWebviewActivity.getPrivateKeyFromCookie();
|
final String privateKey = OPRWebviewActivity.getPrivateKeyFromCookie();
|
||||||
final String name = OPRWebviewActivity.getUsernameFromCookie();
|
final String name = OPRWebviewActivity.getUsernameFromCookie();
|
||||||
if (privateKey == null || privateKey.isEmpty()) {
|
if (privateKey == null || privateKey.isEmpty()) {
|
||||||
|
@ -408,7 +395,7 @@ public class MenuBuilder {
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (openDBAPI.checkPrivateKeyValid(name,privateKey)){
|
if (openDBAPI.checkPrivateKeyValid(name, privateKey)) {
|
||||||
app.runInUIThread(new Runnable() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -419,64 +406,12 @@ public class MenuBuilder {
|
||||||
mapActivity.getString(R.string.select_picture)), PICK_IMAGE);
|
mapActivity.getString(R.string.select_picture)), PICK_IMAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
OprStartFragment.showInstance(mapActivity.getSupportFragmentManager());
|
OprStartFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSelectedImage(final View view, final InputStream image) {
|
|
||||||
Thread t = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
uploadImageToPlace(view, image);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
t.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uploadImageToPlace(View view, InputStream image) {
|
|
||||||
//compress image
|
|
||||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(image);
|
|
||||||
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
||||||
bmp.compress(Bitmap.CompressFormat.PNG, 70, os);
|
|
||||||
byte[] buff = os.toByteArray();
|
|
||||||
InputStream serverData = new ByteArrayInputStream(buff);
|
|
||||||
String url = BuildConfig.OPR_BASE_URL + "api/ipfs/image";
|
|
||||||
String response = NetworkUtils.sendPostDataRequest(url, serverData);
|
|
||||||
if (response != null) {
|
|
||||||
int res = 0;
|
|
||||||
try {
|
|
||||||
res = openDBAPI.uploadImage(
|
|
||||||
placeId,
|
|
||||||
OPRWebviewActivity.getPrivateKeyFromCookie()
|
|
||||||
, OPRWebviewActivity.getUsernameFromCookie(),
|
|
||||||
response);
|
|
||||||
} catch (FailedVerificationException e) {
|
|
||||||
LOG.error(e);
|
|
||||||
app.showToastMessage(view.getResources().getString(R.string.cannot_upload_image));
|
|
||||||
}
|
|
||||||
if (res != 200) {
|
|
||||||
//image was uploaded but not added to blockchain
|
|
||||||
app.showToastMessage(view.getResources().getString(R.string.cannot_upload_image));
|
|
||||||
} else {
|
|
||||||
String str = MessageFormat.format(view.getResources()
|
|
||||||
.getString(R.string.successfully_uploaded_pattern), 1, 1);
|
|
||||||
app.showToastMessage(str);
|
|
||||||
//refresh the image
|
|
||||||
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), imageCardListener));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
app.showToastMessage(view.getResources().getString(R.string.cannot_upload_image));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
//TODO feature under development
|
//TODO feature under development
|
||||||
//b.setVisibility(View.GONE);
|
//b.setVisibility(View.GONE);
|
||||||
|
@ -493,6 +428,73 @@ public class MenuBuilder {
|
||||||
false, null, false);
|
false, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerResultListener(final View view) {
|
||||||
|
mapActivity.registerActivityResultListener(new ActivityResultListener(PICK_IMAGE, new ActivityResultListener.
|
||||||
|
OnActivityResultListener() {
|
||||||
|
@Override
|
||||||
|
public void onResult(int resultCode, Intent resultData) {
|
||||||
|
handleSelectedImage(view, resultData.getData());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleSelectedImage(final View view, final Uri uri) {
|
||||||
|
Thread t = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = app.getContentResolver().openInputStream(uri);
|
||||||
|
if (inputStream != null) {
|
||||||
|
uploadImageToPlace(view, inputStream);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e);
|
||||||
|
} finally {
|
||||||
|
Algorithms.closeStream(inputStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uploadImageToPlace(View view, InputStream image) {
|
||||||
|
InputStream serverData = new ByteArrayInputStream(compressImage(image));
|
||||||
|
String url = BuildConfig.OPR_BASE_URL + "api/ipfs/image";
|
||||||
|
String response = NetworkUtils.sendPostDataRequest(url, serverData);
|
||||||
|
if (response != null) {
|
||||||
|
int res = 0;
|
||||||
|
try {
|
||||||
|
res = openDBAPI.uploadImage(
|
||||||
|
placeId,
|
||||||
|
OPRWebviewActivity.getPrivateKeyFromCookie(),
|
||||||
|
OPRWebviewActivity.getUsernameFromCookie(),
|
||||||
|
response);
|
||||||
|
} catch (FailedVerificationException e) {
|
||||||
|
LOG.error(e);
|
||||||
|
app.showToastMessage(R.string.cannot_upload_image);
|
||||||
|
}
|
||||||
|
if (res != 200) {
|
||||||
|
//image was uploaded but not added to blockchain
|
||||||
|
app.showToastMessage(R.string.cannot_upload_image);
|
||||||
|
} else {
|
||||||
|
app.showToastMessage(R.string.successfully_uploaded_pattern, 1, 1);
|
||||||
|
//refresh the image
|
||||||
|
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), imageCardListener));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.showToastMessage(R.string.cannot_upload_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] compressImage(InputStream image) {
|
||||||
|
BufferedInputStream bufferedInputStream = new BufferedInputStream(image);
|
||||||
|
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
bmp.compress(Bitmap.CompressFormat.PNG, 70, os);
|
||||||
|
return os.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
private void startLoadingImages() {
|
private void startLoadingImages() {
|
||||||
if (onlinePhotoCardsRow == null) {
|
if (onlinePhotoCardsRow == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -500,7 +502,7 @@ public class MenuBuilder {
|
||||||
startLoadingImagesTask();
|
startLoadingImagesTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLoadingImagesTask(){
|
private void startLoadingImagesTask() {
|
||||||
onlinePhotoCards = new ArrayList<>();
|
onlinePhotoCards = new ArrayList<>();
|
||||||
onlinePhotoCardsRow.setProgressCard();
|
onlinePhotoCardsRow.setProgressCard();
|
||||||
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), imageCardListener));
|
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), imageCardListener));
|
||||||
|
|
|
@ -12,17 +12,14 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class OprStartFragment extends BaseOsmAndFragment {
|
public class OprStartFragment extends BaseOsmAndFragment {
|
||||||
|
|
Loading…
Reference in a new issue