Implemented profile color for few dialogs
This commit is contained in:
parent
790b10e2ac
commit
b295198f8b
10 changed files with 272 additions and 139 deletions
|
@ -6,46 +6,57 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:paddingLeft="@dimen/context_menu_padding_margin_large"
|
||||||
|
android:paddingRight="@dimen/context_menu_padding_margin_large"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_large"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_large"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/shared_string_name"/>
|
android:text="@string/shared_string_name"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/Name"
|
android:id="@+id/Name"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="@dimen/text_margin_small"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="@dimen/text_margin_small"
|
||||||
android:text="">
|
android:text="">
|
||||||
|
|
||||||
<requestFocus/>
|
<requestFocus/>
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
android:text="@string/edit_tilesource_choose_existing"/>
|
android:text="@string/edit_tilesource_choose_existing"/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/TileSourceSpinner"
|
android:id="@+id/TileSourceSpinner"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="@dimen/text_margin_small"
|
||||||
android:layout_marginRight="5dp"/>
|
android:layout_marginRight="@dimen/text_margin_small"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
android:text="@string/edit_tilesource_url_to_load"/>
|
android:text="@string/edit_tilesource_url_to_load"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/URLToLoad"
|
android:id="@+id/URLToLoad"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:lines="5"
|
android:lines="5"
|
||||||
|
@ -53,43 +64,52 @@
|
||||||
android:text=""/>
|
android:text=""/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit_tilesource_minzoom"/>
|
android:text="@string/edit_tilesource_minzoom"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/MinZoom"
|
android:id="@+id/MinZoom"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""/>
|
android:text=""/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit_tilesource_maxzoom"/>
|
android:text="@string/edit_tilesource_maxzoom"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/MaxZoom"
|
android:id="@+id/MaxZoom"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""/>
|
android:text=""/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:text="@string/edit_tilesource_expiration_time"/>
|
android:text="@string/edit_tilesource_expiration_time"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/ExpirationTime"
|
android:id="@+id/ExpirationTime"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""/>
|
android:text=""/>
|
||||||
|
|
||||||
<CheckBox
|
<android.support.v7.widget.AppCompatCheckBox
|
||||||
android:id="@+id/EllipticMercator"
|
android:id="@+id/EllipticMercator"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
android:text="@string/edit_tilesource_elliptic_tile"/>
|
android:text="@string/edit_tilesource_elliptic_tile"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,14 @@ public class DialogListItemAdapter extends BaseAdapter {
|
||||||
|
|
||||||
public static DialogListItemAdapter createSingleChoiceAdapter(String[] mData, boolean nightMode, int selected, OsmandApplication app,
|
public static DialogListItemAdapter createSingleChoiceAdapter(String[] mData, boolean nightMode, int selected, OsmandApplication app,
|
||||||
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
|
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
|
||||||
return new DialogListItemAdapter(mData, selected, null, nightMode, app,
|
|
||||||
compoundButtonColor, themeRes, listener, false);
|
return new DialogListItemAdapter(mData, selected, null, nightMode, app, compoundButtonColor, themeRes, listener, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DialogListItemAdapter createMultiChoiceAdapter(String[] mData, boolean nightMode, boolean checkedItems[], OsmandApplication app,
|
public static DialogListItemAdapter createMultiChoiceAdapter(String[] mData, boolean nightMode, boolean checkedItems[], OsmandApplication app,
|
||||||
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
|
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
|
||||||
return new DialogListItemAdapter(mData, INVALID_ID, checkedItems, nightMode, app,
|
|
||||||
compoundButtonColor, themeRes, listener, true);
|
return new DialogListItemAdapter(mData, INVALID_ID, checkedItems, nightMode, app, compoundButtonColor, themeRes, listener, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DialogListItemAdapter(String[] mData, int selected, boolean[] checkedItems, boolean nightMode, OsmandApplication app,
|
private DialogListItemAdapter(String[] mData, int selected, boolean[] checkedItems, boolean nightMode, OsmandApplication app,
|
||||||
|
|
|
@ -4,6 +4,7 @@ package net.osmand.plus.activities;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.view.ContextThemeWrapper;
|
import android.support.v7.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -22,6 +23,7 @@ import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -493,80 +495,85 @@ public class MapActivityLayers {
|
||||||
items[i++] = entry.getValue();
|
items[i++] = entry.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() {
|
OsmandApplication app = getApplication();
|
||||||
@Override
|
boolean nightMode = isNightMode(app);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
int themeRes = getThemeRes(app);
|
||||||
String layerKey = entriesMapList.get(which).getKey();
|
int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||||
switch (layerKey) {
|
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||||
case layerOsmVector:
|
items, nightMode, selectedItem, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||||
settings.MAP_ONLINE_DATA.set(false);
|
@Override
|
||||||
updateMapSource(mapView, null);
|
public void onClick(View v) {
|
||||||
updateItem(it, adapter, null);
|
int which = (int) v.getTag();
|
||||||
break;
|
String layerKey = entriesMapList.get(which).getKey();
|
||||||
case layerEditInstall:
|
switch (layerKey) {
|
||||||
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {
|
case layerOsmVector:
|
||||||
|
settings.MAP_ONLINE_DATA.set(false);
|
||||||
|
updateMapSource(mapView, null);
|
||||||
|
updateItem(it, adapter, null);
|
||||||
|
break;
|
||||||
|
case layerEditInstall:
|
||||||
|
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(TileSourceTemplate object) {
|
public boolean publish(TileSourceTemplate object) {
|
||||||
settings.MAP_TILE_SOURCES.set(object.getName());
|
settings.MAP_TILE_SOURCES.set(object.getName());
|
||||||
settings.MAP_ONLINE_DATA.set(true);
|
|
||||||
if(it != null) {
|
|
||||||
it.setDescription(object.getName());
|
|
||||||
}
|
|
||||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case layerInstallMore:
|
|
||||||
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
|
||||||
TileSourceTemplate template = null;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean publish(TileSourceTemplate object) {
|
|
||||||
if (object == null) {
|
|
||||||
if (count == 1) {
|
|
||||||
settings.MAP_TILE_SOURCES.set(template.getName());
|
|
||||||
settings.MAP_ONLINE_DATA.set(true);
|
settings.MAP_ONLINE_DATA.set(true);
|
||||||
updateItem(it, adapter, template.getName());
|
if(it != null) {
|
||||||
|
it.setDescription(object.getName());
|
||||||
|
}
|
||||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||||
} else {
|
return true;
|
||||||
selectMapLayer(mapView, it, adapter);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
count++;
|
|
||||||
template = object;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
break;
|
});
|
||||||
default:
|
break;
|
||||||
settings.MAP_TILE_SOURCES.set(layerKey);
|
case layerInstallMore:
|
||||||
settings.MAP_ONLINE_DATA.set(true);
|
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
updateItem(it, adapter, layerKey);
|
TileSourceTemplate template = null;
|
||||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
int count = 0;
|
||||||
break;
|
|
||||||
|
@Override
|
||||||
|
public boolean publish(TileSourceTemplate object) {
|
||||||
|
if (object == null) {
|
||||||
|
if (count == 1) {
|
||||||
|
settings.MAP_TILE_SOURCES.set(template.getName());
|
||||||
|
settings.MAP_ONLINE_DATA.set(true);
|
||||||
|
updateItem(it, adapter, template.getName());
|
||||||
|
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||||
|
} else {
|
||||||
|
selectMapLayer(mapView, it, adapter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
count++;
|
||||||
|
template = object;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
settings.MAP_TILE_SOURCES.set(layerKey);
|
||||||
|
settings.MAP_ONLINE_DATA.set(true);
|
||||||
|
updateItem(it, adapter, layerKey);
|
||||||
|
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
dialog.dismiss();
|
builder.setAdapter(dialogAdapter, null);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(R.string.shared_string_dismiss, null);
|
builder.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
builder.show();
|
dialogAdapter.setDialog(builder.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateItem(@Nullable ContextMenuItem item,
|
private void updateItem(@Nullable ContextMenuItem item,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.activities.actions;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -55,4 +56,12 @@ public class OsmAndAction {
|
||||||
public void showDialog() {
|
public void showDialog() {
|
||||||
mapActivity.showDialog(getDialogID());
|
mapActivity.showDialog(getDialogID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNightMode() {
|
||||||
|
return mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThemeRes() {
|
||||||
|
return isNightMode() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,14 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.widget.AppCompatCheckBox;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
@ -24,6 +25,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
|
||||||
|
@ -111,11 +113,16 @@ public class StartGPSStatus extends OsmAndAction {
|
||||||
final int dp12 = AndroidUtils.dpToPx(mapActivity, 12f);
|
final int dp12 = AndroidUtils.dpToPx(mapActivity, 12f);
|
||||||
final int dp8 = AndroidUtils.dpToPx(mapActivity, 8f);
|
final int dp8 = AndroidUtils.dpToPx(mapActivity, 8f);
|
||||||
lv.setPadding(0, dp8, 0, dp8);
|
lv.setPadding(0, dp8, 0, dp8);
|
||||||
final CheckBox cb = new CheckBox(activity);
|
final AppCompatCheckBox cb = new AppCompatCheckBox(activity);
|
||||||
cb.setText(R.string.shared_string_remember_my_choice);
|
cb.setText(R.string.shared_string_remember_my_choice);
|
||||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||||
lp.setMargins(dp24, dp8, dp8, dp24);
|
lp.setMargins(dp24, dp8, dp8, dp24);
|
||||||
cb.setLayoutParams(lp);
|
cb.setLayoutParams(lp);
|
||||||
|
cb.setPadding(dp8, 0, 0, 0);
|
||||||
|
int textColorPrimary = ContextCompat.getColor(activity, isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
|
||||||
|
int selectedModeColor = ContextCompat.getColor(activity, getSettings().getApplicationMode().getIconColorInfo().getColor(isNightMode()));
|
||||||
|
cb.setTextColor(textColorPrimary);
|
||||||
|
UiUtilities.setupCompoundButton(isNightMode(), selectedModeColor, cb);
|
||||||
|
|
||||||
final int layout = R.layout.list_menu_item_native;
|
final int layout = R.layout.list_menu_item_native;
|
||||||
final ArrayAdapter<GpsStatusApps> adapter = new ArrayAdapter<GpsStatusApps>(mapActivity, layout, GpsStatusApps.values()) {
|
final ArrayAdapter<GpsStatusApps> adapter = new ArrayAdapter<GpsStatusApps>(mapActivity, layout, GpsStatusApps.values()) {
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
|
@ -31,13 +35,18 @@ public class OsmNotesMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
||||||
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
final OsmandSettings settings = app.getSettings();
|
||||||
final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
|
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean nightMode = isNightMode(app);
|
||||||
|
final int themeRes = getThemeRes(app);
|
||||||
|
final int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||||
|
|
||||||
final int osmNotesStringId = R.string.layer_osm_bugs;
|
final int osmNotesStringId = R.string.layer_osm_bugs;
|
||||||
final int showZoomLevelStringId = R.string.show_from_zoom_level;
|
final int showZoomLevelStringId = R.string.show_from_zoom_level;
|
||||||
final int showClosedNotesStringId = R.string.show_closed_notes;
|
final int showClosedNotesStringId = R.string.show_closed_notes;
|
||||||
|
@ -60,11 +69,11 @@ public class OsmNotesMenu {
|
||||||
} else if (itemId == showZoomLevelStringId) {
|
} else if (itemId == showZoomLevelStringId) {
|
||||||
int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
|
int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
|
||||||
|
|
||||||
new AlertDialog.Builder(mapActivity)
|
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||||
.setTitle(R.string.show_from_zoom_level)
|
zoomStrings, nightMode, checked, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||||
.setSingleChoiceItems(zoomStrings, checked, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(View v) {
|
||||||
|
int which = (int) v.getTag();
|
||||||
showOsmBugsZoomPref.set(zoomIntValues[which]);
|
showOsmBugsZoomPref.set(zoomIntValues[which]);
|
||||||
ContextMenuItem item = adapter.getItem(position);
|
ContextMenuItem item = adapter.getItem(position);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
@ -72,11 +81,14 @@ public class OsmNotesMenu {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
dialog.dismiss();
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.setNegativeButton(R.string.shared_string_dismiss, null)
|
);
|
||||||
.show();
|
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(mapActivity, themeRes))
|
||||||
|
.setTitle(R.string.show_from_zoom_level)
|
||||||
|
.setAdapter(dialogAdapter, null)
|
||||||
|
.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
|
dialogAdapter.setDialog(b.show());
|
||||||
} else if (itemId == showClosedNotesStringId) {
|
} else if (itemId == showClosedNotesStringId) {
|
||||||
showClosedOsmBugsPref.set(isChecked);
|
showClosedOsmBugsPref.set(isChecked);
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
|
@ -86,7 +98,6 @@ public class OsmNotesMenu {
|
||||||
};
|
};
|
||||||
|
|
||||||
boolean showOsmBugs = showOsmBugsPref.get();
|
boolean showOsmBugs = showOsmBugsPref.get();
|
||||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
int toggleIconColorId;
|
int toggleIconColorId;
|
||||||
if (showOsmBugs) {
|
if (showOsmBugs) {
|
||||||
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||||
|
@ -135,4 +146,15 @@ public class OsmNotesMenu {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNightMode(OsmandApplication app) {
|
||||||
|
if (app == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getThemeRes(OsmandApplication app) {
|
||||||
|
return isNightMode(app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.widget.AppCompatCheckBox;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
@ -26,6 +28,7 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -433,16 +436,22 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
names[i] = downloaded.get(i).getName();
|
names[i] = downloaded.get(i).getName();
|
||||||
}
|
}
|
||||||
final boolean[] selected = new boolean[downloaded.size()];
|
final boolean[] selected = new boolean[downloaded.size()];
|
||||||
builder.setMultiChoiceItems(names, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
boolean nightMode = isNightMode(activity, app);
|
||||||
|
int themeResId = getThemeRes(activity, app);
|
||||||
@Override
|
int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app,
|
||||||
selected[which] = isChecked;
|
selectedProfileColor, themeResId, new View.OnClickListener() {
|
||||||
if (entriesMap.containsKey(downloaded.get(which).getName()) && isChecked) {
|
@Override
|
||||||
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
|
public void onClick(View v) {
|
||||||
|
int which = (int) v.getTag();
|
||||||
|
selected[which] = !selected[which];
|
||||||
|
if (entriesMap.containsKey(downloaded.get(which).getName()) && selected[which]) {
|
||||||
|
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
});
|
builder.setAdapter(dialogAdapter, null);
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
builder.setTitle(R.string.select_tile_source_to_install);
|
builder.setTitle(R.string.select_tile_source_to_install);
|
||||||
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
|
||||||
|
@ -467,8 +476,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialogAdapter.setDialog(builder.show());
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
@ -478,6 +486,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
|
final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
|
||||||
|
boolean nightMode = isNightMode(activity, app);
|
||||||
|
final int dp8 = AndroidUtils.dpToPx(app, 8f);
|
||||||
|
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
|
||||||
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png",
|
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png",
|
||||||
"png", 17, 5, 256, 16, 32000);
|
"png", 17, 5, 256, 16, 32000);
|
||||||
final TileSourceTemplate[] result = new TileSourceTemplate[]{ts};
|
final TileSourceTemplate[] result = new TileSourceTemplate[]{ts};
|
||||||
|
@ -489,7 +500,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
final EditText minZoom = (EditText) view.findViewById(R.id.MinZoom);
|
final EditText minZoom = (EditText) view.findViewById(R.id.MinZoom);
|
||||||
final EditText maxZoom = (EditText) view.findViewById(R.id.MaxZoom);
|
final EditText maxZoom = (EditText) view.findViewById(R.id.MaxZoom);
|
||||||
final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime);
|
final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime);
|
||||||
final CheckBox elliptic = (CheckBox) view.findViewById(R.id.EllipticMercator);
|
final AppCompatCheckBox elliptic = (AppCompatCheckBox) view.findViewById(R.id.EllipticMercator);
|
||||||
|
elliptic.setTextColor(textColorPrimary);
|
||||||
|
elliptic.setPadding(dp8, 0, 0, 0);
|
||||||
|
UiUtilities.setupCompoundButton(app, elliptic, nightMode, true);
|
||||||
updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic);
|
updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic);
|
||||||
|
|
||||||
final ArrayList<String> templates = new ArrayList<>(entriesMap.keySet());
|
final ArrayList<String> templates = new ArrayList<>(entriesMap.keySet());
|
||||||
|
|
|
@ -4,14 +4,16 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.widget.AppCompatCheckedTextView;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
@ -21,6 +23,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -144,26 +147,33 @@ public class RoutingOptionsHelper {
|
||||||
entries[k] = mapActivity.getResources().getString(R.string.install_more);
|
entries[k] = mapActivity.getResources().getString(R.string.install_more);
|
||||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||||
|
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
boolean nightMode = isNightMode(app);
|
||||||
bld.setSingleChoiceItems(entries, selected, new DialogInterface.OnClickListener() {
|
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
|
||||||
|
int themeRes = getThemeRes(app);
|
||||||
@Override
|
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
|
||||||
String value = entrieValues[which];
|
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||||
if (MORE_VALUE.equals(value)) {
|
entries, nightMode, selected, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||||
final Intent intent = new Intent(mapActivity, DownloadActivity.class);
|
@Override
|
||||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
public void onClick(View v) {
|
||||||
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
int which = (int) v.getTag();
|
||||||
mapActivity.startActivity(intent);
|
String value = entrieValues[which];
|
||||||
} else {
|
if (MORE_VALUE.equals(value)) {
|
||||||
if (callback != null) {
|
final Intent intent = new Intent(mapActivity, DownloadActivity.class);
|
||||||
callback.processResult(value);
|
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||||
|
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
|
||||||
|
mapActivity.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.processResult(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
);
|
||||||
}
|
AlertDialog.Builder bld = new AlertDialog.Builder(themedContext);
|
||||||
});
|
bld.setAdapter(dialogAdapter, null);
|
||||||
bld.show();
|
dialogAdapter.setDialog(bld.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVoiceProviderName(Context ctx, String value) {
|
public String getVoiceProviderName(Context ctx, String value) {
|
||||||
|
@ -315,8 +325,10 @@ public class RoutingOptionsHelper {
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
final boolean nightMode = isNightMode(app);
|
||||||
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
|
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
|
||||||
|
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
|
||||||
|
final int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||||
final int layout = R.layout.list_menu_item_native_singlechoice;
|
final int layout = R.layout.list_menu_item_native_singlechoice;
|
||||||
|
|
||||||
|
@ -330,9 +342,12 @@ public class RoutingOptionsHelper {
|
||||||
v = UiUtilities.getInflater(mapActivity, nightMode).inflate(layout, parent, false);
|
v = UiUtilities.getInflater(mapActivity, nightMode).inflate(layout, parent, false);
|
||||||
}
|
}
|
||||||
final ContextMenuItem item = adapter.getItem(position);
|
final ContextMenuItem item = adapter.getItem(position);
|
||||||
TextView tv = (TextView) v.findViewById(R.id.text1);
|
AppCompatCheckedTextView tv = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
|
||||||
tv.setText(item.getTitle());
|
tv.setText(item.getTitle());
|
||||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
UiUtilities.setupCompoundButtonDrawable(app, nightMode, selectedModeColor, tv.getCheckMarkDrawable());
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -590,6 +605,17 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNightMode(OsmandApplication app) {
|
||||||
|
if (app == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThemeRes(OsmandApplication app) {
|
||||||
|
return isNightMode(app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LocalRoutingParameter {
|
public static class LocalRoutingParameter {
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ContourLinesMenu {
|
||||||
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||||
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
||||||
}
|
}
|
||||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
boolean nightMode = isNightMode(mapActivity.getMyApplication());
|
||||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||||
adapter.setProfileDependent(true);
|
adapter.setProfileDependent(true);
|
||||||
|
@ -329,6 +329,13 @@ public class ContourLinesMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNightMode(OsmandApplication app) {
|
||||||
|
if (app == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
}
|
||||||
|
|
||||||
public static void closeDashboard(MapActivity mapActivity) {
|
public static void closeDashboard(MapActivity mapActivity) {
|
||||||
mapActivity.getDashboard().hideDashboard(false);
|
mapActivity.getDashboard().hideDashboard(false);
|
||||||
|
|
|
@ -4,7 +4,9 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
|
@ -13,6 +15,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.DialogListItemAdapter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -359,7 +362,9 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
final Runnable callback) {
|
final Runnable callback) {
|
||||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
||||||
p.getAttrName(), p.getName());
|
p.getAttrName(), p.getName());
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(activity);
|
boolean nightMode = isNightMode(activity, app);
|
||||||
|
int themeRes = getThemeRes(activity, app);
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
|
||||||
b.setTitle(propertyDescr);
|
b.setTitle(propertyDescr);
|
||||||
|
|
||||||
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
|
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
|
||||||
|
@ -382,18 +387,22 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
possibleValues[j]);
|
possibleValues[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||||
@Override
|
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
possibleValuesString, nightMode, i, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||||
if (which == 0) {
|
|
||||||
pref.set("");
|
@Override
|
||||||
} else {
|
public void onClick(View v) {
|
||||||
pref.set(possibleValues[which - 1]);
|
int which = (int) v.getTag();
|
||||||
|
if (which == 0) {
|
||||||
|
pref.set("");
|
||||||
|
} else {
|
||||||
|
pref.set(possibleValues[which - 1]);
|
||||||
|
}
|
||||||
|
refreshMapComplete(activity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
refreshMapComplete(activity);
|
);
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
b.setNegativeButton(R.string.shared_string_dismiss, null);
|
b.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
b.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
b.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -403,7 +412,8 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
b.show();
|
b.setAdapter(dialogAdapter, null);
|
||||||
|
dialogAdapter.setDialog(b.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -420,4 +430,15 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
activity.updateMapSettings();
|
activity.updateMapSettings();
|
||||||
activity.getMapView().refreshMap(true);
|
activity.getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isNightMode(Activity activity, OsmandApplication app) {
|
||||||
|
if (activity == null || app == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return activity instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getThemeRes(Activity activity, OsmandApplication app) {
|
||||||
|
return isNightMode(activity, app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue