-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
411 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
app/src/main/java/com/teester/whatsnearby/main/DebugPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.teester.whatsnearby.main; | ||
|
||
import com.teester.whatsnearby.R; | ||
import com.teester.whatsnearby.data.source.SourceContract; | ||
|
||
public class DebugPresenter implements MainActivityContract.DebugPresenter { | ||
|
||
private MainActivityContract.DebugView view; | ||
private SourceContract.Preferences preferences; | ||
|
||
public DebugPresenter(MainActivityContract.DebugView view, SourceContract.Preferences preferences) { | ||
this.view = view; | ||
this.preferences = preferences; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
|
||
} | ||
|
||
@Override | ||
public void destroy() { | ||
|
||
} | ||
|
||
@Override | ||
public void getDetails() { | ||
getLastQuery(); | ||
getCheckDistance(); | ||
getLastNotificationTime(); | ||
getLastQueryTime(); | ||
getQueryDistance(); | ||
getAccuracy(); | ||
} | ||
|
||
private void getQueryDistance() { | ||
float preference = preferences.getFloatPreference("distance_to_last_location"); | ||
String querydistance = String.format("%.0fm", preference); | ||
int color = R.color.green; | ||
if (preference < 20) { | ||
color = R.color.red; | ||
} | ||
view.setQuerydistance(querydistance, color); | ||
} | ||
|
||
private void getLastQueryTime() { | ||
long lastQueryTime = preferences.getLongPreference("last_query_time"); | ||
long ago = (System.currentTimeMillis() - lastQueryTime) / 60000; | ||
String lastQueryTime2 = String.format("%d mins ago", ago); | ||
int color = R.color.green; | ||
if (ago < 60) { | ||
color = R.color.red; | ||
} | ||
view.setLastQueryTime(lastQueryTime2, color); | ||
} | ||
|
||
private void getLastNotificationTime() { | ||
long lastNotificationTime = preferences.getLongPreference("last_notification_time"); | ||
long ago = (System.currentTimeMillis() - lastNotificationTime) / 60000; | ||
int color = R.color.green; | ||
if (ago < 60) { | ||
color = R.color.red; | ||
} | ||
String lastNotificationTimeString = String.format("%d mins ago", ago); | ||
view.setLastNotificationTime(lastNotificationTimeString, color); | ||
} | ||
|
||
private void getCheckDistance() { | ||
float preference = preferences.getFloatPreference("distance_to_last_query"); | ||
String checkdistance = String.format("%.0fm", preference); | ||
int color = R.color.green; | ||
if (preference > 20) { | ||
color = R.color.red; | ||
} | ||
view.setCheckdistance(checkdistance, color); | ||
} | ||
|
||
private void getLastQuery() { | ||
String lastQuery = preferences.getStringPreference("last_query"); | ||
view.setLastQuery(lastQuery); | ||
} | ||
|
||
private void getAccuracy() { | ||
float accuracy = preferences.getFloatPreference("location_accuracy"); | ||
String accuracyString = String.format("%.0fm", accuracy); | ||
int accuracyColor = R.color.green; | ||
if (accuracy > 50) { | ||
accuracyColor = R.color.red; | ||
} | ||
view.setAccuracy(accuracyString, accuracyColor); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
app/src/main/java/com/teester/whatsnearby/main/FragmentDebug.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.teester.whatsnearby.main; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.teester.whatsnearby.R; | ||
import com.teester.whatsnearby.data.source.Preferences; | ||
import com.teester.whatsnearby.data.source.SourceContract; | ||
|
||
public class FragmentDebug extends Fragment implements MainActivityContract.DebugView { | ||
|
||
private TextView lastQueryTime; | ||
private TextView lastNotificationTime; | ||
private TextView lastQuery; | ||
private TextView accuracy; | ||
private TextView querydistance; | ||
private TextView checkdistance; | ||
private MainActivityContract.DebugPresenter debugPresenter; | ||
private SourceContract.Preferences preferences; | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
SourceContract.Preferences preferences = new Preferences(getContext()); | ||
debugPresenter = new DebugPresenter(this, preferences); | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
super.onCreateView(inflater, container, savedInstanceState); | ||
return inflater.inflate(R.layout.fragment_debug, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
this.lastQueryTime = view.findViewById(R.id.textView6); | ||
this.lastNotificationTime = view.findViewById(R.id.textView7); | ||
this.lastQuery = view.findViewById(R.id.textView8); | ||
this.accuracy = view.findViewById(R.id.textView16); | ||
this.querydistance = view.findViewById(R.id.textView14); | ||
this.checkdistance = view.findViewById(R.id.textView15); | ||
|
||
debugPresenter.getDetails(); | ||
} | ||
|
||
@Override | ||
public void setLastQueryTime(String time, int color) { | ||
this.lastQueryTime.setText(time); | ||
this.lastQueryTime.setTextColor(getResources().getColor(color)); | ||
} | ||
|
||
@Override | ||
public void setLastNotificationTime(String notificationTime, int color) { | ||
this.lastNotificationTime.setText(notificationTime); | ||
this.lastNotificationTime.setTextColor(getResources().getColor(color)); | ||
} | ||
|
||
@Override | ||
public void setLastQuery(String queryTime) { | ||
this.lastQuery.setText(queryTime); | ||
} | ||
|
||
@Override | ||
public void setAccuracy(String accuracy, int color) { | ||
this.accuracy.setText(accuracy); | ||
this.accuracy.setTextColor(getResources().getColor(color)); | ||
} | ||
|
||
@Override | ||
public void setQuerydistance(String querydistance, int color) { | ||
this.querydistance.setText(querydistance); | ||
this.querydistance.setTextColor(getResources().getColor(color)); | ||
} | ||
|
||
@Override | ||
public void setCheckdistance(String queryTimeSince, int color) { | ||
this.checkdistance.setText(queryTimeSince); | ||
this.checkdistance.setTextColor(getResources().getColor(color)); | ||
} | ||
|
||
@Override | ||
public void setPresenter(MainActivityContract.DebugPresenter presenter) { | ||
|
||
} | ||
} |
Oops, something went wrong.