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