Files
KeePassDX/src/com/android/keepass/Util.java

68 lines
2.0 KiB
Java

/*
* 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 2 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.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.ClipboardManager;
import android.widget.TextView;
public class Util {
public static String getClipboard(Context context) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
return clipboard.getText().toString();
}
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));
}
}
public static String getEditText(Activity act, int resId) {
TextView te = (TextView) act.findViewById(resId);
assert(te == null);
if (te != null) {
return te.getText().toString();
} else {
return "";
}
}
public static void setEditText(Activity act, int resId, String str) {
TextView te = (TextView) act.findViewById(resId);
assert(te == null);
if (te != null) {
te.setText(str);
}
}
}