Made telemetry dialog material (#6726)
* Made telemetry dialog material * cleaned up attribution_main_menu
This commit is contained in:
@@ -18,7 +18,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -51,11 +50,9 @@ import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
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;
|
||||
@@ -2869,14 +2866,15 @@ public class MapView extends FrameLayout {
|
||||
|
||||
// Called when someone presses the attribution icon
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Context context = v.getContext();
|
||||
String[] items = context.getResources().getStringArray(R.array.attribution_names);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AttributionAlertDialogStyle);
|
||||
public void onClick(View view) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapView.getContext(), R.style.TelemAlertDialogStyle);
|
||||
builder.setTitle(R.string.attributionsDialogTitle);
|
||||
builder.setAdapter(new ArrayAdapter<>(context, R.layout.attribution_list_item, items), this);
|
||||
AlertDialog dialog = builder.show();
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(mapView.getAttributionTintColor()));
|
||||
String[] items = mapView.getContext().getResources().getStringArray(R.array.attribution_names);
|
||||
builder.setAdapter(new ArrayAdapter<>(mapView.getContext(), R.layout.attribution_list_item, items), this);
|
||||
AlertDialog attributionDialog = builder.show();
|
||||
|
||||
// TODO Change listview text color to mapView.getAttributionTintColor()
|
||||
}
|
||||
|
||||
// Called when someone selects an attribution, 'Improve this map' adds location data to the url
|
||||
@@ -2884,45 +2882,38 @@ public class MapView extends FrameLayout {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final Context context = ((Dialog) dialog).getContext();
|
||||
if (which == ATTRIBUTION_INDEX_TELEMETRY_SETTINGS) {
|
||||
|
||||
int array = R.array.attribution_telemetry_options;
|
||||
if (MapboxEventManager.getMapboxEventManager().isTelemetryEnabled()) {
|
||||
array = R.array.attribution_telemetry_options_already_participating;
|
||||
}
|
||||
String[] items = context.getResources().getStringArray(array);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AttributionAlertDialogStyle);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.TelemAlertDialogStyle);
|
||||
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() {
|
||||
builder.setMessage(R.string.attributionTelemetryMessage);
|
||||
builder.setPositiveButton(R.string.attributionTelemetryPositive, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
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().setTelemetryEnabled(false);
|
||||
telemDialog.cancel();
|
||||
return;
|
||||
case 2:
|
||||
MapboxEventManager.getMapboxEventManager().setTelemetryEnabled(true);
|
||||
telemDialog.cancel();
|
||||
return;
|
||||
}
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MapboxEventManager.getMapboxEventManager().setTelemetryEnabled(true);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(R.string.attributionTelemetryNeutral, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
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);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.attributionTelemetryNegative, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MapboxEventManager.getMapboxEventManager().setTelemetryEnabled(false);
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog telemDialog = builder.show();
|
||||
telemDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mapView.getAttributionTintColor());
|
||||
telemDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mapView.getAttributionTintColor());
|
||||
telemDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(mapView.getAttributionTintColor());
|
||||
return;
|
||||
}
|
||||
String url = context.getResources().getStringArray(R.array.attribution_links)[which];
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="@android:color/white" />
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:textAllCaps="true"
|
||||
android:textAppearance="?android:attr/textAppearanceButton"
|
||||
android:textColor="@color/mapbox_blue"/>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?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>
|
||||
@@ -6,16 +6,6 @@
|
||||
<item>Improve this map</item>
|
||||
<item>Telemetry Settings</item>
|
||||
</array>
|
||||
<array name="attribution_telemetry_options">
|
||||
<item>Tell Me More</item>
|
||||
<item>Don\'t Participate</item>
|
||||
<item>Participate</item>
|
||||
</array>
|
||||
<array name="attribution_telemetry_options_already_participating">
|
||||
<item>Tell Me More</item>
|
||||
<item>Stop Participating</item>
|
||||
<item>Keep Participating</item>
|
||||
</array>
|
||||
<!-- If editing this array update MapView.ATTRIBUTION_INDEX_IMPROVE_THIS_MAP -->
|
||||
<array name="attribution_links" formatted="false" translatable="false">
|
||||
<item>https://www.mapbox.com/about/maps/</item>
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<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="attributionTelemetryPositive">Agree</string>
|
||||
<string name="attributionTelemetryNegative">Disagree</string>
|
||||
<string name="attributionTelemetryNeutral">More info</string>
|
||||
<string name="mapboxIconContentDescription">The Mapbox logo.</string>
|
||||
<string name="infoWindowTitle">Title</string>
|
||||
<string name="infoWindowDescription">Description</string>
|
||||
|
||||
@@ -6,4 +6,6 @@
|
||||
<item name="android:textColorPrimary">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="TelemAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"/>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user