added #if EXCLUDE

This commit is contained in:
Philipp Crocoll 2014-05-25 06:12:52 +02:00
parent e871664ff4
commit 3e95b528e3

View File

@ -40,7 +40,7 @@ namespace keepass2android
/// The notifications require to be displayed by a service in order to be kept when the activity is closed
/// after searching for a URL.
[Service]
public class CopyToClipboardService: Service
public class CopyToClipboardService : Service
{
@ -72,7 +72,7 @@ namespace keepass2android
ctx.StartService(i);
}
public CopyToClipboardService (IntPtr javaReference, JniHandleOwnership transfer)
public CopyToClipboardService(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}
@ -137,11 +137,13 @@ namespace keepass2android
}
else //UpdateKeyboard
{
#if !EXCLUDE_KEYBOARD
//this action is received when the data in the entry has changed (e.g. by plugins)
//update the keyboard data.
//Check if keyboard is (still) available
if (Keepass2android.Kbbridge.KeyboardData.EntryId == entry.Uuid.ToHexString())
MakeAccessibleForKeyboard(entry);
#endif
}
}
if (intent.Action == Intents.CopyStringToClipboard)
@ -185,12 +187,13 @@ namespace keepass2android
{
UnregisterReceiver(_notificationDeletedBroadcastReceiver);
}
if ( _notificationManager != null ) {
if (_notificationManager != null)
{
_notificationManager.Cancel(NotifyPassword);
_notificationManager.Cancel(NotifyUsername);
_notificationManager.Cancel(NotifyKeyboard);
_numElementsToWaitFor= 0;
_numElementsToWaitFor = 0;
ClearKeyboard(true);
}
if (_clearClipboardTask != null)
@ -298,8 +301,8 @@ namespace keepass2android
private bool ClearNotifications()
{
// Notification Manager
_notificationManager = (NotificationManager) GetSystemService(NotificationService);
// Notification Manager
_notificationManager = (NotificationManager)GetSystemService(NotificationService);
_notificationManager.Cancel(NotifyPassword);
_notificationManager.Cancel(NotifyUsername);
@ -397,7 +400,8 @@ namespace keepass2android
private readonly Timer _timer = new Timer();
internal void TimeoutCopyToClipboard(String text) {
internal void TimeoutCopyToClipboard(String text)
{
Util.CopyToClipboard(this, text);
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
@ -406,31 +410,37 @@ namespace keepass2android
long clipClearTime = long.Parse(sClipClear);
_clearClipboardTask = new ClearClipboardTask(this, text, _uiThreadCallback);
if ( clipClearTime > 0 ) {
if (clipClearTime > 0)
{
_numElementsToWaitFor++;
_timer.Schedule(_clearClipboardTask, clipClearTime);
}
}
// Task which clears the clipboard, and sends a toast to the foreground.
private class ClearClipboardTask : TimerTask {
private class ClearClipboardTask : TimerTask
{
private readonly String _clearText;
private readonly CopyToClipboardService _service;
private readonly Handler _handler;
public ClearClipboardTask(CopyToClipboardService service, String clearText, Handler handler) {
public ClearClipboardTask(CopyToClipboardService service, String clearText, Handler handler)
{
_clearText = clearText;
_service = service;
_handler = handler;
}
public override void Run() {
public override void Run()
{
String currentClip = Util.GetClipboard(_service);
_handler.Post( () => _service.OnWaitElementDeleted(ClearClipboard));
if ( currentClip.Equals(_clearText) ) {
_handler.Post(() => _service.OnWaitElementDeleted(ClearClipboard));
if (currentClip.Equals(_clearText))
{
Util.CopyToClipboard(_service, "");
_handler.Post( () => {
_handler.Post(() =>
{
Toast.MakeText(_service, Resource.String.ClearClipboard, ToastLength.Long).Show();
});
}
@ -445,12 +455,13 @@ namespace keepass2android
private Notification GetNotification(String intentText, int descResId, int drawableResId, String entryName) {
private Notification GetNotification(String intentText, int descResId, int drawableResId, String entryName)
{
String desc = GetString(descResId);
String title = GetString(Resource.String.app_name);
if (!String.IsNullOrEmpty(entryName))
title += " (" + entryName +")";
title += " (" + entryName + ")";
Notification notify = new Notification(drawableResId, desc, Java.Lang.JavaSystem.CurrentTimeMillis());
@ -485,7 +496,7 @@ namespace keepass2android
class NotificationDeletedBroadcastReceiver: BroadcastReceiver
class NotificationDeletedBroadcastReceiver : BroadcastReceiver
{
readonly CopyToClipboardService _service;
public NotificationDeletedBroadcastReceiver(CopyToClipboardService service)
@ -551,7 +562,8 @@ namespace keepass2android
[IntentFilter(new[] { Intents.CopyUsername, Intents.CopyPassword, Intents.CheckKeyboard })]
class CopyToClipboardBroadcastReceiver : BroadcastReceiver
{
public CopyToClipboardBroadcastReceiver(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
public CopyToClipboardBroadcastReceiver(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}
@ -568,7 +580,7 @@ namespace keepass2android
//this should always be non-null, but if the OS has killed the app, it might occur.
if (App.Kp2a.GetDb().LastOpenedEntry == null)
{
Intent i = new Intent(context, typeof (AppKilledInfo));
Intent i = new Intent(context, typeof(AppKilledInfo));
i.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);
context.StartActivity(i);
return;