Merge pull request #5179 from osmandapp/WebPCheckFix

check for webP images
This commit is contained in:
Alexander Sytnyk 2018-03-28 17:59:38 +03:00 committed by GitHub
commit 3c208a8797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 80 additions and 40 deletions

View file

@ -69,6 +69,7 @@
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
android:id="@+id/action_bar_image_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_image_height" android:layout_height="@dimen/action_bar_image_height"
android:background="?attr/actionModeBackground"> android:background="?attr/actionModeBackground">

View file

@ -8,6 +8,7 @@ import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider; import android.support.v4.content.FileProvider;
@ -162,7 +163,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
View emptyView = view.findViewById(android.R.id.empty); View emptyView = view.findViewById(android.R.id.empty);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_favorites_day : R.drawable.ic_empty_state_favorites_night); if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_favorites_day : R.drawable.ic_empty_state_favorites_night);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
Button importButton = (Button) emptyView.findViewById(R.id.import_button); Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() { importButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -99,12 +99,17 @@ public class NotesFragment extends OsmAndListFragment {
ViewStub emptyStub = (ViewStub) view.findViewById(R.id.empty_view_stub); ViewStub emptyStub = (ViewStub) view.findViewById(R.id.empty_view_stub);
emptyStub.setLayoutResource(R.layout.empty_state_av_notes); emptyStub.setLayoutResource(R.layout.empty_state_av_notes);
emptyView = emptyStub.inflate(); emptyView = emptyStub.inflate();
int icRes = getMyApplication().getSettings().isLightContent()
? R.drawable.ic_empty_state_av_notes_day : R.drawable.ic_empty_state_av_notes_night;
((ImageView) emptyView.findViewById(R.id.empty_state_image_view)).setImageResource(icRes);
emptyView.setBackgroundColor(getResources().getColor(getMyApplication().getSettings() emptyView.setBackgroundColor(getResources().getColor(getMyApplication().getSettings()
.isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark)); .isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark));
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
if (Build.VERSION.SDK_INT >= 18) {
int icRes = getMyApplication().getSettings().isLightContent()
? R.drawable.ic_empty_state_av_notes_day : R.drawable.ic_empty_state_av_notes_night;
emptyImageView.setImageResource(icRes);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
return view; return view;
} }

View file

@ -5,6 +5,7 @@ import android.content.res.ColorStateList;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
@ -222,37 +223,41 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
} }
private void updateHelpImage() { private void updateHelpImage() {
OsmandSettings settings = getSettings(); if (Build.VERSION.SDK_INT >= 18) {
int count = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get(); OsmandSettings settings = getSettings();
LinkedList<Drawable> imgList = new LinkedList<>(); int count = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
imgList.add(getDeviceImg()); LinkedList<Drawable> imgList = new LinkedList<>();
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get()) { imgList.add(getDeviceImg());
imgList.add(getGuideLineOneImg()); if (settings.SHOW_LINES_TO_FIRST_MARKERS.get()) {
if (count == 2) { imgList.add(getGuideLineOneImg());
imgList.add(getGuideLineTwoImg());
}
}
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
imgList.add(getArrowOneImg());
if (count == 2) {
imgList.add(getArrowTwoImg());
}
}
if (settings.MARKERS_DISTANCE_INDICATION_ENABLED.get()) {
if (settings.MAP_MARKERS_MODE.get().isWidgets()) {
imgList.add(getWidget1Img());
if (count == 2) { if (count == 2) {
imgList.add(getWidget2Img()); imgList.add(getGuideLineTwoImg());
}
} else {
imgList.add(getTopBar1Img());
if (count == 2) {
imgList.add(getTopBar2Img());
} }
} }
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
imgList.add(getArrowOneImg());
if (count == 2) {
imgList.add(getArrowTwoImg());
}
}
if (settings.MARKERS_DISTANCE_INDICATION_ENABLED.get()) {
if (settings.MAP_MARKERS_MODE.get().isWidgets()) {
imgList.add(getWidget1Img());
if (count == 2) {
imgList.add(getWidget2Img());
}
} else {
imgList.add(getTopBar1Img());
if (count == 2) {
imgList.add(getTopBar2Img());
}
}
}
((ImageView) mainView.findViewById(R.id.action_bar_image))
.setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()])));
} else {
mainView.findViewById(R.id.action_bar_image_container).setVisibility(View.GONE);
} }
((ImageView) mainView.findViewById(R.id.action_bar_image))
.setImageDrawable(new LayerDrawable(imgList.toArray(new Drawable[imgList.size()])));
} }
private Drawable getTopBar2Img() { private Drawable getTopBar2Img() {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@ -126,7 +127,11 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
final View emptyView = mainView.findViewById(R.id.empty_view); final View emptyView = mainView.findViewById(R.id.empty_view);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(mapActivity.getMyApplication().getSettings().isLightContent() ? R.drawable.ic_empty_state_marker_list_day : R.drawable.ic_empty_state_marker_list_night); if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(mapActivity.getMyApplication().getSettings().isLightContent() ? R.drawable.ic_empty_state_marker_list_day : R.drawable.ic_empty_state_marker_list_night);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
recyclerView.setEmptyView(emptyView); recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

View file

@ -7,6 +7,7 @@ import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
@ -304,7 +305,11 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
} }
}); });
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_group_night : R.drawable.ic_empty_state_marker_group_day); if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_group_night : R.drawable.ic_empty_state_marker_group_day);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
recyclerView.setEmptyView(emptyView); recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);

View file

@ -7,6 +7,7 @@ import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
@ -203,7 +204,11 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
}); });
final View emptyView = mainView.findViewById(R.id.empty_view); final View emptyView = mainView.findViewById(R.id.empty_view);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_history_night : R.drawable.ic_empty_state_marker_history_day); if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(night ? R.drawable.ic_empty_state_marker_history_night : R.drawable.ic_empty_state_marker_history_day);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
recyclerView.setEmptyView(emptyView); recyclerView.setEmptyView(emptyView);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);

View file

@ -30,7 +30,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
items.add(new DescriptionItem(getString(R.string.measurement_tool_save_as_new_track_descr))); items.add(new DescriptionItem(getString(R.string.measurement_tool_save_as_new_track_descr)));
if (Build.VERSION.SDK_INT >= 17) { if (Build.VERSION.SDK_INT >= 18) {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
View imagesRow = View.inflate(new ContextThemeWrapper(getContext(), themeRes), View imagesRow = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.fragment_save_as_new_track_images_row, null); R.layout.fragment_save_as_new_track_images_row, null);

View file

@ -333,7 +333,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
listView.addFooterView(footerView); listView.addFooterView(footerView);
emptyView = v.findViewById(android.R.id.empty); emptyView = v.findViewById(android.R.id.empty);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_trip_day : R.drawable.ic_empty_state_trip_night); if (Build.VERSION.SDK_INT >= 18) {
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_trip_day : R.drawable.ic_empty_state_trip_night);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
Button importButton = (Button) emptyView.findViewById(R.id.import_button); Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() { importButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -140,12 +141,16 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
ViewStub emptyStub = (ViewStub) view.findViewById(R.id.empty_view_stub); ViewStub emptyStub = (ViewStub) view.findViewById(R.id.empty_view_stub);
emptyStub.setLayoutResource(R.layout.empty_state_osm_edits); emptyStub.setLayoutResource(R.layout.empty_state_osm_edits);
emptyView = emptyStub.inflate(); emptyView = emptyStub.inflate();
int icRes = getMyApplication().getSettings().isLightContent()
? R.drawable.ic_empty_state_osm_edits_day : R.drawable.ic_empty_state_osm_edits_night;
((ImageView) emptyView.findViewById(R.id.empty_state_image_view)).setImageResource(icRes);
emptyView.setBackgroundColor(getResources().getColor(getMyApplication().getSettings() emptyView.setBackgroundColor(getResources().getColor(getMyApplication().getSettings()
.isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark)); .isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark));
ImageView emptyImageView = emptyView.findViewById(R.id.empty_state_image_view);
if (Build.VERSION.SDK_INT >= 18) {
int icRes = getMyApplication().getSettings().isLightContent()
? R.drawable.ic_empty_state_osm_edits_day : R.drawable.ic_empty_state_osm_edits_night;
emptyImageView.setImageResource(icRes);
} else {
emptyImageView.setVisibility(View.INVISIBLE);
}
FragmentManager fm = getChildFragmentManager(); FragmentManager fm = getChildFragmentManager();
Fragment optionsFragment = fm.findFragmentByTag(OsmEditOptionsBottomSheetDialogFragment.TAG); Fragment optionsFragment = fm.findFragmentByTag(OsmEditOptionsBottomSheetDialogFragment.TAG);
if (optionsFragment != null) { if (optionsFragment != null) {