From acb13b80f034fb3b672b8621edbf590dd35d9957 Mon Sep 17 00:00:00 2001 From: Ivan Baranov Date: Wed, 13 Jul 2016 18:30:21 +0300 Subject: [PATCH] Fix naming and snackbar strings. --- .../ui/fence/beacon/BeaconFenceActivity.java | 22 +++++++--------- .../fence/location/LocationFenceActivity.java | 26 +++++++++---------- .../ui/fence/time/TimeFenceActivity.java | 24 ++++++++--------- .../user/DetectedActivityFenceActivity.java | 26 +++++++++---------- .../res/layout/activity_location_fence.xml | 2 +- 5 files changed, 49 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/com/hitherejoe/aware/ui/fence/beacon/BeaconFenceActivity.java b/app/src/main/java/com/hitherejoe/aware/ui/fence/beacon/BeaconFenceActivity.java index a080064..d3db027 100644 --- a/app/src/main/java/com/hitherejoe/aware/ui/fence/beacon/BeaconFenceActivity.java +++ b/app/src/main/java/com/hitherejoe/aware/ui/fence/beacon/BeaconFenceActivity.java @@ -41,10 +41,8 @@ public class BeaconFenceActivity extends AppCompatActivity { private static final int BEACON_ZONE_IN = 0; private static final int BEACON_ZONE_OUT = 1; - @BindView(R.id.layout_root) - RelativeLayout mLayoutHeadphoneFence; - @BindView(R.id.text_headphone_state) - TextView mHeadphoneText; + @BindView(R.id.layout_root) RelativeLayout mLayoutBeaconFence; + @BindView(R.id.text_headphone_state) TextView mBeaconText; private GoogleApiClient mGoogleApiClient; private PendingIntent mPendingIntent; @@ -115,11 +113,11 @@ private void setupGoogleApiClient() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutBeaconFence, "Fence Registered", Snackbar.LENGTH_LONG).show(); } else { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutBeaconFence, "Fence Not Registered", Snackbar.LENGTH_LONG).show(); } @@ -135,14 +133,14 @@ private void unregisterFences() { .build()).setResultCallback(new ResultCallbacks() { @Override public void onSuccess(@NonNull Status status) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutBeaconFence, "Fence Removed", Snackbar.LENGTH_LONG).show(); } @Override public void onFailure(@NonNull Status status) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutBeaconFence, "Fence Not Removed", Snackbar.LENGTH_LONG).show(); } @@ -151,10 +149,10 @@ public void onFailure(@NonNull Status status) { private void setBeaconState(int beaconState) { if (beaconState == BEACON_ZONE_IN) { - mHeadphoneText.setText(R.string.text_in_beacon_zone); + mBeaconText.setText(R.string.text_in_beacon_zone); } else { - mHeadphoneText.setText(R.string.text_not_in_beacon_zone); + mBeaconText.setText(R.string.text_not_in_beacon_zone); } } @@ -176,8 +174,8 @@ public void onReceive(Context context, Intent intent) { setBeaconState(BEACON_ZONE_OUT); break; case FenceState.UNKNOWN: - Snackbar.make(mLayoutHeadphoneFence, - "Oops, your headphone status is unknown!", + Snackbar.make(mLayoutBeaconFence, + "Oops, your beacon status is unknown!", Snackbar.LENGTH_LONG).show(); break; } diff --git a/app/src/main/java/com/hitherejoe/aware/ui/fence/location/LocationFenceActivity.java b/app/src/main/java/com/hitherejoe/aware/ui/fence/location/LocationFenceActivity.java index adac1d6..ade24ac 100644 --- a/app/src/main/java/com/hitherejoe/aware/ui/fence/location/LocationFenceActivity.java +++ b/app/src/main/java/com/hitherejoe/aware/ui/fence/location/LocationFenceActivity.java @@ -43,7 +43,7 @@ public class LocationFenceActivity extends AppCompatActivity { public static final int STATUS_EXITING = 3; @BindView(R.id.layout_location_fence) RelativeLayout mLayoutLocationFence; - @BindView(R.id.text_headphone_state) TextView mHeadphoneText; + @BindView(R.id.text_location_state) TextView mLocationText; private static final int PERMISSION_REQUEST_ACCESS_FINE_LOCATION = 940; @@ -162,19 +162,19 @@ public void onFailure(@NonNull Status status) { }); } - private void setHeadphoneState(int status) { + private void setLocationState(int status) { switch (status) { case STATUS_IN: - mHeadphoneText.setText(R.string.text_at_home); + mLocationText.setText(R.string.text_at_home); break; case STATUS_OUT: - mHeadphoneText.setText(R.string.text_not_at_home); + mLocationText.setText(R.string.text_not_at_home); break; case STATUS_ENTERING: - mHeadphoneText.setText(R.string.text_entering_home); + mLocationText.setText(R.string.text_entering_home); break; case STATUS_EXITING: - mHeadphoneText.setText(R.string.text_exiting_home); + mLocationText.setText(R.string.text_exiting_home); break; } } @@ -191,42 +191,42 @@ public void onReceive(Context context, Intent intent) { if (TextUtils.equals(fenceState.getFenceKey(), IN_LOCATION_FENCE_KEY)) { switch (fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_IN); + setLocationState(STATUS_IN); break; case FenceState.FALSE: - setHeadphoneState(STATUS_OUT); + setLocationState(STATUS_OUT); break; case FenceState.UNKNOWN: Snackbar.make(mLayoutLocationFence, - "Oops, your headphone status is unknown!", + "Oops, your location status is unknown!", Snackbar.LENGTH_LONG).show(); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), EXITING_LOCATION_FENCE_KEY)) { switch (fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_EXITING); + setLocationState(STATUS_EXITING); break; case FenceState.FALSE: break; case FenceState.UNKNOWN: Snackbar.make(mLayoutLocationFence, - "Oops, your headphone status is unknown!", + "Oops, your location status is unknown!", Snackbar.LENGTH_LONG).show(); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), ENTERING_LOCATION_FENCE_KEY)) { switch (fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_ENTERING); + setLocationState(STATUS_ENTERING); break; case FenceState.FALSE: break; case FenceState.UNKNOWN: Snackbar.make(mLayoutLocationFence, - "Oops, your headphone status is unknown!", + "Oops, your location status is unknown!", Snackbar.LENGTH_LONG).show(); break; } diff --git a/app/src/main/java/com/hitherejoe/aware/ui/fence/time/TimeFenceActivity.java b/app/src/main/java/com/hitherejoe/aware/ui/fence/time/TimeFenceActivity.java index 9510941..a406d25 100644 --- a/app/src/main/java/com/hitherejoe/aware/ui/fence/time/TimeFenceActivity.java +++ b/app/src/main/java/com/hitherejoe/aware/ui/fence/time/TimeFenceActivity.java @@ -36,8 +36,8 @@ public class TimeFenceActivity extends AppCompatActivity { private static final int TIME_WITHIN = 0; private static final int TIME_NOT_IN = 1; - @BindView(R.id.layout_root) RelativeLayout mLayoutHeadphoneFence; - @BindView(R.id.text_headphone_state) TextView mHeadphoneText; + @BindView(R.id.layout_root) RelativeLayout mLayoutTimeFence; + @BindView(R.id.text_headphone_state) TextView mTimeText; private GoogleApiClient mGoogleApiClient; private PendingIntent mPendingIntent; @@ -79,22 +79,22 @@ protected void onStop() { } private void setupFence() { - AwarenessFence headphoneFence = TimeFence.inDailyInterval(TimeZone.getDefault(), + AwarenessFence timeFence = TimeFence.inDailyInterval(TimeZone.getDefault(), 0L, 24L * 60L * 60L * 1000L); Awareness.FenceApi.updateFences( mGoogleApiClient, new FenceUpdateRequest.Builder() - .addFence(TIME_FENCE_KEY, headphoneFence, mPendingIntent) + .addFence(TIME_FENCE_KEY, timeFence, mPendingIntent) .build()) .setResultCallback(new ResultCallback() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutTimeFence, "Fence Registered", Snackbar.LENGTH_LONG).show(); } else { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutTimeFence, "Fence Not Registered", Snackbar.LENGTH_LONG).show(); } @@ -110,14 +110,14 @@ private void unregisterFence() { .build()).setResultCallback(new ResultCallbacks() { @Override public void onSuccess(@NonNull Status status) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutTimeFence, "Fence Removed", Snackbar.LENGTH_LONG).show(); } @Override public void onFailure(@NonNull Status status) { - Snackbar.make(mLayoutHeadphoneFence, + Snackbar.make(mLayoutTimeFence, "Fence Not Removed", Snackbar.LENGTH_LONG).show(); } @@ -126,9 +126,9 @@ public void onFailure(@NonNull Status status) { private void setTimeState(int timeState) { if (timeState == TIME_WITHIN) { - mHeadphoneText.setText(R.string.text_that_time); + mTimeText.setText(R.string.text_that_time); } else { - mHeadphoneText.setText(R.string.text_not_that_time); + mTimeText.setText(R.string.text_not_that_time); } } @@ -150,8 +150,8 @@ public void onReceive(Context context, Intent intent) { setTimeState(TIME_NOT_IN); break; case FenceState.UNKNOWN: - Snackbar.make(mLayoutHeadphoneFence, - "Oops, your headphone status is unknown!", + Snackbar.make(mLayoutTimeFence, + "Oops, your time status is unknown!", Snackbar.LENGTH_LONG).show(); break; } diff --git a/app/src/main/java/com/hitherejoe/aware/ui/fence/user/DetectedActivityFenceActivity.java b/app/src/main/java/com/hitherejoe/aware/ui/fence/user/DetectedActivityFenceActivity.java index 1ceee3d..66d3085 100644 --- a/app/src/main/java/com/hitherejoe/aware/ui/fence/user/DetectedActivityFenceActivity.java +++ b/app/src/main/java/com/hitherejoe/aware/ui/fence/user/DetectedActivityFenceActivity.java @@ -84,15 +84,15 @@ protected void onStop() { } private void registerFences() { - AwarenessFence headphoneFence = DetectedActivityFence.during(DetectedActivity.WALKING); - AwarenessFence startWalking = DetectedActivityFence.starting(DetectedActivity.WALKING); + AwarenessFence duringWalkingFence = DetectedActivityFence.during(DetectedActivity.WALKING); + AwarenessFence startWalkingFence = DetectedActivityFence.starting(DetectedActivity.WALKING); AwarenessFence stopWalkingFence = DetectedActivityFence.stopping(DetectedActivity.WALKING); Awareness.FenceApi.updateFences( mGoogleApiClient, new FenceUpdateRequest.Builder() - .addFence(DURING_FENCE_KEY, headphoneFence, mPendingIntent) - .addFence(STARTING_FENCE_KEY, startWalking, mPendingIntent) + .addFence(DURING_FENCE_KEY, duringWalkingFence, mPendingIntent) + .addFence(STARTING_FENCE_KEY, startWalkingFence, mPendingIntent) .addFence(STOPPING_FENCE_KEY, stopWalkingFence, mPendingIntent) .build()) .setResultCallback(new ResultCallback() { @@ -135,8 +135,8 @@ public void onFailure(@NonNull Status status) { }); } - private void setHeadphoneState(int headphoneState) { - switch (headphoneState) { + private void setUserState(int userState) { + switch (userState) { case STATUS_DEFAULT: mDetectedActivityText.setText(R.string.text_still); @@ -191,40 +191,40 @@ public void onReceive(Context context, Intent intent) { if (TextUtils.equals(fenceState.getFenceKey(), DURING_FENCE_KEY)) { switch(fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_DURING); + setUserState(STATUS_DURING); break; case FenceState.FALSE: - setHeadphoneState(STATUS_DEFAULT); + setUserState(STATUS_DEFAULT); break; case FenceState.UNKNOWN: Snackbar.make(mLayoutDetectedActivityFence, - "Oops, your headphone status is unknown!", + "Oops, your user status is unknown!", Snackbar.LENGTH_LONG).show(); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), STARTING_FENCE_KEY)) { switch(fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_STARTING); + setUserState(STATUS_STARTING); break; case FenceState.FALSE: break; case FenceState.UNKNOWN: Snackbar.make(mLayoutDetectedActivityFence, - "Oops, your headphone status is unknown!", + "Oops, your user status is unknown!", Snackbar.LENGTH_LONG).show(); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), STOPPING_FENCE_KEY)) { switch(fenceState.getCurrentState()) { case FenceState.TRUE: - setHeadphoneState(STATUS_STOPPING); + setUserState(STATUS_STOPPING); break; case FenceState.FALSE: break; case FenceState.UNKNOWN: Snackbar.make(mLayoutDetectedActivityFence, - "Oops, your headphone status is unknown!", + "Oops, your user status is unknown!", Snackbar.LENGTH_LONG).show(); break; } diff --git a/app/src/main/res/layout/activity_location_fence.xml b/app/src/main/res/layout/activity_location_fence.xml index 798c33c..75f069b 100644 --- a/app/src/main/res/layout/activity_location_fence.xml +++ b/app/src/main/res/layout/activity_location_fence.xml @@ -6,7 +6,7 @@ android:orientation="vertical">