small changes within the plugins activity
This commit is contained in:
parent
5c392ec83f
commit
53a3a415c3
2 changed files with 24 additions and 15 deletions
|
@ -10,13 +10,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="10dp"
|
||||
android:textStyle="bold"
|
||||
android:textSize="18sp" android:drawableRight="@drawable/list_activities_dot_marker1_pressed" android:drawableLeft="@drawable/list_activities_plugin_menu_symbol" android:text="@string/extra_settings" android:gravity="center_vertical" android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/ic_background_plugin_listitem">
|
||||
android:textSize="20sp" android:drawableRight="@drawable/list_activities_dot_marker1_pressed" android:drawableLeft="@drawable/list_activities_plugin_menu_symbol" android:text="@string/extra_settings" android:gravity="center_vertical" android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/ic_background_plugin_listitem">
|
||||
</TextView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/plugin_descr"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:maxLines="7"
|
||||
android:text="@string/osmand_extra_settings_description"
|
||||
android:textColor="@color/color_light_gray"
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -18,9 +19,10 @@ import android.widget.TextView;
|
|||
public class PluginsActivity extends OsmandListActivity {
|
||||
|
||||
private List<OsmandPlugin> availablePlugins;
|
||||
private Set<String> enabledPlugins = new LinkedHashSet<String>();
|
||||
private Set<String> clickedPlugins = new LinkedHashSet<String>();
|
||||
private Set<String> restartPlugins = new LinkedHashSet<String>();
|
||||
|
||||
private static int colorGreen = 0xff23CC6C;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -31,7 +33,6 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
List<OsmandPlugin> enabledPlugins = OsmandPlugin.getEnabledPlugins();
|
||||
for(OsmandPlugin p : enabledPlugins) {
|
||||
restartPlugins.add(p.getId());
|
||||
this.enabledPlugins.add(p.getId());
|
||||
}
|
||||
|
||||
titleBar.afterSetContentView();
|
||||
|
@ -41,16 +42,20 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
super.onListItemClick(l, v, position, id);
|
||||
|
||||
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());
|
||||
if (!enable || clickedPlugins.contains(item.getId())) {
|
||||
boolean ok = OsmandPlugin.enablePlugin(((OsmandApplication) getApplication()), item, enable);
|
||||
if (ok) {
|
||||
if (!enable) {
|
||||
restartPlugins.remove(item.getId());
|
||||
} else {
|
||||
restartPlugins.add(item.getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clickedPlugins.add(item.getId());
|
||||
}
|
||||
getListAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
@ -73,16 +78,19 @@ public class PluginsActivity extends OsmandListActivity {
|
|||
LayoutInflater inflater = getLayoutInflater();
|
||||
v = inflater.inflate(net.osmand.plus.R.layout.plugins_list_item, parent, false);
|
||||
}
|
||||
final View row = v;
|
||||
OsmandPlugin plugin = getItem(position);
|
||||
boolean toBeEnabled = restartPlugins.contains(plugin.getId());
|
||||
int resourceId = toBeEnabled ? R.drawable.list_activities_dot_marker2_pressed : R.drawable.list_activities_dot_marker1_pressed;
|
||||
|
||||
final View row = v;
|
||||
TextView nameView = (TextView) row.findViewById(R.id.plugin_name);
|
||||
nameView.setText(plugin.getName());
|
||||
nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(resourceId), null);
|
||||
|
||||
TextView description = (TextView) row.findViewById(R.id.plugin_descr);
|
||||
description.setText(plugin.getDescription());
|
||||
boolean toBeEnabled = restartPlugins.contains(plugin.getId());
|
||||
int right = toBeEnabled ? R.drawable.list_activities_dot_marker2_pressed : R.drawable.list_activities_dot_marker1_pressed;
|
||||
nameView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.list_activities_plugin_menu_symbol), null, getResources().getDrawable(right), null);
|
||||
description.setVisibility(clickedPlugins.contains(plugin.getId()) ? View.VISIBLE : View.GONE);
|
||||
description.setTextColor(toBeEnabled? colorGreen : Color.LTGRAY);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue