Skip to content

Commit

Permalink
Merge pull request #253 from DP-3T/develop
Browse files Browse the repository at this point in the history
Version 1.2.1
  • Loading branch information
simonroesch committed Dec 4, 2020
2 parents 293e126 + 339f8be commit 4898ab6
Show file tree
Hide file tree
Showing 29 changed files with 1,120 additions and 173 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
applicationId "ch.admin.bag.dp3t"
minSdkVersion 23
targetSdkVersion 30
versionCode 12000
versionName "1.2.0"
versionCode 12010
versionName "1.2.1"
resConfigs "en", "fr", "de", "it", "pt", "es", "sq", "bs", "hr", "sr", "rm", "tr", "ti"

buildConfigField "long", "BUILD_TIME", readPropertyWithDefault('buildTimestamp', System.currentTimeMillis()) + 'L'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import androidx.fragment.app.FragmentManager;

import org.dpppt.android.sdk.DP3T;
import org.dpppt.android.sdk.internal.nearby.ExposureWindowMatchingWorker;

import ch.admin.bag.dp3t.R;
import ch.admin.bag.dp3t.networking.CertificatePinning;
Expand Down Expand Up @@ -58,6 +59,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
CertificatePinning.setEnabled(isChecked, v.getContext());
DP3T.setCertificatePinner(CertificatePinning.getCertificatePinner());
});

view.findViewById(R.id.debug_trigger_exposure_check)
.setOnClickListener(v -> ExposureWindowMatchingWorker.startMatchingWorker(v.getContext()));
}

}
4 changes: 4 additions & 0 deletions app/src/dev/java/ch/admin/bag/dp3t/debug/DebugFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;

import org.dpppt.android.sdk.DP3T;
import org.dpppt.android.sdk.internal.nearby.ExposureWindowMatchingWorker;
import org.dpppt.android.sdk.internal.storage.ExposureDayStorage;
import org.dpppt.android.sdk.models.DayDate;
import org.dpppt.android.sdk.models.ExposureDay;
Expand Down Expand Up @@ -98,6 +99,9 @@ private void setupSdkViews(View view) {
CertificatePinning.setEnabled(isChecked, v.getContext());
DP3T.setCertificatePinner(CertificatePinning.getCertificatePinner());
});

view.findViewById(R.id.debug_trigger_exposure_check)
.setOnClickListener(v -> ExposureWindowMatchingWorker.startMatchingWorker(v.getContext()));
}

private void setupStateOptions(View view) {
Expand Down
55 changes: 49 additions & 6 deletions app/src/log/java/ch/admin/bag/dp3t/debug/DebugFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,59 @@
*/
package ch.admin.bag.dp3t.debug;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import org.dpppt.android.sdk.DP3T;
import org.dpppt.android.sdk.internal.nearby.ExposureWindowMatchingWorker;

import ch.admin.bag.dp3t.R;
import ch.admin.bag.dp3t.networking.CertificatePinning;

public class DebugFragment extends Fragment {

/**
* DOES NOT (AND MUST NOT) EXIST ON PROD.
*/
public static final boolean EXISTS = false;
public static final boolean EXISTS = true;

public static void startDebugFragment(FragmentManager parentFragmentManager) {
parentFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.slide_enter, R.anim.slide_exit, R.anim.slide_pop_enter, R.anim.slide_pop_exit)
.replace(R.id.main_fragment_container, DebugFragment.newInstance())
.addToBackStack(DebugFragment.class.getCanonicalName())
.commit();
}

public static DebugFragment newInstance() {
return new DebugFragment();
}

public DebugFragment() {
super(R.layout.fragment_debug);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.contacts_toolbar);
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());

view.findViewById(R.id.debug_card_sdkstate).setVisibility(View.GONE);

view.findViewById(R.id.debug_card_overridestate).setVisibility(View.GONE);

CheckBox certPinningCheckbox = view.findViewById(R.id.debug_certificate_pinning);
certPinningCheckbox.setChecked(CertificatePinning.isEnabled());
certPinningCheckbox.setOnCheckedChangeListener((v, isChecked) -> {
CertificatePinning.setEnabled(isChecked, v.getContext());
DP3T.setCertificatePinner(CertificatePinning.getCertificatePinner());
});

public static void startDebugFragment(FragmentManager parentFragmentManager) { }
view.findViewById(R.id.debug_trigger_exposure_check)
.setOnClickListener(v -> ExposureWindowMatchingWorker.startMatchingWorker(v.getContext()));
}

}
}
6 changes: 3 additions & 3 deletions app/src/main/java/ch/admin/bag/dp3t/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void checkRedirectionIntents() {
checkIntentForActions();

if (!consumedExposedIntent) {
boolean isHotlineCallPending = secureStorage.isHotlineCallPending();
boolean isOpenLeitfadenPending = secureStorage.isOpenLeitfadenPending();
boolean isExposed = tracingViewModel.getTracingStatusInterface().wasContactReportedAsExposed();
if (isHotlineCallPending && isExposed) {
if (isOpenLeitfadenPending && isExposed) {
gotoReportsFragment();
}
}
Expand All @@ -113,7 +113,7 @@ private void checkIntentForActions() {
String intentAction = intent.getAction();
boolean launchedFromHistory = (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
if (ACTION_INFORMED_GOTO_REPORTS.equals(intentAction) && !launchedFromHistory) {
secureStorage.setHotlineCallPending(false);
secureStorage.setLeitfadenOpenPending(false);
secureStorage.setReportsHeaderAnimationPending(false);
gotoReportsFragment();
intent.setAction(null);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ch/admin/bag/dp3t/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static void createNewContactNotification(Context context, int contactId)
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NotificationUtil.NOTIFICATION_ID_CONTACT, notification);

secureStorage.setHotlineCallPending(true);
secureStorage.setLeitfadenOpenPending(true);
secureStorage.setReportsHeaderAnimationPending(true);
secureStorage.setLastShownContactId(contactId);
}
Expand Down
81 changes: 42 additions & 39 deletions app/src/main/java/ch/admin/bag/dp3t/reports/ReportsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
import androidx.transition.Transition;
import androidx.transition.TransitionManager;

import java.util.List;

import org.dpppt.android.sdk.models.ExposureDay;

import ch.admin.bag.dp3t.R;
import ch.admin.bag.dp3t.home.model.TracingStatusInterface;
import ch.admin.bag.dp3t.storage.SecureStorage;
import ch.admin.bag.dp3t.util.DateUtils;
import ch.admin.bag.dp3t.util.NotificationUtil;
import ch.admin.bag.dp3t.util.PhoneUtil;
import ch.admin.bag.dp3t.util.UrlUtil;
Expand All @@ -55,16 +58,13 @@ public static ReportsFragment newInstance() {

private View healthyView;
private View saveOthersView;
private View hotlineView;
private View leitfadenView;
private View infectedView;

private TextView callHotlineLastText1;
private TextView callHotlineLastText2;

private TextView xDaysLeftTextview;


private boolean hotlineJustCalled = false;
private boolean leitfadenJustOpened = false;

public ReportsFragment() { super(R.layout.fragment_reports); }

Expand All @@ -87,22 +87,25 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

healthyView = view.findViewById(R.id.reports_healthy);
saveOthersView = view.findViewById(R.id.reports_save_others);
hotlineView = view.findViewById(R.id.reports_hotline);
leitfadenView = view.findViewById(R.id.reports_leitfaden);
infectedView = view.findViewById(R.id.reports_infected);

callHotlineLastText1 = hotlineView.findViewById(R.id.card_encounters_last_call);
callHotlineLastText2 = saveOthersView.findViewById(R.id.card_encounters_last_call);
xDaysLeftTextview = saveOthersView.findViewById(R.id.x_days_left_textview);

Button callHotlineButton1 = hotlineView.findViewById(R.id.card_encounters_button);
Button callHotlineButton2 = saveOthersView.findViewById(R.id.card_encounters_button);
Button openSwisscovidLeitfadenButton1 = leitfadenView.findViewById(R.id.card_encounters_button);
Button openSwisscovidLeitfadenButton2 = saveOthersView.findViewById(R.id.card_encounters_button);

callHotlineButton1.setOnClickListener(view1 -> callHotline());
callHotlineButton2.setOnClickListener(view1 -> callHotline());
openSwisscovidLeitfadenButton1.setOnClickListener(view1 -> openSwissCovidLeitfaden());
openSwisscovidLeitfadenButton2.setOnClickListener(view1 -> openSwissCovidLeitfaden());

View callHotlineButton1 = leitfadenView.findViewById(R.id.item_call_hotline_layout);
View callHotlineButton2 = saveOthersView.findViewById(R.id.item_call_hotline_layout);
callHotlineButton1.setOnClickListener(v -> callHotline());
callHotlineButton2.setOnClickListener(v -> callHotline());

Button faqButton1 = healthyView.findViewById(R.id.card_encounters_faq_button);
Button faqButton2 = saveOthersView.findViewById(R.id.card_encounters_faq_button);
Button faqButton3 = hotlineView.findViewById(R.id.card_encounters_faq_button);
Button faqButton3 = leitfadenView.findViewById(R.id.card_encounters_faq_button);
Button faqButton4 = infectedView.findViewById(R.id.card_encounters_faq_button);

faqButton1.setOnClickListener(v -> showFaq());
Expand All @@ -117,7 +120,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
tracingViewModel.getAppStatusLiveData().observe(getViewLifecycleOwner(), tracingStatusInterface -> {
healthyView.setVisibility(View.GONE);
saveOthersView.setVisibility(View.GONE);
hotlineView.setVisibility(View.GONE);
leitfadenView.setVisibility(View.GONE);
infectedView.setVisibility(View.GONE);

ReportsHeaderFragment.Type headerType;
Expand Down Expand Up @@ -145,9 +148,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
} else if (tracingStatusInterface.wasContactReportedAsExposed()) {
headerType = ReportsHeaderFragment.Type.POSSIBLE_INFECTION;
numExposureDays = tracingStatusInterface.getExposureDays().size();
boolean isHotlineCallPending = secureStorage.isHotlineCallPending();
if (isHotlineCallPending) {
hotlineView.setVisibility(View.VISIBLE);
boolean isOpenLeitfadenPending = secureStorage.isOpenLeitfadenPending();
if (isOpenLeitfadenPending) {
leitfadenView.setVisibility(View.VISIBLE);
} else {
saveOthersView.setVisibility(View.VISIBLE);
}
Expand All @@ -159,7 +162,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
} else {
xDaysLeftTextview.setText(getString(R.string.date_in_days).replace("{COUNT}", String.valueOf(daysLeft)));
}
hotlineView.findViewById(R.id.delete_reports).setOnClickListener(v -> deleteNotifications(tracingStatusInterface));
leitfadenView.findViewById(R.id.delete_reports)
.setOnClickListener(v -> deleteNotifications(tracingStatusInterface));
saveOthersView.findViewById(R.id.delete_reports)
.setOnClickListener(v -> deleteNotifications(tracingStatusInterface));
} else {
Expand All @@ -178,8 +182,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

private void deleteNotifications(TracingStatusInterface tracingStatusInterface) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.NextStep_AlertDialogStyle);
builder.setMessage(R.string.delete_reports_dialog)
.setPositiveButton(R.string.android_button_ok, (dialog, id) -> {
builder.setMessage(R.string.delete_notification_dialog)
.setPositiveButton(R.string.delete_reports_button, (dialog, id) -> {
tracingStatusInterface.resetExposureDays(getContext());
getParentFragmentManager().popBackStack();
})
Expand All @@ -198,34 +202,33 @@ private void showFaq() {
UrlUtil.openUrl(getContext(), getString(R.string.faq_button_url));
}

private void openSwissCovidLeitfaden() {
leitfadenJustOpened = true;
secureStorage.leitfadenOpened();
List<ExposureDay> exposureDays = tracingViewModel.getAppStatusLiveData().getValue().getExposureDays();
StringBuilder contactDates = new StringBuilder();
String delimiter = "";
for (ExposureDay exposureDay : exposureDays) {
contactDates.append(delimiter);
contactDates.append(exposureDay.getExposedDate().formatAsString());
delimiter = ",";
}
UrlUtil.openUrl(getContext(), getString(R.string.swisscovid_leitfaden_url).replace("{CONTACT_DATES}", contactDates));
}

private void callHotline() {
hotlineJustCalled = true;
secureStorage.justCalledHotline();
PhoneUtil.callHelpline(getContext());
}

@Override
public void onResume() {
super.onResume();

if (hotlineJustCalled) {
hotlineJustCalled = false;
hotlineView.setVisibility(View.GONE);
if (leitfadenJustOpened) {
leitfadenJustOpened = false;
leitfadenView.setVisibility(View.GONE);
saveOthersView.setVisibility(View.VISIBLE);
}

long lastHotlineCallTimestamp = secureStorage.lastHotlineCallTimestamp();
if (lastHotlineCallTimestamp != 0) {
((TextView) hotlineView.findViewById(R.id.card_encounters_title)).setText(R.string.meldungen_detail_call_again);

String date = DateUtils.getFormattedDateTime(lastHotlineCallTimestamp);
date = getString(R.string.meldungen_detail_call_last_call).replace("{DATE}", date);
callHotlineLastText1.setText(date);
callHotlineLastText2.setText(date);
} else {
callHotlineLastText1.setText("");
callHotlineLastText2.setText("");
}
}


Expand Down
23 changes: 10 additions & 13 deletions app/src/main/java/ch/admin/bag/dp3t/storage/SecureStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public class SecureStorage {
private static final String KEY_INFORM_TOKEN_REQ = "inform_token_req";
private static final String KEY_ONBOARDING_COMPLETED = "onboarding_completed";
private static final String KEY_LAST_SHOWN_CONTACT_ID = "last_shown_contact_id";
private static final String KEY_HOTLINE_CALL_PENDING = "hotline_call_pending";
private static final String KEY_HOTLINE_LAST_CALL_TIMESTAMP = "hotline_ever_called_timestamp";

//KEY_LEITFADEN_OPEN_PENDING key value is kept to old value to avoid migration issues
private static final String KEY_LEITFADEN_OPEN_PENDING = "hotline_call_pending";

private static final String KEY_PENDING_REPORTS_HEADER_ANIMATION = "pending_reports_header_animation";
private static final String KEY_CONFIG_FORCE_UPDATE = "config_do_force_update";
private static final String KEY_CONFIG_HAS_INFOBOX = "has_ghettobox";
Expand Down Expand Up @@ -143,21 +145,16 @@ public void setLastShownContactId(int contactId) {
prefs.edit().putInt(KEY_LAST_SHOWN_CONTACT_ID, contactId).apply();
}

public boolean isHotlineCallPending() {
return prefs.getBoolean(KEY_HOTLINE_CALL_PENDING, false);
}

public void setHotlineCallPending(boolean pending) {
prefs.edit().putBoolean(KEY_HOTLINE_CALL_PENDING, pending).apply();
public boolean isOpenLeitfadenPending() {
return prefs.getBoolean(KEY_LEITFADEN_OPEN_PENDING, false);
}

public long lastHotlineCallTimestamp() {
return prefs.getLong(KEY_HOTLINE_LAST_CALL_TIMESTAMP, 0);
public void setLeitfadenOpenPending(boolean pending) {
prefs.edit().putBoolean(KEY_LEITFADEN_OPEN_PENDING, pending).apply();
}

public void justCalledHotline() {
prefs.edit().putBoolean(KEY_HOTLINE_CALL_PENDING, false)
.putLong(KEY_HOTLINE_LAST_CALL_TIMESTAMP, System.currentTimeMillis())
public void leitfadenOpened() {
prefs.edit().putBoolean(KEY_LEITFADEN_OPEN_PENDING, false)
.apply();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public static void updateStatusView(View statusView, NotificationState state, lo
triangle.setVisibility(View.VISIBLE);
triangle.setImageResource(R.drawable.triangle_status_exposed);
infoContainer.setVisibility(View.VISIBLE);
infoText.setText(R.string.exposed_info_contact_hotline);
infoTel.setText(R.string.exposed_info_contact_hotline_name);
infoText.setText(R.string.exposed_info_answer_questions_in_leitfaden);
infoTel.setText(R.string.exposed_info_swisscovid_leitfaden);
infoSince.setVisibility(View.VISIBLE);
if (daySinceExposed == 0) {
String string = context.getString(R.string.date_today);
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/ic_infoline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
~ Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch>
~
~ This Source Code Form is subject to the terms of the Mozilla Public
~ License, v. 2.0. If a copy of the MPL was not distributed with this
~ file, You can obtain one at https://mozilla.org/MPL/2.0/.
~
~ SPDX-License-Identifier: MPL-2.0
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20,15.5c-1.25,0 -2.45,-0.2 -3.57,-0.57 -0.35,-0.11 -0.74,-0.03 -1.02,0.24l-2.2,2.2c-2.83,-1.44 -5.15,-3.75 -6.59,-6.58l2.2,-2.21c0.28,-0.27 0.36,-0.66 0.25,-1.01C8.7,6.45 8.5,5.25 8.5,4c0,-0.55 -0.45,-1 -1,-1L4,3C3.45,3 3,3.45 3,4c0,9.39 7.61,17 17,17 0.55,0 1,-0.45 1,-1v-3.5c0,-0.55 -0.45,-1 -1,-1zM12,3v10l3,-3h6L21,3L12,3z"
android:fillColor="#4A4969"
android:fillType="evenOdd"/>
</vector>
Loading

0 comments on commit 4898ab6

Please sign in to comment.