From 1b40b90794fad6b78009fbc131e9742aeb286ede Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 6 Mar 2015 21:33:57 +0100 Subject: [PATCH] Fix ui glitches --- OsmAnd/res/layout/application_loading.xml | 1 + .../layout/expandable_list_item_category.xml | 67 +++++++++++-------- .../expandable_list_item_category_btn.xml | 37 ---------- OsmAnd/res/layout/favorites_tree.xml | 18 +++++ .../res/layout/search_history_list_item.xml | 3 +- OsmAnd/res/layout/update_index.xml | 4 ++ OsmAnd/res/values/strings.xml | 2 +- .../activities/FavoritesTreeFragment.java | 54 ++++++++++----- .../plus/dashboard/DashPluginsFragment.java | 30 ++++----- .../src/net/osmand/plus/osmo/OsMoPlugin.java | 3 - 10 files changed, 117 insertions(+), 102 deletions(-) delete mode 100644 OsmAnd/res/layout/expandable_list_item_category_btn.xml create mode 100644 OsmAnd/res/layout/favorites_tree.xml diff --git a/OsmAnd/res/layout/application_loading.xml b/OsmAnd/res/layout/application_loading.xml index 4916242b96..4eac51ad23 100644 --- a/OsmAnd/res/layout/application_loading.xml +++ b/OsmAnd/res/layout/application_loading.xml @@ -18,6 +18,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="1" + android:visibility="gone" android:layout_gravity="center_vertical" android:textColor="@color/dashboard_divider_light" android:text="@string/loading_data" diff --git a/OsmAnd/res/layout/expandable_list_item_category.xml b/OsmAnd/res/layout/expandable_list_item_category.xml index f49b164974..61d7d103af 100644 --- a/OsmAnd/res/layout/expandable_list_item_category.xml +++ b/OsmAnd/res/layout/expandable_list_item_category.xml @@ -1,36 +1,47 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minHeight="@dimen/list_header_height" + android:orientation="horizontal" + android:paddingLeft="@dimen/list_header_padding" > - + - + - + + + android:visibility="gone" + android:background="?attr/options_button_background" + android:src="?attr/list_settings_icon"/> + \ No newline at end of file diff --git a/OsmAnd/res/layout/expandable_list_item_category_btn.xml b/OsmAnd/res/layout/expandable_list_item_category_btn.xml deleted file mode 100644 index adb3d6811e..0000000000 --- a/OsmAnd/res/layout/expandable_list_item_category_btn.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/favorites_tree.xml b/OsmAnd/res/layout/favorites_tree.xml new file mode 100644 index 0000000000..e1da19d2c6 --- /dev/null +++ b/OsmAnd/res/layout/favorites_tree.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/search_history_list_item.xml b/OsmAnd/res/layout/search_history_list_item.xml index a89fc07153..ffb6c6b085 100644 --- a/OsmAnd/res/layout/search_history_list_item.xml +++ b/OsmAnd/res/layout/search_history_list_item.xml @@ -6,8 +6,7 @@ android:background="?attr/expandable_list_item_background" android:minHeight="@dimen/list_item_height" android:orientation="horizontal" - android:paddingLeft="@dimen/list_content_padding" - android:paddingRight="@dimen/list_content_padding"> + android:paddingLeft="@dimen/list_content_padding"> @@ -23,6 +25,8 @@ android:id="@+id/header" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:gravity="center_vertical" android:layout_marginBottom="@dimen/list_header_padding" android:text="@string/download_tab_updates"/> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 392fcdfff0..b010ec402e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1262,7 +1262,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Increase amount of map detail shown Show more map detail Routing data - Format: + Format POI (Point of interest) search Address search Coordinates diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 8543d8d20d..1413c487c3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -1,14 +1,5 @@ package net.osmand.plus.activities; -import android.content.pm.ActivityInfo; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; -import android.os.Handler; -import android.support.v4.view.MenuItemCompat; -import android.support.v7.view.ActionMode; -import android.support.v7.widget.PopupMenu; -import android.support.v7.widget.SearchView; -import android.view.*; import gnu.trove.list.array.TIntArrayList; import java.io.File; @@ -36,6 +27,8 @@ import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.dialogs.DirectionsDialogs; +import net.osmand.plus.download.DownloadIndexAdapter; +import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.myplaces.FavoritesActivity; @@ -45,11 +38,28 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.res.Resources; +import android.graphics.Color; +import android.graphics.PorterDuff; import android.graphics.Typeface; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Handler; import android.support.v4.app.FragmentActivity; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.view.ActionMode; +import android.support.v7.widget.PopupMenu; +import android.support.v7.widget.SearchView; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.CheckBox; @@ -57,6 +67,7 @@ import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.Filter; import android.widget.Filterable; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; @@ -74,7 +85,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { public static final int SELECT_DESTINATIONS_ID = 5; public static final int SELECT_DESTINATIONS_ACTION_MODE_ID = 6; - private FavouritesAdapter favouritesAdapter; + private FavouritesAdapter favouritesAdapter = new FavouritesAdapter();; private FavouritesDbHelper helper; private boolean selectionMode = false; @@ -89,7 +100,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { super.onAttach(activity); helper = getMyApplication().getFavorites(); - favouritesAdapter = new FavouritesAdapter(); favouritesAdapter.synchronizeGroups(); setAdapter(favouritesAdapter); @@ -128,6 +138,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { }.execute(); } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.favorites_tree, container, false); + ExpandableListView listView = (ExpandableListView)view.findViewById(android.R.id.list); + favouritesAdapter.synchronizeGroups(); + listView.setAdapter(favouritesAdapter); + setListView(listView); + return view; + } @Override public void onResume() { @@ -711,9 +731,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { boolean same = (selectionMode && checkBox) || (!selectionMode && !checkBox); if (row == null || !same) { LayoutInflater inflater = getActivity().getLayoutInflater(); - row = inflater.inflate( - selectionMode ? R.layout.expandable_list_item_category : - R.layout.expandable_list_item_category_btn, parent, false); + row = inflater.inflate(R.layout.expandable_list_item_category, parent, false); fixBackgroundRepeat(row); } adjustIndicator(groupPosition, isExpanded, row, getMyApplication().getSettings().isLightContent()); @@ -743,7 +761,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { } }); } else { - final ImageView ch = (ImageView) row.findViewById(R.id.check_item); + final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item); + ch.setVisibility(View.GONE); + } + final View ch = row.findViewById(R.id.options); + if(!selectionMode) { ch.setVisibility(View.VISIBLE); ch.setOnClickListener(new View.OnClickListener() { @Override @@ -752,6 +774,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { } }); + } else { + ch.setVisibility(View.GONE); } return row; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java index edad45b44d..79645eba67 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java @@ -32,20 +32,6 @@ public class DashPluginsFragment extends DashBaseFragment { public static final String TAG = "DASH_PLUGINS_FRAGMENT"; - private final CompoundButton.OnCheckedChangeListener enableDisableListener = - new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - View pluginView = AndroidUtils.findParentViewById(buttonView, R.id.dash_plugin_item); - OsmandPlugin plugin = (OsmandPlugin)pluginView.getTag(); - if (plugin.isActive() == isChecked || plugin.needsInstallation()) { - return; - } - if (OsmandPlugin.enablePlugin(getActivity(), getMyApplication(), plugin, isChecked)) { - updatePluginState(pluginView); - } - } - }; private final View.OnClickListener getListener = new View.OnClickListener() { @@ -148,7 +134,7 @@ public class DashPluginsFragment extends DashBaseFragment { } private void inflatePluginView(LayoutInflater inflater, ViewGroup container, - OsmandPlugin plugin) { + final OsmandPlugin plugin) { View view = inflater.inflate(R.layout.dash_plugin_item, container, false); view.setTag(plugin); @@ -166,7 +152,19 @@ public class DashPluginsFragment extends DashBaseFragment { getButton.setOnClickListener(getListener); enableDisableButton.setOnCheckedChangeListener(null); updatePluginState(view); - enableDisableButton.setOnCheckedChangeListener(enableDisableListener); + final View pluginView = view; + enableDisableButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (plugin.isActive() == isChecked || plugin.needsInstallation()) { + return; + } + if (OsmandPlugin.enablePlugin(getActivity(), getMyApplication(), plugin, isChecked)) { + + updatePluginState(pluginView); + } + } + }); container.addView(view); } } diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 3367a4a475..ba96fef3ab 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -75,9 +75,6 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer @Override public boolean init(final OsmandApplication app, Activity activity) { - if(true) { - throw new IllegalStateException("Don't enable !!!"); - } if (service == null) { service = new OsMoService(app, this); tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL,