Trackbook got an About screen

This commit is contained in:
y20k 2016-09-07 12:30:46 +02:00
parent 3789c66f3b
commit 87636e9a64
11 changed files with 273 additions and 25 deletions

View file

@ -43,16 +43,10 @@ Which Permissions does Trackbook need?
### Permission "INTERNET" ### Permission "INTERNET"
Trackbook needs to download map data from Open Street Map servers and therefore needs access to the internet. Trackbook needs to download map data from Open Street Map servers and therefore needs access to the internet.
### Permission "ACCESS_NETWORK_STATE" ### Permission "ACCESS_NETWORK_STATE" and "ACCESS_WIFI_STATE"
tbd
### Permission "ACCESS_WIFI_STATE"
tbd tbd
### Permission "ACCESS_COARSE_LOCATION" ### Permission "ACCESS_COARSE_LOCATION" and "ACCESS_FINE_LOCATION"
tbd
### Permission "ACCESS_FINE_LOCATION"
tbd tbd
### Permission "WRITE_EXTERNAL_STORAGE" ### Permission "WRITE_EXTERNAL_STORAGE"

View file

@ -9,7 +9,7 @@ android {
minSdkVersion 22 minSdkVersion 22
targetSdkVersion 24 targetSdkVersion 24
versionCode 1 versionCode 1
versionName "0.1 (The Great Gig in the Sky)" versionName "0.1.0 (The Great Gig in the Sky)"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
buildTypes { buildTypes {

View file

@ -24,13 +24,30 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/TrackbookAppTheme.NoActionBar"> android:theme="@style/TrackbookAppTheme.NoActionBar"
android:launchMode="singleTop">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<!-- INFOSHEET ACTIVITY -->
<activity
android:name=".InfosheetActivity"
android:label="@string/title_activity_infosheet"
android:parentActivityName=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.y20k.trackbook.MainActivity" />
</activity>
<!-- PLAYER SERVICE --> <!-- PLAYER SERVICE -->
<service <service
android:name=".TrackerService" android:name=".TrackerService"

View file

@ -0,0 +1,49 @@
/**
* InfosheetActivity.java
* Implements the app's infosheet activity
* The infosheet activity sets up infosheet screens for "About" and "How to"
*
* This file is part of
* TRANSISTOR - Radio App for Android
*
* Copyright (c) 2015-16 - Y20K.org
* Licensed under the MIT-License
* http://opensource.org/licenses/MIT
*/
package org.y20k.trackbook;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.y20k.trackbook.helpers.TrackbookKeys;
/**
* InfosheetActivity class
*/
public final class InfosheetActivity extends AppCompatActivity implements TrackbookKeys {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get activity title from intent
Intent intent = this.getIntent();
// set activity title
if (intent.hasExtra(EXTRA_INFOSHEET_TITLE)) {
this.setTitle(intent.getStringExtra(EXTRA_INFOSHEET_TITLE));
}
// set activity view
if (intent.hasExtra(EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(EXTRA_INFOSHEET_CONTENT, -1) == INFOSHEET_CONTENT_ABOUT) {
setContentView(R.layout.fragment_infosheet_about);
}
}
}

View file

@ -38,7 +38,6 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast; import android.widget.Toast;
import org.y20k.trackbook.helpers.LogHelper;
import org.y20k.trackbook.helpers.TrackbookKeys; import org.y20k.trackbook.helpers.TrackbookKeys;
import java.util.ArrayList; import java.util.ArrayList;
@ -57,7 +56,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Main class variables */ /* Main class variables */
private boolean mTracking; private boolean mTrackerServiceRunning;
private boolean mPermissionsGranted; private boolean mPermissionsGranted;
private List<String> mMissingPermissions; private List<String> mMissingPermissions;
private View mRootView; private View mRootView;
@ -71,9 +70,9 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// set state of tracking // set state of tracking
mTracking = false; mTrackerServiceRunning = false;
if (savedInstanceState != null) { if (savedInstanceState != null) {
mTracking = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false); mTrackerServiceRunning = savedInstanceState.getBoolean(INSTANCE_TRACKING_STATE, false);
} }
// check permissions on Android 6 and higher // check permissions on Android 6 and higher
@ -116,7 +115,13 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
// CASE ABOUT // CASE ABOUT
case R.id.action_bar_about: case R.id.action_bar_about:
LogHelper.v(LOG_TAG, "About was selected"); // TODO remove // get title
String aboutTitle = getString(R.string.header_about);
// put title and content into intent and start activity
Intent aboutIntent = new Intent(this, InfosheetActivity.class);
aboutIntent.putExtra(EXTRA_INFOSHEET_TITLE, aboutTitle);
aboutIntent.putExtra(EXTRA_INFOSHEET_CONTENT, INFOSHEET_CONTENT_ABOUT);
startActivity(aboutIntent);
return true; return true;
// CASE DEFAULT // CASE DEFAULT
@ -128,7 +133,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean(INSTANCE_TRACKING_STATE, mTracking); outState.putBoolean(INSTANCE_TRACKING_STATE, mTrackerServiceRunning);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -137,6 +142,12 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Intent intent = getIntent();
if (intent.hasExtra(EXTRA_TRACKING_STATE)) {
mTrackerServiceRunning = intent.getBooleanExtra(EXTRA_TRACKING_STATE, false);
mMainActivityFragment.setTrackingState(mTrackerServiceRunning);
}
// if not in onboarding mode: set state of FloatingActionButton // if not in onboarding mode: set state of FloatingActionButton
if (mFloatingActionButton != null) { if (mFloatingActionButton != null) {
setFloatingActionButtonState(); setFloatingActionButtonState();
@ -233,7 +244,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
/* Handles tap on the record button */ /* Handles tap on the record button */
private void handleFloatingActionButtonClick(View view) { private void handleFloatingActionButtonClick(View view) {
if (mTracking) { if (mTrackerServiceRunning) {
// show snackbar // show snackbar
Snackbar.make(view, R.string.snackbar_message_tracking_stopped, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); Snackbar.make(view, R.string.snackbar_message_tracking_stopped, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
@ -250,7 +261,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
Snackbar.make(view, R.string.snackbar_message_tracking_started, Snackbar.LENGTH_SHORT).setAction("Action", null).show(); Snackbar.make(view, R.string.snackbar_message_tracking_started, Snackbar.LENGTH_SHORT).setAction("Action", null).show();
// change state // change state
mTracking = true; mTrackerServiceRunning = true;
setFloatingActionButtonState(); setFloatingActionButtonState();
// get last location from MainActivity Fragment // get last location from MainActivity Fragment
@ -264,13 +275,13 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
} }
// update tracking state in MainActivityFragment // update tracking state in MainActivityFragment
mMainActivityFragment.setTrackingState(mTracking); mMainActivityFragment.setTrackingState(mTrackerServiceRunning);
} }
/* Set state of FloatingActionButton */ /* Set state of FloatingActionButton */
private void setFloatingActionButtonState() { private void setFloatingActionButtonState() {
if (mTracking) { if (mTrackerServiceRunning) {
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp); mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp);
} else { } else {
mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp); mFloatingActionButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp);
@ -304,7 +315,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// change state // change state
mTracking = false; mTrackerServiceRunning = false;
setFloatingActionButtonState(); setFloatingActionButtonState();
// pass tracking state to MainActivityFragment // pass tracking state to MainActivityFragment

View file

@ -194,6 +194,7 @@ public class MainActivityFragment extends Fragment implements TrackbookKeys {
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -306,14 +307,22 @@ public class MainActivityFragment extends Fragment implements TrackbookKeys {
public void setTrackingState (boolean trackingState) { public void setTrackingState (boolean trackingState) {
mTrackerServiceRunning = trackingState; mTrackerServiceRunning = trackingState;
// got a new track (from notification)=
Intent intent = mActivity.getIntent();
if (intent.hasExtra(EXTRA_TRACK)) {
LogHelper.v(LOG_TAG, "ding !!!");
mTrack = intent.getParcelableExtra(EXTRA_TRACK);
}
// turn on/off tracking for MainActivity Fragment - prevent double tracking // turn on/off tracking for MainActivity Fragment - prevent double tracking
if (mTrackerServiceRunning) { if (mTrackerServiceRunning) {
stopPreliminaryTracking(); stopPreliminaryTracking();
} else if (!mLocalTrackerRunning){ } else if (!mLocalTrackerRunning){
startPreliminaryTracking(); startPreliminaryTracking();
if (mTrack != null) { }
drawTrackOverlay(mTrack);
} if (mTrack != null) {
drawTrackOverlay(mTrack);
} }
// update marker // update marker

View file

@ -96,6 +96,10 @@ public class NotificationHelper implements TrackbookKeys {
// explicit intent for notification tap // explicit intent for notification tap
Intent tapActionIntent = new Intent(mService, MainActivity.class); Intent tapActionIntent = new Intent(mService, MainActivity.class);
tapActionIntent.setAction(Intent.ACTION_MAIN);
tapActionIntent.addCategory(Intent.CATEGORY_LAUNCHER);
tapActionIntent.putExtra(EXTRA_TRACK, track);
tapActionIntent.putExtra(EXTRA_TRACKING_STATE, true);
// explicit intent for stopping playback // explicit intent for stopping playback
Intent stopActionIntent = new Intent(mService, TrackerService.class); Intent stopActionIntent = new Intent(mService, TrackerService.class);

View file

@ -31,6 +31,9 @@ public interface TrackbookKeys {
/* EXTRAS */ /* EXTRAS */
public static final String EXTRA_TRACK = "TRACK"; public static final String EXTRA_TRACK = "TRACK";
public static final String EXTRA_LAST_LOCATION = "LAST_LOCATION"; public static final String EXTRA_LAST_LOCATION = "LAST_LOCATION";
public static final String EXTRA_TRACKING_STATE = "TRACKING_STATE";
public static final String EXTRA_INFOSHEET_TITLE = "EXTRA_INFOSHEET_TITLE";
public static final String EXTRA_INFOSHEET_CONTENT = "INFOSHEET_CONTENT";
/* ARGS */ /* ARGS */
public static final String ARG_PERMISSIONS_GRANTED = "ArgPermissionsGranted"; public static final String ARG_PERMISSIONS_GRANTED = "ArgPermissionsGranted";
@ -66,5 +69,6 @@ public interface TrackbookKeys {
/* MISC */ /* MISC */
public static final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124; public static final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
public static final int TRACKER_SERVICE_NOTIFICATION_ID = 1; public static final int TRACKER_SERVICE_NOTIFICATION_ID = 1;
public static final int INFOSHEET_CONTENT_ABOUT = 1;
} }

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:scrollbars="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h1_about"
android:textAppearance="@android:style/TextAppearance.Large"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h2_recorder"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h3_version"
android:textAppearance="@android:style/TextAppearance.Small"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_bare"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_marginTop="4dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_free"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_marginTop="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_github"
android:textAppearance="@android:style/TextAppearance.Small"
android:layout_marginTop="4dp"
android:autoLink="web" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_license"
android:textAppearance="@android:style/TextAppearance.Small"
android:autoLink="web" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_osmdroid"
android:textAppearance="@android:style/TextAppearance.Small"
android:autoLink="web" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h2_permissions"
android:textAppearance="@android:style/TextAppearance.Medium"
android:layout_marginTop="8dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h3_internet"
android:textAppearance="@android:style/TextAppearance.Small"
android:textStyle="bold"
android:layout_marginTop="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_internet"
android:textAppearance="@android:style/TextAppearance.Small" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h3_network"
android:textAppearance="@android:style/TextAppearance.Small"
android:textStyle="bold"
android:layout_marginTop="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_network"
android:textAppearance="@android:style/TextAppearance.Small" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h3_location"
android:textAppearance="@android:style/TextAppearance.Small"
android:textStyle="bold"
android:layout_marginEnd="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_location"
android:textAppearance="@android:style/TextAppearance.Small" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_h3_external"
android:textAppearance="@android:style/TextAppearance.Small"
android:textStyle="bold"
android:layout_marginTop="2dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infosheet_about_p_external"
android:textAppearance="@android:style/TextAppearance.Small" />
</LinearLayout>
</ScrollView>

View file

@ -10,6 +10,7 @@
android:visible="true" android:visible="true"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_bar_about" android:id="@+id/action_bar_about"
android:orderInCategory="100" android:orderInCategory="100"

View file

@ -1,11 +1,14 @@
<resources> <resources>
<!-- activities --> <!-- activities -->
<string name="app_name">Trackbook</string> <string name="app_name">Trackbook</string>
<string name="title_activity_infosheet">Info Sheet</string>
<!-- menu entries --> <!-- menu entries -->
<string name="menu_my_location">My Location</string> <string name="menu_my_location">My Location</string>
<string name="menu_about">About</string> <string name="menu_about">About</string>
<!-- headers -->
<string name="header_about">About</string>
<!-- notification --> <!-- notification -->
<string name="notification_title_trackbook_running">Trackbook running</string> <string name="notification_title_trackbook_running">Trackbook running</string>
@ -23,7 +26,7 @@
<string name="toast_message_unable_to_start_app">Unable to start Trackbook.</string> <string name="toast_message_unable_to_start_app">Unable to start Trackbook.</string>
<string name="toast_message_location_offline">Location is turned off.</string> <string name="toast_message_location_offline">Location is turned off.</string>
<string name="toast_message_acquiring_location">Acquiring current location.</string> <string name="toast_message_acquiring_location">Acquiring current location.</string>
<string name="toast_message_my_location">My Location.</string> <string name="toast_message_my_location">Last recorded location:</string>
<!-- map markers --> <!-- map markers -->
<string name="marker_my_location_title">My current location.</string> <string name="marker_my_location_title">My current location.</string>
@ -41,5 +44,23 @@
<string name="layout_onboading_p_permission_storage">Maxime et commodi modi officiis at deleniti fugit. Magnam atque provident est et nulla incidunt. Beatae excepturi repudiandae aut facilis aperiam. Et totam qui doloremque. Asperiores est ut perspiciatis ducimus ut aut rerum minus. Voluptatem facilis qui minus corporis explicabo eos.</string> <string name="layout_onboading_p_permission_storage">Maxime et commodi modi officiis at deleniti fugit. Magnam atque provident est et nulla incidunt. Beatae excepturi repudiandae aut facilis aperiam. Et totam qui doloremque. Asperiores est ut perspiciatis ducimus ut aut rerum minus. Voluptatem facilis qui minus corporis explicabo eos.</string>
<string name="layout_onboading_button_okay">Got it!</string> <string name="layout_onboading_button_okay">Got it!</string>
<!-- infosheet about -->
<string name="infosheet_about_h1_about">About Trackbook</string>
<string name="infosheet_about_h2_recorder">Movement recorder for Android</string>
<string name="infosheet_about_h3_version">Version 0.1 ("The Great Gig in the Sky")</string>
<string name="infosheet_about_p_bare">Trackbook is a bare bones app for recording your movements. Trackbook is great for hiking, vacation or workout. Once started it displays your movements on a map. You can save your recorded tracks and share them with friends.</string>
<string name="infosheet_about_p_free">Trackbook is free software. It is published under the MIT open source license. Trackbook uses osmdroid to display the map. osmdroid is also free software. It is published under the Apache License. Want to help? You can find the code on GitHub. GitHub is also a good place to file bugs or even to contribute, if you are interested.</string>
<string name="infosheet_about_p_github">https://github.com/y20k/trackbook</string>
<string name="infosheet_about_p_osmdroid">https://github.com/osmdroid/osmdroid</string>
<string name="infosheet_about_p_license">https://opensource.org/licenses/MIT</string>
<string name="infosheet_about_h2_permissions">Which Permissions does Trackbook need?</string>
<string name="infosheet_about_h3_internet">Permission INTERNET</string>
<string name="infosheet_about_p_internet">Trackbook needs to download map data from Open Street Map servers and therefore needs access to the internet.</string>
<string name="infosheet_about_h3_network">Permission ACCESS_WIFI_STATE and ACCESS_NETWORK_STATE</string>
<string name="infosheet_about_p_network">tbd</string>
<string name="infosheet_about_h3_location">Permission ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION</string>
<string name="infosheet_about_p_location">tbd</string>
<string name="infosheet_about_h3_external">Permission WRITE_EXTERNAL_STORAGE</string>
<string name="infosheet_about_p_external">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>
</resources> </resources>