Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MapObjectShareable.java « sharing « util « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de59c169239099d9146eb6df242a69cc9df97a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.mapswithme.util.sharing;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.widget.placepage.SponsoredHotel;
import com.mapswithme.util.statistics.Statistics;

class MapObjectShareable extends BaseShareable
{
  MapObjectShareable(Activity context, @NonNull MapObject mapObject, @Nullable SponsoredHotel sponsoredHotel)
  {
    super(context);

    final Activity activity = getActivity();
    final String ge0Url = Framework.nativeGetGe0Url(mapObject.getLat(), mapObject.getLon(), mapObject.getScale(), mapObject.getTitle());

    final String subject;
    String text;
    if (MapObject.isOfType(MapObject.MY_POSITION, mapObject))
    {
      subject = activity.getString(R.string.my_position_share_email_subject);
      text = activity.getString(R.string.my_position_share_email,
                                Framework.nativeGetNameAndAddress(mapObject.getLat(), mapObject.getLon()),
                                ge0Url,
                                Framework.getHttpGe0Url(mapObject.getLat(), mapObject.getLon(), mapObject.getScale(), mapObject.getTitle()));
    }
    else
    {
      subject = activity.getString(R.string.bookmark_share_email_subject);

      text = lineWithBreak(activity.getString(R.string.sharing_call_action_look)) +
                 lineWithBreak(mapObject.getTitle()) +
                 lineWithBreak(mapObject.getSubtitle()) +
                 lineWithBreak(mapObject.getAddress()) +
                 lineWithBreak(ge0Url);

      if (sponsoredHotel != null)
      {
        text += lineWithBreak(activity.getString(R.string.sharing_booking)) +
                    sponsoredHotel.getUrlBook();
      }
    }

    setSubject(subject);
    setText(text);
  }

  private String lineWithBreak(String title)
  {
    if (!TextUtils.isEmpty(title))
      return title + "\n";

    return "";
  }

  @Override
  public void share(SharingTarget target)
  {
    super.share(target);
    Statistics.INSTANCE.trackPlaceShared(target.name);
  }

  @Override
  public String getMimeType()
  {
    return null;
  }
}