initial ui for the dropdown track selection (see #10)
This commit is contained in:
parent
c67cb3ec7f
commit
911958a0af
14 changed files with 363 additions and 12 deletions
|
@ -22,9 +22,9 @@ android {
|
|||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:25.1.0'
|
||||
compile 'com.android.support:design:25.1.0'
|
||||
compile 'com.android.support:cardview-v7:25.1.0'
|
||||
compile 'com.android.support:appcompat-v7:25.1.1'
|
||||
compile 'com.android.support:design:25.1.1'
|
||||
compile 'com.android.support:cardview-v7:25.1.1'
|
||||
compile 'org.osmdroid:osmdroid-android:5.6.3'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
}
|
||||
|
|
|
@ -622,6 +622,9 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
|||
LocalBroadcastManager.getInstance(mActivity).sendBroadcast(i);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* End of inner class
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
@ -651,5 +654,8 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
|||
mStorageHelper.deleteTempFile();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* End of inner class
|
||||
*/
|
||||
|
||||
}
|
|
@ -32,6 +32,8 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.osmdroid.api.IMapController;
|
||||
|
@ -42,6 +44,7 @@ import org.osmdroid.views.overlay.ItemizedIconOverlay;
|
|||
import org.osmdroid.views.overlay.compass.CompassOverlay;
|
||||
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider;
|
||||
import org.y20k.trackbook.core.Track;
|
||||
import org.y20k.trackbook.helpers.DropdownAdapter;
|
||||
import org.y20k.trackbook.helpers.LogHelper;
|
||||
import org.y20k.trackbook.helpers.MapHelper;
|
||||
import org.y20k.trackbook.helpers.StorageHelper;
|
||||
|
@ -66,6 +69,9 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
private MapView mMapView;
|
||||
private IMapController mController;
|
||||
private ItemizedIconOverlay mTrackOverlay;
|
||||
private ArrayAdapter<String> mTrackSelectorAdapter;
|
||||
private DropdownAdapter mDropdownAdapter;
|
||||
private Spinner mDropdown;
|
||||
private TextView mDistanceView;
|
||||
private TextView mStepsView;
|
||||
private TextView mWaypointsView;
|
||||
|
@ -87,6 +93,9 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
// store activity
|
||||
mActivity = getActivity();
|
||||
|
||||
// create drop-down adapter
|
||||
mDropdownAdapter = new DropdownAdapter(mActivity);
|
||||
|
||||
// listen for finished save operation
|
||||
mTrackSavedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
|
@ -140,8 +149,10 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
mController.setZoom(16);
|
||||
}
|
||||
|
||||
// get views for track selector
|
||||
mDropdown = (Spinner) mRootView.findViewById(R.id.track_selector);
|
||||
|
||||
// get views
|
||||
// get views for statistics sheet
|
||||
View statisticsView = mRootView.findViewById(R.id.statistics_view);
|
||||
mDistanceView = (TextView) mRootView.findViewById(R.id.statistics_data_distance);
|
||||
mStepsView = (TextView) mRootView.findViewById(R.id.statistics_data_steps);
|
||||
|
@ -213,6 +224,11 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
StorageHelper storageHelper = new StorageHelper(mActivity);
|
||||
|
||||
// mTrackSelectorAdapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_spinner_dropdown_item, storageHelper.getListOfTracks());
|
||||
// mDropdown.setAdapter(mTrackSelectorAdapter);
|
||||
mDropdown.setAdapter(mDropdownAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -315,5 +331,8 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
displayTrack();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* End of inner class
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
/**
|
||||
* DropdownHelper.java
|
||||
* Implements a dropdown menu
|
||||
* The dropdown menu used to select tracks
|
||||
*
|
||||
* This file is part of
|
||||
* TRACKBOOK - Movement Recorder for Android
|
||||
*
|
||||
* Copyright (c) 2016-17 - Y20K.org
|
||||
* Licensed under the MIT-License
|
||||
* http://opensource.org/licenses/MIT
|
||||
*
|
||||
* Trackbook uses osmdroid - OpenStreetMap-Tools for Android
|
||||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
|
||||
package org.y20k.trackbook.helpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.database.DataSetObserver;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.ThemedSpinnerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.y20k.trackbook.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* DropdownHelper class
|
||||
*/
|
||||
public class DropdownAdapter implements ThemedSpinnerAdapter, TrackbookKeys {
|
||||
|
||||
/* Define log tag */
|
||||
private static final String LOG_TAG = DropdownAdapter.class.getSimpleName();
|
||||
|
||||
|
||||
/* Main class variables */
|
||||
private Activity mActivity;
|
||||
private final ThemedSpinnerAdapter.Helper mDropdownAdapterHelper;
|
||||
private List<TrackBundle> mTrackBundleList;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
public DropdownAdapter(Activity activity) {
|
||||
// store activity
|
||||
mActivity = activity;
|
||||
|
||||
// fill list with track bundles
|
||||
initializeTrackBundleList();
|
||||
|
||||
// create an adapter helper
|
||||
mDropdownAdapterHelper = new ThemedSpinnerAdapter.Helper(activity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDropDownViewTheme(@Nullable Resources.Theme theme) {
|
||||
mDropdownAdapterHelper.setDropDownViewTheme(theme);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Resources.Theme getDropDownViewTheme() {
|
||||
return mDropdownAdapterHelper.getDropDownViewTheme();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// getView -> collapsed view of dropdown
|
||||
View view = convertView;
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = mDropdownAdapterHelper.getDropDownViewInflater();
|
||||
view = inflater.inflate(R.layout.custom_dropdown_item_collapsed, parent, false);
|
||||
}
|
||||
((TextView) view).setText(getItem(position).getTrackName());
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
// getDropDownView -> expanded view of dropdown
|
||||
View view = convertView;
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = mDropdownAdapterHelper.getDropDownViewInflater();
|
||||
// view = inflater.inflate(R.layout.custom_dropdown_item_expanded, parent, false);
|
||||
view = inflater.inflate(R.layout.support_simple_spinner_dropdown_item, parent, false);
|
||||
}
|
||||
((TextView) view).setText(getItem(position).getTrackName());
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerDataSetObserver(DataSetObserver dataSetObserver) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTrackBundleList.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TrackBundle getItem(int i) {
|
||||
return mTrackBundleList.get(i);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return mTrackBundleList.size() == 0;
|
||||
}
|
||||
|
||||
|
||||
/* Initializes list of track bundles */
|
||||
private void initializeTrackBundleList() {
|
||||
|
||||
// get list of files from storage
|
||||
StorageHelper storageHelper = new StorageHelper(mActivity);
|
||||
File files[] = storageHelper.getListOfTrackbookFiles();
|
||||
|
||||
// fill list with track bundles
|
||||
mTrackBundleList = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
mTrackBundleList.add(new TrackBundle(file));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class: Container for file and corresponding name of a track
|
||||
*/
|
||||
private class TrackBundle {
|
||||
File trackFile;
|
||||
String trackName;
|
||||
|
||||
/* Constructor */
|
||||
TrackBundle(File file) {
|
||||
trackFile = file;
|
||||
trackName = buildTrackName(file);
|
||||
}
|
||||
|
||||
/* Getter for track fike */
|
||||
File getTrackFile() {
|
||||
return trackFile;
|
||||
}
|
||||
|
||||
/* Getter for track name */
|
||||
String getTrackName() {
|
||||
return trackName;
|
||||
}
|
||||
|
||||
/* Builds a readable track name from the track's file name */
|
||||
String buildTrackName(File file) {
|
||||
// todo get date back from track name
|
||||
Date date = null;
|
||||
|
||||
// todo get name according to current locale
|
||||
String readableTrackName = null;
|
||||
|
||||
return file.getName();
|
||||
// return readableTrackName;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* End of inner class
|
||||
*/
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ import android.util.Log;
|
|||
*/
|
||||
public final class LogHelper {
|
||||
|
||||
private final static boolean mTesting = false;
|
||||
private final static boolean mTesting = true;
|
||||
|
||||
public static void d(final String tag, String message) {
|
||||
// include logging only in debug versions
|
||||
|
|
|
@ -36,9 +36,11 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
|
@ -188,6 +190,32 @@ public class StorageHelper implements TrackbookKeys {
|
|||
}
|
||||
|
||||
|
||||
/* Gets a list of .trackbook files - excluding the temp file */
|
||||
public File[] getListOfTrackbookFiles() {
|
||||
// TODO HANDLE CASE: EMPTY FILE LIST
|
||||
|
||||
// get files and sort them
|
||||
return sortFiles(mFolder.listFiles());
|
||||
}
|
||||
|
||||
|
||||
/* Gets a list of tracks based on their file names */
|
||||
public List<String> getListOfTracks() {
|
||||
List<String> listOfTracks = new ArrayList<String>();
|
||||
|
||||
// get files and sort them
|
||||
File[] files = mFolder.listFiles();
|
||||
files = sortFiles(files);
|
||||
|
||||
for (File file : files) {
|
||||
listOfTracks.add(file.getName());
|
||||
}
|
||||
|
||||
// TODO HANDLE CASE: EMPTY FILE LIST
|
||||
return listOfTracks;
|
||||
}
|
||||
|
||||
|
||||
/* Gets most current track from directory */
|
||||
private File getMostCurrentTrack() {
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"
|
||||
android:fillColor="@color/trackbook_white" />
|
||||
</vector>
|
12
app/src/main/res/layout/custom_dropdown_item_collapsed.xml
Normal file
12
app/src/main/res/layout/custom_dropdown_item_collapsed.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView android:id="@android:id/text1"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingStart="@dimen/activity_horizontal_margin"
|
||||
android:paddingEnd="@dimen/activity_horizontal_margin"
|
||||
android:textColor="@color/trackbook_white"
|
||||
android:ellipsize="marquee"
|
||||
android:maxLines="1" />
|
13
app/src/main/res/layout/custom_dropdown_item_expanded.xml
Normal file
13
app/src/main/res/layout/custom_dropdown_item_expanded.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView android:id="@android:id/text1"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingStart="@dimen/activity_horizontal_margin"
|
||||
android:paddingEnd="@dimen/activity_horizontal_margin"
|
||||
android:textColor="@color/trackbook_white"
|
||||
android:background="@color/trackbook_blue"
|
||||
android:ellipsize="marquee"
|
||||
android:maxLines="1" />
|
|
@ -8,12 +8,49 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivityMapFragment">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- MAP VIEW -->
|
||||
<org.osmdroid.views.MapView
|
||||
android:id="@+id/track_map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/descr_map_last_track" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/trackbook_blue_85percent">
|
||||
<Spinner
|
||||
android:id="@+id/track_selector"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start|center"
|
||||
android:theme="@style/TrackbookAppTheme.PopupOverlay"
|
||||
android:contentDescription="@string/descr_track_selector" />
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center"
|
||||
android:background="@drawable/ic_delete_forever_white_24dp"
|
||||
android:contentDescription="@string/descr_delete_button" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- MAP VIEW --> <!-- TODO remove -->
|
||||
<!-- <org.osmdroid.views.MapView
|
||||
android:id="@+id/track_map"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/descr_map_last_track" />
|
||||
android:contentDescription="@string/descr_map_last_track" /> -->
|
||||
|
||||
<!-- BOTTOM SHEET -->
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
|
|
|
@ -112,5 +112,7 @@
|
|||
<string name="descr_statistics_sheet_p_duration_value">Wert: Dauer</string>
|
||||
<string name="descr_statistics_sheet_p_recording_start_value">Wert: Start der Aufzeichnung</string>
|
||||
<string name="descr_statistics_sheet_p_recording_end_value">Wert: Ende der Aufzeichnung</string>
|
||||
<string name="descr_track_selector">Auswahl-Menü für weitere Aufzeichnungen</string>
|
||||
<string name="descr_delete_button">Button Track Löschen</string>
|
||||
|
||||
</resources>
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources><string name="app_name">Trackbook</string> <string name="title_activity_infosheet">情報シート</string>
|
||||
<resources>
|
||||
<string name="app_name">Trackbook</string>
|
||||
<string name="title_activity_infosheet">情報シート</string>
|
||||
|
||||
<string name="menu_my_location">私の場所</string>
|
||||
<string name="menu_about">アプリについて</string>
|
||||
|
@ -36,6 +38,7 @@
|
|||
<string name="toast_message_track_clear">現在のトラック データを削除しました。</string>
|
||||
|
||||
<string name="marker_description_source">ソース</string>
|
||||
<string name="marker_description_time">時間</string>
|
||||
<string name="marker_description_accuracy">精度</string>
|
||||
|
||||
<string name="statistics_sheet_h1_statistics">統計情報</string>
|
||||
|
@ -97,6 +100,7 @@
|
|||
<string name="descr_statistics_sheet_p_duration_value">値: 期間</string>
|
||||
<string name="descr_statistics_sheet_p_recording_start_value">値: 記録の開始</string>
|
||||
<string name="descr_statistics_sheet_p_recording_end_value">値: 記録の終了</string>
|
||||
<string name="descr_track_selector">Dropdown menu for further tracks</string>
|
||||
<string name="descr_delete_button">Track delete button</string>
|
||||
|
||||
<string name="marker_description_time">時間</string>
|
||||
</resources>
|
||||
|
|
|
@ -113,5 +113,7 @@
|
|||
<string name="descr_statistics_sheet_p_duration_value">Value: duration</string>
|
||||
<string name="descr_statistics_sheet_p_recording_start_value">Value: start of recording</string>
|
||||
<string name="descr_statistics_sheet_p_recording_end_value">Value: end of recording</string>
|
||||
<string name="descr_track_selector">Dropdown menu for further tracks</string>
|
||||
<string name="descr_delete_button">Track delete button</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
</style>
|
||||
|
||||
<style name="TrackbookAppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="TrackbookAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<style name="TrackbookAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
|
||||
<!-- <item name="colorBackground">@color/trackbook_red</item> -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue