keepass2android/src/PluginHostTest/PluginListActivity.cs

52 lines
1.8 KiB
C#
Raw Normal View History

2014-04-22 00:27:13 -04:00
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Widget;
using PluginHostTest;
namespace keepass2android
{
//TODO theme?
[Activity (Label = "Plugins (TODO)", ConfigurationChanges=ConfigChanges.Orientation|ConfigChanges.KeyboardHidden )]
public class PluginListActivity : ListActivity
{
private PluginArrayAdapter _pluginArrayAdapter;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//TODO _design.ApplyTheme();
SetContentView(Resource.Layout.plugin_list);
PluginDatabase pluginDb = new PluginDatabase(this);
List<PluginItem> items = (from pluginPackage in pluginDb.GetAllPluginPackages()
let version = PackageManager.GetPackageInfo(pluginPackage, 0).VersionName
let enabledStatus = pluginDb.IsEnabled(pluginPackage) ? GetString(Resource.String.plugin_enabled) : GetString(Resource.String.plugin_disabled)
select new PluginItem(pluginPackage, "the plugin", Resource.Drawable.Icon, version, enabledStatus)).ToList();
/*
{
new PluginItem("PluginA", Resource.Drawable.Icon, "keepass2android.plugina", "connected"),
new PluginItem("KeepassNFC", Resource.Drawable.Icon, "com.bla.blubb.plugina", "disconnected")
};
* */
_pluginArrayAdapter = new PluginArrayAdapter(this, Resource.Layout.ListViewPluginRow, items);
ListAdapter = _pluginArrayAdapter;
ListView listView = FindViewById<ListView>(Android.Resource.Id.List);
listView.ItemClick +=
(sender, args) =>
{
Intent i = new Intent(this, typeof(PluginDetailsActivity));
i.PutExtra("PluginPackage", items[args.Position].Package);
StartActivity(i);
};
// Create your application here
}
}
}