This commit is contained in:
Alexey Kulish 2018-02-05 14:15:58 +03:00
parent ccf4740989
commit 6ec8a82bba
5 changed files with 75 additions and 162 deletions

View file

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/share_fragment_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp">
<TextView
android:id="@+id/header_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:text="@string/share_menu_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<ListView
android:id="@+id/list"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -1,53 +1,61 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/share_fragment_layout" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent" android:layout_width="match_parent"
android:background="@android:color/transparent"> android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bottom_menu_view_bg"
android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp"> android:layout_height="@dimen/bottom_sheet_title_height"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:text="@string/share_menu_location"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView <ListView
android:id="@+id/header_caption" android:id="@+id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:text="@string/share_menu_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:baselineAligned="false" android:divider="@null"
android:orientation="horizontal"> android:dividerHeight="0dp"/>
<ListView
android:id="@+id/list"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/cancel_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -1688,7 +1688,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
private void doLayoutMenu() { private void doLayoutMenu() {
final int posY = getPosY(getViewY(), false); final int posY = getPosY(getViewY(), false, menu.getCurrentMenuState());
setViewY(posY, true, !initLayout || !centered); setViewY(posY, true, !initLayout || !centered);
updateMainViewLayout(posY); updateMainViewLayout(posY);
} }

View file

@ -131,32 +131,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
this.builder.setLight(isLight()); this.builder.setLight(isLight());
} }
public void onCreated() { protected void onCreated() {
/*
toolbarController = new ContextMenuToolbarController(this);
toolbarController.setTitle(getNameStr());
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.backToolbarAction(MenuController.this);
}
}
});
toolbarController.setOnTitleClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.close();
}
}
});
*/
} }
@Override @Override

View file

@ -3,7 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager; import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -17,13 +17,14 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem; import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
import net.osmand.plus.widgets.TextViewEx;
import java.util.List; import java.util.List;
public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClickListener { public class ShareMenuFragment extends MenuBottomSheetDialogFragment implements OnItemClickListener {
public static final String TAG = "ShareMenuFragment"; public static final String TAG = "ShareMenuFragment";
private ArrayAdapter<ShareItem> listAdapter; private ArrayAdapter<ShareItem> listAdapter;
@ -40,56 +41,41 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.share_menu_fragment, container, false); final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.share_menu_fragment, container);
View mainView = view.findViewById(R.id.main_view); if (nightMode) {
if (menu.isLandscapeLayout()) { ((TextViewEx) view.findViewById(R.id.title_text_view)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
AndroidUtils.addStatusBarPadding21v(getContext(), view);
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
} }
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), headerCaption, !menu.isLight());
ListView listView = (ListView) view.findViewById(R.id.list); ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter(); listAdapter = createAdapter();
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
listView.setOnItemClickListener(this); listView.setOnItemClickListener(this);
view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
setupHeightAndBackground(view, R.id.scroll_view);
return view; return view;
} }
@Override
public void onStart() {
super.onStart();
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
}
@Override
public void onStop() {
super.onStop();
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
}
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
menu.saveMenu(outState); menu.saveMenu(outState);
} }
public static void showInstance(ShareMenu menu) { public static void showInstance(ShareMenu menu) {
int slideInAnim = menu.getSlideInAnimation();
int slideOutAnim = menu.getSlideOutAnimation();
ShareMenuFragment fragment = new ShareMenuFragment(); ShareMenuFragment fragment = new ShareMenuFragment();
fragment.menu = menu; fragment.menu = menu;
menu.getMapActivity().getSupportFragmentManager().beginTransaction() fragment.setUsedOnMap(true);
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) fragment.show(menu.getMapActivity().getSupportFragmentManager(), ShareMenuFragment.TAG);
.add(R.id.fragmentContainer, fragment, TAG)
.addToBackStack(TAG).commit();
} }
private ArrayAdapter<ShareItem> createAdapter() { private ArrayAdapter<ShareItem> createAdapter() {
@ -103,13 +89,13 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
if (v == null) { if (v == null) {
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null); v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
} }
AndroidUtils.setBackground(v.getContext(), v, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark); AndroidUtils.setBackground(v.getContext(), v, nightMode, R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
final ShareItem item = getItem(position); final ShareItem item = getItem(position);
ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(menu.getMapActivity().getMyApplication() icon.setImageDrawable(menu.getMapActivity().getMyApplication()
.getIconsCache().getIcon(item.getIconResourceId(), menu.isLight())); .getIconsCache().getIcon(item.getIconResourceId(), !nightMode));
TextView name = (TextView) v.findViewById(R.id.name); TextView name = (TextView) v.findViewById(R.id.name);
AndroidUtils.setTextPrimaryColor(v.getContext(), name, !menu.isLight()); AndroidUtils.setTextPrimaryColor(v.getContext(), name, nightMode);
name.setText(getContext().getText(item.getTitleResourceId())); name.setText(getContext().getText(item.getTitleResourceId()));
return v; return v;
} }
@ -118,15 +104,12 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
dismiss();
menu.share(listAdapter.getItem(position)); menu.share(listAdapter.getItem(position));
disableTransitionAnimation();
dismissMenu();
} }
public void dismissMenu() { public void dismissMenu() {
menu.getMapActivity().getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); dismiss();
if (menu.getMapActivity().getContextMenu().isVisible()) { menu.getMapActivity().getContextMenu().close();
menu.getMapActivity().getContextMenu().close();
}
} }
} }