Raplaced split action bar with linear layout
This commit is contained in:
parent
71bd4fbf8a
commit
0bbbbf6197
13 changed files with 292 additions and 179 deletions
6
OsmAnd/res/drawable/bottom_menu_item.xml
Normal file
6
OsmAnd/res/drawable/bottom_menu_item.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/gpx_time_span_color" android:state_selected="true"/>
|
||||
<item android:drawable="@color/gpx_time_span_color" android:state_pressed="true"/>
|
||||
</selector>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/dashboard_divider" android:state_selected="true"></item>
|
||||
<item android:drawable="@color/dashboard_divider" android:state_pressed="true"></item>
|
||||
<item android:drawable="@color/dashboard_divider" android:state_selected="true"/>
|
||||
<item android:drawable="@color/dashboard_divider" android:state_pressed="true"/>
|
||||
</selector>
|
|
@ -1,9 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layout"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/layout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View android:id="@+id/devider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/dashboard_divider"/>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/dashboard_black"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
|
@ -45,5 +45,19 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
|
||||
<View android:id="@+id/devider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/dashboard_divider"/>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/dashboard_black"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</TabHost>
|
|
@ -3,10 +3,12 @@
|
|||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.view.*;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -14,6 +16,7 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.search.BottomMenuItem;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -24,9 +27,6 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.text.Spannable;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
|
@ -56,6 +56,7 @@ public class FavouritesListFragment extends ListFragment implements SearchActivi
|
|||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints());
|
||||
setListAdapter(favouritesAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private OsmandApplication getApplication() {
|
||||
|
@ -100,6 +101,13 @@ public class FavouritesListFragment extends ListFragment implements SearchActivi
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (getActivity() instanceof SearchActivity) {
|
||||
((SearchActivity)getActivity()).setupBottomMenu(new ArrayList<BottomMenuItem>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package net.osmand.plus.activities;
|
|||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
|
@ -16,6 +18,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.search.BottomMenuItem;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
|
@ -111,64 +114,60 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
|
|||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
boolean light = app.getSettings().isLightActionBar();
|
||||
MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
||||
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(NAVIGATE_TO);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||
BottomMenuItem menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
|
||||
setMsg(R.string.context_menu_item_directions_to).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(NAVIGATE_TO);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
menuItem = new BottomMenuItem();
|
||||
if (targets.getPointToNavigate() != null) {
|
||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light
|
||||
: R.drawable.ic_action_flage_dark);
|
||||
menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
|
||||
setMsg(R.string.context_menu_item_intermediate_point);
|
||||
} else {
|
||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light
|
||||
: R.drawable.ic_action_flag_dark);
|
||||
menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
|
||||
setMsg(R.string.context_menu_item_destination_point);
|
||||
}
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(ADD_WAYPOINT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
//}
|
||||
menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.search_shown_on_map);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark);
|
||||
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
menuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(SHOW_ON_MAP);
|
||||
return true;
|
||||
public void onClick(View v) {
|
||||
select(ADD_WAYPOINT);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem = menu.add(0, ADD_TO_FAVORITE, 0, R.string.add_to_favourite);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark).
|
||||
setMsg(R.string.search_shown_on_map).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(SHOW_ON_MAP);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(ADD_TO_FAVORITE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark).
|
||||
setMsg(R.string.add_to_favourite).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(ADD_TO_FAVORITE);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 19.01.2015.
|
||||
*/
|
||||
public class BottomMenuItem {
|
||||
private int icon;
|
||||
private View.OnClickListener onClickListener;
|
||||
private int msg;
|
||||
|
||||
public BottomMenuItem setIcon(int iconId) {
|
||||
this.icon = iconId;
|
||||
return BottomMenuItem.this;
|
||||
}
|
||||
|
||||
public BottomMenuItem setMsg(int message) {
|
||||
this.msg = message;
|
||||
return BottomMenuItem.this;
|
||||
}
|
||||
|
||||
public BottomMenuItem setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
return BottomMenuItem.this;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public int getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public View.OnClickListener getOnClickListener(){
|
||||
return onClickListener;
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ import java.util.Locale;
|
|||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Build;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
|
@ -33,16 +33,7 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
import android.widget.TabWidget;
|
||||
import android.widget.TextView;
|
||||
import android.support.v7.app.ActionBar.OnNavigationListener;
|
||||
|
||||
public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener {
|
||||
|
@ -83,12 +74,13 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
|||
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||
private boolean showOnlyOneTab;
|
||||
|
||||
|
||||
public interface SearchActivityChild {
|
||||
|
||||
public void locationUpdate(LatLon l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private View getTabIndicator(TabHost tabHost, int imageId, int stringId){
|
||||
View r = getLayoutInflater().inflate(R.layout.search_main_tab_header, tabHost, false);
|
||||
ImageView tabImage = (ImageView)r.findViewById(R.id.TabImage);
|
||||
|
@ -104,9 +96,6 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
|||
super.onCreate(savedInstanceState);
|
||||
long t = System.currentTimeMillis();
|
||||
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
|
||||
}
|
||||
setContentView(R.layout.search_main);
|
||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
Integer tab = settings.SEARCH_TAB.get();
|
||||
|
@ -189,7 +178,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
|||
|
||||
protected Class<?> getFragment(int tab) {
|
||||
if(tab == POI_TAB_INDEX) {
|
||||
return SearchPoiFilterActivity.class;
|
||||
return SearchPoiFilterFragment.class;
|
||||
} else if(tab == ADDRESS_TAB_INDEX) {
|
||||
return searchOnLine ? SearchAddressOnlineFragment.class : SearchAddressFragment.class;
|
||||
} else if(tab == LOCATION_TAB_INDEX) {
|
||||
|
@ -201,7 +190,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
|||
} else if(tab == FAVORITES_TAB_INDEX) {
|
||||
return FavouritesListFragment.class;
|
||||
}
|
||||
return SearchPoiFilterActivity.class;
|
||||
return SearchPoiFilterFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -296,6 +285,31 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
|||
}
|
||||
}
|
||||
|
||||
public void setupBottomMenu(List<BottomMenuItem> menuItems) {
|
||||
LinearLayout bottomControls = (LinearLayout) findViewById(R.id.bottomControls);
|
||||
if (bottomControls == null) {
|
||||
return;
|
||||
}
|
||||
bottomControls.removeAllViews();
|
||||
|
||||
if (menuItems.size() == 0) {
|
||||
findViewById(R.id.devider).setVisibility(View.GONE);
|
||||
} else {
|
||||
findViewById(R.id.devider).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
for (BottomMenuItem item : menuItems) {
|
||||
ImageButton imageButton = new ImageButton(this);
|
||||
imageButton.setImageResource(item.getIcon());
|
||||
TableRow.LayoutParams params = new TableRow.LayoutParams(0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f);
|
||||
params.gravity = Gravity.CENTER_VERTICAL;
|
||||
imageButton.setLayoutParams(params);
|
||||
imageButton.setOnClickListener(item.getOnClickListener());
|
||||
imageButton.setBackgroundResource(R.drawable.bottom_menu_item);
|
||||
bottomControls.addView(imageButton);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocation(net.osmand.Location location){
|
||||
if (location != null) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
|
@ -93,73 +95,73 @@ public class SearchAddressFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(NAVIGATE_TO);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||
BottomMenuItem menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
|
||||
setMsg(R.string.context_menu_item_directions_to).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(NAVIGATE_TO);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
TargetPointsHelper targets = ((OsmandApplication) getApplication()).getTargetPointsHelper();
|
||||
menuItem = new BottomMenuItem();
|
||||
if (targets.getPointToNavigate() != null) {
|
||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark);
|
||||
menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
|
||||
setMsg(R.string.context_menu_item_intermediate_point);
|
||||
} else {
|
||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark);
|
||||
menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
|
||||
setMsg(R.string.context_menu_item_destination_point);
|
||||
}
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
menuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
public void onClick(View v) {
|
||||
select(ADD_WAYPOINT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.search_shown_on_map);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark);
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(SHOW_ON_MAP);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_marker_light : R.drawable.ic_action_marker_dark).
|
||||
setMsg(R.string.search_shown_on_map).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(SHOW_ON_MAP);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem = menu.add(0, ADD_TO_FAVORITE, 0, R.string.add_to_favourite);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark).
|
||||
setMsg(R.string.add_to_favourite).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select(ADD_TO_FAVORITE);
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
select(ADD_TO_FAVORITE);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address);
|
||||
MenuItemCompat.setShowAsAction(menuItem,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark);
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
((SearchActivity) getActivity()).startSearchAddressOnline();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark).
|
||||
setMsg(R.string.search_online_address).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
((SearchActivity) getActivity()).startSearchAddressOnline();
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
if (getActivity() instanceof SearchActivity) {
|
||||
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OsmandApplication getApplication() {
|
||||
|
|
|
@ -58,33 +58,34 @@ public class SearchAddressOnlineFragment extends Fragment implements SearchActiv
|
|||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
MenuItem menuItem;
|
||||
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightActionBar();
|
||||
menuItem = menu.add(0, 1, 0, R.string.search_offline_clear_search);
|
||||
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark);
|
||||
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||
BottomMenuItem menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark).
|
||||
setMsg(R.string.search_offline_clear_search).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
searchText.setText("");
|
||||
adapter.clear();
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem = new BottomMenuItem().
|
||||
setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark).
|
||||
setMsg(R.string.search_offline_address).
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
((SearchActivity) getActivity()).startSearchAddressOffline();
|
||||
}
|
||||
});
|
||||
menuItems.add(menuItem);
|
||||
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
searchText.setText("");
|
||||
adapter.clear();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (getActivity() instanceof SearchActivity) {
|
||||
menuItem = menu.add(0, 0, 0, R.string.search_offline_address);
|
||||
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark);
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
((SearchActivity) getActivity()).startSearchAddressOffline();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.view.*;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -20,10 +22,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.Spannable;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -67,6 +66,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
|||
});
|
||||
getListView().addFooterView(clearButton);
|
||||
setListAdapter(historyAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,4 +176,10 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (getActivity() instanceof SearchActivity) {
|
||||
((SearchActivity)getActivity()).setupBottomMenu(new ArrayList<BottomMenuItem>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.*;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.NameFinderPoiFilter;
|
||||
|
@ -23,9 +24,6 @@ import net.osmand.plus.render.RenderingIcons;
|
|||
import net.osmand.plus.resources.ResourceManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -35,13 +33,14 @@ import android.widget.Toast;
|
|||
|
||||
|
||||
|
||||
public class SearchPoiFilterActivity extends ListFragment implements SearchActivityChild {
|
||||
public class SearchPoiFilterFragment extends ListFragment implements SearchActivityChild {
|
||||
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||
public static final int REQUEST_POI_EDIT = 55;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
@ -60,7 +59,7 @@ public class SearchPoiFilterActivity extends ListFragment implements SearchActiv
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
refreshPoiListAdapter();
|
||||
}
|
||||
|
||||
|
@ -180,6 +179,11 @@ public class SearchPoiFilterActivity extends ListFragment implements SearchActiv
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
((SearchActivity)getActivity()).setupBottomMenu(new ArrayList<BottomMenuItem>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void locationUpdate(LatLon l) {
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.*;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.TransportRoute;
|
||||
import net.osmand.data.TransportStop;
|
||||
|
@ -31,10 +32,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -110,6 +108,7 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
|
|||
if(intermediateList.getCount() == 0){
|
||||
intermediateListAdapater.add(null);
|
||||
}
|
||||
setHasOptionsMenu(true);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -324,10 +323,9 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
|
|||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int i = which;
|
||||
if(i >= 0){
|
||||
TransportStop stop = stops.get(i);
|
||||
showContextMenuOnStop(stop, item, i);
|
||||
if(which >= 0){
|
||||
TransportStop stop = stops.get(which);
|
||||
showContextMenuOnStop(stop, item, which);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,6 +624,11 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (getActivity() instanceof SearchActivity) {
|
||||
((SearchActivity)getActivity()).setupBottomMenu(new ArrayList<BottomMenuItem>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue