Merge pull request #7932 from osmandapp/Fix_7752
Fix #7752 Create define/edit menu item on the Download map->Local->Online and c…
This commit is contained in:
commit
92a9f98bed
4 changed files with 47 additions and 6 deletions
|
@ -31,6 +31,7 @@
|
|||
</EditText>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TileSourceHint"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -528,7 +528,7 @@ public class MapActivityLayers {
|
|||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}, null);
|
||||
break;
|
||||
case layerInstallMore:
|
||||
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
|
|
|
@ -17,7 +17,9 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.Collator;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.OsmAndCollator;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
|
@ -36,10 +38,10 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
|||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.resources.IncrementalChangesManager;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -237,6 +239,20 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
info.getFileName());
|
||||
confirm.setMessage(getString(R.string.clear_confirmation_msg, fn));
|
||||
confirm.show();
|
||||
} else if (resId == R.string.shared_string_edit) {
|
||||
OsmandRasterMapsPlugin.defineNewEditLayer(getDownloadActivity(),
|
||||
new ResultMatcher<TileSourceManager.TileSourceTemplate>() {
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean publish(TileSourceManager.TileSourceTemplate object) {
|
||||
getDownloadActivity().reloadLocalIndexes();
|
||||
return true;
|
||||
}
|
||||
}, info.getName());
|
||||
} else if (resId == R.string.local_index_mi_restore) {
|
||||
new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info);
|
||||
} else if (resId == R.string.shared_string_delete) {
|
||||
|
@ -782,7 +798,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getDownloadActivity());
|
||||
builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size()));
|
||||
builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), String.valueOf(selectedItems.size())));
|
||||
builder.setPositiveButton(actionButton, listener);
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.show();
|
||||
|
@ -1220,6 +1236,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
return true;
|
||||
}
|
||||
});
|
||||
if (info.getType() == LocalIndexType.TILES_DATA && (info.getAttachedObject() instanceof ITileSource) &&
|
||||
((ITileSource) info.getAttachedObject()).couldBeDownloadedFromInternet()) {
|
||||
item = optionsMenu.getMenu().add(R.string.shared_string_edit)
|
||||
.setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
performBasicOperation(R.string.shared_string_edit, info);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (info.getType() == LocalIndexType.TILES_DATA && (info.getAttachedObject() instanceof ITileSource) &&
|
||||
((ITileSource)info.getAttachedObject()).couldBeDownloadedFromInternet()) {
|
||||
item = optionsMenu.getMenu().add(R.string.clear_tile_data)
|
||||
|
@ -1230,7 +1258,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
performBasicOperation(R.string.clear_tile_data, info);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
final IndexItem update = filesToUpdate.get(info.getFileName());
|
||||
if (update != null) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -42,7 +43,6 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.dialogs.RasterMapMenu;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -478,7 +478,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public static void defineNewEditLayer(final Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher) {
|
||||
public static void defineNewEditLayer(final Activity activity, final ResultMatcher<TileSourceTemplate> resultMatcher, String editedLayerName) {
|
||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
|
||||
|
@ -492,6 +492,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
View view = UiUtilities.getInflater(activity, isNightMode(activity, app)).inflate(R.layout.editing_tile_source, null);
|
||||
final EditText name = (EditText) view.findViewById(R.id.Name);
|
||||
final Spinner existing = (Spinner) view.findViewById(R.id.TileSourceSpinner);
|
||||
final TextView existingHint = (TextView) view.findViewById(R.id.TileSourceHint);
|
||||
final EditText urlToLoad = (EditText) view.findViewById(R.id.URLToLoad);
|
||||
final EditText minZoom = (EditText) view.findViewById(R.id.MinZoom);
|
||||
final EditText maxZoom = (EditText) view.findViewById(R.id.MaxZoom);
|
||||
|
@ -511,6 +512,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
existing.setAdapter(adapter);
|
||||
if (editedLayerName != null) {
|
||||
File f = ((OsmandApplication) activity.getApplication()).getAppPath(
|
||||
IndexConstants.TILES_INDEX_DIR + templates.get(adapter.getPosition(editedLayerName)));
|
||||
TileSourceTemplate template = TileSourceManager.createTileSourceTemplate(f);
|
||||
if (template != null) {
|
||||
result[0] = template.copy();
|
||||
updateTileSourceEditView(result[0], name, urlToLoad, minZoom, maxZoom, expire, elliptic);
|
||||
}
|
||||
existingHint.setVisibility(View.GONE);
|
||||
existing.setVisibility(View.GONE);
|
||||
}
|
||||
existing.setSelection(0);
|
||||
existing.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue