Skip to content
Merged
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
2 changes: 2 additions & 0 deletions app/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,6 @@
<string name="personalid_camera_permission_msg">Para tomar una foto, CommCare necesita permiso para usar la cámara de tu dispositivo.</string>
<string name="personalid_capture_photo">Tomar foto</string>
<string name="personalid_configuration_locked_account">Su cuenta ha sido bloqueada. Por favor, contacte con el servicio de asistencia.</string>
<string name="play_service_update_error">Asegúrese de que los servicios de Google Play sean compatibles con el dispositivo y estén actualizados.</string>

</resources>
3 changes: 3 additions & 0 deletions app/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,7 @@ License.
<string name="personalid_camera_permission_title">Autorisation pour la caméra</string>
<string name="personalid_camera_permission_msg">Afin de prendre une photo, CommCare a besoin de l\'autorisation d\'utiliser l\'appareil photo de votre appareil.</string>
<string name="personalid_capture_photo">Prendre une photo</string>
<string name="play_service_update_error">Veuillez vous assurer que les services Google Play sont pris en charge sur l\'appareil et sont à jour.</string>


</resources>
2 changes: 2 additions & 0 deletions app/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,6 @@ License.
<string name="personalid_camera_permission_msg">तस्वीर लेने के लिए, CommCare को आपके डिवाइस के कैमरे का उपयोग करने की अनुमति चाहिए।</string>
<string name="personalid_capture_photo">तस्वीर लें</string>
<string name="personalid_configuration_locked_account">आपका खाता लॉक कर दिया गया है। कृपया सहायता से संपर्क करें</string>
<string name="play_service_update_error">कृपया सुनिश्चित करें कि डिवाइस पर Google Play सेवाएं समर्थित हैं और अद्यतित हैं।</string>

</resources>
2 changes: 2 additions & 0 deletions app/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,6 @@
<string name="personalid_camera_permission_title">Permissão para câmara</string>
<string name="personalid_camera_permission_msg">Para tirar uma fotografia, o CommCare precisa de permissão para utilizar a câmara do seu dispositivo.</string>
<string name="personalid_capture_photo">Capturar foto</string>
<string name="play_service_update_error">Certifique-se de que os serviços do Google Play sejam suportados no dispositivo e estejam atualizados.</string>

</resources>
2 changes: 2 additions & 0 deletions app/res/values-sw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,6 @@
<string name="personalid_camera_permission_title">Ruhusa ya kamera</string>
<string name="personalid_camera_permission_msg">Ili kupiga picha, CommCare inahitaji ruhusa ya kutumia kamera ya kifaa chako.</string>
<string name="personalid_capture_photo">Piga Picha</string>
<string name="play_service_update_error">Tafadhali hakikisha kuwa huduma za Google Play zinatumika kwenye kifaa na zimesasishwa.</string>

</resources>
1 change: 1 addition & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -640,4 +640,5 @@

<string name="my_credentials">My Credentials</string>
<string name="credential">Credential</string>
<string name="play_service_update_error">Please make sure Google Play services is supported on the device and is up to date.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.location.Location;
import android.os.Bundle;
Expand All @@ -26,6 +27,8 @@
import androidx.navigation.NavDirections;
import androidx.navigation.Navigation;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.tasks.Task;
import com.google.android.play.core.integrity.StandardIntegrityManager;
import com.google.android.gms.auth.api.identity.Identity;
Expand Down Expand Up @@ -60,6 +63,7 @@
import java.util.HashMap;
import java.util.Objects;

import static android.app.ProgressDialog.show;
import static com.google.android.play.core.integrity.model.IntegrityDialogResponseCode.DIALOG_SUCCESSFUL;
import static org.commcare.utils.Permissions.shouldShowPermissionRationale;

Expand All @@ -76,6 +80,9 @@ public class PersonalIdPhoneFragment extends Fragment implements CommCareLocatio
private CommCareLocationController locationController;
private ActivityResultLauncher<String[]> locationPermissionLauncher;
private ActivityResultLauncher<IntentSenderRequest> resolutionLauncher;
private String playServicesError;
private ActivityResultLauncher<IntentSenderRequest> playServicesResolutionLauncher;



private static final String[] REQUIRED_PERMISSIONS = new String[]{
Expand All @@ -96,6 +103,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
integrityTokenApiRequestHelper = new IntegrityTokenApiRequestHelper(getViewLifecycleOwner());
initializeUi();
registerLauncher();
checkGooglePlayServices();
return binding.getRoot();
}

Expand All @@ -118,6 +126,26 @@ public void onDestroyView() {
binding = null;
}

private void checkGooglePlayServices() {
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int status = googleApiAvailability.isGooglePlayServicesAvailable(requireActivity());
if (status != ConnectionResult.SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pm-dimagi I am also seeing some concept of googleApiAvailability.isUserResolvableError(resultCode) and then showing the dialog error with requestCode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

playServicesError = "play_services_"+ status;
Logger.log(LogTypes.TYPE_MAINTENANCE, "Google Play Services issue:" + playServicesError);
if (googleApiAvailability.isUserResolvableError(status)) {
GoogleApiAvailability.getInstance().showErrorDialogFragment(
requireActivity(),
status,
playServicesResolutionLauncher,
dialog -> onConfigurationFailure(playServicesError,
getString(R.string.play_service_update_error)));
} else {
onConfigurationFailure(playServicesError,
getString(R.string.play_service_update_error));
}
}
}

private void initializeUi() {
binding.countryCode.setText(phoneNumberHelper.setDefaultCountryCode(getContext()));
binding.checkText.setMovementMethod(LinkMovementMethod.getInstance());
Expand Down Expand Up @@ -343,6 +371,15 @@ private void registerLauncher() {
}
}
);

playServicesResolutionLauncher = registerForActivityResult(
new ActivityResultContracts.StartIntentSenderForResult(),
result -> {
if (result.getResultCode() != Activity.RESULT_OK) {
onConfigurationFailure(playServicesError, getString(R.string.play_service_update_error));
}
}
);
}


Expand Down