summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/views/FileSelectLayout.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-12-11 10:18:06 +0100
committerArne Schwabe <arne@rfc2549.org>2013-12-11 10:18:06 +0100
commit49653f7c3811a29afc92b3def7430e962a39fe0b (patch)
tree74460916357ae9f0dd1849290d29881f3a4f423b /src/de/blinkt/openvpn/views/FileSelectLayout.java
parentce1dba9a001049264449eadd138a9b1d93eccba3 (diff)
Move activities and views into packages
--HG-- rename : src/de/blinkt/openvpn/ConfigConverter.java => src/de/blinkt/openvpn/activities/ConfigConverter.java rename : src/de/blinkt/openvpn/app/CreateShortcuts.java => src/de/blinkt/openvpn/activities/CreateShortcuts.java rename : src/de/blinkt/openvpn/DisconnectVPN.java => src/de/blinkt/openvpn/activities/DisconnectVPN.java rename : src/de/blinkt/openvpn/FileSelect.java => src/de/blinkt/openvpn/activities/FileSelect.java rename : src/de/blinkt/openvpn/LogWindow.java => src/de/blinkt/openvpn/activities/LogWindow.java rename : src/de/blinkt/openvpn/MainActivity.java => src/de/blinkt/openvpn/activities/MainActivity.java rename : src/de/blinkt/openvpn/FileSelectLayout.java => src/de/blinkt/openvpn/views/FileSelectLayout.java rename : src/de/blinkt/openvpn/RemoteCNPreference.java => src/de/blinkt/openvpn/views/RemoteCNPreference.java rename : src/de/blinkt/openvpn/fragments/SeekBarTicks.java => src/de/blinkt/openvpn/views/SeekBarTicks.java extra : rebase_source : fccff1bc269dbc0ae33b96a4947b8a6e2924efeb
Diffstat (limited to 'src/de/blinkt/openvpn/views/FileSelectLayout.java')
-rw-r--r--src/de/blinkt/openvpn/views/FileSelectLayout.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/views/FileSelectLayout.java b/src/de/blinkt/openvpn/views/FileSelectLayout.java
new file mode 100644
index 00000000..7ee96884
--- /dev/null
+++ b/src/de/blinkt/openvpn/views/FileSelectLayout.java
@@ -0,0 +1,105 @@
+package de.blinkt.openvpn.views;
+
+import de.blinkt.openvpn.R;
+import de.blinkt.openvpn.VpnProfile;
+import de.blinkt.openvpn.activities.FileSelect;
+import de.blinkt.openvpn.core.X509Utils;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+
+public class FileSelectLayout extends LinearLayout implements OnClickListener {
+
+ private final boolean mIsCertificate;
+ private TextView mDataView;
+ private String mData;
+ private Fragment mFragment;
+ private int mTaskId;
+ private Button mSelectButton;
+ private boolean mBase64Encode;
+ private String mTitle;
+ private boolean mShowClear;
+ private TextView mDataDetails;
+
+ public FileSelectLayout( Context context, AttributeSet attrset) {
+ super(context,attrset);
+ inflate(getContext(), R.layout.file_select, this);
+
+ TypedArray ta = context.obtainStyledAttributes(attrset, R.styleable.FileSelectLayout);
+
+ mTitle = ta.getString(R.styleable.FileSelectLayout_title);
+ mIsCertificate = ta.getBoolean(R.styleable.FileSelectLayout_certificate,true);
+
+ TextView tview = (TextView) findViewById(R.id.file_title);
+ tview.setText(mTitle);
+
+ mDataView = (TextView) findViewById(R.id.file_selected_item);
+ mDataDetails = (TextView) findViewById(R.id.file_selected_description);
+ mSelectButton = (Button) findViewById(R.id.file_select_button);
+ mSelectButton.setOnClickListener(this);
+
+ ta.recycle();
+ }
+
+ public void setFragment(Fragment fragment, int i)
+ {
+ mTaskId = i;
+ mFragment = fragment;
+ }
+
+ public void getCertificateFileDialog() {
+ Intent startFC = new Intent(getContext(),FileSelect.class);
+ startFC.putExtra(FileSelect.START_DATA, mData);
+ startFC.putExtra(FileSelect.WINDOW_TITLE,mTitle);
+ if(mBase64Encode)
+ startFC.putExtra(FileSelect.DO_BASE64_ENCODE, true);
+ if(mShowClear)
+ startFC.putExtra(FileSelect.SHOW_CLEAR_BUTTON, true);
+ mFragment.startActivityForResult(startFC,mTaskId);
+ }
+
+
+ public String getData() {
+ return mData;
+ }
+
+ public void setData(String data, Context c) {
+ mData = data;
+ if(data==null) {
+ mDataView.setText(mFragment.getString(R.string.no_data));
+ mDataDetails.setText("");
+ }else {
+ if(mData.startsWith(VpnProfile.INLINE_TAG))
+ mDataView.setText(R.string.inline_file_data);
+ else
+ mDataView.setText(data);
+ if(mIsCertificate)
+ mDataDetails.setText(X509Utils.getCertificateFriendlyName(c,data));
+ }
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ if(v == mSelectButton) {
+ getCertificateFileDialog();
+ }
+ }
+
+ public void setBase64Encode() {
+ mBase64Encode =true;
+ }
+
+ public void setShowClear() {
+ mShowClear=true;
+ }
+
+}