Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d82920760f
6 changed files with 160 additions and 45 deletions
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/list_destination"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||
tools:text="Some description"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatCheckBox
|
||||
android:id="@+id/compound_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,16 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:gravity="center_vertical">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
|
@ -20,15 +19,33 @@
|
|||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_polygom_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Berlin trip"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Some title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:visibility="gone"
|
||||
tools:text="Some description"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/number_count_text"
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.base.bottomsheetmenu;
|
|||
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public class BaseBottomSheetItem {
|
|||
}
|
||||
|
||||
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
|
||||
View view = getView(app, nightMode);
|
||||
View view = getView(app, container, nightMode);
|
||||
if (tag != null) {
|
||||
view.setTag(tag);
|
||||
}
|
||||
|
@ -61,13 +62,14 @@ public class BaseBottomSheetItem {
|
|||
}
|
||||
}
|
||||
|
||||
private View getView(OsmandApplication app, boolean nightMode) {
|
||||
private View getView(OsmandApplication app, ViewGroup parent, boolean nightMode) {
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
if (layoutId != INVALID_ID) {
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
return view = View.inflate(new ContextThemeWrapper(app, themeRes), layoutId, null);
|
||||
return view = LayoutInflater.from(new ContextThemeWrapper(app, themeRes))
|
||||
.inflate(layoutId, parent, false);
|
||||
}
|
||||
throw new RuntimeException("BottomSheetItem must have specified view or layoutId.");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
private boolean checked;
|
||||
private ColorStateList buttonTintList;
|
||||
|
||||
private CompoundButton compoundButton;
|
||||
|
||||
public BottomSheetItemWithCompoundButton(View customView,
|
||||
@LayoutRes int layoutId,
|
||||
Object tag,
|
||||
|
@ -45,10 +47,15 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
this.buttonTintList = buttonTintList;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
compoundButton.setChecked(checked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
|
||||
super.inflate(app, container, nightMode);
|
||||
CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
|
||||
compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
|
||||
compoundButton.setChecked(checked);
|
||||
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ public class MapMarkersGroupViewHolder extends RecyclerView.ViewHolder {
|
|||
ImageView icon;
|
||||
TextView name;
|
||||
TextView numberCount;
|
||||
TextView description;
|
||||
|
||||
public MapMarkersGroupViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
name = itemView.findViewById(R.id.name_text);
|
||||
numberCount = itemView.findViewById(R.id.number_count_text);
|
||||
description = itemView.findViewById(R.id.description_text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TracksGroupsAdapter extends GroupsAdapter {
|
||||
|
||||
|
@ -29,6 +33,9 @@ public class TracksGroupsAdapter extends GroupsAdapter {
|
|||
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
markersGroupViewHolder.name.setText(gpx.getFile().getName().replace(".gpx", "").replace("/", " ").replace("_", " "));
|
||||
markersGroupViewHolder.numberCount.setText(String.valueOf(gpx.getAnalysis().wptPoints));
|
||||
String description = getDescription(gpx);
|
||||
markersGroupViewHolder.description.setVisibility(description == null ? View.GONE : View.VISIBLE);
|
||||
markersGroupViewHolder.description.setText(description);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +44,26 @@ public class TracksGroupsAdapter extends GroupsAdapter {
|
|||
return gpxFiles.size() + 1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getDescription(GpxDataItem item) {
|
||||
Set<String> categories = item.getAnalysis().wptCategoryNames;
|
||||
if (categories != null && !categories.isEmpty() && !(categories.size() == 1 && categories.contains(""))) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<String> it = categories.iterator();
|
||||
while (it.hasNext()) {
|
||||
String category = it.next();
|
||||
if (!category.equals("")) {
|
||||
sb.append(category);
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private GpxDataItem getItem(int position) {
|
||||
return gpxFiles.get(position - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue