Fix ui glitches

This commit is contained in:
Victor Shcherb 2015-03-06 21:33:57 +01:00
parent b83410bcbd
commit 1b40b90794
10 changed files with 117 additions and 102 deletions

View file

@ -18,6 +18,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:visibility="gone"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:textColor="@color/dashboard_divider_light" android:textColor="@color/dashboard_divider_light"
android:text="@string/loading_data" android:text="@string/loading_data"

View file

@ -1,36 +1,47 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:minHeight="@dimen/list_header_height"
android:minHeight="@dimen/list_header_height" android:orientation="horizontal"
android:paddingRight="@dimen/list_content_padding" android:paddingLeft="@dimen/list_header_padding" >
android:paddingLeft="@dimen/list_header_padding">
<ImageView <CheckBox
android:id="@+id/explist_indicator" android:id="@+id/check_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/list_header_top_margin" android:layout_gravity="center_vertical"
android:src="@drawable/expandable_category_unpushed"/> android:background="?attr/options_button_background"
android:focusable="false"
android:visibility="gone" />
<TextView <ImageView
android:id="@+id/category_name" android:id="@+id/explist_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_header_text_left_margin" android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/list_header_top_margin" android:src="@drawable/expandable_category_unpushed" />
android:textSize="@dimen/list_header_text_size"
tools:text="@string/lorem_ipsum"/>
<CheckBox <TextView
android:id="@+id/check_item" android:id="@+id/category_name"
android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_marginTop="@dimen/list_header_settings_top_margin" android:layout_height="wrap_content"
android:background="?attr/options_button_background" android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_header_text_left_margin"
android:textSize="@dimen/list_header_text_size"
tools:text="@string/lorem_ipsum" />
<ImageView
android:id="@+id/options"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:focusable="false" android:focusable="false"
android:visibility="gone"/> android:visibility="gone"
android:background="?attr/options_button_background"
android:src="?attr/list_settings_icon"/>
</LinearLayout> </LinearLayout>

View file

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_header_height"
android:paddingLeft="@dimen/list_header_padding">
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/list_header_top_margin"
android:src="@drawable/expandable_category_unpushed"/>
<TextView
android:id="@+id/category_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_header_text_left_margin"
android:layout_marginTop="@dimen/list_header_top_margin"
android:layout_weight="1"
android:maxLines="1"
android:textSize="@dimen/list_header_text_size"
tools:text="@string/lorem_ipsum"/>
<ImageView
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/list_header_settings_top_margin"
android:layout_marginRight="@dimen/list_header_settings_top_margin"
android:background="?attr/options_button_background"
android:focusable="false"
android:src="?attr/list_settings_icon"/>
</LinearLayout>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ExpandableListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:groupIndicator="@android:color/transparent" />
</LinearLayout>

View file

@ -6,8 +6,7 @@
android:background="?attr/expandable_list_item_background" android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height" android:minHeight="@dimen/list_item_height"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding">
android:paddingRight="@dimen/list_content_padding">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"

View file

@ -9,12 +9,14 @@
android:id="@+id/header_layout" android:id="@+id/header_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/list_header_height"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/list_header_padding"> android:paddingLeft="@dimen/list_header_padding">
<CheckBox <CheckBox
android:id="@+id/select_all" android:id="@+id/select_all"
android:focusable="false" android:focusable="false"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/list_header_text_left_margin" android:layout_marginRight="@dimen/list_header_text_left_margin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
@ -23,6 +25,8 @@
android:id="@+id/header" android:id="@+id/header"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginBottom="@dimen/list_header_padding" android:layout_marginBottom="@dimen/list_header_padding"
android:text="@string/download_tab_updates"/> android:text="@string/download_tab_updates"/>
</LinearLayout> </LinearLayout>

View file

@ -1262,7 +1262,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="rendering_attr_hmRendered_description">Increase amount of map detail shown</string> <string name="rendering_attr_hmRendered_description">Increase amount of map detail shown</string>
<string name="rendering_attr_hmRendered_name">Show more map detail</string> <string name="rendering_attr_hmRendered_name">Show more map detail</string>
<string name="local_index_routing_data">Routing data</string> <string name="local_index_routing_data">Routing data</string>
<string name="navigate_point_format">Format:</string> <string name="navigate_point_format">Format</string>
<string name="poi_search_desc">POI (Point of interest) search</string> <string name="poi_search_desc">POI (Point of interest) search</string>
<string name="address_search_desc">Address search</string> <string name="address_search_desc">Address search</string>
<string name="navpoint_search_desc">Coordinates</string> <string name="navpoint_search_desc">Coordinates</string>

View file

@ -1,14 +1,5 @@
package net.osmand.plus.activities; 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 gnu.trove.list.array.TIntArrayList;
import java.io.File; import java.io.File;
@ -36,6 +27,8 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs; 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.ColorDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
@ -45,11 +38,28 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity; 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.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.CheckBox; import android.widget.CheckBox;
@ -57,6 +67,7 @@ import android.widget.EditText;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.Filter; import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; 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_ID = 5;
public static final int SELECT_DESTINATIONS_ACTION_MODE_ID = 6; public static final int SELECT_DESTINATIONS_ACTION_MODE_ID = 6;
private FavouritesAdapter favouritesAdapter; private FavouritesAdapter favouritesAdapter = new FavouritesAdapter();;
private FavouritesDbHelper helper; private FavouritesDbHelper helper;
private boolean selectionMode = false; private boolean selectionMode = false;
@ -89,7 +100,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
super.onAttach(activity); super.onAttach(activity);
helper = getMyApplication().getFavorites(); helper = getMyApplication().getFavorites();
favouritesAdapter = new FavouritesAdapter();
favouritesAdapter.synchronizeGroups(); favouritesAdapter.synchronizeGroups();
setAdapter(favouritesAdapter); setAdapter(favouritesAdapter);
@ -128,6 +138,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
}.execute(); }.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 @Override
public void onResume() { public void onResume() {
@ -711,9 +731,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
boolean same = (selectionMode && checkBox) || (!selectionMode && !checkBox); boolean same = (selectionMode && checkBox) || (!selectionMode && !checkBox);
if (row == null || !same) { if (row == null || !same) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
row = inflater.inflate( row = inflater.inflate(R.layout.expandable_list_item_category, parent, false);
selectionMode ? R.layout.expandable_list_item_category :
R.layout.expandable_list_item_category_btn, parent, false);
fixBackgroundRepeat(row); fixBackgroundRepeat(row);
} }
adjustIndicator(groupPosition, isExpanded, row, getMyApplication().getSettings().isLightContent()); adjustIndicator(groupPosition, isExpanded, row, getMyApplication().getSettings().isLightContent());
@ -743,7 +761,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
}); });
} else { } 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.setVisibility(View.VISIBLE);
ch.setOnClickListener(new View.OnClickListener() { ch.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -752,6 +774,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
}); });
} else {
ch.setVisibility(View.GONE);
} }
return row; return row;
} }

View file

@ -32,20 +32,6 @@ public class DashPluginsFragment extends DashBaseFragment {
public static final String TAG = "DASH_PLUGINS_FRAGMENT"; 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() { private final View.OnClickListener getListener = new View.OnClickListener() {
@ -148,7 +134,7 @@ public class DashPluginsFragment extends DashBaseFragment {
} }
private void inflatePluginView(LayoutInflater inflater, ViewGroup container, private void inflatePluginView(LayoutInflater inflater, ViewGroup container,
OsmandPlugin plugin) { final OsmandPlugin plugin) {
View view = inflater.inflate(R.layout.dash_plugin_item, container, false); View view = inflater.inflate(R.layout.dash_plugin_item, container, false);
view.setTag(plugin); view.setTag(plugin);
@ -166,7 +152,19 @@ public class DashPluginsFragment extends DashBaseFragment {
getButton.setOnClickListener(getListener); getButton.setOnClickListener(getListener);
enableDisableButton.setOnCheckedChangeListener(null); enableDisableButton.setOnCheckedChangeListener(null);
updatePluginState(view); 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); container.addView(view);
} }
} }

View file

@ -75,9 +75,6 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
@Override @Override
public boolean init(final OsmandApplication app, Activity activity) { public boolean init(final OsmandApplication app, Activity activity) {
if(true) {
throw new IllegalStateException("Don't enable !!!");
}
if (service == null) { if (service == null) {
service = new OsMoService(app, this); service = new OsMoService(app, this);
tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL, tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL,