From 25343c84b6fc3cbd1f7f51bb3722e62cb7ae3acf Mon Sep 17 00:00:00 2001 From: errol pais Date: Sat, 11 Nov 2017 17:10:48 -0800 Subject: [PATCH 01/10] Created UploadsCounter to count answers not uploaded Seperated logic out of Answers Counter to represent answers to quests that haven't been uploaded. --- .../streetcomplete/ApplicationComponent.java | 2 + .../streetcomplete/MainActivity.java | 23 +++++-- .../statistics/AnswersCounter.java | 22 +------ .../statistics/UploadsCounter.java | 62 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 14 ++++- 5 files changed, 95 insertions(+), 28 deletions(-) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java diff --git a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java index b85c279e96..c8e9c6c730 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java +++ b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java @@ -19,6 +19,7 @@ import de.westnordost.streetcomplete.settings.SettingsFragment; import de.westnordost.streetcomplete.settings.QuestSelectionFragment; import de.westnordost.streetcomplete.statistics.AnswersCounter; +import de.westnordost.streetcomplete.statistics.UploadsCounter; import de.westnordost.streetcomplete.tangram.MapControlsFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; import de.westnordost.streetcomplete.util.SerializedSavedState; @@ -41,6 +42,7 @@ public interface ApplicationComponent void inject(SettingsActivity settingsActivity); void inject(AnswersCounter answersCounter); + void inject(UploadsCounter uploadsCounter); void inject(AddOpeningHoursForm addOpeningHoursForm); void inject(AddRoadNameForm addRoadNameForm); diff --git a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java index 4be89aaeeb..7bbb4c69e3 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java +++ b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java @@ -68,6 +68,7 @@ import de.westnordost.streetcomplete.settings.SettingsActivity; import de.westnordost.streetcomplete.statistics.AnswersCounter; import de.westnordost.streetcomplete.location.LocationState; +import de.westnordost.streetcomplete.statistics.UploadsCounter; import de.westnordost.streetcomplete.tangram.MapFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; import de.westnordost.streetcomplete.tools.CrashReportExceptionHandler; @@ -106,6 +107,7 @@ public class MainActivity extends AppCompatActivity implements private ProgressBar progressBar; private AnswersCounter answersCounter; + private UploadsCounter uploadsCounter; private float mapRotation, mapTilt; @@ -180,6 +182,7 @@ public void onServiceDisconnected(ComponentName className) questController.onCreate(); answersCounter = toolbar.findViewById(R.id.answersCounter); + uploadsCounter = toolbar.findViewById(R.id.uploadsCounter); questSource.onCreate(this); @@ -207,6 +210,7 @@ public void onServiceDisconnected(ComponentName className) super.onStart(); answersCounter.update(); + uploadsCounter.update(); registerReceiver(locationAvailabilityReceiver, LocationUtil.createLocationAvailabilityIntentFilter()); @@ -298,8 +302,10 @@ private void confirmUndo(final OsmQuest quest) .setView(inner) .setPositiveButton(R.string.undo_confirm_positive, (dialog, which) -> { - questController.undoOsmQuest(quest); - answersCounter.undidQuest(quest.getChangesSource()); + + questController.undoOsmQuest(quest); + uploadsCounter.undidQuest(quest.getChangesSource()); + }) .setNegativeButton(R.string.undo_confirm_negative, null) .show(); @@ -473,7 +479,10 @@ else if(e instanceof OsmAuthorizationException) @AnyThread @Override public void onFinished() { - runOnUiThread(() -> answersCounter.update()); + runOnUiThread(() -> { + answersCounter.update(); + uploadsCounter.update(); + }); } }; @@ -585,9 +594,11 @@ else if(e instanceof OsmAuthorizationException) Location[] locations = new Location[]{ lastLocation, mapFragment.getDisplayedLocation() }; questSource.findSource(questId, group, locations, source -> { - closeQuestDetailsFor(questId, group); - answersCounter.answeredQuest(source); - questController.solveQuest(questId, group, answer, source); + + closeQuestDetailsFor(questId, group); + uploadsCounter.answeredQuest(source); + questController.solveQuest(questId, group, answer, source); + }); } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java index f5e429c9f6..5b550a9e2c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java @@ -7,16 +7,12 @@ import javax.inject.Inject; import de.westnordost.streetcomplete.Injector; -import de.westnordost.streetcomplete.data.QuestStatus; -import de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao; import de.westnordost.streetcomplete.data.statistics.QuestStatisticsDao; public class AnswersCounter extends android.support.v7.widget.AppCompatTextView { @Inject QuestStatisticsDao questStatisticsDB; - @Inject OsmQuestDao questDB; - private int answeredQuests; private int solvedQuests; public AnswersCounter(Context context) @@ -42,25 +38,12 @@ private void init() Injector.instance.getApplicationComponent().inject(this); } - public void answeredQuest(String source) - { - answeredQuests++; - updateText(); - } - - public void undidQuest(String source) - { - answeredQuests--; - updateText(); - } - public void update() { new AsyncTask() { @Override protected Void doInBackground(Void... params) { - answeredQuests = questDB.getCount(null, QuestStatus.ANSWERED); solvedQuests = questStatisticsDB.getTotalAmount(); return null; } @@ -75,10 +58,7 @@ public void update() private void updateText() { String text = "" + solvedQuests; - if(answeredQuests < 0) text += " (" + answeredQuests + ")"; - else if(answeredQuests > 0) text += " (+" + answeredQuests + ")"; - - // min ems = number of digits in solved quests plus the "(+XX)" for answered quests + // min ems = number of digits in solved quests setMinEms((int) Math.floor(Math.log10(solvedQuests)) + 4 + 2); setText(text); } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java new file mode 100644 index 0000000000..cce0014478 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java @@ -0,0 +1,62 @@ +package de.westnordost.streetcomplete.statistics; + +import android.content.Context; +import android.os.AsyncTask; +import android.util.AttributeSet; + +import javax.inject.Inject; + +import de.westnordost.streetcomplete.Injector; +import de.westnordost.streetcomplete.data.QuestStatus; +import de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao; + +public class UploadsCounter extends android.support.v7.widget.AppCompatTextView { + + @Inject + OsmQuestDao questDB; + + private int answeredQuests; + + public UploadsCounter(Context context, AttributeSet attrs) { + super(context, attrs); + Injector.instance.getApplicationComponent().inject(this); + } + + public void answeredQuest(String source) { + answeredQuests++; + updateText(); + } + + public void undidQuest(String source) { + answeredQuests--; + updateText(); + } + + public void update() { + new AsyncTask() { + @Override + protected Void doInBackground(Void... params) { + answeredQuests = questDB.getCount(null, QuestStatus.ANSWERED); + return null; + } + + @Override + protected void onPostExecute(Void result) { + updateText(); + } + }.execute(); + } + + private void updateText() { + String text = ""; + if (answeredQuests < 0) { + text += answeredQuests; + } else if (answeredQuests > 0) { + text += "+" + answeredQuests; + } + + // min ems = number of digits in "(+XX)" for answered quests + setMinEms(4 + 2); + setText(text); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 8f064f97df..a51e6f153c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -46,6 +46,18 @@ android:drawablePadding="2dp" /> + + - + \ No newline at end of file From 55ee8996f6ff85fcf79a26c53a5cc8459d8051c7 Mon Sep 17 00:00:00 2001 From: errol pais Date: Fri, 29 Dec 2017 15:57:44 -0600 Subject: [PATCH 02/10] Changes the upload answered quests counter to be the file upload icon --- app/src/main/res/drawable/ic_file_upload_24dp.xml | 9 +++++++++ app/src/main/res/layout/activity_main.xml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/ic_file_upload_24dp.xml diff --git a/app/src/main/res/drawable/ic_file_upload_24dp.xml b/app/src/main/res/drawable/ic_file_upload_24dp.xml new file mode 100644 index 0000000000..f945022ded --- /dev/null +++ b/app/src/main/res/drawable/ic_file_upload_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a51e6f153c..21c22e26bc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -42,7 +42,7 @@ android:paddingEnd="8dp" android:paddingStart="8dp" android:gravity="center_vertical" - android:drawableStart="@drawable/ic_star_white_24dp" + android:drawableStart="@drawable/ic_file_upload_24dp" android:drawablePadding="2dp" /> From f3534b8e6599e63af634adfe52a3b6c43386b7fb Mon Sep 17 00:00:00 2001 From: errol pais Date: Sun, 12 Nov 2017 21:05:06 -0800 Subject: [PATCH 03/10] Removes ems setting and padding for Answer and Upload Counters --- .../statistics/AnswersCounter.java | 2 -- .../statistics/UploadsCounter.java | 4 +--- app/src/main/res/layout/activity_main.xml | 23 ++++++++----------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java index 5b550a9e2c..b1598cd274 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java @@ -58,8 +58,6 @@ public void update() private void updateText() { String text = "" + solvedQuests; - // min ems = number of digits in solved quests - setMinEms((int) Math.floor(Math.log10(solvedQuests)) + 4 + 2); setText(text); } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java index cce0014478..7d3318ed3e 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java @@ -48,15 +48,13 @@ protected void onPostExecute(Void result) { } private void updateText() { - String text = ""; + String text = "0"; if (answeredQuests < 0) { text += answeredQuests; } else if (answeredQuests > 0) { text += "+" + answeredQuests; } - // min ems = number of digits in "(+XX)" for answered quests - setMinEms(4 + 2); setText(text); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 21c22e26bc..5778245bc7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,30 +33,25 @@ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:elevation="4dp"> - - + android:drawableStart="@drawable/ic_star_white_24dp" + android:drawablePadding="2dp" + /> From 20fcb6dca9293799d802da2a00a237d83ae29d0f Mon Sep 17 00:00:00 2001 From: errol pais Date: Sun, 12 Nov 2017 21:28:28 -0800 Subject: [PATCH 04/10] Sets UploadCounter text to number of answered quests --- .../streetcomplete/statistics/AnswersCounter.java | 3 +-- .../streetcomplete/statistics/UploadsCounter.java | 9 +-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java index b1598cd274..de0ad4101f 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java @@ -57,7 +57,6 @@ public void update() private void updateText() { - String text = "" + solvedQuests; - setText(text); + setText(String.valueOf(solvedQuests)); } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java index 7d3318ed3e..bec4c4b8a6 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java @@ -48,13 +48,6 @@ protected void onPostExecute(Void result) { } private void updateText() { - String text = "0"; - if (answeredQuests < 0) { - text += answeredQuests; - } else if (answeredQuests > 0) { - text += "+" + answeredQuests; - } - - setText(text); + setText(String.valueOf(answeredQuests)); } } From 36bab43c2bbecd87bfb4e46a09fd6ed649821a91 Mon Sep 17 00:00:00 2001 From: errol pais Date: Wed, 15 Nov 2017 18:25:09 -0800 Subject: [PATCH 05/10] Moves upload trigger from the menu dropdown to when the uploads counter is clicked --- .../westnordost/streetcomplete/MainActivity.java | 16 ++++++++++++---- app/src/main/res/menu/menu_main.xml | 6 ++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java index 7bbb4c69e3..ba6b2a212b 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java +++ b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java @@ -184,6 +184,18 @@ public void onServiceDisconnected(ComponentName className) answersCounter = toolbar.findViewById(R.id.answersCounter); uploadsCounter = toolbar.findViewById(R.id.uploadsCounter); + uploadsCounter.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (isConnected()) { + uploadChanges(); + } + else { + Toast.makeText(MainActivity.this, R.string.offline, Toast.LENGTH_SHORT).show(); + } + } + }); + questSource.onCreate(this); getSupportFragmentManager().beginTransaction() @@ -346,10 +358,6 @@ private int getQuestTitleResId(Quest quest, Map tags) if(isConnected()) downloadDisplayedArea(); else Toast.makeText(this, R.string.offline, Toast.LENGTH_SHORT).show(); return true; - case R.id.action_upload: - if(isConnected()) uploadChanges(); - else Toast.makeText(this, R.string.offline, Toast.LENGTH_SHORT).show(); - return true; } return super.onOptionsItemSelected(item); diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 2c987e670e..1526841a59 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -6,11 +6,9 @@ android:icon="@drawable/ic_undo_white_24dp" android:orderInCategory="1" app:showAsAction="ifRoom" /> - + android:orderInCategory="3" app:showAsAction="never" /> + android:orderInCategory="4" app:showAsAction="never" /> From 03af3ba8cedff3811b946780c50dfe23db1db4b4 Mon Sep 17 00:00:00 2001 From: errol pais Date: Sat, 25 Nov 2017 13:08:53 -0600 Subject: [PATCH 06/10] Renames AnswersCounter class to UploadedAnswersCounter --- .../streetcomplete/ApplicationComponent.java | 4 ++-- .../de/westnordost/streetcomplete/MainActivity.java | 10 +++++----- ...AnswersCounter.java => UploadedAnswersCounter.java} | 8 ++++---- app/src/main/res/layout/activity_main.xml | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) rename app/src/main/java/de/westnordost/streetcomplete/statistics/{AnswersCounter.java => UploadedAnswersCounter.java} (77%) diff --git a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java index c8e9c6c730..b0ba5dfc47 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java +++ b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java @@ -18,7 +18,7 @@ import de.westnordost.streetcomplete.settings.SettingsActivity; import de.westnordost.streetcomplete.settings.SettingsFragment; import de.westnordost.streetcomplete.settings.QuestSelectionFragment; -import de.westnordost.streetcomplete.statistics.AnswersCounter; +import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; import de.westnordost.streetcomplete.statistics.UploadsCounter; import de.westnordost.streetcomplete.tangram.MapControlsFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; @@ -41,7 +41,7 @@ public interface ApplicationComponent void inject(SettingsFragment settingsFragment); void inject(SettingsActivity settingsActivity); - void inject(AnswersCounter answersCounter); + void inject(UploadedAnswersCounter uploadedAnswersCounter); void inject(UploadsCounter uploadsCounter); void inject(AddOpeningHoursForm addOpeningHoursForm); diff --git a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java index ba6b2a212b..147dc9b71d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java +++ b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java @@ -66,7 +66,7 @@ import de.westnordost.streetcomplete.quests.QuestAnswerComponent; import de.westnordost.streetcomplete.quests.FindQuestSourceComponent; import de.westnordost.streetcomplete.settings.SettingsActivity; -import de.westnordost.streetcomplete.statistics.AnswersCounter; +import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; import de.westnordost.streetcomplete.location.LocationState; import de.westnordost.streetcomplete.statistics.UploadsCounter; import de.westnordost.streetcomplete.tangram.MapFragment; @@ -106,7 +106,7 @@ public class MainActivity extends AppCompatActivity implements private QuestGroup clickedQuestGroup = null; private ProgressBar progressBar; - private AnswersCounter answersCounter; + private UploadedAnswersCounter uploadedAnswersCounter; private UploadsCounter uploadsCounter; private float mapRotation, mapTilt; @@ -181,7 +181,7 @@ public void onServiceDisconnected(ComponentName className) questController.onCreate(); - answersCounter = toolbar.findViewById(R.id.answersCounter); + uploadedAnswersCounter = toolbar.findViewById(R.id.uploadedAnswersCounter); uploadsCounter = toolbar.findViewById(R.id.uploadsCounter); uploadsCounter.setOnClickListener(new View.OnClickListener() { @@ -221,7 +221,7 @@ public void onClick(View view) { { super.onStart(); - answersCounter.update(); + uploadedAnswersCounter.update(); uploadsCounter.update(); registerReceiver(locationAvailabilityReceiver, LocationUtil.createLocationAvailabilityIntentFilter()); @@ -488,7 +488,7 @@ else if(e instanceof OsmAuthorizationException) @AnyThread @Override public void onFinished() { runOnUiThread(() -> { - answersCounter.update(); + uploadedAnswersCounter.update(); uploadsCounter.update(); }); } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadedAnswersCounter.java similarity index 77% rename from app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java rename to app/src/main/java/de/westnordost/streetcomplete/statistics/UploadedAnswersCounter.java index de0ad4101f..7782aa2728 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/AnswersCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadedAnswersCounter.java @@ -9,25 +9,25 @@ import de.westnordost.streetcomplete.Injector; import de.westnordost.streetcomplete.data.statistics.QuestStatisticsDao; -public class AnswersCounter extends android.support.v7.widget.AppCompatTextView +public class UploadedAnswersCounter extends android.support.v7.widget.AppCompatTextView { @Inject QuestStatisticsDao questStatisticsDB; private int solvedQuests; - public AnswersCounter(Context context) + public UploadedAnswersCounter(Context context) { super(context); init(); } - public AnswersCounter(Context context, AttributeSet attrs) + public UploadedAnswersCounter(Context context, AttributeSet attrs) { super(context, attrs); init(); } - public AnswersCounter(Context context, AttributeSet attrs, int defStyleAttr) + public UploadedAnswersCounter(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5778245bc7..85fc8f86e7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -43,8 +43,8 @@ android:gravity="center_vertical" /> - Date: Sat, 25 Nov 2017 13:19:46 -0600 Subject: [PATCH 07/10] Renames UploadsCounter to UnsyncedAnswersCounter --- .../streetcomplete/ApplicationComponent.java | 4 +- .../streetcomplete/MainActivity.java | 41 ++++++++----------- ...unter.java => UnsyncedAnswersCounter.java} | 4 +- app/src/main/res/layout/activity_main.xml | 4 +- 4 files changed, 23 insertions(+), 30 deletions(-) rename app/src/main/java/de/westnordost/streetcomplete/statistics/{UploadsCounter.java => UnsyncedAnswersCounter.java} (88%) diff --git a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java index b0ba5dfc47..e1aa1cc6e4 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java +++ b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java @@ -19,7 +19,7 @@ import de.westnordost.streetcomplete.settings.SettingsFragment; import de.westnordost.streetcomplete.settings.QuestSelectionFragment; import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; -import de.westnordost.streetcomplete.statistics.UploadsCounter; +import de.westnordost.streetcomplete.statistics.UnsyncedAnswersCounter; import de.westnordost.streetcomplete.tangram.MapControlsFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; import de.westnordost.streetcomplete.util.SerializedSavedState; @@ -42,7 +42,7 @@ public interface ApplicationComponent void inject(SettingsActivity settingsActivity); void inject(UploadedAnswersCounter uploadedAnswersCounter); - void inject(UploadsCounter uploadsCounter); + void inject(UnsyncedAnswersCounter unsyncedAnswersCounter); void inject(AddOpeningHoursForm addOpeningHoursForm); void inject(AddRoadNameForm addRoadNameForm); diff --git a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java index 147dc9b71d..43844a6e6d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java +++ b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java @@ -68,7 +68,7 @@ import de.westnordost.streetcomplete.settings.SettingsActivity; import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; import de.westnordost.streetcomplete.location.LocationState; -import de.westnordost.streetcomplete.statistics.UploadsCounter; +import de.westnordost.streetcomplete.statistics.UnsyncedAnswersCounter; import de.westnordost.streetcomplete.tangram.MapFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; import de.westnordost.streetcomplete.tools.CrashReportExceptionHandler; @@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity implements private ProgressBar progressBar; private UploadedAnswersCounter uploadedAnswersCounter; - private UploadsCounter uploadsCounter; + private UnsyncedAnswersCounter unsyncedAnswersCounter; private float mapRotation, mapTilt; @@ -182,17 +182,14 @@ public void onServiceDisconnected(ComponentName className) questController.onCreate(); uploadedAnswersCounter = toolbar.findViewById(R.id.uploadedAnswersCounter); - uploadsCounter = toolbar.findViewById(R.id.uploadsCounter); - - uploadsCounter.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (isConnected()) { - uploadChanges(); - } - else { - Toast.makeText(MainActivity.this, R.string.offline, Toast.LENGTH_SHORT).show(); - } + unsyncedAnswersCounter = toolbar.findViewById(R.id.unsyncedAnswersCounter); + + unsyncedAnswersCounter.setOnClickListener(view -> { + if (isConnected()) { + uploadChanges(); + } + else { + Toast.makeText(MainActivity.this, R.string.offline, Toast.LENGTH_SHORT).show(); } }); @@ -222,7 +219,7 @@ public void onClick(View view) { super.onStart(); uploadedAnswersCounter.update(); - uploadsCounter.update(); + unsyncedAnswersCounter.update(); registerReceiver(locationAvailabilityReceiver, LocationUtil.createLocationAvailabilityIntentFilter()); @@ -314,10 +311,8 @@ private void confirmUndo(final OsmQuest quest) .setView(inner) .setPositiveButton(R.string.undo_confirm_positive, (dialog, which) -> { - - questController.undoOsmQuest(quest); - uploadsCounter.undidQuest(quest.getChangesSource()); - + questController.undoOsmQuest(quest); + unsyncedAnswersCounter.undidQuest(quest.getChangesSource()); }) .setNegativeButton(R.string.undo_confirm_negative, null) .show(); @@ -489,7 +484,7 @@ else if(e instanceof OsmAuthorizationException) { runOnUiThread(() -> { uploadedAnswersCounter.update(); - uploadsCounter.update(); + unsyncedAnswersCounter.update(); }); } }; @@ -602,11 +597,9 @@ else if(e instanceof OsmAuthorizationException) Location[] locations = new Location[]{ lastLocation, mapFragment.getDisplayedLocation() }; questSource.findSource(questId, group, locations, source -> { - - closeQuestDetailsFor(questId, group); - uploadsCounter.answeredQuest(source); - questController.solveQuest(questId, group, answer, source); - + closeQuestDetailsFor(questId, group); + unsyncedAnswersCounter.answeredQuest(source); + questController.solveQuest(questId, group, answer, source); }); } diff --git a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java b/app/src/main/java/de/westnordost/streetcomplete/statistics/UnsyncedAnswersCounter.java similarity index 88% rename from app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java rename to app/src/main/java/de/westnordost/streetcomplete/statistics/UnsyncedAnswersCounter.java index bec4c4b8a6..145389cc97 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/statistics/UploadsCounter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/statistics/UnsyncedAnswersCounter.java @@ -10,14 +10,14 @@ import de.westnordost.streetcomplete.data.QuestStatus; import de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao; -public class UploadsCounter extends android.support.v7.widget.AppCompatTextView { +public class UnsyncedAnswersCounter extends android.support.v7.widget.AppCompatTextView { @Inject OsmQuestDao questDB; private int answeredQuests; - public UploadsCounter(Context context, AttributeSet attrs) { + public UnsyncedAnswersCounter(Context context, AttributeSet attrs) { super(context, attrs); Injector.instance.getApplicationComponent().inject(this); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 85fc8f86e7..f8417632e0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,8 +33,8 @@ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:elevation="4dp"> - Date: Fri, 29 Dec 2017 17:26:17 -0600 Subject: [PATCH 08/10] Defined background for UnsyncedAnswers component since its selectable --- app/src/main/res/layout/activity_main.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f8417632e0..ea1f50bd2f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -41,6 +41,7 @@ android:drawablePadding="2dp" android:drawableStart="@drawable/ic_file_upload_24dp" android:gravity="center_vertical" + android:background="?android:attr/selectableItemBackground" /> Date: Fri, 29 Dec 2017 17:52:19 -0600 Subject: [PATCH 09/10] Adds back padding and minEms to Counters --- app/src/main/res/layout/activity_main.xml | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ea1f50bd2f..09ad1d13f5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -33,26 +33,31 @@ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:elevation="4dp"> + + - From 710223cf89fbb7ca959a4ed14d0e71be4070e287 Mon Sep 17 00:00:00 2001 From: errol pais Date: Fri, 29 Dec 2017 18:33:18 -0600 Subject: [PATCH 10/10] Removes the title in the Toolbar so that counters now start at the left hand side of the toolbar --- .../streetcomplete/MainActivity.java | 25 ++++++++++--------- app/src/main/res/layout/activity_main.xml | 2 -- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java index 43844a6e6d..c0cee2fcc8 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java +++ b/app/src/main/java/de/westnordost/streetcomplete/MainActivity.java @@ -1,7 +1,6 @@ package de.westnordost.streetcomplete; import android.animation.ObjectAnimator; -import android.support.v4.app.FragmentManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -18,6 +17,7 @@ import android.support.annotation.AnyThread; import android.support.annotation.Nullable; import android.support.annotation.UiThread; +import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.AppCompatActivity; @@ -46,38 +46,38 @@ import de.westnordost.osmapi.common.errors.OsmApiReadResponseException; import de.westnordost.osmapi.common.errors.OsmAuthorizationException; import de.westnordost.osmapi.common.errors.OsmConnectionException; +import de.westnordost.osmapi.map.data.BoundingBox; +import de.westnordost.osmapi.map.data.Element; +import de.westnordost.osmapi.map.data.LatLon; +import de.westnordost.osmapi.map.data.OsmElement; import de.westnordost.streetcomplete.about.AboutFragment; import de.westnordost.streetcomplete.data.Quest; import de.westnordost.streetcomplete.data.QuestAutoSyncer; -import de.westnordost.streetcomplete.data.upload.QuestChangesUploadProgressListener; -import de.westnordost.streetcomplete.data.upload.QuestChangesUploadService; import de.westnordost.streetcomplete.data.QuestController; -import de.westnordost.streetcomplete.data.download.QuestDownloadProgressListener; -import de.westnordost.streetcomplete.data.download.QuestDownloadService; import de.westnordost.streetcomplete.data.QuestGroup; import de.westnordost.streetcomplete.data.VisibleQuestListener; +import de.westnordost.streetcomplete.data.download.QuestDownloadProgressListener; +import de.westnordost.streetcomplete.data.download.QuestDownloadService; import de.westnordost.streetcomplete.data.osm.OsmQuest; +import de.westnordost.streetcomplete.data.upload.QuestChangesUploadProgressListener; +import de.westnordost.streetcomplete.data.upload.QuestChangesUploadService; import de.westnordost.streetcomplete.data.upload.VersionBannedException; import de.westnordost.streetcomplete.location.LocationRequestFragment; +import de.westnordost.streetcomplete.location.LocationState; import de.westnordost.streetcomplete.location.LocationUtil; import de.westnordost.streetcomplete.oauth.OAuthPrefs; import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; +import de.westnordost.streetcomplete.quests.FindQuestSourceComponent; import de.westnordost.streetcomplete.quests.OsmQuestAnswerListener; import de.westnordost.streetcomplete.quests.QuestAnswerComponent; -import de.westnordost.streetcomplete.quests.FindQuestSourceComponent; import de.westnordost.streetcomplete.settings.SettingsActivity; -import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; -import de.westnordost.streetcomplete.location.LocationState; import de.westnordost.streetcomplete.statistics.UnsyncedAnswersCounter; +import de.westnordost.streetcomplete.statistics.UploadedAnswersCounter; import de.westnordost.streetcomplete.tangram.MapFragment; import de.westnordost.streetcomplete.tangram.QuestsMapFragment; import de.westnordost.streetcomplete.tools.CrashReportExceptionHandler; import de.westnordost.streetcomplete.util.SlippyMapMath; import de.westnordost.streetcomplete.util.SphericalEarthMath; -import de.westnordost.osmapi.map.data.BoundingBox; -import de.westnordost.osmapi.map.data.Element; -import de.westnordost.osmapi.map.data.LatLon; -import de.westnordost.osmapi.map.data.OsmElement; import de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder; public class MainActivity extends AppCompatActivity implements @@ -177,6 +177,7 @@ public void onServiceDisconnected(ComponentName className) } Toolbar toolbar = findViewById(R.id.toolbar); + toolbar.setTitle(""); setSupportActionBar(toolbar); questController.onCreate(); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 09ad1d13f5..0c20dcafd5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -40,7 +40,6 @@ android:gravity="center_vertical" android:drawableStart="@drawable/ic_star_white_24dp" android:drawablePadding="2dp" - android:minEms="7" android:paddingEnd="8dp" android:paddingStart="8dp" /> @@ -53,7 +52,6 @@ android:drawableStart="@drawable/ic_file_upload_24dp" android:gravity="center_vertical" android:background="?android:attr/selectableItemBackground" - android:minEms="7" android:paddingEnd="8dp" android:paddingStart="8dp" />