Plugins screen redesign

This commit is contained in:
Alexey Pelykh 2015-01-30 14:58:42 +02:00
parent 4692710d4e
commit a25e3ca8b3
35 changed files with 251 additions and 172 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View 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="#ff8f00" />
<corners
android:radius="3dp" />
</shape>

View file

@ -0,0 +1,10 @@
<?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">
<bitmap
android:src="@drawable/ic_overflow_menu_dark"
android:gravity="top|end" />
</item>
</layer-list>

View file

@ -0,0 +1,10 @@
<?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">
<bitmap
android:src="@drawable/ic_overflow_menu_light"
android:gravity="top|end" />
</item>
</layer-list>

View file

@ -1,21 +1,17 @@
<?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="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<TextView
android:id="@+id/Label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/select_plugin_to_activate"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_marginTop="10dp"/>
android:layout_margin="6dp"
android:divider="@null"
android:dividerHeight="4dp"
tools:listitem="@layout/plugins_list_item" />
</LinearLayout>

View file

@ -1,72 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="84dp"
android:background="?attr/card_bg"
android:padding="2dp"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?attr/expandable_category_color"
android:paddingBottom="3dp"
android:paddingTop="6dp" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/plugin_logo"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_margin="8dp"
android:background="@drawable/bg_plugin_logo"
android:src="@drawable/ic_extension_dark"
android:scaleType="center"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp" >
<CheckBox
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="top" />
</LinearLayout>
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<TextView
android:id="@+id/plugin_name"
style="@style/ListText"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:paddingRight="10dp"
android:text="@string/extra_settings"
android:textColor="?android:textColorPrimary"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="4dp"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical" >
<ImageView
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:src="@drawable/ic_action_settings_dark" />
</LinearLayout>
</LinearLayout>
android:textSize="19sp"
android:textStyle="bold"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginBottom="4dp"
android:layout_marginRight="50dp"
android:layout_marginEnd="50dp"
tools:text="@string/lorem_ipsum" />
<TextView
android:id="@+id/plugin_descr"
android:id="@+id/plugin_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="7"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
android:text="@string/osmand_extra_settings_description"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:visibility="gone" >
</TextView>
</LinearLayout>
android:lines="2"
android:maxLines="2"
android:ellipsize="end"
tools:text="@string/lorem_ipsum" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:orientation="horizontal">
<ImageView
android:id="@+id/plugin_is_enabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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:background="?attr/ic_plugin_options"/>
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="lorem_ipsum">لوريم أيبسزم, أول كلمات من نص لاتيني يستعمل بتصميم مواقع الإنترنت بدلا من الإنجليزية للتشديد على أهمية عناصر التصميم على الفحوى </string>
</resources>

View file

@ -8,6 +8,10 @@
<attr name="reset_image" format="reference"/>
<attr name="bottomToolBarColor" format="color" />
<attr name="card_bg" format="reference" />
<attr name="ic_action_check" format="reference" />
<attr name="ic_extension" format="reference" />
<attr name="ic_overflow_menu" format="reference" />
<attr name="ic_plugin_options" format="reference" />
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="lorem_ipsum">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut gravida purus quis enim
consequat tristique. Vestibulum euismod laoreet semper. Proin pretium vulputate maximus.
Curabitur accumsan pretium consectetur. Donec vehicula tincidunt molestie. Duis dignissim
commodo nunc efficitur posuere. Proin in ultrices tellus. Morbi a efficitur leo. Etiam
dapibus, ante ac fringilla.</string>
</resources>

View file

@ -1237,7 +1237,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="osmand_extra_settings_description">Display settings for advanced map configuration (like increase map details) and some device-specifics.</string>
<string name="osmand_development_plugin_description">Show settings for development and debugging features like route simulation or rendering performance display.</string>
<string name="plugins_screen">Plugins</string>
<string name="select_plugin_to_activate">Touch a Plugin to activate or deactivate it. (Restarting OsmAnd may be required.)</string>
<string name="prefs_plugins_descr">Plugins activate advanced settings and additional functionality</string>
<string name="prefs_plugins">Plugins</string>
<string name="tip_recent_changes_0_8_0_t">Changes in 0.8.0:
@ -2085,4 +2084,6 @@ 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>
</resources>

View file

@ -76,6 +76,10 @@
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
<item name="card_bg">@drawable/bg_card_light</item>
<item name="ic_action_check">@drawable/ic_action_check_light</item>
<item name="ic_extension">@drawable/ic_extension_light</item>
<item name="ic_overflow_menu">@drawable/ic_overflow_menu_light</item>
<item name="ic_plugin_options">@drawable/ic_plugin_options_light</item>
</style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
@ -89,6 +93,10 @@
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
<item name="card_bg">@drawable/bg_card_dark</item>
<item name="ic_action_check">@drawable/ic_action_check_dark</item>
<item name="ic_extension">@drawable/ic_extension_dark</item>
<item name="ic_overflow_menu">@drawable/ic_overflow_menu_dark</item>
<item name="ic_plugin_options">@drawable/ic_plugin_options_dark</item>
</style>
<style name="OsmandLightDarkActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">

View file

@ -1,126 +1,151 @@
package net.osmand.plus.activities;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.osmo.OsMoPlugin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.support.v7.widget.PopupMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
public class PluginsActivity extends OsmandListActivity {
public static final int ACTIVE_PLUGINS_LIST_MODIFIED = 1;
private List<OsmandPlugin> availablePlugins;
private Set<String> clickedPlugins = new LinkedHashSet<String>();
private Set<String> restartPlugins = new LinkedHashSet<String>();
private boolean activePluginsListModified = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.plugins);
getSupportActionBar().setTitle(R.string.plugins_screen);
availablePlugins = OsmandPlugin.getAvailablePlugins();
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
for(OsmandPlugin p : enabledPlugins) {
restartPlugins.add(p.getId());
}
setListAdapter(new OsmandPluginsAdapter(availablePlugins));
}
private void click(int position) {
OsmandPlugin item = getListAdapter().getItem(position);
boolean enable = !restartPlugins.contains(item.getId());
boolean ok = OsmandPlugin.enablePlugin(((OsmandApplication) getApplication()), item, enable);
if (ok) {
if (!enable) {
restartPlugins.remove(item.getId());
} else {
restartPlugins.add(item.getId());
}
setResult(ACTIVE_PLUGINS_LIST_MODIFIED);
}
clickedPlugins.add(item.getId());
getListAdapter().notifyDataSetChanged();
setListAdapter(new PluginsListAdapter());
}
@Override
public OsmandPluginsAdapter getListAdapter() {
return (OsmandPluginsAdapter) super.getListAdapter();
public PluginsListAdapter getListAdapter() {
return (PluginsListAdapter) super.getListAdapter();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
click(position);
OsmandPlugin plugin = view.getTag() instanceof OsmandPlugin
? (OsmandPlugin)view.getTag()
: null;
if (plugin == null) {
return;
}
protected class OsmandPluginsAdapter extends ArrayAdapter<OsmandPlugin> {
//TODO: open details
togglePluginEnabled(plugin);
}
public OsmandPluginsAdapter(List<OsmandPlugin> plugins) {
super(PluginsActivity.this, R.layout.plugins_list_item, plugins);
private void togglePluginEnabled(OsmandPlugin plugin) {
boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
enableDisablePlugin(plugin, !isEnabled);
}
private void enableDisablePlugin(OsmandPlugin plugin, boolean enable) {
boolean ok = OsmandPlugin.enablePlugin(((OsmandApplication) getApplication()), plugin,
enable);
if (!ok) {
return;
}
if (!activePluginsListModified) {
setResult(ACTIVE_PLUGINS_LIST_MODIFIED);
activePluginsListModified = true;
}
getListAdapter().notifyDataSetChanged();
}
protected class PluginsListAdapter extends ArrayAdapter<OsmandPlugin> {
public PluginsListAdapter() {
super(PluginsActivity.this, R.layout.plugins_list_item,
OsmandPlugin.getAvailablePlugins());
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.plugins_list_item, parent, false);
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = getLayoutInflater().inflate(R.layout.plugins_list_item, parent, false);
}
OsmandPlugin plugin = getItem(position);
boolean toBeEnabled = restartPlugins.contains(plugin.getId());
final View row = v;
CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
ch.setOnClickListener(null);
ch.setChecked(toBeEnabled);
ch.setOnClickListener(new View.OnClickListener() {
final OsmandPlugin plugin = getItem(position);
final boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
view.setTag(plugin);
ImageView pluginLogo = (ImageView)view.findViewById(R.id.plugin_logo);
if (plugin.getId().equals(OsMoPlugin.ID)) {
pluginLogo.setImageResource(R.drawable.ic_osmo_dark);
}
TextView pluginName = (TextView)view.findViewById(R.id.plugin_name);
pluginName.setText(plugin.getName());
pluginName.setContentDescription(plugin.getName() + " " + getString(isEnabled
? R.string.item_checked
: R.string.item_unchecked));
TextView pluginDescription = (TextView)view.findViewById(R.id.plugin_description);
pluginDescription.setText(plugin.getDescription());
View pluginIsEnabled = view.findViewById(R.id.plugin_is_enabled);
pluginIsEnabled.setVisibility(isEnabled ? View.VISIBLE : View.INVISIBLE);
View pluginOptions = view.findViewById(R.id.plugin_options);
pluginOptions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
click(position);
}
});
TextView nameView = (TextView) row.findViewById(R.id.plugin_name);
nameView.setText(plugin.getName());
nameView.setContentDescription(plugin.getName() + " " + getString(toBeEnabled ? R.string.item_checked : R.string.item_unchecked));
View rw = row.findViewById(R.id.settings);
final Class<? extends Activity> st = plugin.getSettingsActivity();
rw.setVisibility(toBeEnabled && st != null ? View.VISIBLE : View.GONE);
rw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (st != null) {
startActivity(new Intent(PluginsActivity.this, st));
}
showOptionsMenu(v, plugin);
}
});
TextView description = (TextView) row.findViewById(R.id.plugin_descr);
description.setText(plugin.getDescription());
description.setVisibility(clickedPlugins.contains(plugin.getId()) ||
!restartPlugins.contains(plugin.getId()) ? View.VISIBLE : View.GONE);
return row;
return view;
}
}
private void showOptionsMenu(View v, final OsmandPlugin plugin) {
final boolean isEnabled = OsmandPlugin.getEnabledPlugins().contains(plugin);
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
final PopupMenu optionsMenu = new PopupMenu(this, v);
MenuItem enableDisableItem = optionsMenu.getMenu().add(isEnabled
? R.string.disable_plugin
: R.string.enable_plugin);
enableDisableItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
enableDisablePlugin(plugin, !isEnabled);
optionsMenu.dismiss();
return true;
}
});
if (settingsActivity != null) {
MenuItem settingsItem = optionsMenu.getMenu().add(R.string.settings);
settingsItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
startActivity(new Intent(PluginsActivity.this, settingsActivity));
optionsMenu.dismiss();
return true;
}
});
settingsItem.setEnabled(isEnabled);
}
optionsMenu.show();
}
}