fix issue 122, 119
git-svn-id: https://osmand.googlecode.com/svn/trunk@643 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
522ac6916f
commit
75cfb3d2c6
4 changed files with 63 additions and 17 deletions
|
@ -5,8 +5,16 @@
|
||||||
android:layout_height="fill_parent" android:orientation="vertical">
|
android:layout_height="fill_parent" android:orientation="vertical">
|
||||||
|
|
||||||
<TextView android:id="@+id/Label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/select_index_file_to_download"></TextView>
|
<TextView android:id="@+id/Label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/select_index_file_to_download"></TextView>
|
||||||
|
|
||||||
|
<EditText android:id="@+id/search_box"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/download_type_to_filter"
|
||||||
|
android:inputType="text"
|
||||||
|
android:layout_marginLeft="3dp" android:layout_marginRight="3dp"
|
||||||
|
android:maxLines="1"/>
|
||||||
|
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" ></ListView>
|
||||||
<Button android:id="@+id/DownloadButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/download_files"
|
<Button android:id="@+id/DownloadButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/download_files"
|
||||||
android:layout_marginLeft = "15dp" android:layout_marginRight = "15dp" android:visibility="gone"/>
|
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp" android:visibility="gone"/>
|
||||||
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent"
|
|
||||||
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" android:fastScrollEnabled="true"></ListView>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="download_type_to_filter">фильтровать</string>
|
||||||
<string name="use_high_res_maps">Карта высокого разрешения</string>
|
<string name="use_high_res_maps">Карта высокого разрешения</string>
|
||||||
<string name="use_high_res_maps_descr">Отображать 1:1 карты для устройств высокого разрешения</string>
|
<string name="use_high_res_maps_descr">Отображать 1:1 карты для устройств высокого разрешения</string>
|
||||||
<string name="unknown_location">В данный момент местоположение не определено</string>
|
<string name="unknown_location">В данный момент местоположение не определено</string>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="download_type_to_filter">type to filter</string>
|
||||||
<string name="use_high_res_maps">High resolution map</string>
|
<string name="use_high_res_maps">High resolution map</string>
|
||||||
<string name="use_high_res_maps_descr">Use high resolution map for high density devices</string>
|
<string name="use_high_res_maps_descr">Use high resolution map for high density devices</string>
|
||||||
<string name="unknown_location">Location unknown yet</string>
|
<string name="unknown_location">Location unknown yet</string>
|
||||||
|
|
|
@ -53,11 +53,15 @@ import android.content.DialogInterface;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Filterable;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -70,6 +74,21 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
private ProgressDialog progressFileDlg = null;
|
private ProgressDialog progressFileDlg = null;
|
||||||
private ProgressDialog progressListDlg = null;
|
private ProgressDialog progressListDlg = null;
|
||||||
private LinkedHashMap<String, DownloadEntry> entriesToDownload = new LinkedHashMap<String, DownloadEntry>();
|
private LinkedHashMap<String, DownloadEntry> entriesToDownload = new LinkedHashMap<String, DownloadEntry>();
|
||||||
|
private TextWatcher textWatcher = new TextWatcher() {
|
||||||
|
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
|
int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before,
|
||||||
|
int count) {
|
||||||
|
((DownloadIndexAdapter)getListAdapter()).getFilter().filter(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -85,6 +104,10 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EditText filterText = (EditText) findViewById(R.id.search_box);
|
||||||
|
filterText.addTextChangedListener(textWatcher);
|
||||||
|
|
||||||
if(downloadListIndexThread.getCachedIndexFiles() != null){
|
if(downloadListIndexThread.getCachedIndexFiles() != null){
|
||||||
setListAdapter(new DownloadIndexAdapter(new ArrayList<Entry<String,String>>(downloadListIndexThread.getCachedIndexFiles().entrySet())));
|
setListAdapter(new DownloadIndexAdapter(new ArrayList<Entry<String,String>>(downloadListIndexThread.getCachedIndexFiles().entrySet())));
|
||||||
} else {
|
} else {
|
||||||
|
@ -434,6 +457,10 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
if(isFinishing()){
|
if(isFinishing()){
|
||||||
interruptDownloading = true;
|
interruptDownloading = true;
|
||||||
}
|
}
|
||||||
|
if (textWatcher != null) {
|
||||||
|
EditText filterText = (EditText) findViewById(R.id.search_box);
|
||||||
|
filterText.removeTextChangedListener(textWatcher);
|
||||||
|
}
|
||||||
downloadListIndexThread.uiActivity = null;
|
downloadListIndexThread.uiActivity = null;
|
||||||
progressFileDlg = null;
|
progressFileDlg = null;
|
||||||
}
|
}
|
||||||
|
@ -537,19 +564,20 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected class DownloadIndexAdapter extends ArrayAdapter<Entry<String, String>> {
|
protected class DownloadIndexAdapter extends ArrayAdapter<Entry<String, String>> implements Filterable {
|
||||||
|
|
||||||
public DownloadIndexAdapter(List<Entry<String, String>> array) {
|
public DownloadIndexAdapter(List<Entry<String, String>> array) {
|
||||||
super(DownloadIndexActivity.this, net.osmand.R.layout.download_index_list_item, array);
|
super(DownloadIndexActivity.this, net.osmand.R.layout.download_index_list_item, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
View row = convertView;
|
View v = convertView;
|
||||||
if (row == null) {
|
if (v == null) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
row = inflater.inflate(net.osmand.R.layout.download_index_list_item, parent, false);
|
v = inflater.inflate(net.osmand.R.layout.download_index_list_item, parent, false);
|
||||||
}
|
}
|
||||||
|
final View row = v;
|
||||||
TextView item = (TextView) row.findViewById(R.id.download_item);
|
TextView item = (TextView) row.findViewById(R.id.download_item);
|
||||||
TextView description = (TextView) row.findViewById(R.id.download_descr);
|
TextView description = (TextView) row.findViewById(R.id.download_descr);
|
||||||
Entry<String, String> e = getItem(position);
|
Entry<String, String> e = getItem(position);
|
||||||
|
@ -572,6 +600,14 @@ public class DownloadIndexActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
CheckBox ch = (CheckBox) row.findViewById(R.id.check_download_item);
|
CheckBox ch = (CheckBox) row.findViewById(R.id.check_download_item);
|
||||||
ch.setChecked(entriesToDownload.containsKey(e.getKey()));
|
ch.setChecked(entriesToDownload.containsKey(e.getKey()));
|
||||||
|
ch.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
||||||
|
ch.setChecked(!ch.isChecked());
|
||||||
|
DownloadIndexActivity.this.onListItemClick(getListView(), row, position, getItemId(position));
|
||||||
|
}
|
||||||
|
});
|
||||||
item.setText(s.trim() + "\n " + name); //$NON-NLS-1$
|
item.setText(s.trim() + "\n " + name); //$NON-NLS-1$
|
||||||
description.setText(e.getValue().replace(':', '\n').trim());
|
description.setText(e.getValue().replace(':', '\n').trim());
|
||||||
return row;
|
return row;
|
||||||
|
|
Loading…
Reference in a new issue