Merge pull request #1075 from Bars107/master
Favorites and updates lists.
This commit is contained in:
commit
9ce7ada675
17 changed files with 381 additions and 267 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>
|
||||||
|
|
|
@ -19,18 +19,18 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/favourite_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/favourite_icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:focusable="true"
|
||||||
android:groupIndicator="@android:color/transparent"/>
|
android:groupIndicator="@android:color/transparent"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -3,65 +3,80 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/expandable_list_item_background"
|
||||||
android:minHeight="@dimen/list_item_height"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="4dp"
|
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:paddingRight="@dimen/list_content_padding"
|
android:paddingRight="@dimen/list_content_padding">
|
||||||
android:background="?attr/expandable_list_item_background"
|
|
||||||
android:paddingTop="4dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<CheckBox
|
||||||
|
android:id="@+id/check_local_index"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="false"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginRight="@dimen/local_index_check_right_margin"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:src="@drawable/ic_sdcard"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||||
|
android:focusable="false"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/local_index_name"
|
||||||
|
style="@style/ListText.Small"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
tools:text="@string/app_version"/>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/check_local_index"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:focusable="false"
|
|
||||||
android:gravity="center_vertical"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/local_index_name"
|
|
||||||
style="@style/ListText.Small"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:maxLines="1"
|
|
||||||
tools:text="@string/lorem_ipsum"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/local_index_size"
|
android:id="@+id/local_index_size"
|
||||||
style="@style/ListText.Small"
|
style="@style/ListText.Small"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="3dp"
|
android:gravity="right"
|
||||||
android:gravity="right"/>
|
tools:text="@string/app_version"/>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/local_index_descr"
|
android:id="@+id/local_index_descr"
|
||||||
style="@style/ListText.Small"
|
style="@style/ListText.Small"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="25"
|
android:layout_marginLeft="7dp"
|
||||||
tools:text="@string/lorem_ipsum"/>
|
android:maxLines="25"
|
||||||
|
tools:text="@string/app_mode_aircraft"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/options"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="?attr/dashboardGeneralButtonStyle"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:focusable="false"
|
||||||
|
android:src="?attr/list_settings_icon"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,37 +1,37 @@
|
||||||
<?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"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/list_item_height"
|
android:minHeight="@dimen/list_item_height"
|
||||||
android:paddingBottom="5dp"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="5dp"
|
android:paddingBottom="5dp"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:paddingRight="@dimen/list_content_padding"
|
android:paddingRight="@dimen/list_content_padding"
|
||||||
android:orientation="horizontal">
|
android:paddingTop="5dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label"
|
android:id="@+id/label"
|
||||||
style="@style/ListText"
|
style="@style/ListText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="0dp"
|
android:layout_marginRight="3dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_weight="1"
|
||||||
android:layout_marginRight="3dp"
|
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
tools:text="@string/lorem_ipsum"
|
android:maxLines="1"
|
||||||
android:layout_weight="1" />
|
android:textColor="?android:textColorPrimary"
|
||||||
|
tools:text="@string/lorem_ipsum"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/remove"
|
android:id="@+id/remove"
|
||||||
android:contentDescription="@string/default_buttons_delete"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:background="?attr/reset_image"
|
||||||
android:layout_height="wrap_content"
|
android:contentDescription="@string/default_buttons_delete"
|
||||||
android:background="?attr/reset_image"
|
android:paddingLeft="2dp"
|
||||||
android:paddingLeft="2dp"
|
android:paddingRight="2dp"
|
||||||
android:paddingRight="2dp"
|
android:paddingTop="2dp"/>
|
||||||
android:paddingTop="2dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
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>
|
|
@ -33,6 +33,7 @@
|
||||||
<dimen name="list_header_bottom_margin">8dp</dimen>
|
<dimen name="list_header_bottom_margin">8dp</dimen>
|
||||||
<dimen name="bottom_tool_bar_size">48dp</dimen>
|
<dimen name="bottom_tool_bar_size">48dp</dimen>
|
||||||
<dimen name="favorites_icon_right_margin">18dp</dimen>
|
<dimen name="favorites_icon_right_margin">18dp</dimen>
|
||||||
|
<dimen name="local_index_check_right_margin">10dp</dimen>
|
||||||
<dimen name="favorites_icon_top_margin">13dp</dimen>
|
<dimen name="favorites_icon_top_margin">13dp</dimen>
|
||||||
<dimen name="dialog_elements_vertical_margin">16dp</dimen>
|
<dimen name="dialog_elements_vertical_margin">16dp</dimen>
|
||||||
<dimen name="dialog_content_margin">24dp</dimen>
|
<dimen name="dialog_content_margin">24dp</dimen>
|
||||||
|
@ -42,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>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FavoritesActivity extends TabActivity implements OsmAndLocationProvider.OsmAndCompassListener, OsmAndLocationProvider.OsmAndLocationListener {
|
public class FavoritesActivity extends TabActivity {
|
||||||
|
|
||||||
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
||||||
private static final String TRACKS = "TRACKS";
|
private static final String TRACKS = "TRACKS";
|
||||||
|
@ -125,10 +125,6 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getMyApplication().getFavorites().getFavouritePoints().size() > 0) {
|
|
||||||
getLocationProvider().addCompassListener(this);
|
|
||||||
getLocationProvider().registerOrUnregisterCompassListener(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandApplication getMyApplication() {
|
public OsmandApplication getMyApplication() {
|
||||||
|
@ -143,9 +139,6 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
((OsmandApplication) getApplication()).getSelectedGpxHelper().setUiListener(FavoritesActivity.class, null);
|
((OsmandApplication) getApplication()).getSelectedGpxHelper().setUiListener(FavoritesActivity.class, null);
|
||||||
getLocationProvider().pauseAllUpdates();
|
|
||||||
getLocationProvider().removeLocationListener(this);
|
|
||||||
getLocationProvider().removeCompassListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSelectedTracks() {
|
public void updateSelectedTracks() {
|
||||||
|
@ -217,25 +210,5 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateCompassValue(float value) {
|
|
||||||
for (WeakReference<Fragment> ref : fragList) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof FavoritesTreeFragment && !f.isDetached()) {
|
|
||||||
((FavoritesTreeFragment) f).updateCompassValue(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateLocation(Location location) {
|
|
||||||
for (WeakReference<Fragment> ref : fragList) {
|
|
||||||
Fragment f = ref.get();
|
|
||||||
if (f instanceof FavoritesTreeFragment && !f.isDetached()) {
|
|
||||||
((FavoritesTreeFragment) f).updateLocation(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,16 @@
|
||||||
*/
|
*/
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -48,7 +47,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
private boolean selectFavoriteMode;
|
private boolean selectFavoriteMode;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
|
@ -87,6 +86,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
locationUpdate(location);
|
locationUpdate(location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,6 +132,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
Drawable arrowImage;
|
||||||
|
|
||||||
public LatLon getLocation() {
|
public LatLon getLocation() {
|
||||||
return location;
|
return location;
|
||||||
|
@ -162,6 +163,14 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
super(activity, R.layout.favourites_list_item, list);
|
super(activity, R.layout.favourites_list_item, list);
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.app = ((OsmandApplication) activity.getApplication());
|
this.app = ((OsmandApplication) activity.getApplication());
|
||||||
|
boolean light = app.getSettings().isLightContent();
|
||||||
|
arrowImage = activity.getResources().getDrawable(R.drawable.ic_destination_arrow_white);
|
||||||
|
arrowImage.mutate();
|
||||||
|
if (light) {
|
||||||
|
arrowImage.setColorFilter(activity.getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
} else {
|
||||||
|
arrowImage.setColorFilter(activity.getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(FavouritePoint model){
|
public String getName(FavouritePoint model){
|
||||||
|
@ -179,8 +188,12 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
row = inflater.inflate(R.layout.favourites_list_item, parent, false);
|
row = inflater.inflate(R.layout.favourites_list_item, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView label = (TextView) row.findViewById(R.id.favourite_label);
|
TextView name = (TextView) row.findViewById(R.id.favourite_label);
|
||||||
|
TextView distanceText = (TextView) row.findViewById(R.id.distance);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||||
|
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||||
|
direction.setImageDrawable(arrowImage);
|
||||||
|
direction.setVisibility(View.VISIBLE);
|
||||||
final FavouritePoint model = getItem(position);
|
final FavouritePoint model = getItem(position);
|
||||||
if (!model.getCategory().isEmpty()){
|
if (!model.getCategory().isEmpty()){
|
||||||
row.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
|
row.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
|
||||||
|
@ -196,9 +209,8 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
.getLongitude()));
|
.getLongitude()));
|
||||||
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " " ;
|
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " " ;
|
||||||
}
|
}
|
||||||
|
distanceText.setText(distance);
|
||||||
label.setText(distance + getName(model), BufferType.SPANNABLE);
|
name.setText(getName(model));
|
||||||
((Spannable) label.getText()).setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.color_distance)), 0, distance.length(), 0);
|
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||||
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
|
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
|
||||||
ch.setVisibility(View.GONE);
|
ch.setVisibility(View.GONE);
|
||||||
|
@ -207,5 +219,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication)getActivity().getApplication();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
|
@ -12,8 +12,6 @@ import android.view.*;
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -23,26 +21,20 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.Item;
|
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
|
||||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
|
||||||
import net.osmand.plus.helpers.ColorDialogs;
|
import net.osmand.plus.helpers.ColorDialogs;
|
||||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
@ -56,7 +48,6 @@ import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
@ -89,9 +80,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<FavoriteGroup>();
|
private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<FavoriteGroup>();
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
Drawable arrowImage;
|
||||||
protected LatLon loc = null;
|
|
||||||
protected Float heading = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
|
@ -101,6 +90,15 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
favouritesAdapter = new FavouritesAdapter();
|
favouritesAdapter = new FavouritesAdapter();
|
||||||
favouritesAdapter.synchronizeGroups();
|
favouritesAdapter.synchronizeGroups();
|
||||||
setAdapter(favouritesAdapter);
|
setAdapter(favouritesAdapter);
|
||||||
|
|
||||||
|
boolean light = getMyApplication().getSettings().isLightContent();
|
||||||
|
arrowImage = getResources().getDrawable(R.drawable.ic_destination_arrow_white);
|
||||||
|
arrowImage.mutate();
|
||||||
|
if (light) {
|
||||||
|
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
} else {
|
||||||
|
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFavorites() {
|
private void deleteFavorites() {
|
||||||
|
@ -135,8 +133,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
// final LatLon mapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
// final LatLon mapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
favouritesAdapter.synchronizeGroups();
|
favouritesAdapter.synchronizeGroups();
|
||||||
|
|
||||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
if(favouritesAdapter.getGroupCount() > 0 &&
|
||||||
if(favouritesAdapter.getGroupCount() > 0 &&
|
|
||||||
"".equals(favouritesAdapter.getGroup(0).name)) {
|
"".equals(favouritesAdapter.getGroup(0).name)) {
|
||||||
getExpandableListView().expandGroup(0);
|
getExpandableListView().expandGroup(0);
|
||||||
}
|
}
|
||||||
|
@ -787,12 +784,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
distanceText.setTextColor(getResources().getColor(R.color.color_distance));
|
distanceText.setTextColor(getResources().getColor(R.color.color_distance));
|
||||||
row.findViewById(R.id.group_image).setVisibility(View.GONE);
|
row.findViewById(R.id.group_image).setVisibility(View.GONE);
|
||||||
|
|
||||||
if(loc != null){
|
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
direction.setVisibility(View.VISIBLE);
|
||||||
direction.setVisibility(View.VISIBLE);
|
direction.setImageDrawable(arrowImage);
|
||||||
DashLocationFragment.updateArrow(getActivity(), loc, new LatLon(model.getLatitude(), model.getLongitude()), direction,
|
|
||||||
10, R.drawable.ic_destination_arrow, heading);
|
|
||||||
}
|
|
||||||
|
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
|
@ -880,34 +874,4 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(Location location) {
|
|
||||||
//This is used as origin for both Fav-list and direction arrows
|
|
||||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
|
||||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
|
||||||
} else {
|
|
||||||
loc = new LatLon(0f, 0f);
|
|
||||||
}
|
|
||||||
updateArrows();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean updateCompassValue(float value) {
|
|
||||||
//heading = value;
|
|
||||||
//updateArrows();
|
|
||||||
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices
|
|
||||||
float lastHeading = heading != null ? heading : 99;
|
|
||||||
heading = value;
|
|
||||||
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
|
||||||
updateArrows();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
heading = lastHeading;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void updateArrows(){
|
|
||||||
favouritesAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
|
|
@ -295,9 +295,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
} else {
|
} else {
|
||||||
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFooterView() {
|
private void addFooterView() {
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class DirectionsDialogs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupPopUpMenuIcon(PopupMenu menu){
|
public static void setupPopUpMenuIcon(PopupMenu menu){
|
||||||
try {
|
try {
|
||||||
Field[] fields = menu.getClass().getDeclaredFields();
|
Field[] fields = menu.getClass().getDeclaredFields();
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||||
|
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -34,13 +35,16 @@ import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
@ -56,6 +60,7 @@ import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -83,6 +88,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
private TextView descriptionText;
|
private TextView descriptionText;
|
||||||
private ProgressBar sizeProgress;
|
private ProgressBar sizeProgress;
|
||||||
|
|
||||||
|
Drawable backup;
|
||||||
|
Drawable sdcard;
|
||||||
|
Drawable planet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.local_index, container, false);
|
View view = inflater.inflate(R.layout.local_index, container, false);
|
||||||
|
@ -98,6 +107,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
descriptionText = (TextView) view.findViewById(R.id.memory_size);
|
descriptionText = (TextView) view.findViewById(R.id.memory_size);
|
||||||
sizeProgress = (ProgressBar) view.findViewById(R.id.memory_progress);
|
sizeProgress = (ProgressBar) view.findViewById(R.id.memory_progress);
|
||||||
updateDescriptionTextWithSize();
|
updateDescriptionTextWithSize();
|
||||||
|
colorDrawables();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +129,19 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void colorDrawables(){
|
||||||
|
boolean light = getMyApplication().getSettings().isLightContent();
|
||||||
|
backup = getActivity().getResources().getDrawable(R.drawable.ic_type_archive);
|
||||||
|
backup.mutate();
|
||||||
|
if (light) {
|
||||||
|
backup.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
|
sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard);
|
||||||
|
sdcard.mutate();
|
||||||
|
sdcard.setColorFilter(getActivity().getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -172,25 +194,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
||||||
if (resId == R.string.local_index_mi_rename) {
|
return performBasicOperation(resId, info);
|
||||||
renameFile(info);
|
|
||||||
} else if (resId == R.string.local_index_mi_restore) {
|
|
||||||
new LocalIndexOperationTask(RESTORE_OPERATION).execute(info);
|
|
||||||
} else if (resId == R.string.local_index_mi_delete) {
|
|
||||||
Builder confirm = new AlertDialog.Builder(getActivity());
|
|
||||||
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
new LocalIndexOperationTask(DELETE_OPERATION).execute(info);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
confirm.setNegativeButton(R.string.default_buttons_no, null);
|
|
||||||
confirm.setMessage(getString(R.string.delete_confirmation_msg, info.getFileName()));
|
|
||||||
confirm.show();
|
|
||||||
} else if (resId == R.string.local_index_mi_backup) {
|
|
||||||
new LocalIndexOperationTask(BACKUP_OPERATION).execute(info);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA){
|
if(info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA){
|
||||||
|
@ -204,7 +208,29 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
adapter.item(R.string.local_index_mi_rename).listen(listener).position(3).reg();
|
adapter.item(R.string.local_index_mi_rename).listen(listener).position(3).reg();
|
||||||
adapter.item(R.string.local_index_mi_delete).listen(listener).position(4).reg();
|
adapter.item(R.string.local_index_mi_delete).listen(listener).position(4).reg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean performBasicOperation(int resId, final LocalIndexInfo info) {
|
||||||
|
if (resId == R.string.local_index_mi_rename) {
|
||||||
|
renameFile(info);
|
||||||
|
} else if (resId == R.string.local_index_mi_restore) {
|
||||||
|
new LocalIndexOperationTask(RESTORE_OPERATION).execute(info);
|
||||||
|
} else if (resId == R.string.local_index_mi_delete) {
|
||||||
|
Builder confirm = new Builder(getActivity());
|
||||||
|
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
new LocalIndexOperationTask(DELETE_OPERATION).execute(info);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
confirm.setNegativeButton(R.string.default_buttons_no, null);
|
||||||
|
confirm.setMessage(getString(R.string.delete_confirmation_msg, info.getFileName()));
|
||||||
|
confirm.show();
|
||||||
|
} else if (resId == R.string.local_index_mi_backup) {
|
||||||
|
new LocalIndexOperationTask(BACKUP_OPERATION).execute(info);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void renameFile(LocalIndexInfo info) {
|
private void renameFile(LocalIndexInfo info) {
|
||||||
final File f = new File(info.getPathToData());
|
final File f = new File(info.getPathToData());
|
||||||
Builder b = new AlertDialog.Builder(getActivity());
|
Builder b = new AlertDialog.Builder(getActivity());
|
||||||
|
@ -922,6 +948,21 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
||||||
}
|
}
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
||||||
|
v.findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openPopUpMenu(v, child);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
|
if (child.isBackupedData()) {
|
||||||
|
icon.setImageDrawable(backup);
|
||||||
|
} else {
|
||||||
|
icon.setImageDrawable(sdcard);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
viewName.setText(getNameToDisplay(child));
|
viewName.setText(getNameToDisplay(child));
|
||||||
if (child.isNotSupported()) {
|
if (child.isNotSupported()) {
|
||||||
viewName.setTextColor(warningColor);
|
viewName.setTextColor(warningColor);
|
||||||
|
@ -962,6 +1003,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
||||||
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
|
icon.setVisibility(View.GONE);
|
||||||
checkbox.setChecked(selectedItems.contains(child));
|
checkbox.setChecked(selectedItems.contains(child));
|
||||||
checkbox.setOnClickListener(new View.OnClickListener() {
|
checkbox.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@ -974,12 +1016,51 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
icon.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openPopUpMenu(View v, final LocalIndexInfo info) {
|
||||||
|
boolean light = getMyApplication().getSettings().isLightContent();
|
||||||
|
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||||
|
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||||
|
final boolean restore = info.isBackupedData();
|
||||||
|
|
||||||
|
MenuItem item = optionsMenu.getMenu().add(restore? R.string.local_index_mi_restore : R.string.local_index_mi_backup)
|
||||||
|
.setIcon(backup);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
performBasicOperation(restore ? R.string.local_index_mi_restore : R.string.local_index_mi_backup, info);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
item = optionsMenu.getMenu().add(R.string.favourites_context_menu_edit)
|
||||||
|
.setIcon(light ? R.drawable.ic_action_edit_light : R.drawable.ic_action_edit_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
performBasicOperation(R.string.local_index_mi_rename, info);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
item = optionsMenu.getMenu().add(R.string.favourites_context_menu_delete)
|
||||||
|
.setIcon(light ? R.drawable.ic_action_delete_light : R.drawable.ic_action_delete_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
performBasicOperation(R.string.local_index_mi_delete, info);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsMenu.show();
|
||||||
|
}
|
||||||
|
|
||||||
private String getNameToDisplay(LocalIndexInfo child) {
|
private String getNameToDisplay(LocalIndexInfo child) {
|
||||||
String mapDescr = getMapDescription(child.getFileName());
|
String mapDescr = getMapDescription(child.getFileName());
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
||||||
|
|
|
@ -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