refactoring (java->c# naming convention)
This commit is contained in:
		@@ -22,7 +22,7 @@ namespace keepass2android
 | 
			
		||||
 | 
			
		||||
			SetContentView(Resource.Layout.donate);
 | 
			
		||||
 | 
			
		||||
			FindViewById(Resource.Id.ok_donate).Click += (sender, args) => { Util.gotoDonateUrl(this);Finish(); };
 | 
			
		||||
			FindViewById(Resource.Id.ok_donate).Click += (sender, args) => { Util.GotoDonateUrl(this);Finish(); };
 | 
			
		||||
			FindViewById(Resource.Id.no_donate).Click += (sender, args) => { Finish(); };
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -543,7 +543,7 @@ namespace keepass2android
 | 
			
		||||
			switch ( item.ItemId ) {
 | 
			
		||||
			case Resource.Id.menu_donate:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoDonateUrl(this);
 | 
			
		||||
						Util.GotoDonateUrl(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.error_failed_to_launch_link, ToastLength.Long).Show();
 | 
			
		||||
					return false;
 | 
			
		||||
@@ -571,7 +571,7 @@ namespace keepass2android
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, url);
 | 
			
		||||
					Util.GotoUrl(this, url);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
@@ -587,14 +587,14 @@ namespace keepass2android
 | 
			
		||||
				*/
 | 
			
		||||
			case Resource.Id.menu_rate:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoMarket(this);
 | 
			
		||||
						Util.GotoMarket(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
					return true;
 | 
			
		||||
			case Resource.Id.menu_suggest_improvements:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
						Util.GotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
@@ -604,7 +604,7 @@ namespace keepass2android
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_translate:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
					Util.GotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -668,7 +668,7 @@ namespace keepass2android
 | 
			
		||||
			addBinaryButton.SetCompoundDrawablesWithIntrinsicBounds( Resources.GetDrawable(Android.Resource.Drawable.IcMenuAdd) , null, null, null);
 | 
			
		||||
			addBinaryButton.Click += (sender, e) => 
 | 
			
		||||
			{
 | 
			
		||||
				Util.showBrowseDialog("/mnt/sdcard", this, Intents.RequestCodeFileBrowseForBinary, false);
 | 
			
		||||
				Util.ShowBrowseDialog("/mnt/sdcard", this, Intents.RequestCodeFileBrowseForBinary, false);
 | 
			
		||||
 | 
			
		||||
			};
 | 
			
		||||
			binariesGroup.AddView(addBinaryButton,layoutParams);
 | 
			
		||||
@@ -698,7 +698,7 @@ namespace keepass2android
 | 
			
		||||
			switch ( item.ItemId ) {
 | 
			
		||||
			case Resource.Id.menu_donate:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoDonateUrl(this);
 | 
			
		||||
						Util.GotoDonateUrl(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.error_failed_to_launch_link, ToastLength.Long).Show();
 | 
			
		||||
					return false;
 | 
			
		||||
@@ -720,21 +720,21 @@ namespace keepass2android
 | 
			
		||||
				break;
 | 
			
		||||
			case Resource.Id.menu_rate:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoMarket(this);
 | 
			
		||||
					Util.GotoMarket(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_suggest_improvements:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
					Util.GotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_translate:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
					Util.GotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -301,7 +301,7 @@ namespace keepass2android
 | 
			
		||||
			switch ( item.ItemId ) {
 | 
			
		||||
			case Resource.Id.menu_donate:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoDonateUrl(this);
 | 
			
		||||
						Util.GotoDonateUrl(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.error_failed_to_launch_link, ToastLength.Long).Show();
 | 
			
		||||
					return false;
 | 
			
		||||
@@ -334,21 +334,21 @@ namespace keepass2android
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_rate:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoMarket(this);
 | 
			
		||||
					Util.GotoMarket(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_suggest_improvements:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
					Util.GotoUrl(this, Resource.String.SuggestionsURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
				return true;
 | 
			
		||||
			case Resource.Id.menu_translate:
 | 
			
		||||
				try {
 | 
			
		||||
					Util.gotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
					Util.GotoUrl(this, Resource.String.TranslationURL);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.no_url_handler, ToastLength.Long).Show();
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -327,7 +327,7 @@ namespace keepass2android
 | 
			
		||||
						filename = parent.AbsolutePath;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				Util.showBrowseDialog(filename, this, Intents.RequestCodeFileBrowseForKeyfile, false);
 | 
			
		||||
				Util.ShowBrowseDialog(filename, this, Intents.RequestCodeFileBrowseForKeyfile, false);
 | 
			
		||||
 | 
			
		||||
			};
 | 
			
		||||
			
 | 
			
		||||
 
 | 
			
		||||
@@ -18,14 +18,8 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
using Android.App;
 | 
			
		||||
using Android.Content;
 | 
			
		||||
using Android.OS;
 | 
			
		||||
using Android.Runtime;
 | 
			
		||||
using Android.Views;
 | 
			
		||||
using Android.Widget;
 | 
			
		||||
using Android.Content.PM;
 | 
			
		||||
using Uri = Android.Net.Uri;
 | 
			
		||||
@@ -34,17 +28,17 @@ namespace keepass2android
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
	public class Util {
 | 
			
		||||
		public static String getClipboard(Context context) {
 | 
			
		||||
		public static String GetClipboard(Context context) {
 | 
			
		||||
			Android.Text.ClipboardManager clipboard = (Android.Text.ClipboardManager) context.GetSystemService(Context.ClipboardService);
 | 
			
		||||
			return clipboard.Text;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public static void copyToClipboard(Context context, String text) {
 | 
			
		||||
		public static void CopyToClipboard(Context context, String text) {
 | 
			
		||||
			Android.Text.ClipboardManager clipboard = (Android.Text.ClipboardManager) context.GetSystemService(Context.ClipboardService);
 | 
			
		||||
			clipboard.Text = text;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public static void gotoUrl(Context context, String url) {
 | 
			
		||||
		public static void GotoUrl(Context context, String url) {
 | 
			
		||||
			if ( url != null && url.Length > 0 ) {
 | 
			
		||||
 | 
			
		||||
				if (url.StartsWith("androidapp://"))
 | 
			
		||||
@@ -60,28 +54,28 @@ namespace keepass2android
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					Android.Net.Uri uri = Android.Net.Uri.Parse(url);
 | 
			
		||||
					Uri uri = Uri.Parse(url);
 | 
			
		||||
					context.StartActivity(new Intent(Intent.ActionView, uri));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public static void gotoUrl(Context context, int resId)  {
 | 
			
		||||
			gotoUrl(context, context.GetString(resId));
 | 
			
		||||
		public static void GotoUrl(Context context, int resId)  {
 | 
			
		||||
			GotoUrl(context, context.GetString(resId));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static void gotoMarket(Context context)
 | 
			
		||||
		public static void GotoMarket(Context context)
 | 
			
		||||
		{
 | 
			
		||||
			gotoUrl(context, context.GetString(Resource.String.MarketURL)+context.PackageName);
 | 
			
		||||
			GotoUrl(context, context.GetString(Resource.String.MarketURL)+context.PackageName);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static void gotoDonateUrl(Context context)
 | 
			
		||||
		public static void GotoDonateUrl(Context context)
 | 
			
		||||
		{
 | 
			
		||||
			string donateUrl = context.GetString(Resource.String.donate_url, 
 | 
			
		||||
			                         new Java.Lang.Object[]{context.Resources.Configuration.Locale.Language,
 | 
			
		||||
															context.PackageName
 | 
			
		||||
			});
 | 
			
		||||
			gotoUrl(context, donateUrl);
 | 
			
		||||
			GotoUrl(context, donateUrl);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		public static String GetEditText(Activity act, int resId) {
 | 
			
		||||
@@ -130,7 +124,7 @@ namespace keepass2android
 | 
			
		||||
			return list.Count > 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static void showBrowseDialog(string filename, Activity act, int requestCodeBrowse, bool forSaving)
 | 
			
		||||
		public static void ShowBrowseDialog(string filename, Activity act, int requestCodeBrowse, bool forSaving)
 | 
			
		||||
		{
 | 
			
		||||
			if ((!forSaving) && (IsIntentAvailable(act, Intent.ActionGetContent, "file/*"))) {
 | 
			
		||||
				Intent i = new Intent(Intent.ActionGetContent);
 | 
			
		||||
@@ -143,7 +137,7 @@ namespace keepass2android
 | 
			
		||||
			{
 | 
			
		||||
				Intent i = new Intent(Intents.FileBrowse);
 | 
			
		||||
				if (filename != null)
 | 
			
		||||
					i.SetData(Android.Net.Uri.Parse("file://" + filename));
 | 
			
		||||
					i.SetData(Uri.Parse("file://" + filename));
 | 
			
		||||
				try
 | 
			
		||||
				{
 | 
			
		||||
					act.StartActivityForResult(i, requestCodeBrowse);
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ namespace keepass2android
 | 
			
		||||
			
 | 
			
		||||
			Button market = (Button) FindViewById(Resource.Id.install_market);
 | 
			
		||||
			market.Click += (sender, e) => {
 | 
			
		||||
					Util.gotoUrl(Context, Resource.String.oi_filemanager_market);
 | 
			
		||||
					Util.GotoUrl(Context, Resource.String.oi_filemanager_market);
 | 
			
		||||
					Cancel();
 | 
			
		||||
				}
 | 
			
		||||
			;
 | 
			
		||||
@@ -53,7 +53,7 @@ namespace keepass2android
 | 
			
		||||
			
 | 
			
		||||
			Button web = (Button) FindViewById(Resource.Id.install_web);
 | 
			
		||||
			web.Click += (sender, e) => {
 | 
			
		||||
					Util.gotoUrl(Context, Resource.String.oi_filemanager_web);
 | 
			
		||||
					Util.GotoUrl(Context, Resource.String.oi_filemanager_web);
 | 
			
		||||
					Cancel();
 | 
			
		||||
				}
 | 
			
		||||
			;
 | 
			
		||||
 
 | 
			
		||||
@@ -185,7 +185,7 @@ namespace keepass2android
 | 
			
		||||
			browseButton.Click += (sender, evt) => {
 | 
			
		||||
				string filename = ((EditText)dialog.FindViewById(Resource.Id.file_filename)).Text;
 | 
			
		||||
				
 | 
			
		||||
				Util.showBrowseDialog(filename, this, requestCodeBrowse, showCreateButton);
 | 
			
		||||
				Util.ShowBrowseDialog(filename, this, requestCodeBrowse, showCreateButton);
 | 
			
		||||
				
 | 
			
		||||
			};
 | 
			
		||||
 | 
			
		||||
@@ -629,7 +629,7 @@ namespace keepass2android
 | 
			
		||||
			switch (item.ItemId) {
 | 
			
		||||
			case Resource.Id.menu_donate:
 | 
			
		||||
				try {
 | 
			
		||||
						Util.gotoDonateUrl(this);
 | 
			
		||||
						Util.GotoDonateUrl(this);
 | 
			
		||||
				} catch (ActivityNotFoundException) {
 | 
			
		||||
					Toast.MakeText(this, Resource.String.error_failed_to_launch_link, ToastLength.Long).Show();
 | 
			
		||||
					return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -326,7 +326,7 @@ namespace keepass2android
 | 
			
		||||
		private readonly Timer _timer = new Timer();
 | 
			
		||||
		
 | 
			
		||||
		internal void TimeoutCopyToClipboard(String text) {
 | 
			
		||||
			Util.copyToClipboard(this, text);
 | 
			
		||||
			Util.CopyToClipboard(this, text);
 | 
			
		||||
			
 | 
			
		||||
			ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
 | 
			
		||||
			String sClipClear = prefs.GetString(GetString(Resource.String.clipboard_timeout_key), GetString(Resource.String.clipboard_timeout_default));
 | 
			
		||||
@@ -353,10 +353,10 @@ namespace keepass2android
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			public override void Run() {
 | 
			
		||||
				String currentClip = Util.getClipboard(_service);
 | 
			
		||||
				String currentClip = Util.GetClipboard(_service);
 | 
			
		||||
				_handler.Post( () => _service.OnWaitElementDeleted(ClearClipboard));
 | 
			
		||||
				if ( currentClip.Equals(_clearText) ) {
 | 
			
		||||
					Util.copyToClipboard(_service, "");
 | 
			
		||||
					Util.CopyToClipboard(_service, "");
 | 
			
		||||
					_handler.Post( () => {
 | 
			
		||||
						Toast.MakeText(_service, Resource.String.ClearClipboard, ToastLength.Long).Show();
 | 
			
		||||
					});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user