icons without paddings

This commit is contained in:
GaidamakUA 2015-08-22 15:55:28 +03:00
parent 002b25e426
commit b118e9f5a3
6 changed files with 201 additions and 136 deletions

View file

@ -6,7 +6,8 @@
android:layout_height="match_parent"
android:background="@color/dashboard_background"
android:orientation="vertical"
tools:context="net.osmand.plus.osmedit.EditPoiFragment">
tools:context="net.osmand.plus.osmedit.EditPoiFragment"
android:clickable="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"

View file

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:background="@color/color_white">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:background="@color/color_white">
<ImageView
android:layout_marginLeft="14dip"
@ -15,19 +16,23 @@
android:layout_height="wrap_content"
android:visibility="gone"
android:gravity="center"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
tools:visibility="visible"
tools:background="@drawable/ic_action_delete_dark"/>
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dip"
android:layout_marginLeft="16dp"
tools:drawableLeft="@drawable/ic_action_search_dark"
android:layout_marginTop="11dip"
android:layout_marginBottom="11dip"
android:gravity="center_vertical"
android:text="@string/layer_poi"
android:textSize="@dimen/default_list_text_size"
android:textColor="@color/color_black"
android:drawablePadding="24dp"
android:layout_weight="1" />
<LinearLayout

View file

@ -1,55 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/MapViewWithLayers"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
android:orientation="vertical" >
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewStub
android:id="@+id/atlasMapRendererViewStub"
<FrameLayout
android:id="@+id/MapViewWithLayers"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
android:orientation="vertical">
<ViewStub
android:id="@+id/atlasMapRendererViewStub"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inflatedId="@+id/atlasMapRendererView"
android:layout="@layout/atlas_map_renderer_view"/>
<net.osmand.plus.views.OsmAndMapSurfaceView
android:id="@+id/MapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/shared_string_map"
android:visibility="gone"/>
<net.osmand.plus.views.OsmAndMapLayersView
android:id="@+id/MapLayersView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/shared_string_map"
android:visibility="gone"/>
</FrameLayout>
<FrameLayout
android:id="@+id/MapHudButtonsOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inflatedId="@+id/atlasMapRendererView"
android:layout="@layout/atlas_map_renderer_view" />
android:layout_height="match_parent">
<net.osmand.plus.views.OsmAndMapSurfaceView
android:id="@+id/MapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/shared_string_map"
android:visibility="gone" />
<include layout="@layout/map_hud_top"/>
<net.osmand.plus.views.OsmAndMapLayersView
android:id="@+id/MapLayersView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/shared_string_map"
android:visibility="gone" />
<include layout="@layout/map_hud_bottom"/>
</FrameLayout>
<include
layout="@layout/dashboard_over_map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<FrameLayout
android:id="@+id/MapHudButtonsOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/map_hud_top" />
<include layout="@layout/map_hud_bottom" />
</FrameLayout>
<include
android:layout_width="match_parent"
<ListView
android:id="@+id/menuItems"
android:layout_width="280dp"
android:layout_height="match_parent"
layout="@layout/dashboard_over_map" />
android:layout_gravity="left"
android:background="@color/dashboard_background"/>
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
</android.support.v4.widget.DrawerLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/title"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="24dp"
android:gravity="center_vertical"
android:padding="16dp"
android:text="@string/layer_poi"
android:textSize="@dimen/default_list_text_size_large"
tools:drawableLeft="@drawable/ic_action_search_dark"/>

View file

@ -289,91 +289,116 @@ public class ContextMenuAdapter {
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = defaultLayoutId;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layoutId, R.id.title,
getItemNames()) {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
Integer lid = getLayoutId(position);
if (lid == R.layout.mode_toggles){
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, new View.OnClickListener() {
@Override
public void onClick(View view) {
if (selected.size() > 0) {
app.getSettings().APPLICATION_MODE.set(selected.iterator().next());
notifyDataSetChanged();
}
if (changeAppModeListener != null) {
changeAppModeListener.onClick(allModes.getResult());
}
}
});
}
if (v == null || (v.getTag() != lid)) {
v = activity.getLayoutInflater().inflate(lid, null);
v.setTag(lid);
}
TextView tv = (TextView) v.findViewById(R.id.title);
tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position));
Drawable imageId = getImage(app, position, holoLight);
if (imageId != null) {
((ImageView) v.findViewById(R.id.icon)).setImageDrawable(imageId);
v.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (v.findViewById(R.id.icon) != null){
v.findViewById(R.id.icon).setVisibility(View.GONE);
}
if(isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);
} else {
tv.setTypeface(null);
}
if (v.findViewById(R.id.check_item) != null) {
final CompoundButton ch = (CompoundButton) v.findViewById(R.id.check_item);
if(selectedList.get(position) != -1) {
ch.setOnCheckedChangeListener(null);
ch.setVisibility(View.VISIBLE);
ch.setChecked(selectedList.get(position) > 0);
final ArrayAdapter<String> la = this;
final OnCheckedChangeListener listener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
OnContextMenuClick ca = getClickAdapter(position);
selectedList.set(position, isChecked ? 1 : 0);
if (ca != null) {
ca.onContextMenuClick(la, getElementId(position), position, isChecked);
}
}
};
ch.setOnCheckedChangeListener(listener);
ch.setVisibility(View.VISIBLE);
} else if (ch != null) {
ch.setVisibility(View.GONE);
}
}
if (v.findViewById(R.id.ProgressBar) != null){
ProgressBar bar = (ProgressBar) v.findViewById(R.id.ProgressBar);
if(loadingList.get(position) == 1){
bar.setVisibility(View.VISIBLE);
} else {
bar.setVisibility(View.INVISIBLE);
}
}
String itemDescr = getItemDescr(position);
if (v.findViewById(R.id.descr) != null){
((TextView)v.findViewById(R.id.descr)).setText(itemDescr);
}
return v;
}
};
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
getItemNames(), app, holoLight);
return listAdapter;
}
public ArrayAdapter<?> createSimpleListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = R.layout.simple_list_menu_item;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
getItemNames(), app, holoLight);
return listAdapter;
}
public class ContextMenuArrayAdapter extends ArrayAdapter<String> {
private Activity activity;
private OsmandApplication app;
private boolean holoLight;
private int layoutId;
public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId,
String[] objects, OsmandApplication app, boolean holoLight) {
super(context, resource, textViewResourceId, objects);
activity = context;
this.app = app;
this.holoLight = holoLight;
layoutId = resource;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
Integer lid = getLayoutId(position);
if (lid == R.layout.mode_toggles){
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, new View.OnClickListener() {
@Override
public void onClick(View view) {
if (selected.size() > 0) {
app.getSettings().APPLICATION_MODE.set(selected.iterator().next());
notifyDataSetChanged();
}
if (changeAppModeListener != null) {
changeAppModeListener.onClick(allModes.getResult());
}
}
});
}
if (convertView == null || (convertView.getTag() != lid)) {
convertView = activity.getLayoutInflater().inflate(lid, null);
convertView.setTag(lid);
}
TextView tv = (TextView) convertView.findViewById(R.id.title);
tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position));
Drawable imageId = getImage(app, position, holoLight);
if (imageId != null) {
if (layoutId == R.layout.simple_list_menu_item) {
tv.setCompoundDrawablesWithIntrinsicBounds(imageId, null, null, null);
} else {
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
}
} else if (convertView.findViewById(R.id.icon) != null){
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
}
if(isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);
} else {
tv.setTypeface(null);
}
if (convertView.findViewById(R.id.check_item) != null) {
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.check_item);
if(selectedList.get(position) != -1) {
ch.setOnCheckedChangeListener(null);
ch.setVisibility(View.VISIBLE);
ch.setChecked(selectedList.get(position) > 0);
final ArrayAdapter<String> la = this;
final OnCheckedChangeListener listener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
OnContextMenuClick ca = getClickAdapter(position);
selectedList.set(position, isChecked ? 1 : 0);
if (ca != null) {
ca.onContextMenuClick(la, getElementId(position), position, isChecked);
}
}
};
ch.setOnCheckedChangeListener(listener);
ch.setVisibility(View.VISIBLE);
} else if (ch != null) {
ch.setVisibility(View.GONE);
}
}
if (convertView.findViewById(R.id.ProgressBar) != null){
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
if(loadingList.get(position) == 1){
bar.setVisibility(View.VISIBLE);
} else {
bar.setVisibility(View.INVISIBLE);
}
}
String itemDescr = getItemDescr(position);
if (convertView.findViewById(R.id.descr) != null){
((TextView)convertView.findViewById(R.id.descr)).setText(itemDescr);
}
return convertView;
}
}
}

View file

@ -22,6 +22,8 @@ import android.view.View;
import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@ -218,6 +220,8 @@ public class MapActivity extends AccessibleActivity {
.add(R.id.fragmentContainer, new FirstUsageFragment(),
FirstUsageFragment.TAG).commit();
}
ListView menuItemsListView = (ListView) findViewById(R.id.menuItems);
menuItemsListView.setAdapter(mapActions.createMainOptionsMenu().createSimpleListAdapter(this, true));
}
private void checkAppInitialization() {