Add create group
This commit is contained in:
parent
bb4848b3ab
commit
0f50345dff
4 changed files with 239 additions and 42 deletions
9
OsmAnd/res/drawable/bg_select_group_button_outline.xml
Normal file
9
OsmAnd/res/drawable/bg_select_group_button_outline.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
<corners android:radius="6dp" />
|
||||||
|
<stroke
|
||||||
|
android:radius="6dp"
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/divider_color_light" />
|
||||||
|
</shape>
|
|
@ -101,8 +101,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="60dp"
|
android:minHeight="60dp"
|
||||||
android:layout_marginEnd="48dp"
|
android:drawableRight="@drawable/btn_circle_transparent_full"
|
||||||
android:layout_marginRight="48dp"
|
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:maxLines="4"
|
android:maxLines="4"
|
||||||
android:scrollHorizontally="false"
|
android:scrollHorizontally="false"
|
||||||
|
@ -171,57 +170,84 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
android:orientation="vertical">
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:letterSpacing="@dimen/description_letter_spacing"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingTop="14dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:paddingBottom="14dp"
|
|
||||||
android:text="@string/select_group"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_regular" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/group_list_button"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/group_list_button_title"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:letterSpacing="@dimen/description_letter_spacing"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="14dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="14dp"
|
||||||
|
android:text="@string/select_group"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/group_list_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:ellipsize="end"
|
android:orientation="horizontal">
|
||||||
android:gravity="center"
|
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/shared_string_list"
|
|
||||||
android:textColor="?attr/active_color_basic"
|
|
||||||
android:textSize="@dimen/text_button_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
|
||||||
|
|
||||||
<ImageView
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/group_list_button_icon"
|
android:id="@+id/group_list_button_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="end"
|
||||||
android:paddingStart="@dimen/content_padding_small"
|
android:ellipsize="end"
|
||||||
android:paddingLeft="@dimen/content_padding_small"
|
android:gravity="center"
|
||||||
android:paddingEnd="@dimen/route_info_buttons_padding_top_bottom"
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
android:maxLines="1"
|
||||||
android:src="@drawable/ic_action_folder"
|
android:text="@string/shared_string_list"
|
||||||
tools:src="@drawable/ic_action_group_select_all" />
|
android:textColor="?attr/active_color_basic"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/group_list_button_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingEnd="@dimen/route_info_buttons_padding_top_bottom"
|
||||||
|
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
||||||
|
android:src="@drawable/ic_action_folder"
|
||||||
|
tools:src="@drawable/ic_action_group_select_all" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="8dp">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/group_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:listitem="@layout/point_group_select_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|
50
OsmAnd/res/layout/point_group_select_item.xml
Normal file
50
OsmAnd/res/layout/point_group_select_item.xml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="142dp"
|
||||||
|
android:layout_height="76dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/outlineRect"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:srcCompat="@drawable/bg_select_group_button_outline" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/groupIcon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:paddingStart="6dp"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
tools:src="@drawable/ic_action_group_select_all" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/counter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:paddingStart="6dp"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
tools:text="255" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/groupName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingTop="33dp"
|
||||||
|
tools:text="@string/favorite" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -16,6 +16,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
@ -23,10 +25,13 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
@ -35,6 +40,10 @@ import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
|
|
||||||
private View view;
|
private View view;
|
||||||
|
@ -43,6 +52,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
private Button addDelDescription;
|
private Button addDelDescription;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
GroupAdapter groupListAdapter;
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,6 +218,26 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
addDelDescription.setText(app.getString(R.string.add_description));
|
addDelDescription.setText(app.getString(R.string.add_description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupListAdapter = new GroupAdapter(app);
|
||||||
|
|
||||||
|
groupListAdapter.setItemClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// int position = recyclerView.getChildAdapterPosition(v);
|
||||||
|
// if (position == RecyclerView.NO_POSITION) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// selectFavorite(favouritePoints.get(position));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false);
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.group_recycler_view);
|
||||||
|
recyclerView.setAdapter(groupListAdapter);
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
groupListAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,4 +451,86 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
||||||
protected Drawable getPaintedIcon(int iconId, int color) {
|
protected Drawable getPaintedIcon(int iconId, int color) {
|
||||||
return getPaintedContentIcon(iconId, color);
|
return getPaintedContentIcon(iconId, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GroupAdapter extends RecyclerView.Adapter<GroupsViewHolder> {
|
||||||
|
|
||||||
|
private static final int VIEW_TYPE_FOOTER = 1;
|
||||||
|
private static final int VIEW_TYPE_CELL = 0;
|
||||||
|
View.OnClickListener listener;
|
||||||
|
OsmandApplication app;
|
||||||
|
List<FavouritesDbHelper.FavoriteGroup> items;
|
||||||
|
|
||||||
|
public GroupAdapter(OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
items = app.getFavorites().getFavoriteGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public GroupsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view;
|
||||||
|
if (viewType == VIEW_TYPE_CELL) {
|
||||||
|
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.point_group_select_item, parent, false);
|
||||||
|
view.setOnClickListener(listener);
|
||||||
|
} else {
|
||||||
|
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.point_group_select_item, parent, false);
|
||||||
|
((ImageView) view.findViewById(R.id.groupIcon)).setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_add));
|
||||||
|
((TextView) view.findViewById(R.id.groupName)).setText(requireMyApplication().getString(R.string.add_group));
|
||||||
|
}
|
||||||
|
return new GroupsViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull GroupsViewHolder holder, int position) {
|
||||||
|
if (position == items.size()) {
|
||||||
|
holder.groupButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Set<String> categories = new HashSet<>();
|
||||||
|
for (FavouritesDbHelper.FavoriteGroup fg : items) {
|
||||||
|
categories.add(fg.getDisplayName(app));
|
||||||
|
}
|
||||||
|
EditCategoryDialogFragment dialogFragment =
|
||||||
|
EditCategoryDialogFragment.createInstance("editorTag", categories, false);
|
||||||
|
dialogFragment.show(getActivity().getSupportFragmentManager(), EditCategoryDialogFragment.TAG);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
final FavouritesDbHelper.FavoriteGroup group = items.get(position);
|
||||||
|
holder.groupName.setText(group.getDisplayName(getMyApplication()));
|
||||||
|
holder.pointsCounter.setText(String.valueOf(group.getPoints().size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
return (position == items.size()) ? VIEW_TYPE_FOOTER : VIEW_TYPE_CELL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items == null ? 0 : items.size() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemClickListener(View.OnClickListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final TextView pointsCounter;
|
||||||
|
final TextView groupName;
|
||||||
|
final ImageView groupIcon;
|
||||||
|
final ImageView groupButton;
|
||||||
|
|
||||||
|
|
||||||
|
public GroupsViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
pointsCounter = (TextView) itemView.findViewById(R.id.counter);
|
||||||
|
groupName = (TextView) itemView.findViewById(R.id.groupName);
|
||||||
|
groupIcon = (ImageView) itemView.findViewById(R.id.groupIcon);
|
||||||
|
groupButton = (ImageView) itemView.findViewById(R.id.outlineRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue