fixed dropdown behavior after new track has been recorded & introduced a simple onboardung (=first start) layout for the LAST TRACKS tab.
This commit is contained in:
parent
22df3abb24
commit
b6868298ee
8 changed files with 62 additions and 25 deletions
|
@ -33,7 +33,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -69,10 +69,11 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
private Activity mActivity;
|
||||
private View mRootView;
|
||||
private MapView mMapView;
|
||||
private LinearLayout mOnboardingView;
|
||||
private IMapController mController;
|
||||
private ItemizedIconOverlay mTrackOverlay;
|
||||
private ArrayAdapter<String> mTrackSelectorAdapter;
|
||||
private DropdownAdapter mDropdownAdapter;
|
||||
private LinearLayout mTrackManagementLayout;
|
||||
private Spinner mDropdown;
|
||||
private TextView mDistanceView;
|
||||
private TextView mStepsView;
|
||||
|
@ -113,13 +114,11 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
if (intent.hasExtra(EXTRA_SAVE_FINISHED) && intent.getBooleanExtra(EXTRA_SAVE_FINISHED, false)) {
|
||||
LogHelper.v(LOG_TAG, "Save operation detected. Start loading the new track.");
|
||||
|
||||
// load track and display map and statistics
|
||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||
loadTrackAsyncHelper.execute();
|
||||
|
||||
// update dropdown menu (and load track in onItemSelected)
|
||||
mDropdownAdapter.refresh();
|
||||
mDropdownAdapter.notifyDataSetChanged();
|
||||
mDropdown.setSelection(0);
|
||||
mDropdown.setAdapter(mDropdownAdapter);
|
||||
mDropdown.setSelection(0, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -136,7 +135,10 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
// inflate root view from xml
|
||||
mRootView = inflater.inflate(R.layout.fragment_main_track, container, false);
|
||||
|
||||
// create basic map
|
||||
// get reference to onboarding layout
|
||||
mOnboardingView = (LinearLayout) mRootView.findViewById(R.id.track_tab_onboarding);
|
||||
|
||||
// get reference to basic map
|
||||
mMapView = (MapView) mRootView.findViewById(R.id.track_map);
|
||||
|
||||
// get map controller
|
||||
|
@ -167,6 +169,7 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
}
|
||||
|
||||
// get views for track selector
|
||||
mTrackManagementLayout = (LinearLayout) mRootView.findViewById(R.id.track_management_layout);
|
||||
mDropdown = (Spinner) mRootView.findViewById(R.id.track_selector);
|
||||
|
||||
// get views for statistics sheet
|
||||
|
@ -184,7 +187,7 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
mTrack = savedInstanceState.getParcelable(INSTANCE_TRACK_TRACK_MAP);
|
||||
displayTrack();
|
||||
} else if (mTrack == null) {
|
||||
// load track and display map and statistics // todo get via mCurrentTrack
|
||||
// load track and display map and statistics
|
||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||
loadTrackAsyncHelper.execute();
|
||||
} else {
|
||||
|
@ -249,7 +252,8 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// show / hide the onboarding layout
|
||||
switchOnboardingLayout();
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,12 +288,9 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
// update current track
|
||||
mCurrentTrack = i;
|
||||
|
||||
// get track file
|
||||
File trackFile = mDropdownAdapter.getItem(i).getTrackFile();
|
||||
|
||||
// load track and display map and statistics
|
||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||
loadTrackAsyncHelper.execute(trackFile);
|
||||
loadTrackAsyncHelper.execute(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -351,33 +352,51 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
|||
}
|
||||
|
||||
|
||||
/* show the onboarding layout, if no track has been recorded yet */
|
||||
private void switchOnboardingLayout() {
|
||||
if (mDropdownAdapter.isEmpty()){
|
||||
// show onboarding layout
|
||||
mMapView.setVisibility(View.GONE);
|
||||
mOnboardingView.setVisibility(View.VISIBLE);
|
||||
mTrackManagementLayout.setVisibility(View.INVISIBLE);
|
||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
} else {
|
||||
// show normal layout
|
||||
mOnboardingView.setVisibility(View.GONE);
|
||||
mMapView.setVisibility(View.VISIBLE);
|
||||
mTrackManagementLayout.setVisibility(View.VISIBLE);
|
||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class: Loads track from external storage using AsyncTask
|
||||
*/
|
||||
private class LoadTrackAsyncHelper extends AsyncTask<File, Void, Void> {
|
||||
private class LoadTrackAsyncHelper extends AsyncTask<Integer, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(File... files) {
|
||||
protected Void doInBackground(Integer... ints) {
|
||||
LogHelper.v(LOG_TAG, "Loading track object in background.");
|
||||
|
||||
StorageHelper storageHelper = new StorageHelper(mActivity);
|
||||
|
||||
if (files.length > 0) {
|
||||
// load track object from given file
|
||||
mTrack = storageHelper.loadTrack(files[0]);
|
||||
if (ints.length > 0) {
|
||||
// get track file from dropdown adapter
|
||||
int item = ints[0];
|
||||
File trackFile = mDropdownAdapter.getItem(item).getTrackFile();
|
||||
LogHelper.v(LOG_TAG, "Loading track number " + item);
|
||||
mTrack = storageHelper.loadTrack(trackFile);
|
||||
} else {
|
||||
// load track object from most current file
|
||||
LogHelper.v(LOG_TAG, "No specific track specified. Loading most current one.");
|
||||
mTrack = storageHelper.loadTrack(FILE_MOST_CURRENT_TRACK);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
LogHelper.v(LOG_TAG, "Loading finished. Displaying map and statistics of track.");
|
||||
|
||||
// display track on map
|
||||
displayTrack();
|
||||
|
|
|
@ -92,6 +92,7 @@ public interface TrackbookKeys {
|
|||
int FAB_STATE_SAVE = 2;
|
||||
int FILE_TEMP_TRACK = 0;
|
||||
int FILE_MOST_CURRENT_TRACK = 1;
|
||||
int NEW_DROPDOWN_ITEM = -1;
|
||||
|
||||
String DIRECTORY_NAME = "tracks";
|
||||
String FILE_TYPE_EXTENSION = ".trackbook";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/onboarding" >
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/descr_map_last_track" />
|
||||
|
||||
<include layout="@layout/fragment_main_track_onboarding" />
|
||||
|
||||
<!-- TRACK SELECTION -->
|
||||
<LinearLayout
|
||||
android:id="@+id/track_management_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
<string name="layout_onboarding_p_permission_storage">Trackbook nutzt osmdroid; osmdroid speichert Kartendaten im Externen Speicher von Android. Der Karten-Cache befindet sich im Ordner osmdroid auf der obersten Ebene des für Nutzer sichtbaren Dateisystems.</string>
|
||||
<string name="layout_onboarding_button_okay">Alles klar!</string>
|
||||
|
||||
<!-- track tab onboarding -->
|
||||
<string name="track_tab_onboarding_h1_part_1">Your recorded tracks</string>
|
||||
<string name="track_tab_onboarding_h1_part_2">… will show up here.</string>
|
||||
|
||||
<!-- infosheet about -->
|
||||
<string name="infosheet_about_h1_about">Über Trackbook</string>
|
||||
<string name="infosheet_about_h2_recorder">Bewegungsrekorder für Android</string>
|
||||
|
|
|
@ -61,6 +61,9 @@
|
|||
<string name="layout_onboarding_p_permission_storage">Trackbook は、Android の外部ストレージに地図タイルをキャッシュする osmdroid を使用します。地図キャッシュは、ユーザー向けファイル・システムの最上位レベルの osmdroid フォルダーで見つけることができます。</string>
|
||||
<string name="layout_onboarding_button_okay">完了!</string>
|
||||
|
||||
<string name="track_tab_onboarding_h1_part_1">Your recorded tracks</string>
|
||||
<string name="track_tab_onboarding_h1_part_2">… will show up here.</string>
|
||||
|
||||
<string name="infosheet_about_h1_about">Trackbook について</string>
|
||||
<string name="infosheet_about_h2_recorder">Android 用の移動レコーダー</string>
|
||||
<string name="infosheet_about_h3_version">Version 1.0 (Astronomy Domine)</string>
|
||||
|
|
|
@ -60,6 +60,9 @@
|
|||
<string name="layout_onboarding_p_permission_storage">Trackbook gebruikt osmdroid. osmdroid slaat kaarttegels op in een cache op Android\'s externe opslag. U kunt de kaartcache vinden in de osmdroid-map op het hoogste niveau van het gebruikersbestandssysteem.</string>
|
||||
<string name="layout_onboarding_button_okay">Ik snap het!</string>
|
||||
|
||||
<string name="track_tab_onboarding_h1_part_1">Your recorded tracks</string>
|
||||
<string name="track_tab_onboarding_h1_part_2">… will show up here.</string>
|
||||
|
||||
<string name="infosheet_about_h1_about">Over Trackbook</string>
|
||||
<string name="infosheet_about_h2_recorder">Bewegingsbijhouding voor Android</string>
|
||||
<string name="infosheet_about_h3_version">Versie 1.0 (Astronomy Domine)</string>
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
<string name="fab_sub_menu_clear">Clear</string>
|
||||
<string name="fab_sub_menu_save_and_clear">Save and Clear</string>
|
||||
|
||||
|
||||
<!-- toast messages -->
|
||||
<string name="toast_message_permissions_granted">Permissions granted.</string>
|
||||
<string name="toast_message_unable_to_start_app">Unable to start Trackbook.</string>
|
||||
|
@ -73,6 +72,10 @@
|
|||
<string name="layout_onboarding_p_permission_storage">Trackbook uses osmdroid, which caches map tiles on Android\'s external storage. You can find the map cache in the osmdroid folder on the top level of the user-facing file system.</string>
|
||||
<string name="layout_onboarding_button_okay">Got it!</string>
|
||||
|
||||
<!-- track tab onboarding -->
|
||||
<string name="track_tab_onboarding_h1_part_1">Your recorded tracks</string>
|
||||
<string name="track_tab_onboarding_h1_part_2">… will show up here.</string>
|
||||
|
||||
<!-- infosheet about -->
|
||||
<string name="infosheet_about_h1_about">About Trackbook</string>
|
||||
<string name="infosheet_about_h2_recorder">Movement Recorder for Android</string>
|
||||
|
|
Loading…
Reference in a new issue