Skip to content

Commit

Permalink
Allow manual testers to use the volume buttons to switch between the …
Browse files Browse the repository at this point in the history
…old and new GeoPoint activity.
  • Loading branch information
zestyping committed Jan 10, 2019
1 parent da48d89 commit e2d17f9
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ConfigurationInfo;
import android.media.AudioManager;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
Expand All @@ -32,6 +33,7 @@
import org.javarosa.form.api.FormEntryPrompt;
import org.odk.collect.android.R;
import org.odk.collect.android.activities.GeoPointActivity;
import org.odk.collect.android.activities.GeoPointGoogleMapActivity;
import org.odk.collect.android.activities.GeoPointMapActivity;
import org.odk.collect.android.activities.GeoPointOsmMapActivity;
import org.odk.collect.android.listeners.PermissionListener;
Expand Down Expand Up @@ -72,6 +74,10 @@ public class GeoPointWidget extends QuestionWidget implements BinaryWidget {

private String stringAnswer;

private boolean isRingerSilent() {
return ((AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE)).getRingerMode() == AudioManager.RINGER_MODE_SILENT;
}

public GeoPointWidget(Context context, FormEntryPrompt prompt) {
super(context, prompt);

Expand Down Expand Up @@ -291,9 +297,12 @@ public void denied() {
private void startGeoPoint() {
Intent i;
if (useMapsV2 && useMaps) {
if (mapSDK.equals(GOOGLE_MAP_KEY)) {
if (isRingerSilent()) {
i = new Intent(getContext(), GeoPointMapActivity.class);
i.putExtra(GeneralKeys.KEY_MAP_SDK, mapSDK);
} else if (mapSDK.equals(GOOGLE_MAP_KEY)) {
if (PlayServicesUtil.isGooglePlayServicesAvailable(getContext())) {
i = new Intent(getContext(), GeoPointMapActivity.class);
i = new Intent(getContext(), GeoPointGoogleMapActivity.class);
} else {
PlayServicesUtil.showGooglePlayServicesAvailabilityErrorDialog(getContext());
return;
Expand Down Expand Up @@ -322,4 +331,4 @@ private void startGeoPoint() {

((Activity) getContext()).startActivityForResult(i, RequestCodes.LOCATION_CAPTURE);
}
}
}

0 comments on commit e2d17f9

Please sign in to comment.