Final dashboard plugin item

This commit is contained in:
Alexey Pelykh 2015-02-02 12:45:31 +02:00
parent f1d26557b8
commit 2a01dce403
4 changed files with 126 additions and 9 deletions

View file

@ -0,0 +1,31 @@
<?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" />
<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" />
</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>

View file

@ -1,20 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="54dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/plugin_logo"
android:layout_width="32dp"
@ -27,18 +29,40 @@
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_name"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:gravity="center_vertical"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="2"
android:textColor="?android:textColorPrimary"
android:textSize="16sp"
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/lorem_ipsum" />
tools:text="@string/lorem_ipsum"/>
<include layout="@layout/check_item_rel" />
<net.osmand.plus.widgets.SwitchEx
android:id="@+id/check_item"
android:layout_width="wrap_content"
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="@drawable/switch_ex_background"
android:minHeight="0dp"
android:minWidth="0dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="9.5dp"
android:paddingRight="9.5dp"
android:textAllCaps="true"
android:textOff="@string/enable_plugin"
android:textOn="@string/disable_plugin"
android:textSize="12sp"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
</LinearLayout>

View file

@ -96,8 +96,7 @@
<item name="windowActionBarOverlay">true</item>
</style>
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
<item name="expandable_category_color">@color/group_background</item>
<item name="android:actionDropDownStyle">@style/Widget.LightSpinner</item>
<item name="actionDropDownStyle">@style/Widget.LightSpinner</item>

View file

@ -0,0 +1,63 @@
package net.osmand.plus.widgets;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.ToggleButton;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
/**
* Created by Alexey Pelykh on 02.02.2015.
*/
public class SwitchEx extends ToggleButton {
public SwitchEx(Context context) {
super(context);
}
public SwitchEx(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs != null) {
TypedArray resolvedAttrs = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.OsmandWidgets, 0, 0);
parseAttributes(resolvedAttrs);
resolvedAttrs.recycle();
}
}
public SwitchEx(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (attrs != null) {
TypedArray resolvedAttrs = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.OsmandWidgets, 0, 0);
parseAttributes(resolvedAttrs);
resolvedAttrs.recycle();
}
}
@TargetApi(21)
public SwitchEx(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
if (attrs != null) {
TypedArray resolvedAttrs = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.OsmandWidgets, defStyleAttr, defStyleRes);
parseAttributes(resolvedAttrs);
resolvedAttrs.recycle();
}
}
private void parseAttributes(TypedArray resolvedAttributes) {
if (resolvedAttributes.hasValue(R.styleable.OsmandWidgets_typeface) && !isInEditMode()) {
String typefaceName = resolvedAttributes.getString(R.styleable.OsmandWidgets_typeface);
Typeface typeface = FontCache.getFont(getContext(), typefaceName);
if (typeface != null)
setTypeface(typeface);
}
}
}