rename back to current names
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Android.Content;
|
||||
using Android.Graphics.Drawables;
|
||||
using keepass2android;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Reperesents the popup menu item in EntryActivity to copy a string to clipboard
|
||||
/// </summary>
|
||||
class CopyToClipboardPopupMenuIcon : IPopupMenuItem
|
||||
{
|
||||
private readonly Context _context;
|
||||
private readonly IStringView _stringView;
|
||||
private readonly bool _isProtected;
|
||||
|
||||
public CopyToClipboardPopupMenuIcon(Context context, IStringView stringView, bool isProtected)
|
||||
{
|
||||
_context = context;
|
||||
_stringView = stringView;
|
||||
_isProtected = isProtected;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return _context.Resources.GetDrawable(Resource.Drawable.baseline_content_copy_24);
|
||||
}
|
||||
}
|
||||
public string Text
|
||||
{
|
||||
get { return _context.Resources.GetString(Resource.String.copy_to_clipboard); }
|
||||
}
|
||||
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
CopyToClipboardService.CopyValueToClipboardWithTimeout(_context, _stringView.Text, _isProtected);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
internal class ExtraStringView : IStringView
|
||||
{
|
||||
private readonly View _container;
|
||||
private readonly TextView _valueView;
|
||||
private readonly TextView _visibleValueView;
|
||||
private readonly TextView _keyView;
|
||||
|
||||
public ExtraStringView(LinearLayout container, TextView valueView, TextView visibleValueView, TextView keyView)
|
||||
{
|
||||
_container = container;
|
||||
_valueView = valueView;
|
||||
_visibleValueView = visibleValueView;
|
||||
_keyView = keyView;
|
||||
}
|
||||
|
||||
public View View
|
||||
{
|
||||
get { return _container; }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _valueView.Text; }
|
||||
set
|
||||
{
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
_container.Visibility = ViewStates.Gone;
|
||||
}
|
||||
else
|
||||
{
|
||||
_container.Visibility = ViewStates.Visible;
|
||||
_valueView.Text = value;
|
||||
if (_visibleValueView != null)
|
||||
_visibleValueView.Text = value;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using Android.Graphics.Drawables;
|
||||
using keepass2android;
|
||||
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Reperesents the popup menu item in EntryActivity to go to the URL in the field
|
||||
/// </summary>
|
||||
class GotoUrlMenuItem : IPopupMenuItem
|
||||
{
|
||||
public string UrlFieldKey { get; }
|
||||
private readonly EntryActivity _ctx;
|
||||
|
||||
public GotoUrlMenuItem(EntryActivity ctx, string urlFieldKey)
|
||||
{
|
||||
UrlFieldKey = urlFieldKey;
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get { return _ctx.Resources.GetDrawable(Resource.Drawable.baseline_upload_24); }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _ctx.Resources.GetString(Resource.String.menu_url); }
|
||||
}
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
_ctx.GotoUrl(UrlFieldKey);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Android.Graphics.Drawables;
|
||||
using KeePassLib;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for popup menu items in EntryActivity
|
||||
/// </summary>
|
||||
internal interface IPopupMenuItem
|
||||
{
|
||||
Drawable Icon { get; }
|
||||
String Text { get; }
|
||||
|
||||
void HandleClick();
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace keepass2android
|
||||
{
|
||||
internal interface IStringView
|
||||
{
|
||||
string Text { set; get; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
using Android.Graphics.Drawables;
|
||||
using keepass2android;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the popup menu item in EntryActivity to open the associated attachment
|
||||
/// </summary>
|
||||
internal class OpenBinaryPopupItem : IPopupMenuItem
|
||||
{
|
||||
private readonly string _key;
|
||||
private readonly EntryActivity _entryActivity;
|
||||
|
||||
public OpenBinaryPopupItem(string key, EntryActivity entryActivity)
|
||||
{
|
||||
_key = key;
|
||||
_entryActivity = entryActivity;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get { return _entryActivity.Resources.GetDrawable(Resource.Drawable.baseline_share_24); }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _entryActivity.Resources.GetString(Resource.String.SaveAttachmentDialog_open); }
|
||||
}
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
Android.Net.Uri newUri = _entryActivity.WriteBinaryToFile(_key, true);
|
||||
if (newUri != null)
|
||||
{
|
||||
_entryActivity.OpenBinaryFile(newUri);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using Android.Content;
|
||||
using Android.Graphics.Drawables;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
class PluginMenuOption
|
||||
{
|
||||
public string DisplayText { get; set; }
|
||||
|
||||
public Drawable Icon { get; set; }
|
||||
|
||||
public Intent Intent { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
using Android.Content;
|
||||
using Android.Graphics.Drawables;
|
||||
using Android.OS;
|
||||
using Keepass2android.Pluginsdk;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a popup menu item in EntryActivity which was added by a plugin. The click will therefore broadcast to the plugin.
|
||||
/// </summary>
|
||||
class PluginPopupMenuItem : IPopupMenuItem
|
||||
{
|
||||
private readonly EntryActivity _activity;
|
||||
private readonly string _pluginPackage;
|
||||
private readonly string _fieldId;
|
||||
private readonly string _popupItemId;
|
||||
private readonly string _displayText;
|
||||
private readonly int _iconId;
|
||||
private readonly Bundle _bundleExtra;
|
||||
|
||||
public PluginPopupMenuItem(EntryActivity activity, string pluginPackage, string fieldId, string popupItemId, string displayText, int iconId, Bundle bundleExtra)
|
||||
{
|
||||
_activity = activity;
|
||||
_pluginPackage = pluginPackage;
|
||||
_fieldId = fieldId;
|
||||
_popupItemId = popupItemId;
|
||||
_displayText = displayText;
|
||||
_iconId = iconId;
|
||||
_bundleExtra = bundleExtra;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get { return _activity.PackageManager.GetResourcesForApplication(_pluginPackage).GetDrawable(_iconId); }
|
||||
}
|
||||
public string Text
|
||||
{
|
||||
get { return _displayText; }
|
||||
}
|
||||
|
||||
public string PopupItemId
|
||||
{
|
||||
get { return _popupItemId; }
|
||||
}
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
Intent i = new Intent(Strings.ActionEntryActionSelected);
|
||||
i.SetPackage(_pluginPackage);
|
||||
i.PutExtra(Strings.ExtraActionData, _bundleExtra);
|
||||
i.PutExtra(Strings.ExtraFieldId, _fieldId);
|
||||
i.PutExtra(Strings.ExtraSender, _activity.PackageName);
|
||||
|
||||
_activity.AddEntryToIntent(i);
|
||||
|
||||
_activity.SendBroadcast(i);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.App;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
internal class StandardStringView : IStringView
|
||||
{
|
||||
private readonly List<int> _viewIds;
|
||||
private readonly int _containerViewId;
|
||||
private readonly Activity _activity;
|
||||
|
||||
public StandardStringView(List<int> viewIds, int containerViewId, Activity activity)
|
||||
{
|
||||
_viewIds = viewIds;
|
||||
_containerViewId = containerViewId;
|
||||
_activity = activity;
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
set
|
||||
{
|
||||
View container = _activity.FindViewById(_containerViewId);
|
||||
foreach (int viewId in _viewIds)
|
||||
{
|
||||
TextView tv = (TextView) _activity.FindViewById(viewId);
|
||||
if (String.IsNullOrEmpty(value))
|
||||
{
|
||||
container.Visibility = tv.Visibility = ViewStates.Gone;
|
||||
}
|
||||
else
|
||||
{
|
||||
container.Visibility = tv.Visibility = ViewStates.Visible;
|
||||
tv.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
get
|
||||
{
|
||||
TextView tv = (TextView) _activity.FindViewById(_viewIds.First());
|
||||
return tv.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
using Android.Graphics.Drawables;
|
||||
using Android.Widget;
|
||||
using keepass2android;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Reperesents the popup menu item in EntryActivity to toggle visibility of all protected strings (e.g. Password)
|
||||
/// </summary>
|
||||
class ToggleVisibilityPopupMenuItem : IPopupMenuItem
|
||||
{
|
||||
private readonly EntryActivity _activity;
|
||||
private readonly TextView _valueView;
|
||||
|
||||
|
||||
public ToggleVisibilityPopupMenuItem(EntryActivity activity, TextView valueView)
|
||||
{
|
||||
_activity = activity;
|
||||
_valueView = valueView;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
//return new TextDrawable("\uF06E", _activity);
|
||||
return _activity.Resources.GetDrawable(Resource.Drawable.baseline_visibility_24);
|
||||
|
||||
}
|
||||
}
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return _activity.Resources.GetString(
|
||||
_activity.GetVisibilityForProtectedView(_valueView) ?
|
||||
Resource.String.menu_hide_password
|
||||
: Resource.String.show_password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
_activity.ToggleVisibility(_valueView);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.Res;
|
||||
using Android.Graphics.Drawables;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using keepass2android;
|
||||
|
||||
namespace keepass2android.EntryActivityClasses
|
||||
{
|
||||
internal class ViewImagePopupItem:IPopupMenuItem
|
||||
{
|
||||
private readonly string _key;
|
||||
private readonly EntryActivity _entryActivity;
|
||||
|
||||
public ViewImagePopupItem(string key, EntryActivity entryActivity)
|
||||
{
|
||||
_key = key;
|
||||
_entryActivity = entryActivity;
|
||||
}
|
||||
public Drawable Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entryActivity.Resources.GetDrawable(Resource.Drawable.baseline_image_24);
|
||||
}
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return _entryActivity.Resources.GetString(Resource.String.ShowAttachedImage);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
_entryActivity.ShowAttachedImage(_key);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using Android.Graphics.Drawables;
|
||||
using keepass2android;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the popup menu item in EntryActivity to store the binary attachment on SD card
|
||||
/// </summary>
|
||||
internal class WriteBinaryToFilePopupItem : IPopupMenuItem
|
||||
{
|
||||
private readonly string _key;
|
||||
private readonly EntryActivity _activity;
|
||||
|
||||
public WriteBinaryToFilePopupItem(string key, EntryActivity activity)
|
||||
{
|
||||
_key = key;
|
||||
_activity = activity;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
get { return _activity.Resources.GetDrawable(Resource.Drawable.baseline_save_24); }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _activity.Resources.GetString(Resource.String.SaveAttachmentDialog_save); }
|
||||
}
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
_activity.WriteBinaryToFile(_key, false);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user