Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b6ef7f6204
13 changed files with 314 additions and 52 deletions
|
@ -22,7 +22,6 @@
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/viewpager"
|
android:id="@+id/viewpager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"/>
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
63
OsmAnd/res/layout/dialog_live_updates_item_settings.xml
Normal file
63
OsmAnd/res/layout/dialog_live_updates_item_settings.xml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/dashboard_blue"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Flevoland"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="The Netherlands"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@color/color_white"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Update: 4 Dec 2015, 14:41"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<GridLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
android:text="Live update"/>
|
||||||
|
<Switch/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
android:text="Only download over WiFi"
|
||||||
|
android:layout_row="2"
|
||||||
|
android:layout_column="0"/>
|
||||||
|
<Switch/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
android:text="Live update"
|
||||||
|
android:layout_row="3"
|
||||||
|
android:layout_column="0"/>
|
||||||
|
<Spinner/>
|
||||||
|
</GridLayout>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@color/color_white"/>
|
||||||
|
</LinearLayout>
|
|
@ -1,12 +1,7 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ListView android:id="@android:id/list"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".liveupdates.LiveUpdatesFragment">
|
tools:context=".liveupdates.LiveUpdatesFragment"/>
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:id="@android:id/list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<merge
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -50,7 +53,6 @@
|
||||||
app:typeface="@string/font_roboto_regular"/>
|
app:typeface="@string/font_roboto_regular"/>
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/nameTextView"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
|
@ -74,7 +76,67 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:minHeight="44dp">
|
android:minHeight="44dp">
|
||||||
|
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:text="Support country"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
app:typeface="@string/font_roboto_regular"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="Ukraine"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
app:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:minHeight="44dp">
|
||||||
|
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:text="Last pay"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
app:typeface="@string/font_roboto_regular"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="25 Nov 2015"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
app:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -82,4 +144,4 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Available maps"/>
|
android:text="Available maps"/>
|
||||||
|
|
||||||
</merge>
|
</LinearLayout>
|
|
@ -132,10 +132,10 @@
|
||||||
<!-- Map colors, layers, special purpose consistency colors -->
|
<!-- Map colors, layers, special purpose consistency colors -->
|
||||||
<color name="pos_heading">#320000FF</color>
|
<color name="pos_heading">#320000FF</color>
|
||||||
<!-- color name="pos_heading_night">#880000FF</color -->
|
<!-- color name="pos_heading_night">#880000FF</color -->
|
||||||
<color name="pos_heading_night">#88ff8800</color>
|
<color name="pos_heading_night">#88536dfe</color>
|
||||||
<color name="pos_area">#280000FF</color>
|
<color name="pos_area">#280000FF</color>
|
||||||
<!-- color name="pos_area_night">#660000FF</color -->
|
<!-- color name="pos_area_night">#660000FF</color -->
|
||||||
<color name="pos_area_night">#66ff8800</color>
|
<color name="pos_area_night">#66536dfe</color>
|
||||||
<color name="pos_around">#707CDC</color> <!-- family blue similar to above -->
|
<color name="pos_around">#707CDC</color> <!-- family blue similar to above -->
|
||||||
|
|
||||||
<color name="gpx_track">#B4B319FF</color>
|
<color name="gpx_track">#B4B319FF</color>
|
||||||
|
|
|
@ -1,20 +1,34 @@
|
||||||
package net.osmand.plus.liveupdates;
|
package net.osmand.plus.liveupdates;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
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.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||||
|
import net.osmand.plus.activities.LocalIndexHelper;
|
||||||
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
|
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||||
|
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Use the {@link LiveUpdatesFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class LiveUpdatesFragment extends Fragment {
|
public class LiveUpdatesFragment extends Fragment {
|
||||||
public static final String TITILE = "Live Updates";
|
public static final String TITILE = "Live Updates";
|
||||||
|
|
||||||
|
@ -26,10 +40,130 @@ public class LiveUpdatesFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_live_updates, container, false);
|
View view = inflater.inflate(R.layout.fragment_live_updates, container, false);
|
||||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
|
View header = inflater.inflate(R.layout.live_updates_header, listView, false);
|
||||||
|
listView.addHeaderView(header);
|
||||||
|
LiveUpdatesAdapter adapter = new LiveUpdatesAdapter(this);
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
new LoadLocalIndexTask(adapter, (ActionBarProgressActivity) getActivity()).execute();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OsmandActionBarActivity getMyActivity() {
|
||||||
|
return (OsmandActionBarActivity) getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class LiveUpdatesAdapter extends ArrayAdapter<LocalIndexInfo> {
|
||||||
|
final LiveUpdatesFragment fragment;
|
||||||
|
public LiveUpdatesAdapter(LiveUpdatesFragment fragment) {
|
||||||
|
super(fragment.getActivity(), R.layout.local_index_list_item, R.id.nameTextView);
|
||||||
|
this.fragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view = convertView;
|
||||||
|
if (view == null) {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||||
|
view = inflater.inflate(R.layout.local_index_list_item, parent, false);
|
||||||
|
view.setTag(new LocalFullMapsViewHolder(view, fragment));
|
||||||
|
}
|
||||||
|
LocalFullMapsViewHolder viewHolder = (LocalFullMapsViewHolder) view.getTag();
|
||||||
|
viewHolder.bindLocalIndexInfo(getItem(position));
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class LocalFullMapsViewHolder {
|
||||||
|
private final ImageView icon;
|
||||||
|
private final TextView nameTextView;
|
||||||
|
private final TextView descriptionTextView;
|
||||||
|
private final ImageButton options;
|
||||||
|
private final LiveUpdatesFragment fragment;
|
||||||
|
|
||||||
|
private LocalFullMapsViewHolder(View view, LiveUpdatesFragment context) {
|
||||||
|
icon = (ImageView) view.findViewById(R.id.icon);
|
||||||
|
nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
||||||
|
descriptionTextView = (TextView) view.findViewById(R.id.descriptionTextView);
|
||||||
|
options = (ImageButton) view.findViewById(R.id.options);
|
||||||
|
this.fragment = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bindLocalIndexInfo(LocalIndexInfo item) {
|
||||||
|
nameTextView.setText(item.getName());
|
||||||
|
descriptionTextView.setText(item.getDescription());
|
||||||
|
OsmandApplication context = fragment.getMyActivity().getMyApplication();
|
||||||
|
icon.setImageDrawable(context.getIconsCache().getContentIcon(R.drawable.ic_map));
|
||||||
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final FragmentManager fragmentManager = fragment.getChildFragmentManager();
|
||||||
|
new SettingsDialogFragment().show(fragmentManager, "settings");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LoadLocalIndexTask
|
||||||
|
extends AsyncTask<Void, LocalIndexInfo, List<LocalIndexInfo>>
|
||||||
|
implements AbstractLoadLocalIndexTask {
|
||||||
|
|
||||||
|
private List<LocalIndexInfo> result;
|
||||||
|
private ArrayAdapter<LocalIndexInfo> adapter;
|
||||||
|
private ActionBarProgressActivity activity;
|
||||||
|
|
||||||
|
public LoadLocalIndexTask(ArrayAdapter<LocalIndexInfo> adapter,
|
||||||
|
ActionBarProgressActivity activity) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<LocalIndexInfo> doInBackground(Void... params) {
|
||||||
|
LocalIndexHelper helper = new LocalIndexHelper(activity.getMyApplication());
|
||||||
|
return helper.getLocalIndexData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFile(LocalIndexInfo... loaded) {
|
||||||
|
publishProgress(loaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(LocalIndexInfo... values) {
|
||||||
|
for (LocalIndexInfo localIndexInfo : values) {
|
||||||
|
if (localIndexInfo.getType() == LocalIndexHelper.LocalIndexType.MAP_DATA) {
|
||||||
|
adapter.add(localIndexInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<LocalIndexInfo> result) {
|
||||||
|
this.result = result;
|
||||||
|
adapter.sort(new Comparator<LocalIndexInfo>() {
|
||||||
|
@Override
|
||||||
|
public int compare(@NonNull LocalIndexInfo lhs, @NonNull LocalIndexInfo rhs) {
|
||||||
|
return lhs.getName().compareTo(rhs.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SettingsDialogFragment extends DialogFragment {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
View view = LayoutInflater.from(getActivity())
|
||||||
|
.inflate(R.layout.dialog_live_updates_item_settings, null);
|
||||||
|
builder.setView(view)
|
||||||
|
.setPositiveButton("SAVE", null)
|
||||||
|
.setNegativeButton("CANCEL", null)
|
||||||
|
.setNeutralButton("UPDATE NOW", null);
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||||
|
|
||||||
public class LivieUpdatesActivity extends OsmandActionBarActivity {
|
public class LivieUpdatesActivity extends ActionBarProgressActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -30,7 +30,7 @@ public class LivieUpdatesActivity extends OsmandActionBarActivity {
|
||||||
|
|
||||||
public static class MyAdapter extends FragmentPagerAdapter {
|
public static class MyAdapter extends FragmentPagerAdapter {
|
||||||
private final Fragment[] fragments = new Fragment[]{new LiveUpdatesFragment()};
|
private final Fragment[] fragments = new Fragment[]{new LiveUpdatesFragment()};
|
||||||
private final String[] titles = new String[] {LiveUpdatesFragment.TITILE};
|
private final String[] titles = new String[]{LiveUpdatesFragment.TITILE};
|
||||||
|
|
||||||
public MyAdapter(FragmentManager fm) {
|
public MyAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm);
|
||||||
|
|
|
@ -7,10 +7,6 @@ import android.widget.ProgressBar;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Denis
|
|
||||||
* on 23.01.15.
|
|
||||||
*/
|
|
||||||
public class ActionBarProgressActivity extends OsmandActionBarActivity {
|
public class ActionBarProgressActivity extends OsmandActionBarActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,7 +12,7 @@ import net.osmand.map.TileSourceManager;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SQLiteTileSource;
|
import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.download.ui.LocalIndexesFragment.LoadLocalIndexTask;
|
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
|
||||||
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<LocalIndexInfo> getLocalIndexData(LoadLocalIndexTask loadTask){
|
public List<LocalIndexInfo> getLocalIndexData(AbstractLoadLocalIndexTask loadTask){
|
||||||
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
|
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
|
||||||
List<LocalIndexInfo> result = new ArrayList<>();
|
List<LocalIndexInfo> result = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -106,8 +106,15 @@ public class LocalIndexHelper {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LocalIndexInfo> getLocalFullMaps(AbstractLoadLocalIndexTask loadTask) {
|
||||||
|
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
|
||||||
|
List<LocalIndexInfo> result = new ArrayList<>();
|
||||||
|
loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps);
|
||||||
|
|
||||||
private void loadVoiceData(File voiceDir, List<LocalIndexInfo> result, boolean backup, LoadLocalIndexTask loadTask) {
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadVoiceData(File voiceDir, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
||||||
if (voiceDir.canRead()) {
|
if (voiceDir.canRead()) {
|
||||||
//First list TTS files, they are preferred
|
//First list TTS files, they are preferred
|
||||||
for (File voiceF : listFilesSorted(voiceDir)) {
|
for (File voiceF : listFilesSorted(voiceDir)) {
|
||||||
|
@ -139,7 +146,7 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTilesData(File tilesPath, List<LocalIndexInfo> result, boolean backup, LoadLocalIndexTask loadTask) {
|
private void loadTilesData(File tilesPath, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
||||||
if (tilesPath.canRead()) {
|
if (tilesPath.canRead()) {
|
||||||
for (File tileFile : listFilesSorted(tilesPath)) {
|
for (File tileFile : listFilesSorted(tilesPath)) {
|
||||||
if (tileFile.isFile() && tileFile.getName().endsWith(SQLiteTileSource.EXT)) {
|
if (tileFile.isFile() && tileFile.getName().endsWith(SQLiteTileSource.EXT)) {
|
||||||
|
@ -171,7 +178,7 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadSrtmData(File mapPath, List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {
|
private void loadSrtmData(File mapPath, List<LocalIndexInfo> result, AbstractLoadLocalIndexTask loadTask) {
|
||||||
if (mapPath.canRead()) {
|
if (mapPath.canRead()) {
|
||||||
for (File mapFile : listFilesSorted(mapPath)) {
|
for (File mapFile : listFilesSorted(mapPath)) {
|
||||||
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
|
@ -184,7 +191,7 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadWikiData(File mapPath, List<LocalIndexInfo> result, LoadLocalIndexTask loadTask) {
|
private void loadWikiData(File mapPath, List<LocalIndexInfo> result, AbstractLoadLocalIndexTask loadTask) {
|
||||||
if (mapPath.canRead()) {
|
if (mapPath.canRead()) {
|
||||||
for (File mapFile : listFilesSorted(mapPath)) {
|
for (File mapFile : listFilesSorted(mapPath)) {
|
||||||
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
|
@ -197,7 +204,7 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadObfData(File mapPath, List<LocalIndexInfo> result, boolean backup, LoadLocalIndexTask loadTask, Map<String, String> loadedMaps) {
|
private void loadObfData(File mapPath, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask, Map<String, String> loadedMaps) {
|
||||||
if (mapPath.canRead()) {
|
if (mapPath.canRead()) {
|
||||||
for (File mapFile : listFilesSorted(mapPath)) {
|
for (File mapFile : listFilesSorted(mapPath)) {
|
||||||
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
|
|
|
@ -50,4 +50,8 @@ public class OsmandActionBarActivity extends AppCompatActivity {
|
||||||
setupHomeButton();
|
setupHomeButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication) getApplication();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,10 +208,6 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
||||||
return localIndexInfos;
|
return localIndexInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandApplication getMyApplication() {
|
|
||||||
return (OsmandApplication) getApplication();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package net.osmand.plus.download.ui;
|
||||||
|
|
||||||
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
|
|
||||||
|
public interface AbstractLoadLocalIndexTask {
|
||||||
|
void loadFile(LocalIndexInfo... loaded);
|
||||||
|
}
|
|
@ -161,7 +161,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
||||||
current.isCancelled() || current.getResult() != null) {
|
current.isCancelled() || current.getResult() != null) {
|
||||||
asyncLoader = new LoadLocalIndexTask();
|
asyncLoader = new LoadLocalIndexTask();
|
||||||
asyncLoader.execute(getActivity());
|
asyncLoader.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,16 +277,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class LoadLocalIndexTask extends AsyncTask<Activity, LocalIndexInfo, List<LocalIndexInfo>> {
|
public class LoadLocalIndexTask extends AsyncTask<Void, LocalIndexInfo, List<LocalIndexInfo>>
|
||||||
|
implements AbstractLoadLocalIndexTask {
|
||||||
|
|
||||||
private List<LocalIndexInfo> result;
|
private List<LocalIndexInfo> result;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<LocalIndexInfo> doInBackground(Activity... params) {
|
protected List<LocalIndexInfo> doInBackground(Void... params) {
|
||||||
LocalIndexHelper helper = new LocalIndexHelper(getMyApplication());
|
LocalIndexHelper helper = new LocalIndexHelper(getMyApplication());
|
||||||
return helper.getLocalIndexData(this);
|
return helper.getLocalIndexData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void loadFile(LocalIndexInfo... loaded) {
|
public void loadFile(LocalIndexInfo... loaded) {
|
||||||
publishProgress(loaded);
|
publishProgress(loaded);
|
||||||
}
|
}
|
||||||
|
@ -888,7 +890,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
LocalIndexInfoViewHolder viewHolder;
|
LocalIndexInfoViewHolder viewHolder;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = LayoutInflater.from(ctx);
|
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||||
convertView = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
convertView = inflater.inflate(R.layout.local_index_list_item, parent, false);
|
||||||
viewHolder = new LocalIndexInfoViewHolder(convertView);
|
viewHolder = new LocalIndexInfoViewHolder(convertView);
|
||||||
convertView.setTag(viewHolder);
|
convertView.setTag(viewHolder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -918,9 +920,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
if (group.getSubfolder() != null) {
|
if (group.getSubfolder() != null) {
|
||||||
name.append(" ").append(group.getSubfolder());
|
name.append(" ").append(group.getSubfolder());
|
||||||
}
|
}
|
||||||
if (group.isBackupedData()) {
|
|
||||||
ctx.getString(R.string.local_indexes_cat_backup);
|
|
||||||
}
|
|
||||||
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
|
||||||
TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
|
TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
|
||||||
List<LocalIndexInfo> list = data.get(group);
|
List<LocalIndexInfo> list = data.get(group);
|
||||||
|
|
Loading…
Reference in a new issue