Add empty states

This commit is contained in:
PavelRatushny 2017-08-03 15:32:49 +03:00
parent 8347dbafbf
commit 68e85bbbf3
7 changed files with 140 additions and 14 deletions

View file

@ -1,9 +1,11 @@
<?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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:background="?attr/ctx_menu_info_view_bg" android:background="?attr/ctx_menu_info_view_bg"
android:orientation="vertical"> android:orientation="vertical">
<ExpandableListView <ExpandableListView
android:id="@android:id/list" android:id="@android:id/list"
@ -18,9 +20,45 @@
android:drawSelectorOnTop="false" android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"/> android:groupIndicator="@android:color/transparent"/>
<TextView <LinearLayout
android:gravity="center_horizontal"
android:id="@android:id/empty" android:id="@android:id/empty"
android:layout_width="wrap_content" android:orientation="vertical"
android:layout_height="wrap_content"/> android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_marginTop="@dimen/my_places_empty_state_image_margin_top"
android:layout_marginBottom="@dimen/my_places_empty_state_image_margin_bottom"
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_empty_state_trip_night_result"/>
<net.osmand.plus.widgets.TextViewEx
android:layout_marginBottom="@dimen/my_places_empty_state_text_interval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/empty_state_my_tracks"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/my_places_empty_state_text_size"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/empty_state_my_tracks_desc"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/my_places_empty_state_text_desc_size"/>
<Button
android:layout_marginTop="@dimen/my_places_empty_state_button_margin_top"
android:id="@+id/import_button"
style="@style/DialogActionButton"
android:text="@string/shared_string_import"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,9 +1,12 @@
<?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"
android:id="@+id/MainLayout" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_height="fill_parent" android:id="@+id/MainLayout"
android:orientation="vertical"> android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="?attr/ctx_menu_info_view_bg">
<ExpandableListView <ExpandableListView
android:id="@android:id/list" android:id="@android:id/list"
@ -16,6 +19,47 @@
android:divider="@null" android:divider="@null"
android:dividerHeight="0dp" android:dividerHeight="0dp"
android:drawSelectorOnTop="false" android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent" /> android:groupIndicator="@android:color/transparent"/>
<LinearLayout
android:gravity="center_horizontal"
android:id="@android:id/empty"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_marginTop="@dimen/my_places_empty_state_image_margin_top"
android:layout_marginBottom="@dimen/my_places_empty_state_image_margin_bottom"
android:id="@+id/empty_state_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_empty_state_favorites_night_result"/>
<net.osmand.plus.widgets.TextViewEx
android:layout_marginBottom="@dimen/my_places_empty_state_text_interval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/empty_state_favourites"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/my_places_empty_state_text_size"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/empty_state_favourites_desc"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/my_places_empty_state_text_desc_size"/>
<Button
android:layout_marginTop="@dimen/my_places_empty_state_button_margin_top"
android:id="@+id/import_button"
style="@style/DialogActionButton"
android:text="@string/shared_string_import"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -78,5 +78,12 @@
<dimen name="default_split_segments_overview">15sp</dimen> <dimen name="default_split_segments_overview">15sp</dimen>
<dimen name="default_split_segments_data">15sp</dimen> <dimen name="default_split_segments_data">15sp</dimen>
<dimen name="default_split_segments_sub">12sp</dimen> <dimen name="default_split_segments_sub">12sp</dimen>
<dimen name="my_places_empty_state_image_margin_top">63dp</dimen>
<dimen name="my_places_empty_state_image_margin_bottom">45dp</dimen>
<dimen name="my_places_empty_state_text_interval">12dp</dimen>
<dimen name="my_places_empty_state_button_margin_top">30dp</dimen>
<dimen name="my_places_empty_state_text_size">20sp</dimen>
<dimen name="my_places_empty_state_text_desc_size">18sp</dimen>
</resources> </resources>

View file

@ -143,4 +143,11 @@
<dimen name="splash_screen_logo_top">150dp</dimen> <dimen name="splash_screen_logo_top">150dp</dimen>
<dimen name="splash_screen_text_bottom">128dp</dimen> <dimen name="splash_screen_text_bottom">128dp</dimen>
<dimen name="my_places_empty_state_image_margin_top">42dp</dimen>
<dimen name="my_places_empty_state_image_margin_bottom">30dp</dimen>
<dimen name="my_places_empty_state_text_interval">8dp</dimen>
<dimen name="my_places_empty_state_button_margin_top">20dp</dimen>
<dimen name="my_places_empty_state_text_size">18sp</dimen>
<dimen name="my_places_empty_state_text_desc_size">16sp</dimen>
</resources> </resources>

View file

@ -2662,4 +2662,8 @@
<string name="retry">Retry</string> <string name="retry">Retry</string>
<string name="add_gpx_waypoint_bottom_sheet_title">Add gpx waypoint</string> <string name="add_gpx_waypoint_bottom_sheet_title">Add gpx waypoint</string>
<string name="shared_string_create">Create</string> <string name="shared_string_create">Create</string>
<string name="empty_state_my_tracks">Add and Record Tracks</string>
<string name="empty_state_my_tracks_desc">Record or import tracks to view</string>
<string name="empty_state_favourites">Add Favorites</string>
<string name="empty_state_favourites_desc">Add favorites on map or import them from filesystem</string>
</resources> </resources>

View file

@ -21,6 +21,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.Filter; import android.widget.Filter;
@ -76,6 +77,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
private FavouritesAdapter favouritesAdapter = new FavouritesAdapter(); private FavouritesAdapter favouritesAdapter = new FavouritesAdapter();
private FavouritesDbHelper helper; private FavouritesDbHelper helper;
private OsmandApplication app;
private boolean selectionMode = false; private boolean selectionMode = false;
private Set<FavouritePoint> favoritesSelected = new LinkedHashSet<>(); private Set<FavouritePoint> favoritesSelected = new LinkedHashSet<>();
private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<>(); private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<>();
@ -88,6 +90,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);
this.app = (OsmandApplication) getActivity().getApplication();
helper = getMyApplication().getFavorites(); helper = getMyApplication().getFavorites();
favouritesAdapter.synchronizeGroups(); favouritesAdapter.synchronizeGroups();
@ -156,6 +159,17 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
footerView = inflater.inflate(R.layout.list_shadow_footer, null, false); footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
listView.addFooterView(footerView); listView.addFooterView(footerView);
} }
View emptyView = view.findViewById(android.R.id.empty);
ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_favorites_day_result : R.drawable.ic_empty_state_favorites_night_result);
Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addTrack();
}
});
listView.setEmptyView(emptyView);
listView.setAdapter(favouritesAdapter); listView.setAdapter(favouritesAdapter);
setListView(listView); setListView(listView);
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -467,6 +481,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
} }
private void addTrack() {
((FavoritesActivity) getActivity()).addTrack();
}
public void shareFavorites(final FavoriteGroup group) { public void shareFavorites(final FavoriteGroup group) {
final AsyncTask<Void, Void, Void> exportTask = new AsyncTask<Void, Void, Void>() { final AsyncTask<Void, Void, Void> exportTask = new AsyncTask<Void, Void, Void>() {

View file

@ -327,9 +327,17 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
footerView = inflater.inflate(R.layout.list_shadow_footer, null, false); footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
listView.addFooterView(footerView); listView.addFooterView(footerView);
TextView emptyTextView = (TextView) v.findViewById(android.R.id.empty); View emptyView = v.findViewById(android.R.id.empty);
emptyTextView.setText("There are no gpx items"); ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
listView.setEmptyView(emptyTextView); emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_trip_day_result : R.drawable.ic_empty_state_trip_night_result);
Button importButton = (Button) emptyView.findViewById(R.id.import_button);
importButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addTrack();
}
});
listView.setEmptyView(emptyView);
if (this.adapter != null) { if (this.adapter != null) {
listView.setAdapter(this.adapter); listView.setAdapter(this.adapter);
} }