Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f24b9c2007
10 changed files with 280 additions and 134 deletions
|
@ -162,6 +162,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="54dp"
|
||||
android:paddingRight="2dp"
|
||||
android:minHeight="52dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginTop="-16dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:clickable="true"
|
||||
|
@ -182,30 +184,14 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_marginRight="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="visible"
|
||||
tools:text="@string/shared_string_downloading"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressPercent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:visibility="visible"
|
||||
tools:text="12%"/>
|
||||
|
||||
</LinearLayout>
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="shared_string_update">Update</string>
|
||||
<string name="rec_photo_description">Photo %1$s</string>
|
||||
<string name="rec_audio_description">Audio %1$s</string>
|
||||
<string name="rec_video_description">Video %1$s</string>
|
||||
|
|
|
@ -224,7 +224,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
getMyApplication().getAppCustomization().pauseActivity(DownloadActivity.class);
|
||||
downloadThread.setUiActivity(null);
|
||||
downloadThread.resetUiActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,6 +89,12 @@ public class DownloadIndexesThread {
|
|||
this.uiActivity = uiActivity;
|
||||
}
|
||||
|
||||
public void resetUiActivity(DownloadEvents uiActivity) {
|
||||
if (this.uiActivity == uiActivity) {
|
||||
this.uiActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
protected void downloadInProgress() {
|
||||
if (uiActivity != null) {
|
||||
|
|
|
@ -55,6 +55,9 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
|
||||
public IndexItem getIndexItem(String fileName) {
|
||||
IndexItem res = null;
|
||||
if (rawResources == null) {
|
||||
return null;
|
||||
}
|
||||
for (IndexItem item : rawResources) {
|
||||
if (fileName.equals(item.getFileName())) {
|
||||
res = item;
|
||||
|
@ -64,6 +67,19 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
return res;
|
||||
}
|
||||
|
||||
public List<IndexItem> getIndexItems(String fileNamePrefix) {
|
||||
List<IndexItem> res = new LinkedList<>();
|
||||
if (rawResources == null) {
|
||||
return res;
|
||||
}
|
||||
for (IndexItem item : rawResources) {
|
||||
if (item.getFileName().toLowerCase().startsWith(fileNamePrefix)) {
|
||||
res.add(item);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void updateLoadedFiles() {
|
||||
initAlreadyLoadedFiles();
|
||||
prepareFilesToUpdate();
|
||||
|
|
|
@ -398,4 +398,10 @@ public class MapContextMenu extends MenuTitleController {
|
|||
public boolean buttonsVisible() {
|
||||
return menuController == null || menuController.buttonsVisible();
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
if (menuController != null) {
|
||||
menuController.updateData();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -156,89 +156,41 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
|
||||
mainView = view.findViewById(R.id.context_menu_main);
|
||||
|
||||
// Title buttons
|
||||
boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null)
|
||||
&& (titleProgressController == null || !titleProgressController.visible);
|
||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
||||
titleButtonsContainer.setVisibility(showButtonsContainer ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Left title button
|
||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
|
||||
if (leftTitleButtonController != null) {
|
||||
leftTitleButton.setText(leftTitleButtonController.caption);
|
||||
leftTitleButton.setVisibility(leftTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
leftTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
leftTitleButtonController.buttonPressed();
|
||||
}
|
||||
});
|
||||
|
||||
if (leftTitleButtonController.needRightText) {
|
||||
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
|
||||
} else {
|
||||
titleButtonRightText.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
leftTitleButton.setVisibility(View.GONE);
|
||||
titleButtonRightText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Right title button
|
||||
final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
|
||||
if (rightTitleButtonController != null) {
|
||||
rightTitleButton.setText(rightTitleButtonController.caption);
|
||||
rightTitleButton.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
rightTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
rightTitleButtonController.buttonPressed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
rightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Top Right title button
|
||||
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
||||
if (topRightTitleButtonController != null) {
|
||||
topRightTitleButton.setText(topRightTitleButtonController.caption);
|
||||
topRightTitleButton.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
topRightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
topRightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
topRightTitleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
topRightTitleButtonController.buttonPressed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
topRightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Progress bar
|
||||
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
||||
if (titleProgressController != null) {
|
||||
|
||||
updateProgress();
|
||||
|
||||
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
|
||||
progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark,
|
||||
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
|
||||
|
@ -248,10 +200,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
titleProgressController.buttonPressed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
titleProgressContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
updateButtonsAndProgress();
|
||||
|
||||
if (menu.isLandscapeLayout()) {
|
||||
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
@ -486,29 +438,82 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void recalculateFullHeightMax() {
|
||||
menuFullHeightMax = menuTitleHeight + (menuBottomViewHeight > 0 ? menuBottomViewHeight : -dpToPx(SHADOW_HEIGHT_BOTTOM_DP));
|
||||
private void updateButtonsAndProgress() {
|
||||
// Title buttons
|
||||
boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null)
|
||||
&& (titleProgressController == null || !titleProgressController.visible);
|
||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
||||
titleButtonsContainer.setVisibility(showButtonsContainer ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Left title button
|
||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
|
||||
if (leftTitleButtonController != null) {
|
||||
leftTitleButton.setText(leftTitleButtonController.caption);
|
||||
leftTitleButton.setVisibility(leftTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
|
||||
private void updateProgress() {
|
||||
if (leftTitleButtonController.needRightText) {
|
||||
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
|
||||
} else {
|
||||
titleButtonRightText.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
leftTitleButton.setVisibility(View.GONE);
|
||||
titleButtonRightText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Right title button
|
||||
final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
|
||||
if (rightTitleButtonController != null) {
|
||||
rightTitleButton.setText(rightTitleButtonController.caption);
|
||||
rightTitleButton.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
} else {
|
||||
rightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Top Right title button
|
||||
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
||||
if (topRightTitleButtonController != null) {
|
||||
topRightTitleButton.setText(topRightTitleButtonController.caption);
|
||||
topRightTitleButton.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
topRightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
topRightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
}
|
||||
} else {
|
||||
topRightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Progress bar
|
||||
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
||||
if (titleProgressController != null) {
|
||||
titleProgressContainer.setVisibility(titleProgressController.visible ? View.VISIBLE : View.GONE);
|
||||
|
||||
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||
final TextView progressTitle = (TextView) view.findViewById(R.id.progressTitle);
|
||||
final TextView progressPercent = (TextView) view.findViewById(R.id.progressPercent);
|
||||
progressTitle.setText(titleProgressController.caption);
|
||||
if (titleProgressController.indeterminate) {
|
||||
progressPercent.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressPercent.setVisibility(View.VISIBLE);
|
||||
progressPercent.setText(titleProgressController.progress + "%");
|
||||
}
|
||||
progressBar.setIndeterminate(titleProgressController.indeterminate);
|
||||
progressBar.setProgress(titleProgressController.progress);
|
||||
|
||||
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
|
||||
progressButton.setVisibility(titleProgressController.buttonVisible ? View.VISIBLE : View.GONE);
|
||||
} else {
|
||||
titleProgressContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildHeader() {
|
||||
|
@ -545,6 +550,18 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getMyApplication().getDownloadThread().setUiActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getMyApplication().getDownloadThread().resetUiActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
@ -583,7 +600,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
menuTitleHeight = menuTopShadowHeight + menuTopShadowAllHeight + dy;
|
||||
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
|
||||
|
||||
recalculateFullHeightMax();
|
||||
menuFullHeightMax = menuTitleHeight + (menuBottomViewHeight > 0 ? menuBottomViewHeight : -dpToPx(SHADOW_HEIGHT_BOTTOM_DP));
|
||||
|
||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||
|
||||
|
@ -824,17 +841,27 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
//DownloadEvents
|
||||
@Override
|
||||
public void newDownloadIndexes() {
|
||||
|
||||
updateOnDownload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadInProgress() {
|
||||
|
||||
updateOnDownload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadHasFinished() {
|
||||
updateOnDownload();
|
||||
}
|
||||
|
||||
private void updateOnDownload() {
|
||||
boolean wasProgressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible;
|
||||
menu.updateData();
|
||||
boolean progressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible;
|
||||
updateButtonsAndProgress();
|
||||
if (wasProgressVisible != progressVisible) {
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
|
|
|
@ -240,6 +240,8 @@ public abstract class MenuController extends BaseMenuController {
|
|||
ShareMenu.show(latLon, title, getMapActivity());
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
}
|
||||
|
||||
public abstract class TitleButtonController {
|
||||
public String caption = "";
|
||||
|
@ -261,13 +263,12 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
public abstract class TitleProgressController {
|
||||
public String caption = "";
|
||||
public int progress;
|
||||
public int progress = 0;
|
||||
public boolean indeterminate;
|
||||
public boolean visible;
|
||||
public boolean buttonVisible;
|
||||
|
||||
public void setIndexesDownloadMode() {
|
||||
progress = 0;
|
||||
caption = getMapActivity().getString(R.string.downloading_list_indexes);
|
||||
indeterminate = true;
|
||||
buttonVisible = false;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -11,41 +13,43 @@ import net.osmand.map.WorldRegion;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class MapDataMenuController extends MenuController {
|
||||
private WorldRegion region;
|
||||
private String regionName;
|
||||
private IndexItem indexItem;
|
||||
private List<IndexItem> otherIndexItems;
|
||||
private String name;
|
||||
|
||||
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final BinaryMapDataObject dataObject) {
|
||||
private DownloadValidationManager downloadValidationManager;
|
||||
private DownloadIndexesThread downloadThread;
|
||||
|
||||
public MapDataMenuController(final OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final BinaryMapDataObject dataObject) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
OsmandRegions osmandRegions = app.getRegions();
|
||||
String fullName = osmandRegions.getFullName(dataObject);
|
||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
this.region = region;
|
||||
if (region != null) {
|
||||
regionName = region.getLocaleName();
|
||||
} else {
|
||||
regionName = dataObject.getName();
|
||||
}
|
||||
|
||||
boolean hasIndexes = app.getDownloadThread().getIndexes().isDownloadedFromInternet;
|
||||
boolean isDownloading = false; //todo
|
||||
this.region = osmandRegions.getRegionData(fullName);
|
||||
name = getPointDescription().getName();
|
||||
downloadValidationManager = new DownloadValidationManager(app);
|
||||
downloadThread = app.getDownloadThread();
|
||||
|
||||
mapActivity.getSupportFragmentManager();
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
getMapActivity().getContextMenu().close();
|
||||
|
||||
final Intent intent = new Intent(getMapActivity(), getMapActivity().getMyApplication()
|
||||
.getAppCustomization().getDownloadIndexActivity());
|
||||
intent.putExtra(DownloadActivity.FILTER_KEY, regionName);
|
||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
getMapActivity().startActivity(intent);
|
||||
if (indexItem != null) {
|
||||
downloadValidationManager.startDownload(mapActivity, indexItem);
|
||||
}
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
|
||||
|
@ -54,8 +58,9 @@ public class MapDataMenuController extends MenuController {
|
|||
rightTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
// todo delete
|
||||
//getMapActivity().getContextMenu().close();
|
||||
if (indexItem != null) {
|
||||
deleteItem();
|
||||
}
|
||||
}
|
||||
};
|
||||
rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
|
||||
|
@ -68,25 +73,21 @@ public class MapDataMenuController extends MenuController {
|
|||
}
|
||||
};
|
||||
topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
|
||||
topRightTitleButtonController.visible = hasIndexes && !isDownloading;
|
||||
|
||||
titleProgressController = new TitleProgressController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
// todo cancel download
|
||||
if (indexItem != null) {
|
||||
downloadThread.cancelDownload(indexItem);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!hasIndexes) {
|
||||
titleProgressController.setIndexesDownloadMode();
|
||||
titleProgressController.visible = true;
|
||||
getMapActivity().getMyApplication().getDownloadThread().runReloadIndexFiles();
|
||||
} else if (isDownloading) {
|
||||
titleProgressController.setMapDownloadMode();
|
||||
titleProgressController.caption = "Downloading..."; // todo
|
||||
titleProgressController.visible = true;
|
||||
} else {
|
||||
titleProgressController.visible = false;
|
||||
|
||||
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
|
||||
downloadThread.runReloadIndexFiles();
|
||||
}
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,7 +107,7 @@ public class MapDataMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public String getNameStr() {
|
||||
return regionName;
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,4 +142,95 @@ public class MapDataMenuController extends MenuController {
|
|||
public boolean buttonsVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateData() {
|
||||
if (indexItem == null) {
|
||||
otherIndexItems = downloadThread.getIndexes().getIndexItems(region.getRegionDownloadNameLC());
|
||||
for (IndexItem i : otherIndexItems) {
|
||||
if (i.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
indexItem = i;
|
||||
otherIndexItems.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
topRightTitleButtonController.visible = otherIndexItems.size() > 0;
|
||||
if (indexItem != null) {
|
||||
if (indexItem.isOutdated()) {
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_update)
|
||||
+ " (" + indexItem.getSizeDescription(getMapActivity()) + ")";
|
||||
} else {
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download)
|
||||
+ " (" + indexItem.getSizeDescription(getMapActivity()) + ")";
|
||||
}
|
||||
}
|
||||
rightTitleButtonController.visible = indexItem != null && indexItem.isDownloaded();
|
||||
|
||||
boolean hasIndexes = downloadThread.getIndexes().isDownloadedFromInternet;
|
||||
boolean isDownloading = indexItem != null && downloadThread.getCurrentDownloadingItem() == indexItem;
|
||||
if (!hasIndexes) {
|
||||
titleProgressController.setIndexesDownloadMode();
|
||||
titleProgressController.visible = true;
|
||||
} else if (isDownloading) {
|
||||
titleProgressController.setMapDownloadMode();
|
||||
titleProgressController.progress = downloadThread.getCurrentDownloadingItemProgress();
|
||||
double mb = indexItem.getArchiveSizeMB();
|
||||
String v ;
|
||||
if (titleProgressController.progress != -1) {
|
||||
v = getMapActivity().getString(R.string.value_downloaded_from_max, mb * titleProgressController.progress / 100, mb);
|
||||
} else {
|
||||
v = getMapActivity().getString(R.string.file_size_in_mb, mb);
|
||||
}
|
||||
if(indexItem.getType() == DownloadActivityType.ROADS_FILE) {
|
||||
titleProgressController.caption = indexItem.getType().getString(getMapActivity()) + " • " + v;
|
||||
} else {
|
||||
titleProgressController.caption = v;
|
||||
}
|
||||
titleProgressController.visible = true;
|
||||
} else {
|
||||
titleProgressController.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteItem() {
|
||||
final OsmandApplication app = getMapActivity().getMyApplication();
|
||||
final File fl = indexItem.getTargetFile(app);
|
||||
if (fl.exists()) {
|
||||
AlertDialog.Builder confirm = new AlertDialog.Builder(getMapActivity());
|
||||
confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
getMapActivity().getContextMenu().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
boolean successfull = Algorithms.removeAllFiles(fl.getAbsoluteFile());
|
||||
if (successfull) {
|
||||
app.getResourceManager().closeFile(fl.getName());
|
||||
}
|
||||
app.getDownloadThread().updateLoadedFiles();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
|
||||
}.execute((Void) null);
|
||||
}
|
||||
});
|
||||
confirm.setNegativeButton(R.string.shared_string_no, null);
|
||||
String fn = FileNameTranslationHelper.getFileName(getMapActivity(), app.getRegions(),
|
||||
indexItem.getVisibleName(getMapActivity(), app.getRegions()));
|
||||
confirm.setMessage(getMapActivity().getString(R.string.delete_confirmation_msg, fn));
|
||||
confirm.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,6 +356,17 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if (o instanceof BinaryMapDataObject) {
|
||||
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
if (region != null) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_WORLD_REGION,
|
||||
view.getContext().getString(R.string.shared_string_map), region.getLocaleName());
|
||||
} else {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_WORLD_REGION,
|
||||
view.getContext().getString(R.string.shared_string_map), ((BinaryMapDataObject) o).getName());
|
||||
}
|
||||
}
|
||||
return new PointDescription(PointDescription.POINT_TYPE_WORLD_REGION,
|
||||
view.getContext().getString(R.string.shared_string_map), "");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue