Add empty states for osm edits

This commit is contained in:
PavelRatushny 2017-11-20 12:36:28 +02:00
parent da3d3f25f2
commit 690ba5dfbb
6 changed files with 137 additions and 27 deletions

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_marginTop="@dimen/empty_state_image_margin_top"
android:layout_marginBottom="@dimen/empty_state_image_margin_bottom"
android:adjustViewBounds="true"
android:layout_marginLeft="@dimen/empty_state_image_margin_left"
android:layout_marginStart="@dimen/empty_state_image_margin_left"
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:src="@drawable/ic_empty_state_osm_edits_night"/>
<LinearLayout
android:clipToPadding="false"
android:paddingLeft="@dimen/empty_state_text_button_padding_left"
android:paddingStart="@dimen/empty_state_text_button_padding_left"
android:paddingRight="@dimen/empty_state_text_button_padding_right"
android:paddingEnd="@dimen/empty_state_text_button_padding_right"
android:paddingTop="@dimen/empty_state_text_button_padding_top"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/empty_state_text_interval"
android:background="@null"
android:text="@string/empty_state_osm_edits"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/empty_state_text_size"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/empty_state_osm_edits_descr"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/empty_state_text_desc_size"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/empty_state_image_margin_bottom"
android:layout_marginTop="@dimen/empty_state_image_margin_top"
tools:src="@drawable/ic_empty_state_osm_edits_night"/>
<net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/empty_state_text_interval"
android:background="@null"
android:text="@string/empty_state_osm_edits"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/empty_state_text_size"/>
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginLeft="@dimen/empty_state_text_desc_margin"
android:layout_marginRight="@dimen/empty_state_text_desc_margin"
android:text="@string/empty_state_osm_edits_descr"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/empty_state_text_desc_size"/>
</LinearLayout>

View file

@ -36,4 +36,9 @@
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"/>
<ViewStub
android:id="@+id/empty_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="empty_state_osm_edits">Create or modify OSM objects</string>
<string name="empty_state_osm_edits_descr">Create or modify OSM POI, opening or commenting OSM Notes, and contributing recorded GPX files.</string>
<string name="shared_string_deleted">Deleted</string>
<string name="shared_string_edited">Edited</string>
<string name="shared_string_added">Added</string>

View file

@ -258,11 +258,9 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabActivity.TabItem> mTabs, Intent intent) {
if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0) {
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
}
mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class));
if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
}
}

View file

@ -19,6 +19,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@ -66,6 +67,8 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
private OsmEditingPlugin plugin;
private View footerView;
private View headerView;
private View emptyView;
private List<OsmPoint> osmEdits;
private OsmEditsAdapter listAdapter;
@ -102,25 +105,17 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
setHasOptionsMenu(true);
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
ListView listView = new ListView(getContext());
View headerView = getActivity().getLayoutInflater().inflate(R.layout.list_item_header, listView, false);
listView.addHeaderView(headerView);
View view = inflater.inflate(R.layout.update_index, container, false);
view.findViewById(R.id.header_layout).setVisibility(View.GONE);
ViewStub emptyStub = (ViewStub) view.findViewById(R.id.empty_view_stub);
emptyStub.setLayoutResource(R.layout.empty_state_osm_edits);
emptyView = emptyStub.inflate();
int icRes = getMyApplication().getSettings().isLightContent()
? R.drawable.ic_empty_state_osm_edits_day : R.drawable.ic_empty_state_osm_edits_night;
((ImageView) emptyView.findViewById(R.id.empty_state_image_view)).setImageResource(icRes);
((TextView) headerView.findViewById(R.id.title_text_view)).setText(R.string.your_edits);
final CheckBox selectAll = (CheckBox) headerView.findViewById(R.id.check_box);
selectAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (selectAll.isChecked()) {
selectAll();
} else {
deselectAll();
}
updateSelectionTitle(actionMode);
}
});
plugin.getPoiModificationLocalUtil().addNodeCommittedListener(this);
return listView;
return view;
}
@Override
@ -357,11 +352,31 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
osmEdits.addAll(l1);
osmEdits.addAll(l2);
ListView listView = getListView();
if (osmEdits.size() > 0 && footerView == null) {
//listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_header, null, false));
footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
listView.setDivider(null);
listView.addFooterView(footerView);
listView.setDivider(null);
listView.setEmptyView(emptyView);
if (osmEdits.size() > 0) {
if (footerView == null) {
footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
listView.addFooterView(footerView);
}
if (headerView == null) {
headerView = getActivity().getLayoutInflater().inflate(R.layout.list_item_header, listView, false);
listView.addHeaderView(headerView);
((TextView) headerView.findViewById(R.id.title_text_view)).setText(R.string.your_edits);
final CheckBox selectAll = (CheckBox) headerView.findViewById(R.id.check_box);
selectAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (selectAll.isChecked()) {
selectAll();
} else {
deselectAll();
}
updateSelectionTitle(actionMode);
}
});
}
}
listAdapter = new OsmEditsAdapter(getMyApplication(), osmEdits);
listAdapter.setSelectedOsmEdits(osmEditsSelected);