Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-19 15:34:30 +02:00
commit 68e3e9ad29
5 changed files with 177 additions and 44 deletions

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/list_item_height"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:paddingTop="6dp"
android:tint="@color/map_widget_blue"
android:src="@drawable/ic_action_osm_live"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/osm_live"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:maxLines="25"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:text="@string/osm_live_banner_desc"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="6dp"
android:textColor="?attr/color_dialog_buttons"
android:textAllCaps="true"
android:textSize="@dimen/default_desc_text_size"
android:text="@string/get_it"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -6,18 +6,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/listMessageTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:padding="@dimen/list_content_padding"
tools:text="Germany"
android:gravity="center"
tools:visibility="visible"
android:visibility="gone"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"

View file

@ -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="get_it">Get it</string>
<string name="get_for">Get for %1$s</string>
<string name="get_for_month">Get for %1$s month</string>
<string name="osm_live_banner_desc">Get unlimited map downloads and updates more than once a month: hourly, daily or weekly.</string>

View file

@ -2,6 +2,7 @@ package net.osmand.plus.download.ui;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
@ -18,12 +19,15 @@ import android.widget.TextView;
import net.osmand.map.OsmandRegions;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.util.Algorithms;
import java.util.Comparator;
import java.util.List;
@ -31,6 +35,7 @@ import java.util.List;
public class UpdatesIndexFragment extends OsmAndListFragment implements DownloadEvents {
private static final int RELOAD_ID = 5;
private UpdateIndexAdapter listAdapter;
private String errorMessage;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -86,7 +91,9 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
final OsmandRegions osmandRegions =
getMyApplication().getResourceManager().getOsmandRegions();
listAdapter = new UpdateIndexAdapter(a, R.layout.download_index_list_item, indexItems);
OsmandSettings settings = getMyApplication().getSettings();
listAdapter = new UpdateIndexAdapter(a, R.layout.download_index_list_item, indexItems,
!settings.LIVE_UPDATES_PURCHASED.get() || settings.SHOULD_SHOW_FREE_VERSION_BANNER.get());
listAdapter.sort(new Comparator<IndexItem>() {
@Override
public int compare(IndexItem indexItem, IndexItem indexItem2) {
@ -102,17 +109,16 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
private void updateErrorMessage() {
final View view = getView();
if (view == null) return;
TextView listMessageTextView = (TextView) view.findViewById(R.id.listMessageTextView);
if (getListAdapter() != null && getListAdapter().getCount() == 0) {
final DownloadResources indexes = getMyActivity().getDownloadThread().getIndexes();
int messageId = indexes.isDownloadedFromInternet ? R.string.everything_up_to_date
: R.string.no_index_file_to_download;
listMessageTextView.setText(messageId);
listMessageTextView.setVisibility(View.VISIBLE);
errorMessage = getString(messageId);
} else {
listMessageTextView.setVisibility(View.GONE);
errorMessage = null;
}
updateUpdateAllButton();
}
private void updateUpdateAllButton() {
@ -125,9 +131,16 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
final List<IndexItem> indexItems = indexes.getItemsToUpdate();
final TextView updateAllButton = (TextView) view.findViewById(R.id.updateAllButton);
if (indexItems.size() == 0 || indexItems.get(0).getType() == null) {
updateAllButton.setVisibility(View.GONE);
if (!Algorithms.isEmpty(errorMessage)) {
updateAllButton.setText(errorMessage);
updateAllButton.setEnabled(false);
updateAllButton.setVisibility(View.VISIBLE);
} else {
updateAllButton.setVisibility(View.GONE);
}
} else {
updateAllButton.setVisibility(View.VISIBLE);
updateAllButton.setEnabled(true);
long downloadsSize = 0;
for (IndexItem indexItem : indexItems) {
downloadsSize += indexItem.getSize();
@ -151,10 +164,16 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(e, vh.getClickAction(e));
ls.onClick(v);
if (listAdapter.isShowOsmLiveBanner() && position == 0) {
Intent intent = new Intent(getMyActivity(), OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyActivity().startActivity(intent);
} else {
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(e, vh.getClickAction(e));
ls.onClick(v);
}
}
public DownloadActivity getMyActivity() {
@ -189,27 +208,73 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
}
private class UpdateIndexAdapter extends ArrayAdapter<IndexItem> {
List<IndexItem> items;
public UpdateIndexAdapter(Context context, int resource, List<IndexItem> items) {
static final int INDEX_ITEM = 0;
static final int OSM_LIVE_BANNER = 1;
List<IndexItem> items;
boolean showOsmLiveBanner;
public UpdateIndexAdapter(Context context, int resource, List<IndexItem> items, boolean showOsmLiveBanner) {
super(context, resource, items);
this.items = items;
this.showOsmLiveBanner = showOsmLiveBanner;
}
public boolean isShowOsmLiveBanner() {
return showOsmLiveBanner;
}
@Override
public int getCount() {
return super.getCount() + (showOsmLiveBanner ? 1 : 0);
}
@Override
public IndexItem getItem(int position) {
if (showOsmLiveBanner && position == 0) {
return null;
} else {
return super.getItem(position - (showOsmLiveBanner ? 1 : 0));
}
}
@Override
public int getPosition(IndexItem item) {
return super.getPosition(item) + (showOsmLiveBanner ? 1 : 0);
}
@Override
public int getViewTypeCount() {
return showOsmLiveBanner ? 2 : 1;
}
@Override
public int getItemViewType(int position) {
return showOsmLiveBanner && position == 0 ? OSM_LIVE_BANNER : INDEX_ITEM;
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
View v = convertView;
int viewType = getItemViewType(position);
if (v == null) {
LayoutInflater inflater = LayoutInflater.from(getMyActivity());
v = inflater.inflate(R.layout.two_line_with_images_list_item, parent, false);
v.setTag(new ItemViewHolder(v, getMyActivity()));
if (viewType == INDEX_ITEM) {
LayoutInflater inflater = LayoutInflater.from(getMyActivity());
v = inflater.inflate(R.layout.two_line_with_images_list_item, parent, false);
v.setTag(new ItemViewHolder(v, getMyActivity()));
} else if (viewType == OSM_LIVE_BANNER) {
LayoutInflater inflater = LayoutInflater.from(getMyActivity());
v = inflater.inflate(R.layout.osm_live_banner_list_item, parent, false);
}
}
if (viewType == INDEX_ITEM) {
ItemViewHolder holder = (ItemViewHolder) v.getTag();
holder.setShowRemoteDate(true);
holder.setShowTypeInDesc(true);
holder.setShowParentRegionName(true);
holder.bindIndexItem(getItem(position));
}
ItemViewHolder holder = (ItemViewHolder) v.getTag();
holder.setShowRemoteDate(true);
holder.setShowTypeInDesc(true);
holder.setShowParentRegionName(true);
holder.bindIndexItem(items.get(position));
return v;
}
}

View file

@ -700,19 +700,23 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
freeSpaceValue.setText(getFreeSpace(settings.getExternalStorageDirectory()));
AppCompatButton changeStorageButton = (AppCompatButton) storageView.findViewById(R.id.storage_change_button);
changeStorageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!DownloadActivity.hasPermissionToWriteExternalStorage(getContext())) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION);
if (wizardType == WizardType.MAP_DOWNLOAD) {
changeStorageButton.setEnabled(false);
} else {
changeStorageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!DownloadActivity.hasPermissionToWriteExternalStorage(getContext())) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION);
} else {
DataStoragePlaceDialogFragment.showInstance(getActivity().getSupportFragmentManager(), false);
} else {
DataStoragePlaceDialogFragment.showInstance(getActivity().getSupportFragmentManager(), false);
}
}
}
});
});
}
}
}