Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple contact counter on main and contact screen #30

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.View;
import android.widget.Button;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -80,6 +81,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
invalidateErrorResolverButtons();
});

tracingViewModel.getNumberOfHandshakesLiveData().observe(getViewLifecycleOwner(), counter -> {
TextView counterView = contactStatusView.findViewById(R.id.status_contact_counter);
counterView.setText(getString(R.string.tracing_active_counter, counter));
});

locationPermissionButton = view.findViewById(R.id.contact_location_permission_button);
locationPermissionButton.setOnClickListener(v -> {
requestedSomething = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -88,6 +90,11 @@ private void setupCards(View view) {
TracingStatusHelper.updateStatusView(contactStatusView, state, titleRes, textRes);
});

tracingViewModel.getNumberOfHandshakesLiveData().observe(getViewLifecycleOwner(), counter -> {
TextView counterView = contactStatusView.findViewById(R.id.status_contact_counter);
counterView.setText(getString(R.string.tracing_active_counter, counter));
});

view.findViewById(R.id.card_notifications).setOnClickListener(
v -> getParentFragmentManager().beginTransaction()
.replace(R.id.main_fragment_container, NotificationsFragment.newInstance())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ LiveData<Boolean> getTracingEnabledLiveData() {
return tracingEnabledLiveData;
}

public LiveData<Integer> getNumberOfHandshakesLiveData() {
return numberOfHandshakesLiveData;
}

public LiveData<Pair<Boolean, Boolean>> getSelfOrContactExposedLiveData() {
return exposedLiveData;
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/layout_status.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
android:layout_height="wrap_content"
tools:text="@string/bluetooth_setting_tracking_active_subtext" />

<TextView
android:id="@+id/status_contact_counter"
style="@style/NextStep.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="@string/bluetooth_setting_tracing_active_counter" />
</LinearLayout>

</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ Die App greift aber nie auf deinen Standort zu!"</string>
<!-- Bluetooth Control: Tracking Aktiv Subtext -->
<string name="bluetooth_setting_tracking_active_subtext">"Begegnungen werden anonym auf deinem Gerät gespeichert."</string>

<!-- Bluetooth Control: Tracking Aktiv Counter -->
<string name="bluetooth_setting_tracing_active_counter">"Anzahl Kontakte: %d"</string>

<!-- Bluetooth Control: Tracking deaktiviert -->
<string name="bluetooth_setting_tracking_inactive">"Tracing deaktiviert"</string>

Expand Down Expand Up @@ -326,6 +329,7 @@ Die App greift aber nie auf deinen Standort zu!"</string>
<string name="meldungen_meldung_more_button">"Mehr erfahren"</string>
<string name="tracing_active_title">"Tracing aktiv"</string>
<string name="tracing_active_text">"Begegnungen werden anonym auf deinem Gerät gespeichert."</string>
<string name="tracing_active_counter">"Anzahl Kontakte: %d"</string>
<string name="tracing_error_title">"Tracing nicht aktiv"</string>
<string name="tracing_error_text">"Aktiviere Tracing und Bluetooth, damit Begegnungen anonym aufgezeichnet werden können."</string>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ L'application n'accède jamais à votre position!"</string>
<!-- Bluetooth Control: Tracking deaktiviert Subtext -->
<string name="bluetooth_setting_tracking_inactive_subtext">"Autorisez Bluetooth pour que les rencontres puissent être enregistrées de manière anonyme."</string>

<!-- Bluetooth Control: Tracking Aktiv Counter -->
<string name="bluetooth_setting_tracing_active_counter">"Nombre de contacts: %d"</string>

<!-- Bluetooth Setting: Titel unten -->
<string name="bluetooth_setting_tracking_explanation_title">"Comment fonctionne le suivi?"</string>

Expand Down Expand Up @@ -320,6 +323,7 @@ L'application n'accède jamais à votre position!"</string>
<string name="meldungen_meldung_more_button">"En savoir plus"</string>
<string name="tracing_active_title">"Suivi actif"</string>
<string name="tracing_active_text">"Les rencontres sont enregistrées de manière anonyme sur votre appareil."</string>
<string name="tracing_active_counter">"Nombre de contacts: %d"</string>
<string name="tracing_error_title">"Suivi non actif"</string>
<string name="tracing_error_text">"Activez le traçage et le Bluetooth pour que les rencontres puissent être enregistrées de manière anonyme."</string>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ Die App greift aber nie auf deinen Standort zu!"</string>
<!-- Bluetooth Control: Tracking Aktiv Subtext -->
<string name="bluetooth_setting_tracking_active_subtext">"Begegnungen werden anonym auf deinem Gerät gespeichert."</string>

<!-- Bluetooth Control: Tracking Aktiv Counter -->
<string name="bluetooth_setting_tracing_active_counter">"Numero di contatti: %d"</string>

<!-- Bluetooth Control: Tracking deaktiviert -->
<string name="bluetooth_setting_tracking_inactive">"Tracing deaktiviert"</string>

Expand Down Expand Up @@ -320,6 +323,7 @@ Die App greift aber nie auf deinen Standort zu!"</string>
<string name="meldungen_meldung_more_button">"Mehr erfahren"</string>
<string name="tracing_active_title">"Tracing aktiv"</string>
<string name="tracing_active_text">"Begegnungen werden anonym auf deinem Gerät gespeichert."</string>
<string name="tracing_active_counter">"Numero di contatti: %d"</string>
<string name="tracing_error_title">"Tracing nicht aktiv"</string>
<string name="tracing_error_text">"Aktiviere Tracing und Bluetooth, damit Begegnungen anonym aufgezeichnet werden können."</string>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ anonymous"</string>
<!-- Bluetooth Control: Tracking Aktiv Subtext -->
<string name="bluetooth_setting_tracking_active_subtext">"Encounters are saved anonymously on your device."</string>

<!-- Bluetooth Control: Tracking Aktiv Counter -->
<string name="bluetooth_setting_tracing_active_counter">"Number of contacts: %d"</string>

<!-- Bluetooth Control: Tracking deaktiviert -->
<string name="bluetooth_setting_tracking_inactive">"Tracing disabled"</string>

Expand Down Expand Up @@ -317,6 +320,7 @@ anonymous"</string>
<string name="meldungen_meldung_more_button">"Learn more"</string>
<string name="tracing_active_title">"Tracing enabled"</string>
<string name="tracing_active_text">"Encounters are saved anonymously on your device."</string>
<string name="tracing_active_counter">"Number of contacts: %d"</string>
<string name="tracing_error_title">"Tracing deactivated"</string>
<string name="tracing_error_text">"Activate tracing and Bluetooth so that encounters can be recorded anonymously."</string>

Expand Down