[android] Added corrected string res for dialogs, added server id for bookmark category

This commit is contained in:
Dmitry Donskoy 2019-01-31 14:39:09 +03:00 committed by Roman Kuznetsov
parent 9468314a46
commit 3997e2d09a
7 changed files with 50 additions and 34 deletions

View file

@ -111,7 +111,7 @@ void PrepareClassRefs(JNIEnv * env)
g_bookmarkCategoryConstructor =
jni::GetConstructorID(env, g_bookmarkCategoryClass,
"(JLjava/lang/String;Ljava/lang/String;"
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZZI)V");
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZZILjava/lang/String;)V");
g_catalogTagClass =
jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/CatalogTag");
@ -926,12 +926,14 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarkCategor
auto const annotation = GetPreferredBookmarkStr(data.m_annotation);
auto const description = GetPreferredBookmarkStr(data.m_description);
auto const accessRules = data.m_accessRules;
auto const serverId = manager.GetCategoryServerId(item);
jni::TScopedLocalRef preferBookmarkStrRef(env, jni::ToJavaString(env, preferBookmarkStr));
jni::TScopedLocalRef authorIdRef(env, jni::ToJavaString(env, data.m_authorId));
jni::TScopedLocalRef authorNameRef(env, jni::ToJavaString(env, data.m_authorName));
jni::TScopedLocalRef annotationRef(env, jni::ToJavaString(env, annotation));
jni::TScopedLocalRef descriptionRef(env, jni::ToJavaString(env, description));
jni::TScopedLocalRef serverIdRef(env, jni::ToJavaString(env, serverId));
return env->NewObject(g_bookmarkCategoryClass,
g_bookmarkCategoryConstructor,
@ -946,7 +948,8 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetBookmarkCategor
static_cast<jboolean>(isFromCatalog),
static_cast<jboolean>(isMyCategory),
static_cast<jboolean>(isVisible),
static_cast<jint>(accessRules));
static_cast<jint>(accessRules),
serverIdRef.get());
};
return ToJavaArray(env, g_bookmarkCategoryClass, categories, bookmarkConverter);
}

View file

@ -257,7 +257,6 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--FIXME text id-->
<TextView
android:minHeight="@dimen/height_block_base"
android:gravity="center_vertical"
@ -279,14 +278,14 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/upload_and_publish_desc"/>
android:text="@string/web_editor_description"/>
<Button
android:id="@+id/edit_on_web_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
style="@style/MwmWidget.Button.Primary"
android:text="@string/edit_on_web"
android:text="@string/edit_on_web_confirm"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
<include layout="@layout/list_divider"/>

View file

@ -33,13 +33,15 @@ public class BookmarkCategory implements Parcelable
private final int mAccessRulesIndex;
private final boolean mIsMyCategory;
private final boolean mIsVisible;
@NonNull
private final String mServerId;
public BookmarkCategory(long id, @NonNull String name, @NonNull String authorId,
@NonNull String authorName, @NonNull String annotation,
@NonNull String description, int tracksCount, int bookmarksCount,
boolean fromCatalog, boolean isMyCategory, boolean isVisible,
int accessRulesIndex)
int accessRulesIndex, @NonNull String serverId)
{
mId = id;
mName = name;
@ -48,6 +50,7 @@ public class BookmarkCategory implements Parcelable
mTracksCount = tracksCount;
mBookmarksCount = bookmarksCount;
mIsMyCategory = isMyCategory;
mServerId = serverId;
mTypeIndex = fromCatalog && !isMyCategory ? Type.DOWNLOADED.ordinal() : Type.PRIVATE.ordinal();
mIsVisible = isVisible;
mAuthor = TextUtils.isEmpty(authorId) || TextUtils.isEmpty(authorName)
@ -142,6 +145,12 @@ public class BookmarkCategory implements Parcelable
return mDescription;
}
@NonNull
public String getServerId()
{
return mServerId;
}
@NonNull
public CountAndPlurals getPluralsCountTemplate()
{
@ -300,6 +309,7 @@ public class BookmarkCategory implements Parcelable
sb.append(", mIsMyCategory=").append(mIsMyCategory);
sb.append(", mIsVisible=").append(mIsVisible);
sb.append(", mAccessRules=").append(getAccessRules());
sb.append(", mServerId=").append(mServerId);
sb.append('}');
return sb.toString();
}
@ -362,6 +372,7 @@ public class BookmarkCategory implements Parcelable
dest.writeByte(this.mIsMyCategory ? (byte) 1 : (byte) 0);
dest.writeByte(this.mIsVisible ? (byte) 1 : (byte) 0);
dest.writeInt(this.mAccessRulesIndex);
dest.writeString(this.mServerId);
}
protected BookmarkCategory(Parcel in)
@ -377,6 +388,7 @@ public class BookmarkCategory implements Parcelable
this.mIsMyCategory = in.readByte() != 0;
this.mIsVisible = in.readByte() != 0;
this.mAccessRulesIndex = in.readInt();
this.mServerId = in.readString();
}
public static final Creator<BookmarkCategory> CREATOR = new Creator<BookmarkCategory>()
@ -402,7 +414,7 @@ public class BookmarkCategory implements Parcelable
ACCESS_RULES_P2P(R.string.access_rules_p_to_p, R.drawable.ic_public_inline),
ACCESS_RULES_PAID(R.string.access_rules_paid, R.drawable.ic_public_inline),
//TODO(@alexzatsepin): Set correct resources.
ACCESS_RULES_AUTHOR_ONLY(R.string.access_rules_p_to_p, R.drawable.ic_public_inline);
ACCESS_RULES_AUTHOR_ONLY(R.string.access_rules_p_to_p, R.drawable.ic_lock);
private final int mResId;
private final int mDrawableResId;

View file

@ -78,7 +78,7 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo
private void shareLink()
{
String emailBody = getString(R.string.edit_your_guide_email_body) + BODY_STRINGS_SEPARATOR +
BookmarkManager.INSTANCE.getCatalogDeeplink(mCategory.getId());
BookmarkManager.INSTANCE.getWebEditorUrl(mCategory.getServerId());
ShareCompat.IntentBuilder.from(getActivity())
.setType(TargetUtils.TYPE_TEXT_PLAIN)
@ -93,14 +93,14 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo
public void onUploadFinished(@NonNull BookmarkManager.UploadResult uploadResult, @NonNull
String description, long originCategoryId, long resultCategoryId)
{
hideProgress();
if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_SUCCESS)
onUploadSucceeded();
else if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_AUTH_ERROR)
authorize();
else
onUploadFailed();
hideProgress();
}
private void onUploadFailed()
@ -120,6 +120,7 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo
private void onUploadSucceeded()
{
mCategory = BookmarkManager.INSTANCE.getAllCategoriesSnapshot().refresh(mCategory);
shareLink();
}
@Override

View file

@ -45,7 +45,6 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
{
public static final int REQ_CODE_CUSTOM_PROPERTIES = 101;
private static final int REQ_CODE_NO_NETWORK_CONNECTION_DIALOG = 103;
private static final int REQ_CODE_ERROR_BROKEN_FILE_DIALOG = 104;
private static final int REQ_CODE_ERROR_COMMON = 106;
private static final int REQ_CODE_ERROR_NOT_ENOUGH_BOOKMARKS = 107;
private static final int REQ_CODE_UPLOAD_CONFIRMATION_DIALOG = 108;
@ -54,7 +53,6 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
private static final String BUNDLE_CURRENT_MODE = "current_mode";
private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog";
private static final String NOT_ENOUGH_BOOKMARKS_DIALOG_TAG = "not_enough_bookmarks_dialog";
private static final String ERROR_BROKEN_FILE_DIALOG_TAG = "error_broken_file_dialog";
private static final String ERROR_COMMON_DIALOG_TAG = "error_common_dialog";
private static final String UPLOAD_CONFIRMATION_DIALOG_TAG = "upload_confirmation_dialog";
private static final String ERROR_HTML_FORMATTING_DIALOG_TAG = "error_html_formatting_dialog";
@ -238,7 +236,7 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
private void shareCategory()
{
String deepLink = BookmarkManager.INSTANCE.getCatalogDeeplink(mCategory.getId());
String deepLink = BookmarkManager.INSTANCE.getWebEditorUrl(mCategory.getServerId());
Intent intent = new Intent(Intent.ACTION_SEND)
.setType(TargetUtils.TYPE_TEXT_PLAIN)
.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_bookmarks_email_body_link, deepLink));
@ -465,7 +463,7 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
uploadResult.ordinal());
if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_MALFORMED_DATA_ERROR)
{
showErrorBrokenFileDialog();
showHtmlFormattingError();
return;
}
@ -507,13 +505,6 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
" Current value = " + mCategory.getAccessRules());
}
private void showErrorBrokenFileDialog()
{
showUploadErrorDialog(R.string.unable_upload_error_subtitle_broken,
REQ_CODE_ERROR_BROKEN_FILE_DIALOG,
ERROR_BROKEN_FILE_DIALOG_TAG);
}
private void showUploadErrorDialog(@StringRes int subtitle, int reqCode, @NonNull String tag)
{
showErrorDialog(R.string.unable_upload_errorr_title, subtitle, reqCode, tag);
@ -521,8 +512,8 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
private void showNotEnoughBookmarksDialog()
{
/* FIXME */
showErrorDialog(R.string.not_enough_memory, R.string.not_enough_memory,
showErrorDialog(R.string.error_public_not_enought_title,
R.string.error_public_not_enought_subtitle,
REQ_CODE_ERROR_NOT_ENOUGH_BOOKMARKS, NOT_ENOUGH_BOOKMARKS_DIALOG_TAG);
}
@ -587,26 +578,25 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
private void showHtmlFormattingError()
{
showConfirmationDialog(REQ_CODE_ERROR_HTML_FORMATTING_DIALOG,
ERROR_HTML_FORMATTING_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title,
R.string.common_check_internet_connection_dialog_title,
R.string.try_again, R.string.cancel);
ERROR_HTML_FORMATTING_DIALOG_TAG, R.string.html_format_error_title,
R.string.html_format_error_title,
R.string.edit_on_web, R.string.cancel);
}
private void showUploadCatalogConfirmationDialog()
{
/*FIXME text later*/
showConfirmationDialog(REQ_CODE_UPLOAD_CONFIRMATION_DIALOG,
UPLOAD_CONFIRMATION_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title,
R.string.common_check_internet_connection_dialog_title,
R.string.try_again, R.string.cancel);
UPLOAD_CONFIRMATION_DIALOG_TAG, R.string.bookmark_public_upload_alert_title,
R.string.bookmark_public_upload_alert_subtitle,
R.string.bookmark_public_upload_alert_ok_button, R.string.cancel);
}
private void showUnresolvedConflictsErrorDialog()
{
/*FIXME text later*/
showConfirmationDialog(REQ_CODE_UPLOAD_CONFIRMATION_DIALOG,
UPLOAD_CONFIRMATION_DIALOG_TAG, R.string.common_check_internet_connection_dialog_title,
R.string.common_check_internet_connection_dialog_title,
R.string.try_again, R.string.cancel);
UPLOAD_CONFIRMATION_DIALOG_TAG,
R.string.public_or_limited_access_after_edit_online_error_title,
R.string.public_or_limited_access_after_edit_online_error_title,
R.string.edit_on_web, R.string.cancel);
}
}

View file

@ -2363,6 +2363,16 @@ bool BookmarkManager::IsCategoryFromCatalog(kml::MarkGroupId categoryId) const
return cat->IsCategoryFromCatalog();
}
std::string BookmarkManager::GetCategoryServerId(kml::MarkGroupId categoryId) const
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
auto cat = GetBmCategory(categoryId);
if (cat == nullptr)
return "";
return cat->GetServerId();
}
std::string BookmarkManager::GetCategoryCatalogDeeplink(kml::MarkGroupId categoryId) const
{
auto cat = GetBmCategory(categoryId);

View file

@ -311,6 +311,7 @@ public:
void ImportDownloadedFromCatalog(std::string const & id, std::string const & filePath);
void UploadToCatalog(kml::MarkGroupId categoryId, kml::AccessRules accessRules);
bool IsCategoryFromCatalog(kml::MarkGroupId categoryId) const;
std::string GetCategoryServerId(kml::MarkGroupId categoryId) const;
std::string GetCategoryCatalogDeeplink(kml::MarkGroupId categoryId) const;
BookmarkCatalog const & GetCatalog() const;