Update indexes view updated
This commit is contained in:
parent
706f32e5d5
commit
9304baf931
6 changed files with 148 additions and 78 deletions
|
@ -43,8 +43,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textSize="12sp"
|
android:textSize="@dimen/download_descr_text_size"
|
||||||
tools:text="@string/lorem_ipsum"/>
|
tools:text="@string/app_version"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/update_descr"
|
android:id="@+id/update_descr"
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/color_distance"
|
android:textColor="@color/color_distance"
|
||||||
android:textSize="12sp"
|
android:textSize="@dimen/download_descr_text_size"
|
||||||
tools:text="@string/lorem_ipsum"
|
tools:text="@string/lorem_ipsum"
|
||||||
android:maxLines="1"/>
|
android:maxLines="1"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -74,9 +74,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="?attr/dashboardGeneralButtonStyle"
|
style="?attr/dashboardGeneralButtonStyle"
|
||||||
android:layout_marginTop="@dimen/list_header_settings_top_margin"
|
|
||||||
android:layout_marginRight="0dp"
|
android:layout_marginRight="0dp"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="center_vertical"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:src="?attr/list_settings_icon"/>
|
android:src="?attr/list_settings_icon"/>
|
||||||
|
|
||||||
|
|
37
OsmAnd/res/layout/update_index.xml
Normal file
37
OsmAnd/res/layout/update_index.xml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?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="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/list_header_padding">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/select_all"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/updates"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/list_header_text_left_margin"
|
||||||
|
android:text="@string/download_tab_updates"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
style="@style/OsmandListView"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
</LinearLayout>
|
|
@ -1,35 +1,48 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:paddingTop="1dp"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="1dp"
|
android:background="?attr/expandable_list_item_background"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:paddingRight="@dimen/list_content_padding">
|
android:paddingBottom="1dp"
|
||||||
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
|
android:paddingRight="@dimen/list_content_padding"
|
||||||
|
android:paddingTop="1dp">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/check_download_item"
|
android:id="@+id/check_download_item"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"
|
android:focusable="false"
|
||||||
android:focusable="false" />
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/download_item"
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:maxLines="7"
|
android:orientation="vertical">
|
||||||
android:layout_weight="1"
|
|
||||||
style="@style/ListText.Small" />
|
<TextView
|
||||||
|
android:id="@+id/download_item"
|
||||||
|
style="@style/ListText.Small"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
tools:text="@string/app_version"
|
||||||
|
android:maxLines="7"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/download_descr"
|
||||||
|
style="@style/ListText.Small"
|
||||||
|
android:textSize="@dimen/download_descr_text_size"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:text="@string/app_version"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/download_descr"
|
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:gravity="right|center_vertical"
|
|
||||||
style="@style/ListText.Small" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -43,6 +43,7 @@
|
||||||
<!-- TextSizes -->
|
<!-- TextSizes -->
|
||||||
<dimen name="list_header_text_size">14sp</dimen>
|
<dimen name="list_header_text_size">14sp</dimen>
|
||||||
<dimen name="showAllButtonTextSize">12sp</dimen>
|
<dimen name="showAllButtonTextSize">12sp</dimen>
|
||||||
|
<dimen name="download_descr_text_size">12sp</dimen>
|
||||||
<dimen name="subHeaderTextSize">14sp</dimen>
|
<dimen name="subHeaderTextSize">14sp</dimen>
|
||||||
<dimen name="dashFavNameTextSize">16sp</dimen>
|
<dimen name="dashFavNameTextSize">16sp</dimen>
|
||||||
<dimen name="dashProgressTextSize">18sp</dimen>
|
<dimen name="dashProgressTextSize">18sp</dimen>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.map.OsmandRegions;
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -29,25 +30,62 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
private OsmandRegions osmandRegions;
|
private OsmandRegions osmandRegions;
|
||||||
private java.text.DateFormat format;
|
private java.text.DateFormat format;
|
||||||
private UpdateIndexAdapter listAdapter;
|
private UpdateIndexAdapter listAdapter;
|
||||||
private int updateColor;
|
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.update_index, container, false);
|
||||||
|
CheckBox selectAll = (CheckBox) view.findViewById(R.id.select_all);
|
||||||
|
selectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
for (IndexItem item : indexItems) {
|
||||||
|
if (isChecked) {
|
||||||
|
List<DownloadEntry> download = item.createDownloadEntry(getMyApplication(), item.getType(), new ArrayList<DownloadEntry>());
|
||||||
|
if (download.size() > 0) {
|
||||||
|
getDownloadActivity().getEntriesToDownload().put(item, download);
|
||||||
|
getDownloadActivity().updateDownloadButton(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getDownloadActivity().getEntriesToDownload().remove(item);
|
||||||
|
getDownloadActivity().updateDownloadButton(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSelectAllVisibility(boolean visible) {
|
||||||
|
View view = getView();
|
||||||
|
if (view == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (visible) {
|
||||||
|
view.findViewById(R.id.header).setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
view.findViewById(R.id.header).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
format = getMyApplication().getResourceManager().getDateFormat();
|
format = getMyApplication().getResourceManager().getDateFormat();
|
||||||
updateColor = getResources().getColor(R.color.color_update);
|
|
||||||
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
||||||
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
|
||||||
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
||||||
indexItems = new ArrayList<IndexItem>(DownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
indexItems = new ArrayList<IndexItem>(DownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
||||||
}
|
}
|
||||||
createListView(indexItems);
|
createListView();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createListView(List<IndexItem> indexItems) {
|
private void createListView() {
|
||||||
|
updateHeader();
|
||||||
if (indexItems.size() == 0) {
|
if (indexItems.size() == 0) {
|
||||||
|
indexItems.clear();
|
||||||
indexItems.add(new IndexItem(getString(R.string.everything_up_to_date), "", 0, "", 0, 0, null));
|
indexItems.add(new IndexItem(getString(R.string.everything_up_to_date), "", 0, "", 0, 0, null));
|
||||||
}
|
}
|
||||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
||||||
|
@ -60,17 +98,27 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
setListAdapter(listAdapter);
|
setListAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateHeader(){
|
||||||
|
View view = getView();
|
||||||
|
if (getView() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String header = getActivity().getString(R.string.download_tab_updates) + " - " + indexItems.size();
|
||||||
|
((TextView) view.findViewById(R.id.updates)).
|
||||||
|
setText(header);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItemsList(List<IndexItem> items) {
|
public void updateItemsList(List<IndexItem> items) {
|
||||||
if(listAdapter == null){
|
if (listAdapter == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
indexItems = new ArrayList<IndexItem>(items);
|
||||||
createListView(new ArrayList<IndexItem>(items));
|
createListView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,7 +127,7 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
onItemSelected(ch, position);
|
onItemSelected(ch, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onItemSelected(CheckBox ch, int position){
|
private void onItemSelected(CheckBox ch, int position) {
|
||||||
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
|
final IndexItem e = (IndexItem) getListAdapter().getItem(position);
|
||||||
if (ch.isChecked()) {
|
if (ch.isChecked()) {
|
||||||
ch.setChecked(!ch.isChecked());
|
ch.setChecked(!ch.isChecked());
|
||||||
|
@ -102,6 +150,7 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
updateHeader();
|
||||||
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||||
|
|
||||||
|
@ -170,11 +219,11 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterExisting() {
|
private void filterExisting() {
|
||||||
final Map<String, String> listAlreadyDownloaded = DownloadActivity.downloadListIndexThread.getDownloadedIndexFileNames();
|
final Map<String, String> listAlreadyDownloaded = DownloadActivity.downloadListIndexThread.getDownloadedIndexFileNames();
|
||||||
|
|
||||||
final List<IndexItem> filtered = new ArrayList<IndexItem>();
|
final List<IndexItem> filtered = new ArrayList<IndexItem>();
|
||||||
for (IndexItem fileItem : listAdapter.getIndexFiles()) {
|
for (IndexItem fileItem : listAdapter.getIndexFiles()) {
|
||||||
if(fileItem.isAlreadyDownloaded(listAlreadyDownloaded)){
|
if (fileItem.isAlreadyDownloaded(listAlreadyDownloaded)) {
|
||||||
filtered.add(fileItem);
|
filtered.add(fileItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,18 +256,19 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
TextView description = (TextView) v.findViewById(R.id.download_descr);
|
TextView description = (TextView) v.findViewById(R.id.download_descr);
|
||||||
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
||||||
IndexItem e = items.get(position);
|
IndexItem e = items.get(position);
|
||||||
if (e.getFileName() == getString(R.string.everything_up_to_date)){
|
if (e.getFileName().equals(getString(R.string.everything_up_to_date))) {
|
||||||
name.setText(e.getFileName());
|
name.setText(e.getFileName());
|
||||||
description.setText("");
|
description.setText("");
|
||||||
ch.setVisibility(View.INVISIBLE);
|
ch.setVisibility(View.INVISIBLE);
|
||||||
|
setSelectAllVisibility(false);
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
String eName = e.getVisibleName(getMyApplication(), osmandRegions);
|
String eName = e.getVisibleName(getMyApplication(), osmandRegions);
|
||||||
|
|
||||||
name.setText(eName.trim()); //$NON-NLS-1$
|
name.setText(eName.trim().replace('\n', ' ')); //$NON-NLS-1$
|
||||||
String d = e.getDate(format) + "\n" + e.getSizeDescription(getMyApplication());
|
String d = e.getDate(format) + " " + e.getSizeDescription(getMyApplication());
|
||||||
description.setText(d);
|
description.setText(d);
|
||||||
|
|
||||||
ch.setChecked(getDownloadActivity().getEntriesToDownload().containsKey(e));
|
ch.setChecked(getDownloadActivity().getEntriesToDownload().containsKey(e));
|
||||||
|
@ -230,42 +280,12 @@ public class UpdatesIndexFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (e.getDate(format) != null) {
|
|
||||||
Map<String, String> indexActivatedFileNames = getDownloadActivity().getIndexActivatedFileNames();
|
|
||||||
Map<String, String> indexFileNames = getDownloadActivity().getIndexFileNames();
|
|
||||||
|
|
||||||
if (indexActivatedFileNames != null && indexFileNames != null){
|
|
||||||
String sfName = e.getTargetFileName();
|
|
||||||
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
|
|
||||||
if (updatableResource && !DownloadActivity.downloadListIndexThread.checkIfItemOutdated(e)) {
|
|
||||||
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
|
|
||||||
+ indexActivatedFileNames.get(sfName));
|
|
||||||
name.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
} else if (e.getDate(format).equals(indexFileNames.get(sfName))) {
|
|
||||||
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
|
|
||||||
+ indexFileNames.get(sfName));
|
|
||||||
name.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
|
||||||
} else if (updatableResource) {
|
|
||||||
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
|
|
||||||
+ indexActivatedFileNames.get(sfName));
|
|
||||||
name.setTextColor(updateColor); // LIGHT_BLUE
|
|
||||||
name.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
} else {
|
|
||||||
name.setText(name.getText() + "\n" + getResources().getString(R.string.local_index_installed) + " : "
|
|
||||||
+ indexFileNames.get(sfName));
|
|
||||||
name.setTextColor(updateColor); // LIGHT_BLUE
|
|
||||||
name.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexFiles(List<IndexItem> filtered) {
|
public void setIndexFiles(List<IndexItem> filtered) {
|
||||||
clear();
|
clear();
|
||||||
for (IndexItem item : filtered){
|
for (IndexItem item : filtered) {
|
||||||
add(item);
|
add(item);
|
||||||
}
|
}
|
||||||
sort(new Comparator<IndexItem>() {
|
sort(new Comparator<IndexItem>() {
|
||||||
|
|
Loading…
Reference in a new issue