summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/FileSelectLayout.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-04-16 19:21:14 +0200
committerArne Schwabe <arne@rfc2549.org>2012-04-16 19:21:14 +0200
commit3e4d8f433239c40311037616b1b8833a06651ae0 (patch)
tree98ab7fce0d011d34677b0beb762d389cb5c39199 /src/de/blinkt/openvpn/FileSelectLayout.java
Initial import
Diffstat (limited to 'src/de/blinkt/openvpn/FileSelectLayout.java')
-rw-r--r--src/de/blinkt/openvpn/FileSelectLayout.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/FileSelectLayout.java b/src/de/blinkt/openvpn/FileSelectLayout.java
new file mode 100644
index 00000000..0615b2ab
--- /dev/null
+++ b/src/de/blinkt/openvpn/FileSelectLayout.java
@@ -0,0 +1,75 @@
+package de.blinkt.openvpn;
+
+import com.lamerman.FileDialog;
+import com.lamerman.SelectionMode;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import android.view.View;
+import android.view.View.OnClickListener;
+
+public class FileSelectLayout extends LinearLayout implements OnClickListener {
+
+ private TextView mData;
+ private Activity mActivity;
+ private int mTaskId;
+ private Button mSelectButton;
+
+ public FileSelectLayout( Context context,AttributeSet attrset) {
+ super(context,attrset);
+ inflate(getContext(), R.layout.file_select, this);
+
+ TypedArray ta = context.obtainStyledAttributes(attrset,R.styleable.FileSelectLayout);
+
+ String title = ta.getString(R.styleable.FileSelectLayout_title);
+
+ TextView tview = (TextView) findViewById(R.id.file_title);
+ tview.setText(title);
+
+ mData = (TextView) findViewById(R.id.file_selected_item);
+ mSelectButton = (Button) findViewById(R.id.file_select_button);
+ mSelectButton.setOnClickListener(this);
+
+ }
+
+ public void setActivity(Activity a, int i)
+ {
+ mTaskId = i;
+ mActivity = a;
+ }
+
+ public void getCertificateFileDialog() {
+ Intent startFC = new Intent(getContext(),FileDialog.class);
+ startFC.putExtra(FileDialog.START_PATH, "/sdcard");
+ startFC.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
+
+ mActivity.startActivityForResult(startFC,mTaskId);
+ }
+
+
+ public String getData() {
+ return mData.getText().toString();
+ }
+
+ public void setData(String data) {
+ mData.setText(data);
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ if(v == mSelectButton) {
+ getCertificateFileDialog();
+ }
+ }
+
+
+
+}