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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<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_selected="true"/>
|
||||||
<item android:drawable="@color/dashboard_divider" android:state_pressed="true"></item>
|
<item android:drawable="@color/dashboard_divider" android:state_pressed="true"/>
|
||||||
</selector>
|
</selector>
|
|
@ -1,9 +1,25 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/layout"
|
|
||||||
android:layout_marginTop="?attr/actionBarSize"
|
android:layout_marginTop="?attr/actionBarSize"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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_height="0dp"
|
||||||
android:layout_weight="1" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</TabHost>
|
</TabHost>
|
|
@ -3,10 +3,12 @@
|
||||||
*/
|
*/
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
|
import android.view.*;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
@ -14,6 +16,7 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
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;
|
||||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
|
@ -24,9 +27,6 @@ import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -56,6 +56,7 @@ public class FavouritesListFragment extends ListFragment implements SearchActivi
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints());
|
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints());
|
||||||
setListAdapter(favouritesAdapter);
|
setListAdapter(favouritesAdapter);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OsmandApplication getApplication() {
|
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
|
@Override
|
||||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
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.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
@ -16,6 +18,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
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;
|
||||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
|
@ -111,64 +114,60 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||||
boolean light = app.getSettings().isLightActionBar();
|
boolean light = app.getSettings().isLightActionBar();
|
||||||
MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to);
|
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
BottomMenuItem menuItem = new BottomMenuItem().
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
|
||||||
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
setMsg(R.string.context_menu_item_directions_to).
|
||||||
|
setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(NAVIGATE_TO);
|
select(NAVIGATE_TO);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
menuItems.add(menuItem);
|
||||||
|
|
||||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
|
menuItem = new BottomMenuItem();
|
||||||
if (targets.getPointToNavigate() != null) {
|
if (targets.getPointToNavigate() != null) {
|
||||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point);
|
menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
setMsg(R.string.context_menu_item_intermediate_point);
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light
|
|
||||||
: R.drawable.ic_action_flage_dark);
|
|
||||||
} else {
|
} else {
|
||||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point);
|
menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
setMsg(R.string.context_menu_item_destination_point);
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light
|
|
||||||
: R.drawable.ic_action_flag_dark);
|
|
||||||
}
|
}
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
menuItem.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(ADD_WAYPOINT);
|
select(ADD_WAYPOINT);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//}
|
menuItems.add(menuItem);
|
||||||
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 = 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
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(SHOW_ON_MAP);
|
select(SHOW_ON_MAP);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
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.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
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
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(ADD_TO_FAVORITE);
|
select(ADD_TO_FAVORITE);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
menuItems.add(menuItem);
|
||||||
|
|
||||||
|
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.content.pm.ActivityInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.view.*;
|
||||||
import android.view.MenuItem;
|
import android.widget.*;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
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.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.util.Log;
|
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.TabHost.TabSpec;
|
||||||
import android.widget.TabWidget;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.support.v7.app.ActionBar.OnNavigationListener;
|
import android.support.v7.app.ActionBar.OnNavigationListener;
|
||||||
|
|
||||||
public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener {
|
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>>();
|
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
private boolean showOnlyOneTab;
|
private boolean showOnlyOneTab;
|
||||||
|
|
||||||
|
|
||||||
public interface SearchActivityChild {
|
public interface SearchActivityChild {
|
||||||
|
|
||||||
public void locationUpdate(LatLon l);
|
public void locationUpdate(LatLon l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private View getTabIndicator(TabHost tabHost, int imageId, int stringId){
|
private View getTabIndicator(TabHost tabHost, int imageId, int stringId){
|
||||||
View r = getLayoutInflater().inflate(R.layout.search_main_tab_header, tabHost, false);
|
View r = getLayoutInflater().inflate(R.layout.search_main_tab_header, tabHost, false);
|
||||||
ImageView tabImage = (ImageView)r.findViewById(R.id.TabImage);
|
ImageView tabImage = (ImageView)r.findViewById(R.id.TabImage);
|
||||||
|
@ -104,9 +96,6 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
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);
|
setContentView(R.layout.search_main);
|
||||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
Integer tab = settings.SEARCH_TAB.get();
|
Integer tab = settings.SEARCH_TAB.get();
|
||||||
|
@ -189,7 +178,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
|
|
||||||
protected Class<?> getFragment(int tab) {
|
protected Class<?> getFragment(int tab) {
|
||||||
if(tab == POI_TAB_INDEX) {
|
if(tab == POI_TAB_INDEX) {
|
||||||
return SearchPoiFilterActivity.class;
|
return SearchPoiFilterFragment.class;
|
||||||
} else if(tab == ADDRESS_TAB_INDEX) {
|
} else if(tab == ADDRESS_TAB_INDEX) {
|
||||||
return searchOnLine ? SearchAddressOnlineFragment.class : SearchAddressFragment.class;
|
return searchOnLine ? SearchAddressOnlineFragment.class : SearchAddressFragment.class;
|
||||||
} else if(tab == LOCATION_TAB_INDEX) {
|
} else if(tab == LOCATION_TAB_INDEX) {
|
||||||
|
@ -201,7 +190,7 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
} else if(tab == FAVORITES_TAB_INDEX) {
|
} else if(tab == FAVORITES_TAB_INDEX) {
|
||||||
return FavouritesListFragment.class;
|
return FavouritesListFragment.class;
|
||||||
}
|
}
|
||||||
return SearchPoiFilterActivity.class;
|
return SearchPoiFilterFragment.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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){
|
public void updateLocation(net.osmand.Location location){
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.osmand.plus.activities.search;
|
package net.osmand.plus.activities.search;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
@ -93,75 +95,75 @@ public class SearchAddressFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MenuItem menuItem = menu.add(0, NAVIGATE_TO, 0, R.string.context_menu_item_directions_to);
|
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
BottomMenuItem menuItem = new BottomMenuItem().
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark).
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
setMsg(R.string.context_menu_item_directions_to).
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(NAVIGATE_TO);
|
select(NAVIGATE_TO);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
menuItems.add(menuItem);
|
||||||
|
|
||||||
TargetPointsHelper targets = ((OsmandApplication) getApplication()).getTargetPointsHelper();
|
TargetPointsHelper targets = ((OsmandApplication) getApplication()).getTargetPointsHelper();
|
||||||
|
menuItem = new BottomMenuItem();
|
||||||
if (targets.getPointToNavigate() != null) {
|
if (targets.getPointToNavigate() != null) {
|
||||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_intermediate_point);
|
menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark).
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
setMsg(R.string.context_menu_item_intermediate_point);
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flage_light : R.drawable.ic_action_flage_dark);
|
|
||||||
} else {
|
} else {
|
||||||
menuItem = menu.add(0, ADD_WAYPOINT, 0, R.string.context_menu_item_destination_point);
|
menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark).
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
setMsg(R.string.context_menu_item_destination_point);
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_flag_light : R.drawable.ic_action_flag_dark);
|
|
||||||
}
|
}
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
menuItem.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(ADD_WAYPOINT);
|
select(ADD_WAYPOINT);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.search_shown_on_map);
|
menuItems.add(menuItem);
|
||||||
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 = 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
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(SHOW_ON_MAP);
|
select(SHOW_ON_MAP);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
menuItems.add(menuItem);
|
||||||
|
|
||||||
menuItem = menu.add(0, ADD_TO_FAVORITE, 0, R.string.add_to_favourite);
|
menuItem = new BottomMenuItem().
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark).
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
setMsg(R.string.add_to_favourite).
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_fav_light : R.drawable.ic_action_fav_dark);
|
setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
select(ADD_TO_FAVORITE);
|
select(ADD_TO_FAVORITE);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address);
|
menuItems.add(menuItem);
|
||||||
MenuItemCompat.setShowAsAction(menuItem,
|
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
menuItem = new BottomMenuItem().
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark);
|
setIcon(light ? R.drawable.ic_action_gnext_light : R.drawable.ic_action_gnext_dark).
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
setMsg(R.string.search_online_address).
|
||||||
|
setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
((SearchActivity) getActivity()).startSearchAddressOnline();
|
((SearchActivity) getActivity()).startSearchAddressOnline();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
menuItems.add(menuItem);
|
||||||
|
|
||||||
|
if (getActivity() instanceof SearchActivity) {
|
||||||
|
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private OsmandApplication getApplication() {
|
private OsmandApplication getApplication() {
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,33 +58,34 @@ public class SearchAddressOnlineFragment extends Fragment implements SearchActiv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
MenuItem menuItem;
|
|
||||||
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightActionBar();
|
boolean light = ((OsmandApplication) getActivity().getApplication()).getSettings().isLightActionBar();
|
||||||
menuItem = menu.add(0, 1, 0, R.string.search_offline_clear_search);
|
List<BottomMenuItem> menuItems = new ArrayList<BottomMenuItem>();
|
||||||
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
BottomMenuItem menuItem = new BottomMenuItem().
|
||||||
menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark);
|
setIcon(light ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark).
|
||||||
|
setMsg(R.string.search_offline_clear_search).
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
searchText.setText("");
|
searchText.setText("");
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getActivity() instanceof SearchActivity) {
|
menuItems.add(menuItem);
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (getActivity() instanceof SearchActivity) {
|
||||||
|
((SearchActivity)getActivity()).setupBottomMenu(menuItems);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package net.osmand.plus.activities.search;
|
package net.osmand.plus.activities.search;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
|
import android.view.*;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
@ -20,10 +22,7 @@ import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
@ -67,6 +66,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
||||||
});
|
});
|
||||||
getListView().addFooterView(clearButton);
|
getListView().addFooterView(clearButton);
|
||||||
setListAdapter(historyAdapter);
|
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.FragmentActivity;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.view.*;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.NameFinderPoiFilter;
|
import net.osmand.plus.NameFinderPoiFilter;
|
||||||
|
@ -23,9 +24,6 @@ import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
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_LAT = SearchActivity.SEARCH_LAT;
|
||||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||||
public static final int REQUEST_POI_EDIT = 55;
|
public static final int REQUEST_POI_EDIT = 55;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
@ -60,7 +59,7 @@ public class SearchPoiFilterActivity extends ListFragment implements SearchActiv
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setHasOptionsMenu(true);
|
||||||
refreshPoiListAdapter();
|
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
|
@Override
|
||||||
public void locationUpdate(LatLon l) {
|
public void locationUpdate(LatLon l) {
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.*;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.TransportRoute;
|
import net.osmand.data.TransportRoute;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
|
@ -31,10 +32,7 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -110,6 +108,7 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
|
||||||
if(intermediateList.getCount() == 0){
|
if(intermediateList.getCount() == 0){
|
||||||
intermediateListAdapater.add(null);
|
intermediateListAdapater.add(null);
|
||||||
}
|
}
|
||||||
|
setHasOptionsMenu(true);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,10 +323,9 @@ public class SearchTransportFragment extends Fragment implements SearchActivityC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int i = which;
|
if(which >= 0){
|
||||||
if(i >= 0){
|
TransportStop stop = stops.get(which);
|
||||||
TransportStop stop = stops.get(i);
|
showContextMenuOnStop(stop, item, which);
|
||||||
showContextMenuOnStop(stop, item, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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