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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
package com.mapswithme.maps.editor;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import android.support.annotation.WorkerThread;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.background.AppBackgroundTracker;
import com.mapswithme.maps.background.WorkerService;
import com.mapswithme.maps.editor.data.FeatureCategory;
import com.mapswithme.maps.editor.data.Language;
import com.mapswithme.maps.editor.data.LocalizedName;
import com.mapswithme.maps.editor.data.LocalizedStreet;
import com.mapswithme.maps.editor.data.NamesDataSource;
/**
* Edits active(selected on the map) feature, which is represented as osm::EditableFeature in the core.
*/
public final class Editor
{
// Should correspond to core osm::FeatureStatus.
@Retention(RetentionPolicy.SOURCE)
@IntDef({UNTOUCHED, DELETED, OBSOLETE, MODIFIED, CREATED})
public @interface FeatureStatus {}
public static final int UNTOUCHED = 0;
public static final int DELETED = 1;
public static final int OBSOLETE = 2;
public static final int MODIFIED = 3;
public static final int CREATED = 4;
private static final AppBackgroundTracker.OnTransitionListener sOsmUploader = new AppBackgroundTracker.OnTransitionListener()
{
@Override
public void onTransit(boolean foreground)
{
if (!foreground)
WorkerService.startActionUploadOsmChanges();
}
};
private Editor() {}
static
{
nativeInit();
}
private static native void nativeInit();
public static void init()
{
MwmApplication.backgroundTracker().addListener(sOsmUploader);
}
@WorkerThread
public static void uploadChanges()
{
if (nativeHasSomethingToUpload() && OsmOAuth.isAuthorized())
nativeUploadChanges(OsmOAuth.getAuthToken(), OsmOAuth.getAuthSecret(), BuildConfig.VERSION_NAME,
BuildConfig.APPLICATION_ID);
}
public static native boolean nativeShouldShowEditPlace();
public static native boolean nativeShouldShowAddPlace();
public static native boolean nativeShouldShowAddBusiness();
@NonNull
public static native int[] nativeGetEditableFields();
public static native String nativeGetCategory();
public static native String nativeGetOpeningHours();
public static native void nativeSetOpeningHours(String openingHours);
public static native String nativeGetPhone();
public static native void nativeSetPhone(String phone);
public static native String nativeGetWebsite();
public static native void nativeSetWebsite(String website);
public static native String nativeGetEmail();
public static native void nativeSetEmail(String email);
public static native int nativeGetStars();
public static native void nativeSetStars(String stars);
public static native String nativeGetOperator();
public static native void nativeSetOperator(String operator);
public static native String nativeGetWikipedia();
public static native void nativeSetWikipedia(String wikipedia);
public static native String nativeGetFlats();
public static native void nativeSetFlats(String flats);
public static native String nativeGetBuildingLevels();
public static native void nativeSetBuildingLevels(String levels);
public static native String nativeGetZipCode();
public static native void nativeSetZipCode(String zipCode);
public static native boolean nativeHasWifi();
public static native boolean nativeSetHasWifi(boolean hasWifi);
public static native boolean nativeIsAddressEditable();
public static native boolean nativeIsNameEditable();
public static native boolean nativeIsBuilding();
public static native NamesDataSource nativeGetNamesDataSource();
public static native void nativeSetNames(@NonNull LocalizedName[] names);
public static native LocalizedName nativeMakeLocalizedName(String langCode, String name);
public static native Language[] nativeGetSupportedLanguages();
public static native LocalizedStreet nativeGetStreet();
public static native void nativeSetStreet(LocalizedStreet street);
@NonNull
public static native LocalizedStreet[] nativeGetNearbyStreets();
public static native String nativeGetHouseNumber();
public static native void nativeSetHouseNumber(String houseNumber);
public static native boolean nativeIsHouseValid(String houseNumber);
public static native boolean nativeIsLevelValid(String level);
public static native boolean nativeIsFlatValid(String flat);
public static native boolean nativeIsZipcodeValid(String zipCode);
public static native boolean nativeIsPhoneValid(String phone);
public static native boolean nativeIsWebsiteValid(String site);
public static native boolean nativeIsEmailValid(String email);
public static native boolean nativeHasSomethingToUpload();
@WorkerThread
private static native void nativeUploadChanges(String token, String secret, String appVersion, String appId);
/**
* @return array [total edits count, uploaded edits count, last upload timestamp in seconds]
*/
@Size(3)
public static native long[] nativeGetStats();
public static native void nativeClearLocalEdits();
/**
* That method should be called, when user opens editor from place page, so that information in editor
* could refresh.
*/
public static native void nativeStartEdit();
/**
* @return true if feature was saved. False if some error occurred (eg. no space)
*/
public static native boolean nativeSaveEditedFeature();
@NonNull
public static native FeatureCategory[] nativeGetAllFeatureCategories(String lang);
@NonNull
public static native FeatureCategory[] nativeSearchFeatureCategories(String query, String lang);
/**
* Creates new object on the map. Places it in the center of current viewport.
* {@link Framework#nativeIsDownloadedMapAtScreenCenter()} should be called before
* to check whether new feature can be created on the map.
*/
public static void createMapObject(FeatureCategory category)
{
nativeCreateMapObject(category.category);
}
public static native void nativeCreateMapObject(int categoryId);
public static native void nativeCreateNote(String text);
public static native void nativePlaceDoesNotExist(String comment);
public static native void nativeRollbackMapObject();
/**
* @return all cuisines keys.
*/
public static native String[] nativeGetCuisines();
/**
* @return selected cuisines keys.
*/
public static native String[] nativeGetSelectedCuisines();
public static native String[] nativeTranslateCuisines(String[] keys);
public static native void nativeSetSelectedCuisines(String [] keys);
/**
* @return properly formatted and appended cuisines string to display in UI.
*/
public static native String nativeGetFormattedCuisine();
public static native String nativeGetMwmName();
public static native long nativeGetMwmVersion();
@FeatureStatus
public static native int nativeGetMapObjectStatus();
public static native boolean nativeIsMapObjectUploaded();
}
|