From cfb910a8ae50e0706d11b15fba39ccd1e7799488 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Thu, 3 Oct 2013 03:49:04 +0200 Subject: [PATCH] refactoring (java->c# naming convention) --- src/keepass2android/DonateReminder.cs | 2 +- src/keepass2android/EntryActivity.cs | 10 +++---- src/keepass2android/EntryEditActivity.cs | 10 +++---- src/keepass2android/GroupBaseActivity.cs | 8 ++--- src/keepass2android/PasswordActivity.cs | 2 +- src/keepass2android/Utils/Util.cs | 30 ++++++++----------- .../fileselect/BrowserDialog.cs | 4 +-- .../fileselect/FileSelectActivity.cs | 4 +-- .../services/CopyToClipboardService.cs | 6 ++-- 9 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/keepass2android/DonateReminder.cs b/src/keepass2android/DonateReminder.cs index ad59f2ff..821409a0 100644 --- a/src/keepass2android/DonateReminder.cs +++ b/src/keepass2android/DonateReminder.cs @@ -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(); }; } } diff --git a/src/keepass2android/EntryActivity.cs b/src/keepass2android/EntryActivity.cs index a6595c7c..3dd7086a 100644 --- a/src/keepass2android/EntryActivity.cs +++ b/src/keepass2android/EntryActivity.cs @@ -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(); } diff --git a/src/keepass2android/EntryEditActivity.cs b/src/keepass2android/EntryEditActivity.cs index 684e7bfc..919e913f 100644 --- a/src/keepass2android/EntryEditActivity.cs +++ b/src/keepass2android/EntryEditActivity.cs @@ -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(); } diff --git a/src/keepass2android/GroupBaseActivity.cs b/src/keepass2android/GroupBaseActivity.cs index 4a5cadc1..4bd78ca0 100644 --- a/src/keepass2android/GroupBaseActivity.cs +++ b/src/keepass2android/GroupBaseActivity.cs @@ -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(); } diff --git a/src/keepass2android/PasswordActivity.cs b/src/keepass2android/PasswordActivity.cs index 8628cc5a..c4eba3d7 100644 --- a/src/keepass2android/PasswordActivity.cs +++ b/src/keepass2android/PasswordActivity.cs @@ -327,7 +327,7 @@ namespace keepass2android filename = parent.AbsolutePath; } } - Util.showBrowseDialog(filename, this, Intents.RequestCodeFileBrowseForKeyfile, false); + Util.ShowBrowseDialog(filename, this, Intents.RequestCodeFileBrowseForKeyfile, false); }; diff --git a/src/keepass2android/Utils/Util.cs b/src/keepass2android/Utils/Util.cs index 2ca59600..4f4a90a0 100644 --- a/src/keepass2android/Utils/Util.cs +++ b/src/keepass2android/Utils/Util.cs @@ -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); diff --git a/src/keepass2android/fileselect/BrowserDialog.cs b/src/keepass2android/fileselect/BrowserDialog.cs index 0528a0e1..2d48a6f1 100644 --- a/src/keepass2android/fileselect/BrowserDialog.cs +++ b/src/keepass2android/fileselect/BrowserDialog.cs @@ -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(); } ; diff --git a/src/keepass2android/fileselect/FileSelectActivity.cs b/src/keepass2android/fileselect/FileSelectActivity.cs index 6f926597..50dc32dd 100644 --- a/src/keepass2android/fileselect/FileSelectActivity.cs +++ b/src/keepass2android/fileselect/FileSelectActivity.cs @@ -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; diff --git a/src/keepass2android/services/CopyToClipboardService.cs b/src/keepass2android/services/CopyToClipboardService.cs index 6ed067a1..2abed6c9 100644 --- a/src/keepass2android/services/CopyToClipboardService.cs +++ b/src/keepass2android/services/CopyToClipboardService.cs @@ -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(); });