A little more refactoring: Removed/moved classes, some renames, ...

Added comments for most classes
This commit is contained in:
Philipp Crocoll
2013-06-15 22:02:48 +02:00
parent d2a06617eb
commit 8b08baa51a
35 changed files with 240 additions and 236 deletions

View File

@@ -4,19 +4,46 @@ using KeePassLib.Serialization;
namespace keepass2android
{
/// <summary>
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
/// </summary>
/// This also contains methods which are UI specific and should be replacable for testing.
public interface IKp2aApp
{
/// <summary>
/// Set the flag that the database needs to be locked.
/// </summary>
void SetShutdown();
/// <summary>
/// Returns the current database
/// </summary>
Database GetDb();
/// <summary>
/// Tell the app that the file from ioc was opened with keyfile.
/// </summary>
void StoreOpenedFileAsRecent(IOConnectionInfo ioc, string keyfile);
/// <summary>
/// Creates a new database and returns it
/// </summary>
Database CreateNewDatabase();
/// <summary>
/// Returns the user-displayable string identified by stringKey
/// </summary>
string GetResourceString(UiStringKey stringKey);
/// <summary>
/// Returns the value from the preferences corresponding to key
/// </summary>
bool GetBooleanPreference(PreferenceKey key);
/// <summary>
/// Asks the user the question "messageKey" with the options Yes/No/Cancel, calls the handler corresponding to the answer.
/// </summary>
void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,
EventHandler<DialogClickEventArgs> yesHandler,
EventHandler<DialogClickEventArgs> noHandler,

View File

@@ -16,20 +16,12 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
*/
using System;
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;
namespace keepass2android
{
/// <summary>
/// Thrown when there is an error adding the keyfie to the user key
/// </summary>
[Serializable]
public class KeyFileException : Exception
{

View File

@@ -1,5 +1,8 @@
namespace keepass2android
{
/// <summary>
/// Keys which can be used to get a preference setting
/// </summary>
public enum PreferenceKey
{
remember_keyfile,

View File

@@ -22,6 +22,9 @@ using Java.Lang;
namespace keepass2android
{
/// <summary>
/// Class to run a task while a progress dialog is shown
/// </summary>
public class ProgressTask {
private readonly Handler _handler;
private readonly RunnableOnFinish _task;

View File

@@ -23,6 +23,9 @@ using KeePassLib.Utility;
namespace keepass2android
{
/// <summary>
/// Helper class providing methods to search a given database for specific things
/// </summary>
public class SearchDbHelper
{
private readonly IKp2aApp _app;
@@ -86,21 +89,21 @@ namespace keepass2android
}
private String extractHost(String url)
private static String ExtractHost(String url)
{
return UrlUtil.GetHost(url.Trim());
}
public PwGroup SearchForHost(Database database, String url, bool allowSubdomains)
{
String host = extractHost(url);
String host = ExtractHost(url);
string strGroupName = _app.GetResourceString(UiStringKey.search_results) + " (\"" + host + "\")";
PwGroup pgResults = new PwGroup(true, true, strGroupName, PwIcon.EMailSearch) {IsVirtual = true};
if (String.IsNullOrWhiteSpace(host))
return pgResults;
foreach (PwEntry entry in database.Entries.Values)
{
String otherHost = extractHost(entry.Strings.ReadSafe(PwDefs.UrlField));
String otherHost = ExtractHost(entry.Strings.ReadSafe(PwDefs.UrlField));
if ((allowSubdomains) && (otherHost.StartsWith("www.")))
otherHost = otherHost.Substring(4); //remove "www."
if (String.IsNullOrWhiteSpace(otherHost))

View File

@@ -22,6 +22,9 @@ using KeePassLib.Interfaces;
namespace keepass2android
{
/// <summary>
/// StatusLogger implementation which shows the progress in a progress dialog
/// </summary>
public class UpdateStatus: IStatusLogger {
private readonly ProgressDialog _progressDialog;
readonly IKp2aApp _app;