Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-06-14 19:10:57 +02:00
commit 243f7ec3e0
13 changed files with 158 additions and 46 deletions

View file

@ -200,11 +200,13 @@ public class Amenity extends MapObject {
return ""; return "";
} }
public List<String> getNames(String tag) { public List<String> getNames(String tag, String defTag) {
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
for (String nm : getAdditionalInfo().keySet()) { for (String nm : getAdditionalInfo().keySet()) {
if (nm.startsWith(tag+":")) { if (nm.startsWith(tag+":")) {
l.add(nm.substring(tag.length() +1)); l.add(nm.substring(tag.length() +1));
} else if(nm.equals(tag)) {
l.add(defTag);
} }
} }
return l; return l;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical" >
<net.osmand.plus.views.controls.PagerSlidingTabStrip <net.osmand.plus.views.controls.PagerSlidingTabStrip
android:id="@+id/sliding_tabs" android:id="@+id/sliding_tabs"
@ -17,7 +17,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible" >
<RelativeLayout <RelativeLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -25,7 +25,7 @@
android:layout_marginLeft="3dp" android:layout_marginLeft="3dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:gravity="center_vertical|left" android:gravity="center_vertical|left"
android:orientation="horizontal"> android:orientation="horizontal" >
<ProgressBar <ProgressBar
android:id="@+id/IndeterminateProgressBar" android:id="@+id/IndeterminateProgressBar"
@ -71,7 +71,7 @@
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal" >
<ProgressBar <ProgressBar
android:id="@+id/memory_progress" android:id="@+id/memory_progress"
@ -88,21 +88,35 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
android:id="@+id/pager" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />
<Button <LinearLayout
android:id="@+id/DownloadButton"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:id="@+id/DownloadLayout"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:background="?attr/downloadButtonBackground" android:orientation="horizontal" >
android:gravity="center"
android:text="@string/shared_string_download" <Button
android:textColor="?attr/pstsTextColor" android:id="@+id/DownloadButton"
android:visibility="gone" /> android:layout_width="0dp"
android:layout_height="@dimen/list_item_height"
android:layout_weight="1"
android:background="?attr/downloadButtonBackground"
android:gravity="center"
android:text="@string/shared_string_download"
android:textColor="?attr/pstsTextColor"/>
<ImageView
android:id="@+id/WikiButton"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:scaleType="centerInside"
android:background="?attr/downloadButtonBackground"
android:gravity="center"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -120,7 +120,7 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
return true; return true;
} }
private void addToDownload(IndexItem item) { protected void addToDownload(IndexItem item) {
List<DownloadEntry> download = item.createDownloadEntry(getMyApplication(), item.getType(), new ArrayList<DownloadEntry>()); List<DownloadEntry> download = item.createDownloadEntry(getMyApplication(), item.getType(), new ArrayList<DownloadEntry>());
getEntriesToDownload().put(item, download); getEntriesToDownload().put(item, download);
} }
@ -152,22 +152,8 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
protected void downloadFilesCheckFreeVersion() { protected void downloadFilesCheckFreeVersion() {
if (Version.isFreeVersion(getMyApplication())) { if (Version.isFreeVersion(getMyApplication())) {
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get(); int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
boolean wiki = false; if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
for (IndexItem es : DownloadActivity.downloadListIndexThread.getEntriesToDownload().keySet()) { dialogToInstallPaid();
if (es.getBasename() != null && es.getBasename().contains("_wiki")) {
wiki = true;
break;
} else if (DownloadActivityType.isCountedInDownloads(es)) {
total++;
}
}
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS || wiki) {
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);
msg.setPositiveButton(R.string.shared_string_ok, null);
msg.show();
} else { } else {
downloadFilesCheckInternet(); downloadFilesCheckInternet();
} }
@ -176,6 +162,31 @@ 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() { protected void downloadFilesCheckInternet() {
if (!getMyApplication().getSettings().isWifiConnected()) { if (!getMyApplication().getSettings().isWifiConnected()) {
if (getMyApplication().getSettings().isInternetConnectionAvailable()) { if (getMyApplication().getSettings().isInternetConnectionAvailable()) {
@ -242,7 +253,7 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
m += getString(R.string.available_downloads_left, MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get()); m += getString(R.string.available_downloads_left, MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get());
msg.setMessage(m); msg.setMessage(m);
if (Version.isMarketEnabled(getMyApplication())) { if (Version.isMarketEnabled(getMyApplication())) {
msg.setNeutralButton(R.string.install_paid, new DialogInterface.OnClickListener() { msg.setPositiveButton(R.string.install_paid, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + "net.osmand.plus")); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + "net.osmand.plus"));
@ -252,8 +263,11 @@ public class BaseDownloadActivity extends ActionBarProgressActivity {
} }
} }
}); });
msg.setNegativeButton(R.string.shared_string_cancel, null);
} else {
msg.setNeutralButton(R.string.shared_string_ok, null);
} }
msg.setPositiveButton(R.string.shared_string_ok, null);
msg.show(); msg.show();
} }
} }

View file

@ -3,8 +3,10 @@ package net.osmand.plus.download;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -19,6 +21,7 @@ import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -137,6 +140,14 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
}); });
findViewById(R.id.WikiButton).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
downloadWikiFiles();
}
});
((ImageView)findViewById(R.id.WikiButton)).setImageResource(R.drawable.ic_action_wikipedia);
downloadTypes = createDownloadTypes(); downloadTypes = createDownloadTypes();
final Intent intent = getIntent(); final Intent intent = getIntent();
@ -160,7 +171,6 @@ public class DownloadActivity extends BaseDownloadActivity {
public Map<String, String> getIndexActivatedFileNames() { public Map<String, String> getIndexActivatedFileNames() {
return downloadListIndexThread != null ? downloadListIndexThread.getIndexActivatedFileNames() : null; return downloadListIndexThread != null ? downloadListIndexThread.getIndexActivatedFileNames() : null;
} }
@ -299,6 +309,36 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
protected void downloadWikiFiles() {
if (Version.isFreeVersion(getMyApplication())) {
dialogToInstallPaid();
} else {
Builder bld = new AlertDialog.Builder(this);
// TODO message
String countries = "";
final List<IndexItem> wi = getWikipediaItems();
for(IndexItem i : wi) {
countries += i.getDescription() +", ";
}
bld.setMessage(countries);
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for(IndexItem i : wi) {
addToDownload(i);
}
}
});
bld.setPositiveButton(R.string.shared_string_cancel, null);
if(wi.size() > 0) {
bld.show();
}
}
}
@Override @Override
public void updateDownloadButton() { public void updateDownloadButton() {
// View view = getView(); // View view = getView();
@ -308,7 +348,7 @@ public class DownloadActivity extends BaseDownloadActivity {
// int x = getExpandableListView().getScrollX(); // int x = getExpandableListView().getScrollX();
// int y = getExpandableListView().getScrollY(); // int y = getExpandableListView().getScrollY();
if (getEntriesToDownload().isEmpty()) { if (getEntriesToDownload().isEmpty()) {
findViewById(R.id.DownloadButton).setVisibility(View.GONE); findViewById(R.id.DownloadLayout).setVisibility(View.GONE);
} else { } else {
BasicProgressAsyncTask<?, ?, ?> task = DownloadActivity.downloadListIndexThread.getCurrentRunningTask(); BasicProgressAsyncTask<?, ?, ?> task = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
boolean running = task instanceof DownloadIndexesThread.DownloadIndexesAsyncTask; boolean running = task instanceof DownloadIndexesThread.DownloadIndexesAsyncTask;
@ -320,7 +360,7 @@ public class DownloadActivity extends BaseDownloadActivity {
} else { } else {
text = getString(R.string.shared_string_downloading) + " (" + downloads + ")"; //$NON-NLS-1$ text = getString(R.string.shared_string_downloading) + " (" + downloads + ")"; //$NON-NLS-1$
} }
findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); findViewById(R.id.DownloadLayout).setVisibility(View.VISIBLE);
if (Version.isFreeVersion(getMyApplication())) { if (Version.isFreeVersion(getMyApplication())) {
int left = DownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get() - downloads; int left = DownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get() - downloads;
boolean excessLimit = left < 0; boolean excessLimit = left < 0;
@ -331,6 +371,8 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
} }
((Button) findViewById(R.id.DownloadButton)).setText(text); ((Button) findViewById(R.id.DownloadButton)).setText(text);
List<IndexItem> wikipediaItems = getWikipediaItems();
findViewById(R.id.WikiButton).setVisibility(wikipediaItems.size() == 0 ? View.GONE : View.VISIBLE);
} }
for(WeakReference<Fragment> ref : fragList) { for(WeakReference<Fragment> ref : fragList) {
@ -356,6 +398,38 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
private List<IndexItem> getWikipediaItems() {
Set<String> wikipediaItems = new HashSet<String>();
Map<String, String> indexed = getMyApplication().getResourceManager().getIndexFileNames();
for(IndexItem i : getEntriesToDownload().keySet()) {
if(i.getType() == DownloadActivityType.NORMAL_FILE) {
boolean fit = true;
fit = fit && i.getFileName().contains("obf");
fit = fit && !i.getFileName().contains("world");
String fname = i.getBasename();
if(fit && !indexed.containsKey(fname+".wiki.obf") ) {
wikipediaItems.add(fname);
}
} else if(i.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
wikipediaItems.remove(i.getBasename());
}
}
List<IndexItem> res = new ArrayList<IndexItem>();
IndexFileList list = downloadListIndexThread.getIndexFiles();
if (list != null) {
List<IndexItem> indexFiles = list.getIndexFiles();
for(IndexItem i : indexFiles) {
if(i.getType() == DownloadActivityType.WIKIPEDIA_FILE &&
wikipediaItems.contains(i.getBasename())) {
res.add(i);
}
}
}
return res;
}
public List<DownloadActivityType> getDownloadTypes() { public List<DownloadActivityType> getDownloadTypes() {
return downloadTypes; return downloadTypes;
} }
@ -436,4 +510,9 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
} }

View file

@ -171,8 +171,7 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
public void deselectAll() { public void deselectAll() {
DownloadActivity.downloadListIndexThread.getEntriesToDownload().clear(); DownloadActivity.downloadListIndexThread.getEntriesToDownload().clear();
listAdapter.notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
getDownloadActivity().updateDownloadButton();
getDownloadActivity().findViewById(R.id.DownloadButton).setVisibility(View.GONE);
} }

View file

@ -96,6 +96,11 @@ public class DownloadIndexesThread {
return indexFiles != null ? indexFiles.getIndexFiles() : null; return indexFiles != null ? indexFiles.getIndexFiles() : null;
} }
public IndexFileList getIndexFiles() {
return indexFiles;
}
public Map<String, String> getIndexFileNames(){ public Map<String, String> getIndexFileNames(){
return indexFileNames; return indexFileNames;
} }
@ -424,7 +429,7 @@ public class DownloadIndexesThread {
AccessibleToast.makeText(uiActivity, R.string.basemap_was_selected_to_download, AccessibleToast.makeText(uiActivity, R.string.basemap_was_selected_to_download,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
if (uiActivity instanceof DownloadActivity){ if (uiActivity instanceof DownloadActivity){
uiActivity.findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE); ((DownloadActivity)uiActivity).updateDownloadButton();
} }
} }
} }

View file

@ -117,7 +117,7 @@ public class DownloadOsmandIndexesHelper {
DownloadActivityType tp = DownloadActivityType.getIndexType(parser.getAttributeValue(null, "type")); DownloadActivityType tp = DownloadActivityType.getIndexType(parser.getAttributeValue(null, "type"));
if (tp != null) { if (tp != null) {
IndexItem it = tp.parseIndexItem(ctx, parser); IndexItem it = tp.parseIndexItem(ctx, parser);
if(it != null) { if(it != null && !it.getFileName().contains("_wiki")) {
result.add(it); result.add(it);
} }
} else if ("osmand_regions".equals(parser.getName())) { } else if ("osmand_regions".equals(parser.getName())) {

View file

@ -226,8 +226,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
public void deselectAll() { public void deselectAll() {
DownloadActivity.downloadListIndexThread.getEntriesToDownload().clear(); DownloadActivity.downloadListIndexThread.getEntriesToDownload().clear();
listAdapter.notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
getDownloadActivity().updateDownloadButton();
getDownloadActivity().findViewById(R.id.DownloadButton).setVisibility(View.GONE);
} }
private void filterExisting() { private void filterExisting() {

View file

@ -465,8 +465,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
final OsmandApplication app, final Amenity a, final Dialog dialog) { final OsmandApplication app, final Amenity a, final Dialog dialog) {
final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT); final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT);
Set<String> names = new TreeSet<String>(); Set<String> names = new TreeSet<String>();
names.addAll(a.getNames("content")); names.addAll(a.getNames("content", "en"));
names.addAll(a.getNames("description")); names.addAll(a.getNames("description", "en"));
for (final String n : names) { for (final String n : names) {
String vn = FileNameTranslationHelper.getVoiceName(ctx, n); String vn = FileNameTranslationHelper.getVoiceName(ctx, n);