diff --git a/OsmAnd/res/layout/dash_updates_item.xml b/OsmAnd/res/layout/dash_updates_item.xml
index d47d3c0821..2e6d866242 100644
--- a/OsmAnd/res/layout/dash_updates_item.xml
+++ b/OsmAnd/res/layout/dash_updates_item.xml
@@ -1,66 +1,67 @@
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/list_item_height"
+ android:layout_marginLeft="@dimen/dashFavIconMargin"
+ android:layout_marginRight="@dimen/dashFavIconMargin"
+ android:orientation="vertical">
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/two_line_with_images_list_item.xml b/OsmAnd/res/layout/two_line_with_images_list_item.xml
index eb2cd10307..924b6e9577 100644
--- a/OsmAnd/res/layout/two_line_with_images_list_item.xml
+++ b/OsmAnd/res/layout/two_line_with_images_list_item.xml
@@ -48,6 +48,12 @@
android:textSize="@dimen/default_sub_text_size"
tools:text="Map, Contour Lines, Wikipedia"/>
+
@@ -60,7 +66,9 @@
android:background="?attr/dashboard_button"
android:focusable="false"
android:focusableInTouchMode="false"
- tools:src="@drawable/ic_action_import"/>
+ tools:src="@drawable/ic_action_import"
+ tools:visibility="visible"
+ android:visibility="gone"/>
\ No newline at end of file
diff --git a/OsmAnd/res/values/ids.xml b/OsmAnd/res/values/ids.xml
new file mode 100644
index 0000000000..3edf8d50b3
--- /dev/null
+++ b/OsmAnd/res/values/ids.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
index 33200ce95d..b788763e96 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java
@@ -117,8 +117,8 @@ public class DashUpdatesFragment extends DashBaseFragment {
String d = item.getDate(getMyApplication().getResourceManager().getDateFormat()) + ", "
+ item.getSizeDescription(getMyApplication());
String eName = name.replace("\n", " ");
- ((TextView) view.findViewById(R.id.map_name)).setText(eName);
- ((TextView) view.findViewById(R.id.map_descr)).setText(d);
+ ((TextView) view.findViewById(R.id.name)).setText(eName);
+ ((TextView) view.findViewById(R.id.description)).setText(d);
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.ProgressBar);
View downloadButton = (view.findViewById(R.id.btn_download));
downloadButton.setOnClickListener(new View.OnClickListener() {
@@ -170,8 +170,8 @@ public class DashUpdatesFragment extends DashBaseFragment {
}
cancelButton.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_remove_dark));
View view = (View) cancelButton.getParent();
- if (view != null && view.findViewById(R.id.map_descr) != null) {
- view.findViewById(R.id.map_descr).setVisibility(View.GONE);
+ if (view != null && view.findViewById(R.id.description) != null) {
+ view.findViewById(R.id.description).setVisibility(View.GONE);
}
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java
index 10339c58c7..6673b5c139 100644
--- a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java
@@ -1,11 +1,14 @@
package net.osmand.plus.download;
import android.app.AlertDialog;
+import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.widget.Toast;
@@ -27,10 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-/**
- * Created by Denis
- * on 25.11.2014.
- */
public class BaseDownloadActivity extends ActionBarProgressActivity {
protected DownloadActivityType type = DownloadActivityType.NORMAL_FILE;
protected OsmandSettings settings;
@@ -162,7 +161,8 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
if (Version.isFreeVersion(getMyApplication())) {
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
- dialogToInstallPaid();
+ new InstallPaidVersionDialogFragment()
+ .show(getSupportFragmentManager(), InstallPaidVersionDialogFragment.TAG);
} else {
downloadFilesCheckInternet();
}
@@ -171,44 +171,11 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
}
}
- protected void dialogToInstallPaid() {
- String msgTx = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "");
- AlertDialog.Builder msg = new AlertDialog.Builder(this);
- msg.setTitle(R.string.free_version_title);
- msg.setMessage(msgTx);
- if (Version.isMarketEnabled(getMyApplication())) {
- msg.setPositiveButton(R.string.install_paid, new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication())
- + "net.osmand.plus"));
- try {
- startActivity(intent);
- } catch (ActivityNotFoundException e) {
- }
- }
- });
- msg.setNegativeButton(R.string.shared_string_cancel, null);
- } else {
- msg.setNeutralButton(R.string.shared_string_ok, null);
- }
- msg.show();
- }
-
protected void downloadFilesCheckInternet() {
if (!getMyApplication().getSettings().isWifiConnected()) {
if (getMyApplication().getSettings().isInternetConnectionAvailable()) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(getString(R.string.download_using_mobile_internet));
- builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- downloadFilesPreCheckSpace();
- }
- });
- builder.setNegativeButton(R.string.shared_string_no, null);
- builder.show();
+ new ConfirmDownloadDialogFragment().show(getSupportFragmentManager(),
+ ConfirmDownloadDialogFragment.TAG);
} else {
AccessibleToast.makeText(this, R.string.no_index_file_to_download, Toast.LENGTH_LONG).show();
}
@@ -289,5 +256,58 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
public void removeFromQueue(IndexItem item) {
downloadQueue.remove(item);
}
+
+ public static class InstallPaidVersionDialogFragment extends DialogFragment {
+ public static final String TAG = "InstallPaidVersionDialogFragment";
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ String msgTx = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "");
+ AlertDialog.Builder msg = new AlertDialog.Builder(getActivity());
+ msg.setTitle(R.string.free_version_title);
+ msg.setMessage(msgTx);
+ if (Version.isMarketEnabled(getMyApplication())) {
+ msg.setPositiveButton(R.string.install_paid, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse(Version.marketPrefix(getMyApplication())
+ + "net.osmand.plus"));
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ }
+ }
+ });
+ msg.setNegativeButton(R.string.shared_string_cancel, null);
+ } else {
+ msg.setNeutralButton(R.string.shared_string_ok, null);
+ }
+ return msg.create();
+ }
+
+ private OsmandApplication getMyApplication() {
+ return (OsmandApplication) getActivity().getApplication();
+ }
+ }
+
+ public static class ConfirmDownloadDialogFragment extends DialogFragment {
+ public static final String TAG = "ConfirmDownloadDialogFragment";
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setMessage(getString(R.string.download_using_mobile_internet));
+ builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ ((BaseDownloadActivity) getActivity()).downloadFilesPreCheckSpace();
+ }
+ });
+ builder.setNegativeButton(R.string.shared_string_no, null);
+ return builder.create();
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
index b1f6285b32..2ca76cc790 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
@@ -360,7 +360,8 @@ public class DownloadActivity extends BaseDownloadActivity {
protected void downloadWikiFiles() {
if (Version.isFreeVersion(getMyApplication())) {
- dialogToInstallPaid();
+ new InstallPaidVersionDialogFragment().show(getSupportFragmentManager(),
+ InstallPaidVersionDialogFragment.TAG);
} else {
Builder bld = new AlertDialog.Builder(this);
final List wi = getWikipediaItems();
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java
index 343e1f23de..9542cc3c51 100644
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/newimplementation/MapsInCategoryFragment.java
@@ -7,6 +7,7 @@ import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ProgressBar;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
@@ -61,8 +62,9 @@ public class MapsInCategoryFragment extends DialogFragment {
createInstance(category).show(getChildFragmentManager(), TAG);
}
- public void onIndexItemSelected(@NonNull IndexItem indexItem) {
- LOG.debug("onIndexItemSelected()");
+ public void startMapDownload(@NonNull IndexItem indexItem,
+ @NonNull ProgressBar progressBar) {
+ LOG.debug("startMapDownload()");
((DownloadActivity) getActivity()).startDownload(indexItem);
}
diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java
index 59909a433d..ab4a5c983d 100644
--- a/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/newimplementation/SubcategoriesFragment.java
@@ -2,6 +2,7 @@ package net.osmand.plus.download.newimplementation;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -13,6 +14,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
@@ -34,7 +36,8 @@ public class SubcategoriesFragment extends Fragment {
ListView listView = new ListView(getActivity());
final OsmandApplication application = (OsmandApplication) getActivity().getApplication();
- final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity());
+ final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
+ (MapsInCategoryFragment) getParentFragment());
listView.setAdapter(mAdapter);
mAdapter.addAll(category.items);
mAdapter.addAll(category.subcats);
@@ -50,9 +53,6 @@ public class SubcategoriesFragment extends Fragment {
if (item instanceof IndexItemCategoryWithSubcat) {
((MapsInCategoryFragment) getParentFragment())
.onCategorySelected((IndexItemCategoryWithSubcat) item);
- } else if (item instanceof IndexItem) {
- ((MapsInCategoryFragment) getParentFragment())
- .onIndexItemSelected((IndexItem) item);
}
}
});
@@ -71,8 +71,11 @@ public class SubcategoriesFragment extends Fragment {
private static class MapFilesAdapter extends ArrayAdapter {
- public MapFilesAdapter(Context context) {
+ final MapsInCategoryFragment fragment;
+
+ public MapFilesAdapter(Context context, MapsInCategoryFragment fragment) {
super(context, R.layout.two_line_with_images_list_item);
+ this.fragment = fragment;
}
@Override
@@ -89,9 +92,10 @@ public class SubcategoriesFragment extends Fragment {
HasName item = getItem(position);
if (item instanceof IndexItemCategoryWithSubcat) {
viewHolder.bindCategory((IndexItemCategoryWithSubcat) item,
- (DownloadActivity)getContext());
+ (DownloadActivity) getContext());
} else if (item instanceof IndexItem) {
- viewHolder.bindIndexItem((IndexItem) item, (DownloadActivity) getContext());
+ viewHolder.bindIndexItem((IndexItem) item, (DownloadActivity) getContext(),
+ fragment);
} else {
throw new IllegalArgumentException("Item must be of type IndexItem or " +
"IndexItemCategory but is of type:" + item.getClass());
@@ -100,19 +104,22 @@ public class SubcategoriesFragment extends Fragment {
}
private static class ViewHolder {
- TextView nameTextView;
- TextView descrTextView;
- ImageView leftImageView;
- ImageView rightImageButton;
+ private final TextView nameTextView;
+ private final TextView descrTextView;
+ private final ImageView leftImageView;
+ private final ImageView rightImageButton;
+ private final ProgressBar progressBar;
public ViewHolder(View convertView) {
nameTextView = (TextView) convertView.findViewById(R.id.name);
descrTextView = (TextView) convertView.findViewById(R.id.description);
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
+ progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
}
- public void bindIndexItem(IndexItem indexItem, DownloadActivity context) {
+ public void bindIndexItem(final IndexItem indexItem, DownloadActivity context,
+ MapsInCategoryFragment fragment) {
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
nameTextView.setText(indexItem.getVisibleName(context,
context.getMyApplication().getRegions()));
@@ -120,8 +127,22 @@ public class SubcategoriesFragment extends Fragment {
nameTextView.setText(indexItem.getType().getString(context));
}
descrTextView.setText(indexItem.getSizeDescription(context));
- leftImageView.setImageDrawable(context.getMyApplication()
- .getIconsCache().getContentIcon(indexItem.getType().getIconResource()));
+ leftImageView.setImageDrawable(getContextIcon(context,
+ indexItem.getType().getIconResource()));
+ rightImageButton.setVisibility(View.VISIBLE);
+ rightImageButton.setImageDrawable(getContextIcon(context,
+ R.drawable.ic_action_import));
+ rightImageButton.setTag(R.id.index_item, indexItem);
+ rightImageButton.setTag(R.id.fragment, fragment);
+ rightImageButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((MapsInCategoryFragment) v.getTag(R.id.fragment))
+ .startMapDownload((IndexItem) v.getTag(R.id.index_item), progressBar);
+ progressBar.setVisibility(View.VISIBLE);
+ }
+ });
+ progressBar.setVisibility(View.GONE);
}
public void bindCategory(IndexItemCategoryWithSubcat category,
@@ -139,8 +160,13 @@ public class SubcategoriesFragment extends Fragment {
} else {
descrTextView.setText(R.string.shared_string_others);
}
- leftImageView.setImageDrawable(context.getMyApplication()
- .getIconsCache().getContentIcon(R.drawable.ic_map));
+ leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
+ rightImageButton.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ }
+
+ private Drawable getContextIcon(DownloadActivity context, int resourceId) {
+ return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
}
}
}