Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
acaef8fc68
8 changed files with 42 additions and 7 deletions
BIN
OsmAnd/res/drawable-xxhdpi/img_help_wikivoyage_articles.webp
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/img_help_wikivoyage_articles.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/img_help_wikivoyage_contribute.webp
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/img_help_wikivoyage_contribute.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
|
@ -103,10 +103,17 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<net.osmand.plus.LockableViewPager
|
||||
android:id="@+id/view_pager"
|
||||
<!-- Coordinator layout is needed in order to display the snackbar above the bottom navigation -->
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<net.osmand.plus.LockableViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_padding_small"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
|
@ -118,7 +118,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_padding_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
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="article_removed">Article removed</string>
|
||||
<string name="wikivoyage_search_hint">Search: Country, City, Province</string>
|
||||
<string name="shared_string_read">Read</string>
|
||||
<string name="saved_articles">Saved articles</string>
|
||||
|
|
|
@ -109,6 +109,14 @@ public class WikivoyageLocalDataHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void restoreSavedArticle(@NonNull WikivoyageArticle article) {
|
||||
if (!isArticleSaved(article)) {
|
||||
savedArticles.add(article);
|
||||
dbHelper.addSavedArticle(article);
|
||||
notifySavedUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeArticleFromSaved(@NonNull WikivoyageArticle article) {
|
||||
WikivoyageArticle savedArticle = getArticle(article.cityId, article.lang);
|
||||
if (savedArticle != null) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.wikivoyage.explore;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -10,6 +11,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -129,7 +131,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
final View divider;
|
||||
final View shadow;
|
||||
|
||||
ItemVH(View itemView) {
|
||||
ItemVH(final View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
content = (TextView) itemView.findViewById(R.id.content);
|
||||
|
@ -160,7 +162,17 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
public void onClick(View view) {
|
||||
Object item = getItemByPosition();
|
||||
if (item != null && item instanceof WikivoyageArticle) {
|
||||
WikivoyageLocalDataHelper.getInstance(app).removeArticleFromSaved((WikivoyageArticle) item);
|
||||
final WikivoyageArticle article = (WikivoyageArticle) item;
|
||||
WikivoyageLocalDataHelper.getInstance(app).removeArticleFromSaved(article);
|
||||
Snackbar snackbar = Snackbar.make(itemView, R.string.article_removed, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WikivoyageLocalDataHelper.getInstance(app).restoreSavedArticle(article);
|
||||
}
|
||||
});
|
||||
AndroidUtils.setSnackbarTextColor(snackbar, R.color.wikivoyage_active_dark);
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -122,6 +122,9 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
|||
if (oldItem instanceof String && newItem instanceof String) {
|
||||
return false;
|
||||
} else if (oldItem instanceof WikivoyageArticle && newItem instanceof WikivoyageArticle) {
|
||||
if (newItemPosition == newItems.size() - 1 && lastItemChanged()) {
|
||||
return false;
|
||||
}
|
||||
WikivoyageArticle oldArticle = (WikivoyageArticle) oldItem;
|
||||
WikivoyageArticle newArticle = (WikivoyageArticle) newItem;
|
||||
return oldArticle.getCityId() == newArticle.getCityId()
|
||||
|
@ -129,5 +132,9 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean lastItemChanged() {
|
||||
return newItems.get(newItems.size() - 1) != oldItems.get(oldItems.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue