Download map from context menu in progress
This commit is contained in:
parent
6c29a3c865
commit
cab8ac2d90
5 changed files with 158 additions and 19 deletions
|
@ -213,6 +213,59 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/download_buttons_container"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/context_menu_buttons_top_margin"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/context_menu_buttons_padding_bottom"
|
||||||
|
android:paddingLeft="62dp"
|
||||||
|
android:paddingRight="2dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/download_buttons_top_border"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/download_button_left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="left|center_vertical"
|
||||||
|
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||||
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
|
android:text="@string/shared_string_download"
|
||||||
|
android:textColor="?attr/contextMenuButtonColor"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/download_button_right"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||||
|
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||||
|
android:text="@string/shared_string_delete"
|
||||||
|
android:textColor="?attr/contextMenuButtonColor"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/title_progress_container"
|
android:id="@+id/title_progress_container"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -785,6 +785,22 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TitleButtonController getLeftDownloadButtonController() {
|
||||||
|
if (menuController != null) {
|
||||||
|
return menuController.getLeftDownloadButtonController();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TitleButtonController getRightDownloadButtonController() {
|
||||||
|
if (menuController != null) {
|
||||||
|
return menuController.getRightDownloadButtonController();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TitleProgressController getTitleProgressController() {
|
public TitleProgressController getTitleProgressController() {
|
||||||
if (menuController != null) {
|
if (menuController != null) {
|
||||||
return menuController.getTitleProgressController();
|
return menuController.getTitleProgressController();
|
||||||
|
|
|
@ -68,6 +68,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
private TitleButtonController leftTitleButtonController;
|
private TitleButtonController leftTitleButtonController;
|
||||||
private TitleButtonController rightTitleButtonController;
|
private TitleButtonController rightTitleButtonController;
|
||||||
private TitleButtonController topRightTitleButtonController;
|
private TitleButtonController topRightTitleButtonController;
|
||||||
|
private TitleButtonController leftDownloadButtonController;
|
||||||
|
private TitleButtonController rightDownloadButtonController;
|
||||||
private TitleProgressController titleProgressController;
|
private TitleProgressController titleProgressController;
|
||||||
|
|
||||||
private int menuTopViewHeight;
|
private int menuTopViewHeight;
|
||||||
|
@ -128,6 +130,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
leftTitleButtonController = menu.getLeftTitleButtonController();
|
leftTitleButtonController = menu.getLeftTitleButtonController();
|
||||||
rightTitleButtonController = menu.getRightTitleButtonController();
|
rightTitleButtonController = menu.getRightTitleButtonController();
|
||||||
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||||
|
|
||||||
|
leftDownloadButtonController = menu.getLeftDownloadButtonController();
|
||||||
|
rightDownloadButtonController = menu.getRightDownloadButtonController();
|
||||||
titleProgressController = menu.getTitleProgressController();
|
titleProgressController = menu.getTitleProgressController();
|
||||||
|
|
||||||
map = getMapActivity().getMapView();
|
map = getMapActivity().getMapView();
|
||||||
|
@ -170,6 +175,28 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Left download button
|
||||||
|
final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
|
||||||
|
if (leftDownloadButtonController != null) {
|
||||||
|
leftDownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
leftDownloadButtonController.buttonPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right download button
|
||||||
|
final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
|
||||||
|
if (rightDownloadButtonController != null) {
|
||||||
|
rightDownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
rightDownloadButtonController.buttonPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Top Right title button
|
// Top Right title button
|
||||||
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
|
||||||
if (topRightTitleButtonController != null) {
|
if (topRightTitleButtonController != null) {
|
||||||
|
@ -564,10 +591,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
|
|
||||||
private void updateButtonsAndProgress() {
|
private void updateButtonsAndProgress() {
|
||||||
// Title buttons
|
// Title buttons
|
||||||
boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null)
|
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
||||||
&& (titleProgressController == null || !titleProgressController.visible);
|
|
||||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
||||||
titleButtonsContainer.setVisibility(showButtonsContainer ? View.VISIBLE : View.GONE);
|
titleButtonsContainer.setVisibility(showTitleButtonsContainer ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
// Left title button
|
// Left title button
|
||||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||||
|
@ -619,6 +645,40 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
topRightTitleButton.setVisibility(View.GONE);
|
topRightTitleButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download buttons
|
||||||
|
boolean showDownloadButtonsContainer = (leftDownloadButtonController != null || rightDownloadButtonController != null)
|
||||||
|
&& (titleProgressController == null || !titleProgressController.visible);
|
||||||
|
final View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
|
||||||
|
downloadButtonsContainer.setVisibility(showDownloadButtonsContainer ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
// Left download button
|
||||||
|
final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
|
||||||
|
if (leftDownloadButtonController != null) {
|
||||||
|
leftDownloadButton.setText(leftDownloadButtonController.caption);
|
||||||
|
leftDownloadButton.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
||||||
|
if (leftIcon != null) {
|
||||||
|
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||||
|
leftDownloadButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
leftDownloadButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right download button
|
||||||
|
final Button rightDownloadButton = (Button) view.findViewById(R.id.download_button_right);
|
||||||
|
if (rightDownloadButtonController != null) {
|
||||||
|
rightDownloadButton.setText(rightDownloadButtonController.caption);
|
||||||
|
rightDownloadButton.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
||||||
|
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||||
|
rightDownloadButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||||
|
} else {
|
||||||
|
rightDownloadButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
||||||
if (titleProgressController != null) {
|
if (titleProgressController != null) {
|
||||||
|
|
|
@ -66,6 +66,8 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
protected TitleButtonController rightTitleButtonController;
|
protected TitleButtonController rightTitleButtonController;
|
||||||
protected TitleButtonController topRightTitleButtonController;
|
protected TitleButtonController topRightTitleButtonController;
|
||||||
|
|
||||||
|
protected TitleButtonController leftDownloadButtonController;
|
||||||
|
protected TitleButtonController rightDownloadButtonController;
|
||||||
protected TitleProgressController titleProgressController;
|
protected TitleProgressController titleProgressController;
|
||||||
|
|
||||||
public MenuController(MenuBuilder builder, PointDescription pointDescription, MapActivity mapActivity) {
|
public MenuController(MenuBuilder builder, PointDescription pointDescription, MapActivity mapActivity) {
|
||||||
|
@ -235,6 +237,14 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
return topRightTitleButtonController;
|
return topRightTitleButtonController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TitleButtonController getLeftDownloadButtonController() {
|
||||||
|
return leftDownloadButtonController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TitleButtonController getRightDownloadButtonController() {
|
||||||
|
return rightDownloadButtonController;
|
||||||
|
}
|
||||||
|
|
||||||
public TitleProgressController getTitleProgressController() {
|
public TitleProgressController getTitleProgressController() {
|
||||||
return titleProgressController;
|
return titleProgressController;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class MapDataMenuController extends MenuController {
|
||||||
OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||||
srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();
|
srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();
|
||||||
|
|
||||||
leftTitleButtonController = new TitleButtonController() {
|
leftDownloadButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
if (backuped) {
|
if (backuped) {
|
||||||
|
@ -112,10 +112,10 @@ public class MapDataMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
|
leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
|
||||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_import;
|
leftDownloadButtonController.leftIconId = R.drawable.ic_action_import;
|
||||||
|
|
||||||
rightTitleButtonController = new TitleButtonController() {
|
rightDownloadButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
if (indexItem != null) {
|
if (indexItem != null) {
|
||||||
|
@ -129,8 +129,8 @@ public class MapDataMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
|
rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
|
||||||
rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
||||||
|
|
||||||
topRightTitleButtonController = new TitleButtonController() {
|
topRightTitleButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -317,28 +317,28 @@ public class MapDataMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
leftTitleButtonController.visible = true;
|
leftDownloadButtonController.visible = true;
|
||||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_import;
|
leftDownloadButtonController.leftIconId = R.drawable.ic_action_import;
|
||||||
if (backuped) {
|
if (backuped) {
|
||||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.local_index_mi_restore);
|
leftDownloadButtonController.caption = getMapActivity().getString(R.string.local_index_mi_restore);
|
||||||
} else if (indexItem != null) {
|
} else if (indexItem != null) {
|
||||||
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
|
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
|
||||||
|| indexItem.getType() == DownloadActivityType.HILLSHADE_FILE)
|
|| indexItem.getType() == DownloadActivityType.HILLSHADE_FILE)
|
||||||
&& srtmDisabled) {
|
&& srtmDisabled) {
|
||||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.get_plugin);
|
leftDownloadButtonController.caption = getMapActivity().getString(R.string.get_plugin);
|
||||||
leftTitleButtonController.leftIconId = 0;
|
leftDownloadButtonController.leftIconId = 0;
|
||||||
} else if (indexItem.isOutdated()) {
|
} else if (indexItem.isOutdated()) {
|
||||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_update);
|
leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_update);
|
||||||
} else if (!downloaded) {
|
} else if (!downloaded) {
|
||||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
|
leftDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_download);
|
||||||
} else {
|
} else {
|
||||||
leftTitleButtonController.visible = false;
|
leftDownloadButtonController.visible = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
leftTitleButtonController.visible = false;
|
leftDownloadButtonController.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rightTitleButtonController.visible = downloaded;
|
rightDownloadButtonController.visible = downloaded;
|
||||||
topRightTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|
topRightTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|
||||||
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
|
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue