Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #89 from divacky/master
Browse files Browse the repository at this point in the history
Clocks movement for proximity
  • Loading branch information
jilleb authored Mar 2, 2020
2 parents 8b84206 + e34ab38 commit 3db26d7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
46 changes: 34 additions & 12 deletions app/src/main/java/com/mqbcoding/stats/DashboardFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
Expand Down Expand Up @@ -114,6 +115,8 @@ public class DashboardFragment extends CarFragment {
//value displayed on graphlayout
private TextView mGraphValueLeft, mGraphValueCenter, mGraphValueRight;
private View rootView;
private View mDashboard_gaudes, mDashboard_consumption;

private String androidClockFormat = "hh:mm a";
int dashboardNum=1;
private String googleGeocodeLocationStr = null;
Expand Down Expand Up @@ -333,6 +336,9 @@ public void run() {

private void setupViews(View rootView) {
//layouts/constrains:
mDashboard_gaudes = rootView.findViewById(R.id.include);
mDashboard_consumption = rootView.findViewById(R.id.include_consumption);

mConstraintClockLeft = rootView.findViewById(R.id.constraintClockLeft);
mConstraintClockCenter = rootView.findViewById(R.id.constraintClockCenter);
mConstraintClockRight = rootView.findViewById(R.id.constraintClockRight);
Expand Down Expand Up @@ -559,7 +565,6 @@ private void onPreferencesChangeHandler() {
mBtnNext.setVisibility(View.VISIBLE);
mBtnPrev.setVisibility(View.VISIBLE);
mtextTitleMain.setVisibility(View.VISIBLE);
mtextTitleMain.setTextColor(Color.WHITE);
}

// Load this only on first run, then leave it alone
Expand Down Expand Up @@ -2276,9 +2281,9 @@ private void updateClock(String query, Speedometer clock, RaySpeedometer visray,

// get the speed from the clock and have the high-visibility rays move to this speed as well

boolean noNewData = clockValue == null;
boolean noNewData = clockValue==null;
if (noNewData)
clockValue = oldValue;
clockValue=oldValue;


//TODO: Updates with a non fixed period could lead to strange graphs
Expand All @@ -2289,7 +2294,7 @@ private void updateClock(String query, Speedometer clock, RaySpeedometer visray,

// don't update when there's nothing to update
// check if old value and new value (rounded to 1 decimal placed) are equal
if (noNewData || Math.round(clockValue * 10) == Math.round(oldValue * 10)) {
if (noNewData || Math.round(clockValue*10) == Math.round(oldValue*10)) {
return;
}

Expand Down Expand Up @@ -2376,39 +2381,57 @@ private void updateTitle() {

//mProximity = true;
if (mProximity != null && mProximity && proximityOn) {
ObjectAnimator animation;
if (dashboardNum<4) animation = ObjectAnimator.ofFloat(mDashboard_gaudes, "y", 90);
else animation = ObjectAnimator.ofFloat(mDashboard_consumption, "y", 90);

animation.setDuration(200);
animation.start();
mTitleClockLeft.setText(mLabelClockL);
mTitleClockCenter.setText(mLabelClockC);
mTitleClockRight.setText(mLabelClockR);
mBtnNext.setVisibility(View.VISIBLE);
mBtnPrev.setVisibility(View.VISIBLE);
//mtextTitleMain.setVisibility(View.VISIBLE);
mtextTitleMain.setTextColor(Color.WHITE);
mtextTitleMain.setVisibility(View.VISIBLE);
// mtextTitleMain.setTextColor(Color.WHITE);
mTitleConsumptionRight.setVisibility(View.VISIBLE);
mTitleConsumptionLeft.setVisibility(View.VISIBLE);
mTitleConsumptionCenter.setVisibility(View.VISIBLE);


} else if (!proximityOn) {
ObjectAnimator animation;
if (dashboardNum<4) animation = ObjectAnimator.ofFloat(mDashboard_gaudes, "y", 90);
else animation = ObjectAnimator.ofFloat(mDashboard_consumption, "y", 90);
animation.setDuration(200);
animation.start();
mTitleClockLeft.setText("");
mTitleClockCenter.setText("");
mTitleClockRight.setText("");
mBtnNext.setVisibility(View.VISIBLE);
mBtnPrev.setVisibility(View.VISIBLE);
//mtextTitleMain.setVisibility(View.VISIBLE);
mtextTitleMain.setTextColor(Color.WHITE);
mtextTitleMain.setVisibility(View.VISIBLE);
//mtextTitleMain.setTextColor(Color.WHITE);
mTitleConsumptionRight.setVisibility(View.INVISIBLE);
mTitleConsumptionLeft.setVisibility(View.INVISIBLE);
mTitleConsumptionCenter.setVisibility(View.INVISIBLE);

} else {
mTitleClockLeft.setText("");
mTitleClockCenter.setText("");
mTitleClockRight.setText("");
mBtnNext.setVisibility(View.INVISIBLE);
mBtnPrev.setVisibility(View.INVISIBLE);
//mtextTitleMain.setVisibility(View.VISIBLE);
mtextTitleMain.setTextColor(Color.DKGRAY);
mtextTitleMain.setVisibility(View.INVISIBLE);
//mtextTitleMain.setTextColor(Color.DKGRAY);
mTitleConsumptionRight.setVisibility(View.INVISIBLE);
mTitleConsumptionLeft.setVisibility(View.INVISIBLE);
mTitleConsumptionCenter.setVisibility(View.INVISIBLE);

ObjectAnimator animation;
if (dashboardNum<4) animation = ObjectAnimator.ofFloat(mDashboard_gaudes, "y", 45);
else animation = ObjectAnimator.ofFloat(mDashboard_consumption, "y", 45);
animation.setDuration(200);
animation.start();
}

String currentTime = getTime();
Expand All @@ -2420,7 +2443,6 @@ private void updateTitle() {
// Display location in left side of Title bar
if (showStreetName) {
String leftTitle="";
Log.v(TAG,"SourceLocation: "+sourceLocation+"!!!");
if (sourceLocation.equals("Geocoding")) {
leftTitle = googleGeocodeLocationStr;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void run() {
int lastAltitude = 0;
try {
lastLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
lastAltitude = (int) mLastDecodedLocation.getAltitude();
lastAltitude = (int) lastLocation.getAltitude();
Log.d(TAG,"Received location: " + lastLocation);
Log.d(TAG,"Received Altitude: " + lastAltitude);
} catch (SecurityException ex) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
layout="@layout/layout_dashboard_consumption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:layout_marginTop="90dp"
android:background="#00000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
Expand Down

0 comments on commit 3db26d7

Please sign in to comment.