Plugins
This commit is contained in:
parent
2ba8c33986
commit
f3979fef89
21 changed files with 123 additions and 62 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -29,5 +29,8 @@ out/
|
|||
# MacOSX
|
||||
.DS_Store
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
|
||||
# Output files
|
||||
/build
|
||||
|
|
6
OsmAnd/res/color/switch_ex_button_text_dark.xml
Normal file
6
OsmAnd/res/color/switch_ex_button_text_dark.xml
Normal file
|
@ -0,0 +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="true" android:color="#ffffff" />
|
||||
</selector>
|
5
OsmAnd/res/color/switch_ex_button_text_light.xml
Normal file
5
OsmAnd/res/color/switch_ex_button_text_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?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:color="#727272" />
|
||||
</selector>
|
|
@ -1,19 +0,0 @@
|
|||
<?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"
|
||||
android:color="#ffffff"/>
|
||||
<item
|
||||
android:state_checked="false"
|
||||
android:state_pressed="true"
|
||||
android:color="#ffffff"/>
|
||||
<item
|
||||
android:state_checked="true"
|
||||
android:state_pressed="false"
|
||||
android:color="#ff8f00"/>
|
||||
<item
|
||||
android:state_checked="true"
|
||||
android:state_pressed="true"
|
||||
android:color="#ff8f00"/>
|
||||
</selector>
|
Binary file not shown.
7
OsmAnd/res/drawable/bg_plugin_logo_disabled_dark.xml
Normal file
7
OsmAnd/res/drawable/bg_plugin_logo_disabled_dark.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid
|
||||
android:color="#525e66" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
</shape>
|
7
OsmAnd/res/drawable/bg_plugin_logo_disabled_light.xml
Normal file
7
OsmAnd/res/drawable/bg_plugin_logo_disabled_light.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid
|
||||
android:color="#cccccc" />
|
||||
<corners
|
||||
android:radius="3dp" />
|
||||
</shape>
|
15
OsmAnd/res/drawable/get_button_background.xml
Normal file
15
OsmAnd/res/drawable/get_button_background.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#4caf50" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#66bb6a" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -1,10 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="6dp"
|
||||
android:right="2dp">
|
||||
<item>
|
||||
<bitmap
|
||||
android:src="@drawable/ic_overflow_menu_dark"
|
||||
android:gravity="top|end" />
|
||||
android:gravity="center" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:top="6dp"
|
||||
android:right="2dp">
|
||||
<item>
|
||||
<bitmap
|
||||
android:src="@drawable/ic_overflow_menu_light"
|
||||
android:gravity="top|end" />
|
||||
android:gravity="center" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
|
@ -4,21 +4,19 @@
|
|||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#ff8f00" />
|
||||
<stroke android:width="1.5dp" android:color="#ff8f00" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_checked="false" android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#ffb24c" />
|
||||
<stroke android:width="1.5dp" android:color="#ffb24c" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_checked="true" android:state_pressed="false">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="@null" />
|
||||
<stroke android:width="1.5dp" android:color="#ff8f00" />
|
||||
<stroke android:width="1.5dp" android:color="#77848c" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_checked="true" android:state_pressed="true">
|
29
OsmAnd/res/drawable/switch_ex_background_light.xml
Normal file
29
OsmAnd/res/drawable/switch_ex_background_light.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#ff8f00" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_checked="false" 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">
|
||||
<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">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="2dp" />
|
||||
<solid android:color="#66ff8f00" />
|
||||
<stroke android:width="1.5dp" android:color="#ff8f00" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_margin="11dp"
|
||||
android:background="@drawable/bg_plugin_logo"
|
||||
android:background="@drawable/bg_plugin_logo_enabled"
|
||||
android:scaleType="center"
|
||||
tools:src="@drawable/ic_extension_dark"/>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:layout_marginStart="6dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/switch_ex_background"
|
||||
android:background="?attr/switch_ex_background"
|
||||
android:minHeight="0dp"
|
||||
android:minWidth="0dp"
|
||||
android:paddingTop="8dp"
|
||||
|
@ -60,7 +60,7 @@
|
|||
android:paddingLeft="9.5dp"
|
||||
android:paddingRight="9.5dp"
|
||||
osmand:textAllCapsCompat="true"
|
||||
android:textColor="@color/switch_ex_text_color"
|
||||
android:textColor="?attr/switch_ex_text_color"
|
||||
android:textOff="@string/enable_plugin"
|
||||
android:textOn="@string/disable_plugin"
|
||||
android:textSize="12sp"
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?attr/actionBarSize">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -16,7 +15,9 @@
|
|||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="144dp"
|
||||
android:visibility="gone"/>
|
||||
android:background="@drawable/bg_plugin_logo_enabled"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_extension_dark"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -45,20 +46,18 @@
|
|||
|
||||
<net.osmand.plus.widgets.SwitchEx
|
||||
android:id="@+id/plugin_enable_disable"
|
||||
android:layout_width="wrap_content"
|
||||
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="@drawable/switch_ex_background"
|
||||
android:minHeight="0dp"
|
||||
android:minWidth="0dp"
|
||||
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="@color/switch_ex_text_color"
|
||||
android:textColor="?attr/switch_ex_text_color"
|
||||
android:textOff="@string/enable_plugin"
|
||||
android:textOn="@string/disable_plugin"
|
||||
android:textSize="12sp"
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/plugin_logo"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/bg_plugin_logo"
|
||||
android:background="@drawable/bg_plugin_logo_enabled"
|
||||
android:scaleType="center"
|
||||
tools:src="@drawable/ic_extension_dark"/>
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
|||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="36dp"
|
||||
android:layout_marginEnd="36dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
@ -40,8 +40,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
|
@ -68,12 +66,13 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|end"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/plugin_is_enabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="6dp"
|
||||
android:src="?attr/ic_action_check"
|
||||
android:visibility="invisible"
|
||||
|
@ -83,6 +82,7 @@
|
|||
android:id="@+id/plugin_options"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="?attr/ic_plugin_options"/>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
<attr name="ic_action_marker2" format="reference" />
|
||||
<attr name="search_background" format="reference" />
|
||||
<attr name="ic_action_settings" format="reference" />
|
||||
<attr name="switch_ex_background" format="reference" />
|
||||
<attr name="switch_ex_text_color" format="color|reference" />
|
||||
<attr name="bg_plugin_logo_disabled" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
|
|
|
@ -101,4 +101,6 @@
|
|||
|
||||
<color name="card_bg_color_light">#ffffff</color>
|
||||
<color name="card_bg_color_dark">#333b40</color>
|
||||
|
||||
<color name="get_button_text">#ffffff</color>
|
||||
</resources>
|
|
@ -158,6 +158,9 @@
|
|||
<item name="actionModeStyle">@style/WhiteActionMode</item>
|
||||
<item name="android:actionMenuTextColor">@color/color_white</item>
|
||||
<item name="actionMenuTextColor">@color/color_white</item>
|
||||
<item name="switch_ex_background">@drawable/switch_ex_background_light</item>
|
||||
<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>
|
||||
</style>
|
||||
|
||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||
|
@ -188,6 +191,9 @@
|
|||
<item name="ic_action_marker2">@drawable/ic_action_marker2_dark</item>
|
||||
<item name="search_background">@color/color_white</item>
|
||||
<item name="ic_action_settings">@drawable/ic_action_settings_dark</item>
|
||||
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item>
|
||||
<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>
|
||||
</style>
|
||||
|
||||
<style name="OsmandLightDarkActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.osmand.plus.R;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -13,7 +14,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class PluginsActivity extends OsmandListActivity {
|
||||
|
@ -80,8 +81,22 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
|
||||
view.setTag(plugin);
|
||||
|
||||
ImageView pluginLogo = (ImageView)view.findViewById(R.id.plugin_logo);
|
||||
ImageButton pluginLogo = (ImageButton)view.findViewById(R.id.plugin_logo);
|
||||
pluginLogo.setImageResource(plugin.getLogoResourceId());
|
||||
if (plugin.isActive()) {
|
||||
pluginLogo.setBackgroundResource(R.drawable.bg_plugin_logo_enabled);
|
||||
} else {
|
||||
TypedArray attributes = getTheme().obtainStyledAttributes(
|
||||
new int[] {R.attr.bg_plugin_logo_disabled});
|
||||
pluginLogo.setBackgroundDrawable(attributes.getDrawable(0));
|
||||
attributes.recycle();
|
||||
}
|
||||
pluginLogo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
enableDisablePlugin(plugin, !plugin.isActive());
|
||||
}
|
||||
});
|
||||
|
||||
TextView pluginName = (TextView)view.findViewById(R.id.plugin_name);
|
||||
pluginName.setText(plugin.getName());
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -34,16 +33,6 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener pluginSettingsListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
OsmandPlugin plugin = (OsmandPlugin)view.getTag();
|
||||
|
||||
Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
|
||||
startActivity(new Intent(getActivity(), settingsActivity));
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener pluginDetailsListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -80,7 +69,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
if (pluginsContainer.getChildCount() > 2) {
|
||||
break;
|
||||
}
|
||||
if (plugin instanceof OsmandDevelopmentPlugin) {
|
||||
if (plugin instanceof OsmandDevelopmentPlugin) {
|
||||
continue;
|
||||
}
|
||||
if (enabledPlugins.contains(plugin)) {
|
||||
|
|
Loading…
Reference in a new issue