diff --git a/app/src/main/java/org/y20k/trackbook/MainActivity.java b/app/src/main/java/org/y20k/trackbook/MainActivity.java index f8b07ed..e896bd9 100644 --- a/app/src/main/java/org/y20k/trackbook/MainActivity.java +++ b/app/src/main/java/org/y20k/trackbook/MainActivity.java @@ -39,7 +39,7 @@ import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.AppCompatActivity; @@ -141,7 +141,6 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys { mTrackingStoppedReceiver = createTrackingStoppedReceiver(); IntentFilter trackingStoppedIntentFilter = new IntentFilter(ACTION_TRACKING_STOPPED); LocalBroadcastManager.getInstance(this).registerReceiver(mTrackingStoppedReceiver, trackingStoppedIntentFilter); - } @@ -642,6 +641,18 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys { break; + case ACTION_CLEAR: + // show map fragment + mBottomNavigationView.setSelectedItemId(R.id.navigation_map); + + // show clear dialog + handleClearButtonClick(); + + // clear intent + intent.setAction(ACTION_DEFAULT); + + break; + default: break; } @@ -715,12 +726,43 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys { } +// public class SectionsPagerAdapter extends FragmentPagerAdapter { +// +// public SectionsPagerAdapter(FragmentManager fm) { +// super(fm); +// } +// +// @Override +// public Fragment getItem(int position) { +// // getItem is called to instantiate the fragment for the given page. +// switch (position) { +// case FRAGMENT_ID_MAP: +// return new MainActivityMapFragment(); +// case FRAGMENT_ID_TRACKS: +// return new MainActivityTrackFragment(); +// } +// return null; +// } +// +// @Override +// public int getCount() { +// return 2; +// } +// +// public Fragment getFragment(int pos) { +// return getItem(pos); +// } +// +// } + + + /** * Inner class: SectionsPagerAdapter that returns a fragment corresponding to one of the tabs. * see also: https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html * and: http://www.truiton.com/2015/12/android-activity-fragment-communication/ */ - public class SectionsPagerAdapter extends FragmentPagerAdapter { + public class SectionsPagerAdapter extends FragmentStatePagerAdapter { private final SparseArray> instantiatedFragments = new SparseArray<>(); @@ -742,7 +784,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys { @Override public int getCount() { - // Show 2 total pages. + // show 2 total pages. return 2; } diff --git a/app/src/main/java/org/y20k/trackbook/helpers/NotificationHelper.java b/app/src/main/java/org/y20k/trackbook/helpers/NotificationHelper.java index acef37e..d00b8a7 100644 --- a/app/src/main/java/org/y20k/trackbook/helpers/NotificationHelper.java +++ b/app/src/main/java/org/y20k/trackbook/helpers/NotificationHelper.java @@ -54,7 +54,7 @@ public final class NotificationHelper implements TrackbookKeys { // build context text for notification builder String contentText = getContextString(context, track); - // ACTION: NOTIFICATION TAP + // ACTION: NOTIFICATION TAP & BUTTON SHOW Intent tapActionIntent = new Intent(context, MainActivity.class); tapActionIntent.setAction(ACTION_SHOW_MAP); tapActionIntent.putExtra(EXTRA_TRACK, track); @@ -70,7 +70,13 @@ public final class NotificationHelper implements TrackbookKeys { Intent stopActionIntent = new Intent(context, TrackerService.class); stopActionIntent.setAction(ACTION_STOP); // pending intent wrapper for notification stop action - PendingIntent stopActionPendingIntent = PendingIntent.getService(context, 12, stopActionIntent, 0); + PendingIntent stopActionPendingIntent = PendingIntent.getService(context, 14, stopActionIntent, 0); + + // ACTION: NOTIFICATION BUTTON RESUME + Intent resumeActionIntent = new Intent(context, TrackerService.class); + resumeActionIntent.setAction(ACTION_RESUME); + // pending intent wrapper for notification resume action + PendingIntent resuneActionPendingIntent = PendingIntent.getService(context, 16, resumeActionIntent, 0); // construct notification in builder builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); @@ -79,10 +85,12 @@ public final class NotificationHelper implements TrackbookKeys { builder.setSmallIcon(R.drawable.ic_notification_small_24dp); builder.setLargeIcon(getNotificationIconLarge(context, tracking)); if (tracking) { - builder.addAction(R.drawable.ic_stop_white_36dp, context.getString(R.string.notification_stop), stopActionPendingIntent); + builder.addAction(R.drawable.ic_stop_white_24dp, context.getString(R.string.notification_stop), stopActionPendingIntent); builder.setContentTitle(context.getString(R.string.notification_title_trackbook_running)); builder.setContentText(getContextString(context, track)); } else { + builder.addAction(R.drawable.ic_fiber_manual_record_white_24dp, context.getString(R.string.notification_resume), resuneActionPendingIntent); + builder.addAction(R.drawable.ic_compass_needle_white_24dp, context.getString(R.string.notification_show), tapActionPendingIntent); builder.setContentTitle(context.getString(R.string.notification_title_trackbook_not_running)); builder.setContentText(getContextString(context, track)); } diff --git a/app/src/main/java/org/y20k/trackbook/helpers/TrackbookKeys.java b/app/src/main/java/org/y20k/trackbook/helpers/TrackbookKeys.java index c2d41bd..65115de 100644 --- a/app/src/main/java/org/y20k/trackbook/helpers/TrackbookKeys.java +++ b/app/src/main/java/org/y20k/trackbook/helpers/TrackbookKeys.java @@ -27,6 +27,8 @@ public interface TrackbookKeys { String ACTION_STOP = "org.y20k.trackbook.action.STOP"; String ACTION_DISMISS = "org.y20k.transistor.action.DISMISS"; String ACTION_RESUME = "org.y20k.transistor.action.RESUME"; + String ACTION_CLEAR = "org.y20k.transistor.action.CLEAR"; + String ACTION_SAVE = "org.y20k.transistor.action.SAVE"; String ACTION_DEFAULT = "DEFAULT"; String ACTION_SHOW_MAP = "SHOW_MAP"; String ACTION_TRACK_UPDATED = "TRACK_UPDATED"; diff --git a/app/src/main/res/drawable/ic_compass_needle_white_24dp.xml b/app/src/main/res/drawable/ic_compass_needle_white_24dp.xml new file mode 100644 index 0000000..f7dddd7 --- /dev/null +++ b/app/src/main/res/drawable/ic_compass_needle_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_stop_white_36dp.xml b/app/src/main/res/drawable/ic_stop_white_24dp.xml similarity index 54% rename from app/src/main/res/drawable/ic_stop_white_36dp.xml rename to app/src/main/res/drawable/ic_stop_white_24dp.xml index 25d2db4..4b6410f 100644 --- a/app/src/main/res/drawable/ic_stop_white_36dp.xml +++ b/app/src/main/res/drawable/ic_stop_white_24dp.xml @@ -1,10 +1,9 @@ - + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> - \ No newline at end of file + diff --git a/app/src/main/res/layout/activity_main_onboarding.xml b/app/src/main/res/layout/activity_main_onboarding.xml index f5ad5bc..e494606 100644 --- a/app/src/main/res/layout/activity_main_onboarding.xml +++ b/app/src/main/res/layout/activity_main_onboarding.xml @@ -1,6 +1,7 @@ @@ -30,13 +31,13 @@ android:layout_marginTop="@dimen/activity_vertical_margin" > + android:contentDescription="@string/layout_onboarding_description_app_icon" + app:srcCompat="@mipmap/ic_launcher" /> + android:contentDescription="@string/layout_onboarding_description_app_icon" + app:srcCompat="@mipmap/ic_launcher" /> Trackbook ist inaktiv Trackbook wird ausgeführt Stopp + Zurücksetzen + Speichernn + Fortsetzen + Show Dauer Entfernung Status der Aufzeichnung diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index e244a0c..b180819 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -11,6 +11,10 @@ Trackbook aktif Trackbook tidak aktif Berhenti + Clear + Save + Resume + Show Durasi Jarak Movement Recording State @@ -24,7 +28,7 @@ Clear - Save and Clear + Save Resume diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b8dc792..4865228 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -11,6 +11,10 @@ Trackbook in esecuzione Trackbook non in esecuzione Stop + Cancella + Salva e ripristina la mappa + Resume + Show Durata Distanza Stato registrazione diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 48d0295..4ee8ed9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -11,6 +11,10 @@ Trackbook 実行中 Trackbook は実行していません 停止 + クリア + 保存してクリア + Resume + Show 期間 距離 移動記録状態 diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 9ad08d7..b1d3f16 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -11,6 +11,10 @@ Trackbook kjører Trackbook kjører ikke Stopp + Tøm + Lagre og tøm + Fortsett + Show Varighet Distanse Bevegelsesopptakstilstand diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 3949a2b..6d59ba7 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -11,6 +11,10 @@ Trackbook is actief Trackbook is niet actief Stoppen + Wissen + Opslaan en wissen + Resume + Show Duur Afstand Movement Recording State diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0c41b9d..004857d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,6 +11,10 @@ Trackbook running Trackbook not running Stop + Clear + Save + Resume + Show Duration Distance Movement Recording State