summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt/openvpn/views')
-rw-r--r--src/de/blinkt/openvpn/views/FileSelectLayout.java156
-rw-r--r--src/de/blinkt/openvpn/views/RemoteCNPreference.java141
-rw-r--r--src/de/blinkt/openvpn/views/SeekBarTicks.java69
3 files changed, 0 insertions, 366 deletions
diff --git a/src/de/blinkt/openvpn/views/FileSelectLayout.java b/src/de/blinkt/openvpn/views/FileSelectLayout.java
deleted file mode 100644
index 362777e4..00000000
--- a/src/de/blinkt/openvpn/views/FileSelectLayout.java
+++ /dev/null
@@ -1,156 +0,0 @@
-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.VpnStatus;
-import de.blinkt.openvpn.core.X509Utils;
-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;
-import de.blinkt.openvpn.fragments.Utils;
-
-import java.io.*;
-
-import static android.os.Build.*;
-
-
-public class FileSelectLayout extends LinearLayout implements OnClickListener {
-
- public void parseResponse(Intent data, Context c) {
- if (VERSION.SDK_INT < VERSION_CODES.KITKAT) {
- String fileData = data.getStringExtra(FileSelect.RESULT_DATA);
- setData(fileData, c);
- } else if (data != null) {
- try {
- String newData = Utils.getFilePickerResult(fileType, data, c);
- if (newData!=null)
- setData(newData, c);
-
- } catch (IOException e) {
- VpnStatus.logException(e);
- }
-
-
- }
- }
-
- public interface FileSelectCallback {
-
- String getString(int res);
-
- void startActivityForResult(Intent startFC, int mTaskId);
- }
-
- private boolean mIsCertificate;
- private TextView mDataView;
- private String mData;
- private FileSelectCallback mFragment;
- private int mTaskId;
- private Button mSelectButton;
- private Utils.FileType fileType;
- private String mTitle;
- private boolean mShowClear;
- private TextView mDataDetails;
-
- public FileSelectLayout(Context context, AttributeSet attrset) {
- super(context, attrset);
-
- TypedArray ta = context.obtainStyledAttributes(attrset, R.styleable.FileSelectLayout);
-
- setupViews(ta.getString(R.styleable.FileSelectLayout_title), ta.getBoolean(R.styleable.FileSelectLayout_certificate, true));
-
- ta.recycle();
- }
-
- public FileSelectLayout (Context context, String title, boolean isCerticate)
- {
- super(context);
-
- setupViews(title, isCerticate);
-
- }
-
- private void setupViews(String title, boolean isCertificate) {
- inflate(getContext(), R.layout.file_select, this);
-
- mTitle = title;
- mIsCertificate = isCertificate;
-
- 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);
- }
-
-
- public void setCaller(FileSelectCallback fragment, int i, Utils.FileType ft) {
- mTaskId = i;
- mFragment = fragment;
- fileType = ft;
- }
-
- public void getCertificateFileDialog() {
- Intent startFC = new Intent(getContext(), FileSelect.class);
- startFC.putExtra(FileSelect.START_DATA, mData);
- startFC.putExtra(FileSelect.WINDOW_TITLE, mTitle);
- if (fileType == Utils.FileType.PKCS12)
- 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(c.getString(R.string.no_data));
- mDataDetails.setText("");
- } else {
- if (mData.startsWith(VpnProfile.DISPLAYNAME_TAG)) {
- mDataView.setText(c.getString(R.string.imported_from_file, VpnProfile.getDisplayName(mData)));
- } 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) {
- if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
- Intent startFilePicker = Utils.getFilePickerIntent(fileType);
- mFragment.startActivityForResult(startFilePicker, mTaskId);
- } else {
- getCertificateFileDialog();
- }
- }
- }
-
-
-
-
- public void setShowClear() {
- mShowClear = true;
- }
-
-}
diff --git a/src/de/blinkt/openvpn/views/RemoteCNPreference.java b/src/de/blinkt/openvpn/views/RemoteCNPreference.java
deleted file mode 100644
index 388f892b..00000000
--- a/src/de/blinkt/openvpn/views/RemoteCNPreference.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package de.blinkt.openvpn.views;
-
-import android.content.Context;
-import android.preference.DialogPreference;
-import android.util.AttributeSet;
-import android.util.Pair;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import de.blinkt.openvpn.R;
-import de.blinkt.openvpn.VpnProfile;
-
-public class RemoteCNPreference extends DialogPreference {
-
-
- private Spinner mSpinner;
- private EditText mEditText;
- private int mDNType;
- private String mDn;
- private TextView mRemoteTLSNote;
- //private ScrollView mScrollView;
-
- public RemoteCNPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setDialogLayoutResource(R.layout.tlsremote);
-
- }
-
- @Override
- protected void onBindDialogView(View view) {
-
- super.onBindDialogView(view);
-
- mEditText = (EditText) view.findViewById(R.id.tlsremotecn);
- mSpinner = (Spinner) view.findViewById(R.id.x509verifytype);
- mRemoteTLSNote = (TextView) view.findViewById(R.id.tlsremotenote);
- //mScrollView = (ScrollView) view.findViewById(R.id.tlsremotescroll);
- if(mDn!=null)
- mEditText.setText(mDn);
-
- populateSpinner();
-
- }
-
-
-
- public String getCNText() {
- return mDn;
- }
-
- public int getAuthtype() {
- return mDNType;
- }
-
- public void setDN(String dn) {
- mDn = dn;
- if(mEditText!=null)
- mEditText.setText(dn);
- }
-
- public void setAuthType(int x509authtype) {
- mDNType = x509authtype;
- if (mSpinner!=null)
- populateSpinner();
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- super.onDialogClosed(positiveResult);
-
- if (positiveResult) {
- String dn = mEditText.getText().toString();
- int authtype = getAuthTypeFromSpinner();
- if (callChangeListener(new Pair<Integer, String>(authtype, dn))) {
- mDn = dn;
- mDNType = authtype;
- }
- }
- }
-
- private void populateSpinner() {
- ArrayAdapter<String> authtypes = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item);
- authtypes.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-
- authtypes.add(getContext().getString(R.string.complete_dn));
- authtypes.add(getContext().getString(R.string.rdn));
- authtypes.add(getContext().getString(R.string.rdn_prefix));
- if ((mDNType == VpnProfile.X509_VERIFY_TLSREMOTE || mDNType == VpnProfile.X509_VERIFY_TLSREMOTE_COMPAT_NOREMAPPING)
- && !(mDn==null || "".equals(mDn))) {
- authtypes.add(getContext().getString(R.string.tls_remote_deprecated));
- mRemoteTLSNote.setVisibility(View.VISIBLE);
- } else {
- mRemoteTLSNote.setVisibility(View.GONE);
- }
- mSpinner.setAdapter(authtypes);
- mSpinner.setSelection(getSpinnerPositionFromAuthTYPE());
- }
-
- private int getSpinnerPositionFromAuthTYPE() {
- switch (mDNType) {
- case VpnProfile.X509_VERIFY_TLSREMOTE_DN:
- return 0;
- case VpnProfile.X509_VERIFY_TLSREMOTE_RDN:
- return 1;
- case VpnProfile.X509_VERIFY_TLSREMOTE_RDN_PREFIX:
- return 2;
- case VpnProfile.X509_VERIFY_TLSREMOTE_COMPAT_NOREMAPPING:
- case VpnProfile.X509_VERIFY_TLSREMOTE:
- if (mDn==null || "".equals(mDn))
- return 1;
- else
- return 3;
-
-
- default:
- return 0;
- }
- }
-
- private int getAuthTypeFromSpinner() {
- int pos = mSpinner.getSelectedItemPosition();
- switch (pos) {
- case 0:
- return VpnProfile.X509_VERIFY_TLSREMOTE_DN;
- case 1:
- return VpnProfile.X509_VERIFY_TLSREMOTE_RDN;
- case 2:
- return VpnProfile.X509_VERIFY_TLSREMOTE_RDN_PREFIX;
- case 3:
- // This is the tls-remote entry, only visible if mDntype is a
- // tls-remote type
- return mDNType;
- default:
- return VpnProfile.X509_VERIFY_TLSREMOTE;
- }
- }
-
-}
diff --git a/src/de/blinkt/openvpn/views/SeekBarTicks.java b/src/de/blinkt/openvpn/views/SeekBarTicks.java
deleted file mode 100644
index 88e8e164..00000000
--- a/src/de/blinkt/openvpn/views/SeekBarTicks.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package de.blinkt.openvpn.views;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-import android.view.ViewConfiguration;
-import android.widget.SeekBar;
-
-public class SeekBarTicks extends SeekBar {
- private Paint mTickPaint;
- private float mTickHeight;
-
- private float tickHeightRatio = 0.6f;
-
- public SeekBarTicks(Context context, AttributeSet attrs) {
- super (context, attrs);
-
- initTicks (context, attrs, android.R.attr.seekBarStyle);
- }
-
-
- public SeekBarTicks(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- initTicks (context, attrs, defStyle);
-
- /*mTickHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- tickHeightDP,
- ctx.getResources().getDisplayMetrics()); */
- }
-
- private void initTicks(Context context, AttributeSet attrs, int defStyle) {
- TypedArray a = context.obtainStyledAttributes(attrs,
- new int[] { android.R.attr.secondaryProgress }, defStyle, 0);
-
-
- int tickColor = a.getColor(0, android.R.color.black);
- mTickPaint = new Paint();
- mTickPaint.setColor( context.getResources().getColor(tickColor));
- a.recycle();
- }
-
-
- @Override
- protected synchronized void onDraw(Canvas canvas) {
- drawTicks(canvas);
- super.onDraw(canvas);
- }
-
- private void drawTicks(Canvas canvas) {
-
- final int available = getWidth() - getPaddingLeft() - getPaddingRight();
- final int availableHeight = getHeight() - getPaddingBottom() - getPaddingTop();
-
- int extrapadding = (int) ((availableHeight- (availableHeight * tickHeightRatio))/2);
-
- int tickSpacing = available / (getMax() );
-
- for (int i = 1; i < getMax(); i++) {
- final float x = getPaddingLeft() + i * tickSpacing;
-
- canvas.drawLine(x, getPaddingTop()+extrapadding, x, getHeight()-getPaddingBottom()-extrapadding, mTickPaint);
- }
- }
-}