Merge branch 'master' of github.com:osmandapp/Osmand
This commit is contained in:
commit
e279b2fed1
28 changed files with 130 additions and 38 deletions
|
@ -5,8 +5,8 @@
|
|||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<stroke android:color="?attr/wikivoyage_active_color" android:width="1dp"/>
|
||||
<solid android:color="?attr/wikivoyage_card_bg_color"/>
|
||||
<stroke android:color="@color/wikivoyage_active_dark" android:width="1dp"/>
|
||||
<solid android:color="@color/wikivoyage_card_bg_dark"/>
|
||||
<corners android:radius="3dp"/>
|
||||
</shape>
|
||||
</item>
|
13
OsmAnd/res/drawable/dialog_active_card_bg_light.xml
Normal file
13
OsmAnd/res/drawable/dialog_active_card_bg_light.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_card_shadow_cr3dp"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<stroke android:color="@color/wikivoyage_active_light" android:width="1dp"/>
|
||||
<solid android:color="@color/wikivoyage_card_bg_light"/>
|
||||
<corners android:radius="3dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_card_shadow_cr3dp"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?attr/wikivoyage_card_bg_color"/>
|
||||
<corners android:radius="3dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -5,7 +5,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?attr/wikivoyage_card_bg_color"/>
|
||||
<solid android:color="@color/wikivoyage_card_bg_dark"/>
|
||||
<corners android:radius="3dp"/>
|
||||
</shape>
|
||||
</item>
|
|
@ -5,7 +5,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?attr/wikivoyage_card_bg_color"/>
|
||||
<solid android:color="@color/wikivoyage_card_bg_light"/>
|
||||
<corners android:radius="3dp"/>
|
||||
</shape>
|
||||
</item>
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="?attr/wikivoyage_card_divider_color"/>
|
||||
android:color="@color/wikivoyage_card_divider_dark"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
12
OsmAnd/res/drawable/travel_card_stroke_bg_light.xml
Normal file
12
OsmAnd/res/drawable/travel_card_stroke_bg_light.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/wikivoyage_card_divider_light"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
||||
</shape>
|
|
@ -2,7 +2,7 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="?attr/wikivoyage_active_color"/>
|
||||
<solid android:color="@color/wikivoyage_active_dark"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
9
OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml
Normal file
9
OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/wikivoyage_active_light"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
||||
</shape>
|
|
@ -2,7 +2,7 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="?attr/wikivoyage_secondary_btn_bg_color"/>
|
||||
<solid android:color="@color/wikivoyage_secondary_btn_bg_dark"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/wikivoyage_secondary_btn_bg_light"/>
|
||||
|
||||
<corners android:radius="3dp"/>
|
||||
|
||||
</shape>
|
|
@ -75,7 +75,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:background="@drawable/wikivoyage_search_card_bg">
|
||||
android:background="?attr/wikivoyage_travel_card_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/search_button"
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/wikivoyage_secondary_btn_bg">
|
||||
android:background="?attr/wikivoyage_secondary_btn_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button_no"
|
||||
|
@ -88,7 +88,7 @@
|
|||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/wikivoyage_secondary_btn_bg">
|
||||
android:background="?attr/wikivoyage_secondary_btn_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button_wifi"
|
||||
|
@ -112,7 +112,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/wikivoyage_primary_btn_bg">
|
||||
android:background="?attr/wikivoyage_primary_btn_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button_yes"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:layout_marginBottom="@dimen/list_header_padding"
|
||||
android:layout_marginLeft="@dimen/card_padding"
|
||||
android:layout_marginRight="@dimen/card_padding"
|
||||
android:background="@drawable/dialog_active_card_bg"
|
||||
android:background="?attr/purchase_dialog_active_card_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/purchase_dialog_card_header"/>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
android:layout_marginBottom="@dimen/list_header_padding"
|
||||
android:layout_marginLeft="@dimen/card_padding"
|
||||
android:layout_marginRight="@dimen/card_padding"
|
||||
android:background="@drawable/dialog_card_bg"
|
||||
android:background="?attr/wikivoyage_travel_card_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/purchase_dialog_card_header"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/wikivoyage_active_card_bg">
|
||||
android:background="?attr/wikivoyage_primary_btn_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_button"
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
android:layout_marginLeft="@dimen/card_padding"
|
||||
android:layout_marginRight="@dimen/card_padding"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="@drawable/wikivoyage_search_card_bg">
|
||||
android:background="?attr/wikivoyage_travel_card_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button_later"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:background="@drawable/travel_card_bg"
|
||||
android:background="?attr/wikivoyage_travel_card_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -64,7 +64,7 @@
|
|||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
android:background="@drawable/travel_card_stroke_bg"
|
||||
android:background="?attr/wikivoyage_travel_card_stroke_bg"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
@ -135,7 +135,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/wikivoyage_secondary_btn_bg">
|
||||
android:background="?attr/wikivoyage_secondary_btn_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/secondary_button"
|
||||
|
@ -165,7 +165,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/wikivoyage_primary_btn_bg">
|
||||
android:background="?attr/wikivoyage_primary_btn_bg">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/primary_button"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:background="@drawable/travel_card_bg"
|
||||
android:background="?attr/wikivoyage_travel_card_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:background="@drawable/travel_card_bg">
|
||||
android:background="?attr/wikivoyage_travel_card_bg">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -81,6 +81,13 @@
|
|||
<attr name="wikivoyage_primary_btn_text_color" format="reference"/>
|
||||
<attr name="wikivoyage_welcome_bg_color" format="reference"/>
|
||||
<attr name="wikivoyage_primary_text_color" format="reference"/>
|
||||
|
||||
<attr name="wikivoyage_travel_card_bg" format="reference"/>
|
||||
<attr name="wikivoyage_travel_card_stroke_bg" format="reference"/>
|
||||
<attr name="wikivoyage_secondary_btn_bg" format="reference"/>
|
||||
<attr name="wikivoyage_primary_btn_bg" format="reference"/>
|
||||
|
||||
<attr name="purchase_dialog_active_card_bg" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
|
|
|
@ -213,6 +213,13 @@
|
|||
<item name="wikivoyage_primary_btn_text_color">@color/wikivoyage_primary_btn_text_light</item>
|
||||
<item name="wikivoyage_welcome_bg_color">@color/wikivoyage_welcome_bg_light</item>
|
||||
<item name="wikivoyage_primary_text_color">@color/wikivoyage_primary_text_light</item>
|
||||
|
||||
<item name="wikivoyage_travel_card_bg">@drawable/travel_card_bg_light</item>
|
||||
<item name="wikivoyage_travel_card_stroke_bg">@drawable/travel_card_stroke_bg_light</item>
|
||||
<item name="wikivoyage_secondary_btn_bg">@drawable/wikivoyage_secondary_btn_bg_light</item>
|
||||
<item name="wikivoyage_primary_btn_bg">@drawable/wikivoyage_primary_btn_bg_light</item>
|
||||
<item name="purchase_dialog_active_card_bg">@drawable/dialog_active_card_bg_light</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
|
||||
|
@ -414,6 +421,13 @@
|
|||
<item name="wikivoyage_primary_btn_text_color">@color/wikivoyage_primary_btn_text_dark</item>
|
||||
<item name="wikivoyage_welcome_bg_color">@color/wikivoyage_welcome_bg_dark</item>
|
||||
<item name="wikivoyage_primary_text_color">@color/wikivoyage_primary_text_dark</item>
|
||||
|
||||
<item name="wikivoyage_travel_card_bg">@drawable/travel_card_bg_dark</item>
|
||||
<item name="wikivoyage_travel_card_stroke_bg">@drawable/travel_card_stroke_bg_dark</item>
|
||||
<item name="wikivoyage_secondary_btn_bg">@drawable/wikivoyage_secondary_btn_bg_dark</item>
|
||||
<item name="wikivoyage_primary_btn_bg">@drawable/wikivoyage_primary_btn_bg_dark</item>
|
||||
<item name="purchase_dialog_active_card_bg">@drawable/dialog_active_card_bg_dark</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||
|
|
|
@ -10,6 +10,8 @@ import com.squareup.picasso.Picasso;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
@ -28,6 +30,8 @@ public class PicassoUtils {
|
|||
|
||||
private static boolean initialized;
|
||||
|
||||
private static Map<String, Boolean> cached = new HashMap<>();
|
||||
|
||||
public static void setupPicasso(@NonNull Context context) {
|
||||
if (!initialized) {
|
||||
File cacheDir = createDefaultCacheDir(context);
|
||||
|
@ -57,6 +61,19 @@ public class PicassoUtils {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cached.clear();
|
||||
}
|
||||
|
||||
public static Boolean isCached(@NonNull String key) {
|
||||
return cached.get(key);
|
||||
}
|
||||
|
||||
public static void setCached(@NonNull String key, boolean val) {
|
||||
cached.put(key, val);
|
||||
}
|
||||
|
||||
public static void clearCachedMap() {
|
||||
cached.clear();
|
||||
}
|
||||
|
||||
public static long getDiskCacheSizeBytes() throws IOException {
|
||||
|
|
|
@ -116,6 +116,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
public void setItems(List<BaseTravelCard> items) {
|
||||
this.items.clear();
|
||||
this.items.addAll(items);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void removeItem(int position) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.squareup.picasso.Picasso;
|
|||
import com.squareup.picasso.RequestCreator;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PicassoUtils;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -76,22 +77,29 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
|||
} else {
|
||||
final ItemVH holder = (ItemVH) viewHolder;
|
||||
TravelArticle article = (TravelArticle) getItem(position);
|
||||
final String url = TravelArticle.getImageUrl(article.getImageTitle(), false);
|
||||
Boolean cached = PicassoUtils.isCached(url);
|
||||
boolean lastItem = position == getItemCount() - 1;
|
||||
|
||||
RequestCreator rc = Picasso.get()
|
||||
.load(TravelArticle.getImageUrl(article.getImageTitle(), false));
|
||||
.load(url);
|
||||
WikivoyageUtils.setupNetworkPolicy(settings, rc);
|
||||
rc.transform(new CropCircleTransformation())
|
||||
.into(holder.icon, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
holder.icon.setVisibility(View.VISIBLE);
|
||||
PicassoUtils.setCached(url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
holder.icon.setVisibility(View.GONE);
|
||||
PicassoUtils.setCached(url, false);
|
||||
}
|
||||
});
|
||||
|
||||
holder.icon.setVisibility(cached != null && cached ? View.VISIBLE : View.GONE);
|
||||
holder.title.setText(article.getTitle());
|
||||
holder.content.setText(article.getContent());
|
||||
holder.partOf.setText(article.getGeoDescription());
|
||||
|
|
|
@ -143,6 +143,12 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
PicassoUtils.clearCachedMap();
|
||||
}
|
||||
|
||||
protected void onDataLoaded() {
|
||||
mainView.findViewById(R.id.progress_bar).setVisibility(View.GONE);
|
||||
updateSearchVisibility();
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.squareup.picasso.Callback;
|
|||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
|
||||
import net.osmand.PicassoUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||
|
@ -40,21 +41,28 @@ public class ArticleTravelCard extends BaseTravelCard {
|
|||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof ArticleTravelVH) {
|
||||
final ArticleTravelVH holder = (ArticleTravelVH) viewHolder;
|
||||
final String url = TravelArticle.getImageUrl(article.getImageTitle(), false);
|
||||
Boolean cached = PicassoUtils.isCached(url);
|
||||
|
||||
RequestCreator rc = Picasso.get()
|
||||
.load(TravelArticle.getImageUrl(article.getImageTitle(), false));
|
||||
.load(url);
|
||||
WikivoyageUtils.setupNetworkPolicy(app.getSettings(), rc);
|
||||
rc.transform(new CropCircleTransformation())
|
||||
.into(holder.icon, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
holder.icon.setVisibility(View.VISIBLE);
|
||||
PicassoUtils.setCached(url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
holder.icon.setVisibility(View.GONE);
|
||||
PicassoUtils.setCached(url, false);
|
||||
}
|
||||
});
|
||||
|
||||
holder.icon.setVisibility(cached != null && cached ? View.VISIBLE : View.GONE);
|
||||
holder.title.setText(article.getTitle());
|
||||
holder.content.setText(article.getPartialContent());
|
||||
holder.partOf.setText(article.getGeoDescription());
|
||||
|
|
|
@ -206,9 +206,9 @@ public class TravelDownloadUpdateCard extends BaseTravelCard {
|
|||
@DrawableRes
|
||||
private int getPrimaryBtnBgRes(boolean enabled) {
|
||||
if (enabled) {
|
||||
return R.drawable.wikivoyage_primary_btn_bg;
|
||||
return nightMode ? R.drawable.wikivoyage_primary_btn_bg_dark : R.drawable.wikivoyage_primary_btn_bg_light;
|
||||
}
|
||||
return R.drawable.wikivoyage_secondary_btn_bg;
|
||||
return nightMode ? R.drawable.wikivoyage_secondary_btn_bg_dark : R.drawable.wikivoyage_secondary_btn_bg_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
|
|
Loading…
Reference in a new issue