mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 00:02:27 -08:00
Handle URL's without protocols.
This commit is contained in:
1 parent
950ddd9cf5
commit
3daa1e7ec6
3 files changed
+18
-2
No files matched your search
@@ -57,4 +57,5 @@
|
||||
<string name="hint_pass">password</string>
|
||||
<string name="hint_conf_pass">confirm password</string>
|
||||
<string name="hint_comment">comment</string>
|
||||
<string name="no_url_handler">No handler for this url.</string>
|
||||
</resources>
|
||||
@@ -29,6 +29,7 @@ import org.phoneid.keepassj2me.PwEntry;
|
||||
import org.phoneid.keepassj2me.Types;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -39,6 +40,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class EntryActivity extends LockingActivity {
|
||||
public static final String KEY_ENTRY = "entry";
|
||||
@@ -174,7 +176,19 @@ public class EntryActivity extends LockingActivity {
|
||||
return true;
|
||||
|
||||
case MENU_GOTO_URL:
|
||||
Util.gotoUrl(this, mEntry.url);
|
||||
String url;
|
||||
url = mEntry.url;
|
||||
|
||||
// Default http:// if no protocol specified
|
||||
if ( ! url.contains("://") ) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
|
||||
try {
|
||||
Util.gotoUrl(this, url);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_url_handler, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case MENU_COPY_USER:
|
||||
timeoutCopyToClipboard(mEntry.username);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.android.keepass;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -37,7 +38,7 @@ public class Util {
|
||||
clipboard.setText(text);
|
||||
}
|
||||
|
||||
public static void gotoUrl(Context context, String url) {
|
||||
public static void gotoUrl(Context context, String url) throws ActivityNotFoundException {
|
||||
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