mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Support Goto Homepage.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
<string name="menu_url">Go to URL</string>
|
||||
<string name="menu_copy_user">Copy User</string>
|
||||
<string name="menu_copy_pass">Copy Password</string>
|
||||
<string name="pass_filename">Filename:</string>
|
||||
<string name="pass_filename">KeePass database filename:</string>
|
||||
|
||||
<string name="menu_homepage">Go to Homepage</string>
|
||||
<string name="homepage">http://www.keepassdroid.com</string>
|
||||
</resources>
|
||||
|
||||
@@ -37,7 +37,7 @@ public class EntryActivity extends Activity {
|
||||
public static final String KEY_ENTRY = "entry";
|
||||
|
||||
private static final int MENU_PASS = Menu.FIRST;
|
||||
private static final int MENU_COPY_URL = Menu.FIRST + 1;
|
||||
private static final int MENU_GOTO_URL = Menu.FIRST + 1;
|
||||
private static final int MENU_COPY_USER = Menu.FIRST + 2;
|
||||
private static final int MENU_COPY_PASS = Menu.FIRST + 3;
|
||||
|
||||
@@ -95,8 +95,8 @@ public class EntryActivity extends Activity {
|
||||
|
||||
menu.add(0, MENU_PASS, 0, R.string.menu_show_password);
|
||||
menu.findItem(MENU_PASS).setIcon(android.R.drawable.ic_menu_view);
|
||||
menu.add(0, MENU_COPY_URL, 0, R.string.menu_url);
|
||||
menu.findItem(MENU_COPY_URL).setIcon(android.R.drawable.ic_menu_upload);
|
||||
menu.add(0, MENU_GOTO_URL, 0, R.string.menu_url);
|
||||
menu.findItem(MENU_GOTO_URL).setIcon(android.R.drawable.ic_menu_upload);
|
||||
menu.add(0, MENU_COPY_USER, 0, R.string.menu_copy_user);
|
||||
menu.findItem(MENU_COPY_USER).setIcon(android.R.drawable.ic_menu_set_as);
|
||||
menu.add(0, MENU_COPY_PASS, 0, R.string.menu_copy_pass);
|
||||
@@ -120,30 +120,17 @@ public class EntryActivity extends Activity {
|
||||
}
|
||||
return true;
|
||||
|
||||
case MENU_COPY_URL:
|
||||
gotoUrl(mEntry.url);
|
||||
case MENU_GOTO_URL:
|
||||
Util.gotoUrl(this, mEntry.url);
|
||||
return true;
|
||||
case MENU_COPY_USER:
|
||||
copyToClipboard(mEntry.username);
|
||||
Util.copyToClipboard(this, mEntry.username);
|
||||
return true;
|
||||
case MENU_COPY_PASS:
|
||||
copyToClipboard(new String(mEntry.getPassword()));
|
||||
Util.copyToClipboard(this, new String(mEntry.getPassword()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void copyToClipboard(String text) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setText(text);
|
||||
}
|
||||
|
||||
private void gotoUrl(String url) {
|
||||
if ( url != null && url.length() > 0 ) {
|
||||
Uri uri = Uri.parse(url);
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@@ -42,7 +44,7 @@ import java.util.Vector;
|
||||
|
||||
public class KeePass extends Activity {
|
||||
|
||||
|
||||
private static final int MENU_HOMEPAGE = Menu.FIRST;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -147,4 +149,24 @@ public class KeePass extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
menu.add(0, MENU_HOMEPAGE, 0, R.string.menu_homepage);
|
||||
menu.findItem(MENU_HOMEPAGE).setIcon(android.R.drawable.ic_menu_upload);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case MENU_HOMEPAGE:
|
||||
Util.gotoUrl(this, getText(R.string.homepage).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
40
src/com/android/keepass/Util.java
Normal file
40
src/com/android/keepass/Util.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2009 Brian Pellin.
|
||||
*
|
||||
* This file is part of KeePassDroid.
|
||||
*
|
||||
* KeePassDroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.android.keepass;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.ClipboardManager;
|
||||
|
||||
public class Util {
|
||||
public static void copyToClipboard(Context context, String text) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setText(text);
|
||||
}
|
||||
|
||||
public static void gotoUrl(Context context, String url) {
|
||||
if ( url != null && url.length() > 0 ) {
|
||||
Uri uri = Uri.parse(url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user