Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-15 11:19:40 +02:00
commit e1b44d0433
2 changed files with 31 additions and 61 deletions

View file

@ -13,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
@ -42,28 +41,6 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
private UpdateIndexAdapter listAdapter;
List<IndexItem> indexItems = new ArrayList<>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.update_index, container, false);
return view;
}
private void refreshSelectAll() {
View view = getView();
if (view == null) {
return;
}
CheckBox selectAll = (CheckBox) view.findViewById(R.id.select_all);
for (IndexItem item : indexItems) {
if (!getMyActivity().getEntriesToDownload().containsKey(item)){
selectAll.setChecked(false);
return;
}
}
selectAll.setChecked(true);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -74,6 +51,11 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.update_index, container, false);
}
private void createListView() {
updateHeader();
if (indexItems.size() == 0) {
@ -96,6 +78,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
}
private void updateHeader() {
osmandRegions = getMyApplication().getRegions();
View view = getView();
if (getView() == null) {
return;
@ -120,25 +103,8 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
onItemSelected(ch, position);
}
private void onItemSelected(CheckBox ch, int position) {
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
if (ch.isChecked()) {
ch.setChecked(!ch.isChecked());
getMyActivity().getEntriesToDownload().remove(e);
getMyActivity().updateFragments();
} else {
List<DownloadEntry> download = e.createDownloadEntry(getMyApplication(), e.getType(), new ArrayList<DownloadEntry>());
if (download.size() > 0) {
getMyActivity().getEntriesToDownload().put(e, download);
getMyActivity().updateFragments();
ch.setChecked(!ch.isChecked());
}
}
refreshSelectAll();
getMyActivity().startDownload(e);
}
public DownloadActivity getMyActivity() {
@ -313,6 +279,10 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
e1.printStackTrace();
}
}
rightImageButton.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(
context.getMyApplication().getIconsCache()
.getContentIcon(R.drawable.ic_action_import));
}

View file

@ -133,7 +133,7 @@ public class ItemViewHolder {
descrTextView.setText(indexItem.getSizeDescription(context));
}
rightImageButton.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(getContextIcon(context, R.drawable.ic_action_import));
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
progressBar.setVisibility(View.GONE);
if (rightButtonAction != RightButtonAction.UNKNOWN) {
@ -195,15 +195,15 @@ public class ItemViewHolder {
int colorId = outdated ? R.color.color_distance : R.color.color_ok;
final int color = context.getResources().getColor(colorId);
mapDateTextView.setTextColor(color);
leftImageView.setImageDrawable(getContextIcon(context,
leftImageView.setImageDrawable(getContentIcon(context,
indexItem.getType().getIconResource(), color));
nameTextView.setTextColor(textColorPrimary);
} else if (disabled) {
leftImageView.setImageDrawable(getContextIcon(context,
leftImageView.setImageDrawable(getContentIcon(context,
indexItem.getType().getIconResource(), textColorSecondary));
nameTextView.setTextColor(textColorSecondary);
} else {
leftImageView.setImageDrawable(getContextIcon(context,
leftImageView.setImageDrawable(getContentIcon(context,
indexItem.getType().getIconResource()));
nameTextView.setTextColor(textColorPrimary);
}
@ -227,14 +227,14 @@ public class ItemViewHolder {
Drawable leftImageDrawable = null;
switch (region.getMapState()) {
case NOT_DOWNLOADED:
leftImageDrawable = getContextIcon(context, R.drawable.ic_map);
leftImageDrawable = getContentIcon(context, R.drawable.ic_map);
break;
case DOWNLOADED:
leftImageDrawable = getContextIcon(context, R.drawable.ic_map,
leftImageDrawable = getContentIcon(context, R.drawable.ic_map,
context.getResources().getColor(R.color.color_ok));
break;
case OUTDATED:
leftImageDrawable = getContextIcon(context, R.drawable.ic_map,
leftImageDrawable = getContentIcon(context, R.drawable.ic_map,
context.getResources().getColor(R.color.color_distance));
break;
}
@ -244,11 +244,11 @@ public class ItemViewHolder {
progressBar.setVisibility(View.GONE);
}
private Drawable getContextIcon(DownloadActivity context, int resourceId) {
private Drawable getContentIcon(DownloadActivity context, int resourceId) {
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
}
private Drawable getContextIcon(DownloadActivity context, int resourceId, int color) {
private Drawable getContentIcon(DownloadActivity context, int resourceId, int color) {
return context.getMyApplication().getIconsCache().getPaintedContentIcon(resourceId, color);
}