This commit is contained in:
Alexey Pelykh 2015-02-06 13:01:54 +02:00
parent 882961b088
commit d3fa67f2aa
40 changed files with 369 additions and 199 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:color="#ffffff" />
<item android:state_checked="true" android:state_pressed="false" android:color="#77848c" />
<item android:state_checked="false" android:state_pressed="false" android:color="#77848c" />
<item android:state_checked="false" android:state_pressed="true" android:color="#ffffff" />
<item android:state_checked="true" android:color="#ffffff" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<size
android:width="360dp"
android:height="144dp"/>
<solid android:color="#ff8f00"/>
</shape>
</item>
<item>
<bitmap android:src="@drawable/ic_extension_dark" android:gravity="center" />
</item>
</layer-list>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@drawable/ic_action_settings_enabled_dark" />
<item android:state_enabled="false"
android:drawable="@drawable/ic_action_settings_disabled_dark" />
</selector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@drawable/ic_action_settings_enabled_light" />
<item android:state_enabled="false"
android:drawable="@drawable/ic_action_settings_disabled_light" />
</selector>

View file

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:state_pressed="false">
<item android:state_checked="true" android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#ff8f00" />
</shape>
</item>
<item android:state_checked="false" android:state_pressed="true">
<item android:state_checked="true" android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#ffb24c" />
</shape>
</item>
<item android:state_checked="true" android:state_pressed="false">
<item android:state_checked="false" android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@null" />
<stroke android:width="1.5dp" android:color="#77848c" />
</shape>
</item>
<item android:state_checked="true" android:state_pressed="true">
<item android:state_checked="false" android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#66ff8f00" />

View file

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:state_pressed="false">
<item android:state_checked="true" android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#ff8f00" />
</shape>
</item>
<item android:state_checked="false" android:state_pressed="true">
<item android:state_checked="true" android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#ffb24c" />
</shape>
</item>
<item android:state_checked="true" android:state_pressed="false">
<item android:state_checked="false" android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@null" />
<stroke android:width="1.5dp" android:color="#727272" />
</shape>
</item>
<item android:state_checked="true" android:state_pressed="true">
<item android:state_checked="false" android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#66ff8f00" />

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/dash_plugin_item"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dash_plugin_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -42,28 +42,56 @@
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/lorem_ipsum"/>
<net.osmand.plus.widgets.SwitchEx
android:id="@+id/check_item"
<FrameLayout
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:background="?attr/switch_ex_background"
android:minHeight="0dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
osmand:textAllCapsCompat="true"
android:textColor="?attr/switch_ex_text_color"
android:textOff="@string/enable_plugin"
android:textOn="@string/disable_plugin"
android:textSize="12sp"
osmand:typeface="@string/font_roboto_medium"/>
android:layout_marginLeft="6dp"
android:layout_marginRight="16dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp">
<net.osmand.plus.widgets.SwitchEx
android:id="@+id/plugin_enable_disable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/switch_ex_background"
android:minHeight="0dp"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:paddingTop="8dp"
android:textColor="?attr/switch_ex_text_color"
android:textOff="@string/enable_plugin"
android:textOn="@string/disable_plugin"
android:textSize="12sp"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/get_plugin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/get_button_background"
android:minHeight="0dp"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:paddingTop="8dp"
android:textColor="@color/get_button_text"
android:text="@string/get_plugin"
android:textSize="12sp"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -35,7 +35,7 @@
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_settings_dark"
android:src="@drawable/ic_action_settings_enabled_dark"
android:focusable="false"
android:gravity="center_vertical" />

View file

@ -13,68 +13,100 @@
tools:context=".activities.PluginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="144dp"
android:background="#ff8f00"
android:scaleType="center"
android:src="@drawable/ic_extension_dark"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="144dp"
android:maxWidth="360dp"
android:scaleType="centerInside"
android:layout_gravity="center_horizontal"
android:src="@drawable/extension_stub"/>
<FrameLayout
android:id="@+id/plugin_header"
android:layout_width="match_parent"
android:layout_height="66dp"
android:background="?attr/plugin_details_header_bg"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="?attr/plugin_details_header_bg">
android:paddingRight="16dp">
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/plugin_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginBottom="9dp"
android:layout_marginTop="9dp"
android:layout_gravity="center_vertical|start"
android:textSize="12sp"
osmand:textAllCapsCompat="true"
android:textColor="?android:textColorPrimary"
android:background="@null"
android:drawableLeft="?attr/ic_action_settings"
android:drawableStart="?attr/ic_action_settings"
android:drawablePadding="10dp"
android:drawableStart="?attr/ic_action_settings"
android:paddingLeft="0dp"
android:paddingRight="16dp"
android:text="@string/plugin_settings_button_caption"
android:textColor="?android:textColorPrimary"
android:textSize="12sp"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.SwitchEx
android:id="@+id/plugin_enable_disable"
<FrameLayout
android:layout_width="139dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:background="?attr/switch_ex_background"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:paddingTop="8dp"
osmand:textAllCapsCompat="true"
android:textColor="?attr/switch_ex_text_color"
android:textOff="@string/enable_plugin"
android:textOn="@string/disable_plugin"
android:textSize="12sp"
osmand:typeface="@string/font_roboto_medium"/>
android:layout_marginTop="16dp">
<net.osmand.plus.widgets.SwitchEx
android:id="@+id/plugin_enable_disable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/switch_ex_background"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:paddingTop="8dp"
android:textColor="?attr/switch_ex_text_color"
android:textOff="@string/enable_plugin"
android:textOn="@string/disable_plugin"
android:textSize="12sp"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/plugin_get"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/get_button_background"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:paddingTop="8dp"
android:textColor="@color/get_button_text"
android:text="@string/get_plugin"
android:textSize="12sp"
android:visibility="gone"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</FrameLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/plugin_header2"
android:id="@+id/plugin_install_header"
android:layout_width="match_parent"
android:layout_height="66dp"
android:background="?attr/plugin_details_install_header_bg"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:background="?attr/plugin_details_header2_bg"
android:visibility="gone"
tools:visibility="visible">
@ -88,6 +120,7 @@
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="?attr/plugin_description_header_text_color"
android:text="@string/plugin_install_needs_network"
osmand:typeface="@string/font_roboto_regular"/>
</LinearLayout>
@ -99,6 +132,8 @@
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="@string/plugin_description_title"
android:textSize="14sp"
android:textColor="?attr/plugin_description_header_text_color"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
@ -109,6 +144,8 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="14dp"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/lorem_ipsum"/>

View file

@ -10,7 +10,6 @@
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="6dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="4dp"

View file

@ -1,88 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="84dp"
android:background="?attr/card_bg"
android:descendantFocusability="blocksDescendants"
android:padding="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="@+id/plugin_logo"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_margin="8dp"
android:background="@drawable/bg_plugin_logo_enabled"
android:scaleType="center"
tools:src="@drawable/ic_extension_dark"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_marginRight="36dp"
android:layout_marginEnd="36dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="19sp"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/lorem_ipsum" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="2"
android:maxLines="2"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/lorem_ipsum" />
</LinearLayout>
</LinearLayout>
android:paddingLeft="6dp"
android:paddingRight="6dp">
<FrameLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|end">
android:background="?attr/card_bg"
android:descendantFocusability="blocksDescendants"
android:padding="2dp">
<ImageView
android:id="@+id/plugin_is_enabled"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="@+id/plugin_logo"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_margin="8dp"
android:background="@drawable/bg_plugin_logo_enabled"
android:scaleType="center"
tools:src="@drawable/ic_extension_dark"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="36dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="36dp"
android:layout_marginStart="6dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="19sp"
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/lorem_ipsum"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="2"
android:maxLines="2"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/lorem_ipsum"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_marginTop="6dp"
android:src="?attr/ic_action_check"
android:visibility="invisible"
tools:visibility="visible"/>
android:layout_height="match_parent"
android:layout_gravity="top|end">
<ImageButton
android:id="@+id/plugin_options"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginTop="6dp"
android:layout_gravity="center_horizontal|bottom"
android:background="?attr/ic_plugin_options"/>
<ImageView
android:id="@+id/plugin_is_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_marginTop="6dp"
android:src="?attr/ic_action_check"
android:visibility="invisible"
tools:visibility="visible"/>
<ImageButton
android:id="@+id/plugin_options"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginTop="6dp"
android:background="?attr/ic_plugin_options"/>
</FrameLayout>
</FrameLayout>
</FrameLayout>

View file

@ -27,8 +27,9 @@
<attr name="switch_ex_text_color" format="color|reference" />
<attr name="bg_plugin_logo_disabled" format="reference" />
<attr name="plugin_details_header_bg" format="color|reference" />
<attr name="plugin_details_header2_bg" format="color|reference" />
<attr name="plugin_details_install_header_bg" format="color|reference" />
<attr name="ic_world_globe" format="reference" />
<attr name="plugin_description_header_text_color" format="color|reference" />
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -107,6 +107,6 @@
<color name="plugin_details_header_bg_light">#ffffff</color>
<color name="plugin_details_header_bg_dark">#333b40</color>
<color name="plugin_details_header2_bg_light">#dbdbdb</color>
<color name="plugin_details_header2_bg_dark">#ffffff</color>
<color name="plugin_details_install_header_bg_light">#dbdbdb</color>
<color name="plugin_details_install_header_bg_dark">#2d3438</color>
</resources>

View file

@ -2085,9 +2085,12 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="av_camera_pic_size_descr">Select internal camera Picture Size</string>
<string name="navigation_intent_invalid">Invalid format: %s</string>
<string name="hide_all_waypoints">Remove all</string>
<string name="enable_plugin">Enable</string>
<string name="disable_plugin">Disable</string>
<string name="enable_plugin">Disabled</string>
<string name="disable_plugin">Enabled</string>
<string name="enable_plugin2">Enable</string>
<string name="disable_plugin2">Disable</string>
<string name="plugin_description_title">Description</string>
<string name="plugin_settings_button_caption">Settings</string>
<string name="plugin_install_needs_network">You need an Internet connection to install this plugin.</string>
<string name="get_plugin">Get</string>
</resources>

View file

@ -162,8 +162,9 @@
<item name="switch_ex_text_color">@color/switch_ex_button_text_light</item>
<item name="bg_plugin_logo_disabled">@drawable/bg_plugin_logo_disabled_light</item>
<item name="plugin_details_header_bg">@color/plugin_details_header_bg_light</item>
<item name="plugin_details_header2_bg">@color/plugin_details_header2_bg_light</item>
<item name="plugin_details_install_header_bg">@color/plugin_details_install_header_bg_light</item>
<item name="ic_world_globe">@drawable/ic_world_globe_light</item>
<item name="plugin_description_header_text_color">#727272</item>
</style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
@ -198,8 +199,9 @@
<item name="switch_ex_text_color">@color/switch_ex_button_text_dark</item>
<item name="bg_plugin_logo_disabled">@drawable/bg_plugin_logo_disabled_dark</item>
<item name="plugin_details_header_bg">@color/plugin_details_header_bg_dark</item>
<item name="plugin_details_header2_bg">@color/plugin_details_header2_bg_dark</item>
<item name="plugin_details_install_header_bg">@color/plugin_details_install_header_bg_dark</item>
<item name="ic_world_globe">@drawable/ic_world_globe_dark</item>
<item name="plugin_description_header_text_color">#70818c</item>
</style>
<style name="OsmandLightDarkActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">

View file

@ -73,13 +73,17 @@ public abstract class OsmandPlugin {
return active;
}
public boolean couldBeActivated() {
public boolean needsInstallation() {
return installURL != null;
}
public void setInstallURL(String installURL) {
this.installURL = installURL;
}
public String getInstallURL() {
return installURL;
}
public void disable(OsmandApplication app) {};
@ -208,7 +212,7 @@ public abstract class OsmandPlugin {
return allPlugins;
}
public static Iterable<OsmandPlugin> getEnabledPlugins(){
public static List<OsmandPlugin> getEnabledPlugins(){
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
for(OsmandPlugin p : allPlugins) {
if(p.isActive()) {
@ -217,6 +221,16 @@ public abstract class OsmandPlugin {
}
return lst;
}
public static List<OsmandPlugin> getNotEnabledPlugins(){
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
for(OsmandPlugin p : allPlugins) {
if(!p.isActive()) {
lst.add(p);
}
}
return lst;
}
@SuppressWarnings("unchecked")
public static <T extends OsmandPlugin> T getEnabledPlugin(Class<T> clz) {

View file

@ -28,7 +28,6 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -731,8 +730,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
final ImageView ch = (ImageView) row.findViewById(R.id.check_item);
ch.setVisibility(View.VISIBLE);
ch.setImageDrawable(getActivity().getResources().getDrawable(
getMyApplication().getSettings().isLightContent() ? R.drawable.ic_action_settings_light
: R.drawable.ic_action_settings_dark));
getMyApplication().getSettings().isLightContent() ? R.drawable.ic_action_settings_enabled_light
: R.drawable.ic_action_settings_enabled_dark));
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -31,10 +31,8 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.dialogs.ConfigureMapMenu;
@ -889,7 +887,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
optionsMenuHelper.item(R.string.settings_activity)
.icons(R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_light)
.icons(R.drawable.ic_action_settings_enabled_dark, R.drawable.ic_action_settings_enabled_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -2,6 +2,7 @@ package net.osmand.plus.activities;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
@ -58,46 +59,48 @@ public class PluginActivity extends OsmandActionBarActivity {
TextView descriptionView = (TextView)findViewById(R.id.plugin_description);
descriptionView.setText(plugin.getDescription());
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
final Button settingsButton = (Button)findViewById(R.id.plugin_settings);
if (settingsActivity == null) {
settingsButton.setVisibility(View.GONE);
} else {
settingsButton.setEnabled(plugin.isActive());
settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(PluginActivity.this, settingsActivity));
}
});
}
Button settingsButton = (Button)findViewById(R.id.plugin_settings);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(PluginActivity.this, plugin.getSettingsActivity()));
}
});
CompoundButton enableDisableButton = (CompoundButton)findViewById(
R.id.plugin_enable_disable);
enableDisableButton.setChecked(plugin.isActive());
enableDisableButton.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (plugin.isActive() == isChecked) {
return;
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (plugin.isActive() == isChecked) {
return;
}
boolean ok = OsmandPlugin.enablePlugin((OsmandApplication)getApplication(), plugin,
isChecked);
settingsButton.setEnabled(isChecked && ok);
boolean ok = OsmandPlugin.enablePlugin((OsmandApplication)getApplication(),
plugin, isChecked);
if (!ok) {
return;
}
updateState();
}
});
Button getButton = (Button)findViewById(R.id.plugin_get);
getButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
}
});
updateState();
}
@Override
protected void onResume() {
super.onResume();
CompoundButton enableDisableButton = (CompoundButton)findViewById(
R.id.plugin_enable_disable);
enableDisableButton.setChecked(plugin.isActive());
updateState();
}
@Override
@ -111,4 +114,33 @@ public class PluginActivity extends OsmandActionBarActivity {
}
return false;
}
private void updateState() {
CompoundButton enableDisableButton = (CompoundButton)findViewById(
R.id.plugin_enable_disable);
Button getButton = (Button)findViewById(R.id.plugin_get);
Button settingsButton = (Button)findViewById(R.id.plugin_settings);
View installHeader = findViewById(R.id.plugin_install_header);
if (plugin.needsInstallation()) {
getButton.setVisibility(View.VISIBLE);
enableDisableButton.setVisibility(View.GONE);
settingsButton.setVisibility(View.GONE);
installHeader.setVisibility(View.VISIBLE);
} else {
getButton.setVisibility(View.GONE);
enableDisableButton.setVisibility(View.VISIBLE);
enableDisableButton.setChecked(plugin.isActive());
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
if (settingsActivity == null) {
settingsButton.setVisibility(View.GONE);
} else {
settingsButton.setEnabled(plugin.isActive());
settingsButton.setVisibility(View.VISIBLE);
}
installHeader.setVisibility(View.GONE);
}
}
}

View file

@ -128,8 +128,8 @@ public class PluginsActivity extends OsmandListActivity {
final PopupMenu optionsMenu = new PopupMenu(this, v);
MenuItem enableDisableItem = optionsMenu.getMenu().add(plugin.isActive()
? R.string.disable_plugin
: R.string.enable_plugin);
? R.string.disable_plugin2
: R.string.enable_plugin2);
enableDisableItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {

View file

@ -533,8 +533,8 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
} else if(model.getType() == GpxDisplayItemType.TRACK_SEGMENT) {
ch.setVisibility(View.VISIBLE);
ch.setImageDrawable(getMyActivity().getResources().getDrawable(
app.getSettings().isLightContent() ? R.drawable.ic_action_settings_light
: R.drawable.ic_action_settings_dark));
app.getSettings().isLightContent() ? R.drawable.ic_action_settings_enabled_light
: R.drawable.ic_action_settings_enabled_dark));
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -1,5 +1,8 @@
package net.osmand.plus.dashboard;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import net.osmand.AndroidUtils;
@ -9,11 +12,13 @@ import net.osmand.plus.activities.PluginActivity;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
@ -29,7 +34,7 @@ public class DashPluginsFragment extends DashBaseFragment {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
View pluginView = AndroidUtils.findParentViewById(buttonView, R.id.dash_plugin_item);
OsmandPlugin plugin = (OsmandPlugin)pluginView.getTag();
if (plugin.isActive() == isChecked) {
if (plugin.isActive() == isChecked || plugin.needsInstallation()) {
return;
}
if (OsmandPlugin.enablePlugin(getMyApplication(), plugin, isChecked)) {
@ -49,6 +54,15 @@ public class DashPluginsFragment extends DashBaseFragment {
}
};
private final View.OnClickListener getListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
View pluginView = AndroidUtils.findParentViewById(view, R.id.dash_plugin_item);
OsmandPlugin plugin = (OsmandPlugin)pluginView.getTag();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
}
};
private final View.OnClickListener pluginDetailsListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -73,24 +87,23 @@ public class DashPluginsFragment extends DashBaseFragment {
});
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getAvailablePlugins();
for(OsmandPlugin plugin : enabledPlugins) {
if (plugin instanceof OsmandDevelopmentPlugin) {
List<OsmandPlugin> notActivePlugins = OsmandPlugin.getNotEnabledPlugins();
Collections.shuffle(notActivePlugins);
for(OsmandPlugin plugin : notActivePlugins) {
if (plugin instanceof OsmandDevelopmentPlugin) {
continue;
}
inflatePluginView(inflater, pluginsContainer, plugin);
break;
}
for(OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
if (pluginsContainer.getChildCount() > 2) {
for(OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
if (pluginsContainer.getChildCount() >= 5) {
break;
}
if (plugin instanceof OsmandDevelopmentPlugin) {
continue;
}
if (enabledPlugins.contains(plugin)) {
continue;
}
inflatePluginView(inflater, pluginsContainer, plugin);
}
@ -117,11 +130,17 @@ public class DashPluginsFragment extends DashBaseFragment {
private void updatePluginState(View pluginView) {
OsmandPlugin plugin = (OsmandPlugin)pluginView.getTag();
boolean isEnabled = plugin.isActive();
CompoundButton enableDisableButton = (CompoundButton)pluginView.findViewById(
R.id.check_item);
enableDisableButton.setChecked(isEnabled);
R.id.plugin_enable_disable);
Button getButton = (Button)pluginView.findViewById(R.id.get_plugin);
if (plugin.needsInstallation()) {
getButton.setVisibility(View.VISIBLE);
enableDisableButton.setVisibility(View.GONE);
} else {
getButton.setVisibility(View.GONE);
enableDisableButton.setVisibility(View.VISIBLE);
enableDisableButton.setChecked(plugin.isActive());
}
ImageButton logoView = (ImageButton)pluginView.findViewById(R.id.plugin_logo);
if (plugin.isActive()) {
@ -148,9 +167,13 @@ public class DashPluginsFragment extends DashBaseFragment {
logoView.setOnClickListener(toggleEnableDisableListener);
logoView.setImageResource(plugin.getLogoResourceId());
CompoundButton enableDisableButton = (CompoundButton)view.findViewById(R.id.check_item);
CompoundButton enableDisableButton =
(CompoundButton)view.findViewById(R.id.plugin_enable_disable);
enableDisableButton.setOnCheckedChangeListener(enableDisableListener);
Button getButton = (Button)view.findViewById(R.id.get_plugin);
getButton.setOnClickListener(getListener);
updatePluginState(view);
container.addView(view);

View file

@ -29,7 +29,6 @@ import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.preference.PreferenceGroup;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Toast;
@ -65,7 +64,7 @@ public class ConfigureMapMenu {
createLayersItems(adapter, ma);
if (!advanced){
adapter.item(R.string.btn_advanced_mode).icons(R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_light)
adapter.item(R.string.btn_advanced_mode).icons(R.drawable.ic_action_settings_enabled_dark, R.drawable.ic_action_settings_enabled_light)
.selected(advanced ? 1 : 0)
.listen(new OnContextMenuClick() {
@Override

View file

@ -438,7 +438,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
device != null && device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
///
if (device != null) {
createMenuItem(menu, SETTINGS_DEV_ID, R.string.settings, R.drawable.ic_action_settings_light, R.drawable.ic_action_settings_dark,
createMenuItem(menu, SETTINGS_DEV_ID, R.string.settings, R.drawable.ic_action_settings_enabled_light, R.drawable.ic_action_settings_enabled_dark,
// there is a bug in Android 4.2 layout
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
}
@ -963,7 +963,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
R.drawable.ic_action_plus_dark, R.drawable.ic_action_plus_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, SETTINGS_ID, R.string.settings,
R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_dark,
R.drawable.ic_action_settings_enabled_dark, R.drawable.ic_action_settings_enabled_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
return super.onCreateOptionsMenu(menu);
}
@ -1162,9 +1162,9 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
v.setVisibility(View.GONE);
} else {
if (getMyApplication().getSettings().isLightContent()){
v.setImageResource(R.drawable.ic_action_settings_light);
v.setImageResource(R.drawable.ic_action_settings_enabled_light);
} else {
v.setImageResource(R.drawable.ic_action_settings_dark);
v.setImageResource(R.drawable.ic_action_settings_enabled_dark);
}
v.setVisibility(View.VISIBLE);
v.setOnClickListener(new View.OnClickListener() {