Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3907 - Adding Telemetry description to dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Feb 13, 2016
1 parent 13e2acb commit 9841f94
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@
import android.view.TextureView;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ZoomButtonsController;
import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
import com.almeros.android.multitouch.gesturedetectors.ShoveGestureDetector;
Expand All @@ -78,15 +80,12 @@
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.location.LocationServices;
import com.mapbox.mapboxsdk.telemetry.MapboxEventManager;
import com.mapbox.mapboxsdk.telemetry.TelemetryService;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -2880,28 +2879,38 @@ public void onClick(DialogInterface dialog, int which) {
}
String[] items = context.getResources().getStringArray(array);
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AttributionAlertDialogStyle);
builder.setTitle(R.string.attributionsDialogTitle);
builder.setAdapter(new ArrayAdapter<>(context, R.layout.attribution_list_item, items), new DialogInterface.OnClickListener() {
builder.setTitle(R.string.attributionTelemetryTitle);
LayoutInflater factory = LayoutInflater.from(context);
View content = factory.inflate(R.layout.attribution_telemetry_view, null);

ListView lv = (ListView) content.findViewById(R.id.telemetryOptionsList);
lv.setAdapter(new ArrayAdapter<String>(context, R.layout.attribution_list_item, items));
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

builder.setView(content);
final AlertDialog telemDialog = builder.show();
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
String url = context.getResources().getStringArray(R.array.attribution_links)[3];
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
context.startActivity(intent);
telemDialog.cancel();
return;
case 1:
MapboxEventManager.getMapboxEventManager(context).setTelemetryEnabled(false);
telemDialog.cancel();
return;
case 2:
MapboxEventManager.getMapboxEventManager(context).setTelemetryEnabled(true);
telemDialog.cancel();
return;
}
}
});

builder.show();
return;
}
String url = context.getResources().getStringArray(R.array.attribution_links)[which];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/attributionTelemetryMessage"
android:gravity="center_horizontal"/>

<ListView
android:id="@+id/telemetryOptionsList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<dimen name="infowindow_offset">-2dp</dimen>
<dimen name="infowindow_line_width">1.5dp</dimen>
<dimen name="seven_dp">7dp</dimen>
<dimen name="eight_dp">8dp</dimen>
<dimen name="ten_dp">10dp</dimen>
<dimen name="sixteen_dp">16dp</dimen>
<dimen name="seventy_six_dp">76dp</dimen>
</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<string name="compassContentDescription">Map compass. Click to reset the map rotation to North.</string>
<string name="attributionsIconContentDescription">Attribution icon. Click to show attribution dialog.</string>
<string name="attributionsDialogTitle">Mapbox Android SDK</string>
<string name="attributionTelemetryTitle">Make Mapbox Maps Better</string>
<string name="attributionTelemetryMessage">You are helping to make OpenStreetMap and Mapbox maps better by contributing anonymous usage data.</string>
<string name="mapboxIconContentDescription">The Mapbox logo.</string>
<string name="infoWindowTitle">Title</string>
<string name="infoWindowDescription">Description</string>
Expand Down

0 comments on commit 9841f94

Please sign in to comment.