summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-10-13 17:07:30 +0200
committerArne Schwabe <arne@rfc2549.org>2013-10-13 17:07:30 +0200
commitd2dc6fa6fc12ca876bb3dcf099ec6694dc7ef061 (patch)
treefc253400a74c2ce9c74f710d85bd1deeb5abdf7e
parent7997868109c0831f2c6d97f342a7e6c6226bf54d (diff)
Add Seekbar with ticks, make a better layout for large screens of the log screen
--HG-- rename : res/layout/logwindow.xml => res/layout-w720dp/logwindow.xml
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/layout-w720dp/logwindow.xml73
-rw-r--r--res/layout/log_silders.xml61
-rw-r--r--res/layout/logwindow.xml56
-rw-r--r--res/values-w600dp/dimens.xml5
-rw-r--r--res/values/dimens.xml7
-rw-r--r--res/values/styles.xml13
-rw-r--r--src/de/blinkt/openvpn/LogWindow.java51
-rw-r--r--src/de/blinkt/openvpn/fragments/SeekbarTicks.java63
-rw-r--r--vpndialogxposed/vpndialogxposed.iml21
10 files changed, 268 insertions, 83 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1472f001..f1d0051e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -27,6 +27,7 @@
<application
android:allowBackup="true"
+ android:theme="@android:style/Theme.DeviceDefault.Light"
android:icon="@drawable/icon"
android:label="@string/app"
android:supportsRtl="true" >
diff --git a/res/layout-w720dp/logwindow.xml b/res/layout-w720dp/logwindow.xml
new file mode 100644
index 00000000..07502e15
--- /dev/null
+++ b/res/layout-w720dp/logwindow.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context=".LogWindow">
+
+ <LinearLayout
+ android:padding="20dp"
+ android:layout_width="wrap_content"
+ android:orientation="horizontal"
+ android:layout_height="match_parent">
+ <LinearLayout
+ android:minWidth="300dp"
+
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+ <include layout="@layout/log_silders"/>
+
+ <Space
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+
+
+ <TextView
+ android:text="Upload"
+ style="@style/logWindowStatusTitle"/>
+
+ <TextView
+ style="@style/logWindowStatusText"
+ android:id="@+id/speedUp"
+ tools:text="4 Mbit/s 6.7 GB"/>
+
+ <TextView
+ android:text="Download"
+ style="@style/logWindowStatusTitle"/>
+
+ <TextView
+ style="@style/logWindowStatusText"
+ android:id="@+id/speedDown"
+ tools:text="2 Mbit/s 4.7 GB"/>
+
+
+ <Space
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+
+ <TextView
+ android:text="Vpn Status"
+ style="@style/logWindowStatusTitle"/>
+
+ <TextView
+ android:id="@+id/speedStatus"
+ tools:text="Connected"
+ style="@style/logWindowStatusText"/>/
+
+
+ </LinearLayout>
+
+
+ <ListView
+ android:id="@android:id/list"
+ android:transcriptMode="normal"
+ android:layout_width="fill_parent"
+ android:layout_height="match_parent"/>
+ </LinearLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/log_silders.xml b/res/layout/log_silders.xml
new file mode 100644
index 00000000..9aadd4d1
--- /dev/null
+++ b/res/layout/log_silders.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+
+<LinearLayout
+ xmlns:tools="http://schemas.android.com/tools"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:id="@+id/logOptionsLayout"
+ android:visibility="gone"
+ tools:visibility="visible"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/log_verbosity_level"/>
+
+
+ <de.blinkt.openvpn.fragments.SeekBarTicks
+ android:id="@+id/LogLevelSlider"
+ android:layout_width="300dp"
+ android:layout_height="wrap_content"
+ tools:max="5"
+ android:indeterminate="false"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Timestamps"/>
+
+ <RadioGroup
+ android:id="@+id/timeFormatRadioGroup"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="None"
+ android:id="@+id/radioNone"
+ />
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Short"
+ android:id="@+id/radioShort"
+ />
+
+ <RadioButton
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="ISO"
+ android:id="@+id/radioISO"
+ />
+
+
+ </RadioGroup>
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/logwindow.xml b/res/layout/logwindow.xml
index d7281346..d1e467b1 100644
--- a/res/layout/logwindow.xml
+++ b/res/layout/logwindow.xml
@@ -1,63 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
- <LinearLayout
- android:orientation="vertical"
- android:id="@+id/logOptionsLayout"
- android:visibility="gone"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/log_verbosity_level"/>
-
- <SeekBar
- android:id="@+id/LogLevelSlider"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:max="5"
- android:indeterminate="false"/>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="Timestamps"/>
-
- <RadioGroup
- android:id="@+id/timeFormatRadioGroup"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="None"
- android:id="@+id/radioNone"
- />
-
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Short"
- android:id="@+id/radioShort"
- />
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="ISO"
- android:id="@+id/radioISO"
- />
-
-
- </RadioGroup>
- </LinearLayout>
+ <include layout="@layout/log_silders"/>
<TextView
android:text="@string/speed_waiting"
diff --git a/res/values-w600dp/dimens.xml b/res/values-w600dp/dimens.xml
new file mode 100644
index 00000000..b83bb856
--- /dev/null
+++ b/res/values-w600dp/dimens.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <bool name="logSildersAlwaysVisible">true</bool>
+
+</resources> \ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 00000000..4f325078
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="paddingItemsSidebarLog">20dp</dimen>
+ <dimen name="stdpadding">8dp</dimen>
+ <bool name="logSildersAlwaysVisible">false</bool>
+
+</resources> \ No newline at end of file
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6614719c..95e709b3 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -48,6 +48,17 @@
<style name="Theme.CreateShortCut" parent="android:Theme.Holo.DialogWhenLarge" />
- <dimen name="stdpadding">8dp</dimen>
+ <style name="logWindowStatusText">
+ <item name="android:paddingLeft">@dimen/paddingItemsSidebarLog</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+ </style>
+
+ <style name="logWindowStatusTitle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ </style>
+
</resources> \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java
index 11becf9c..1c38705c 100644
--- a/src/de/blinkt/openvpn/LogWindow.java
+++ b/src/de/blinkt/openvpn/LogWindow.java
@@ -23,6 +23,7 @@ import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.*;
import android.widget.AdapterView.OnItemLongClickListener;
+import de.blinkt.openvpn.core.OpenVPNManagement;
import de.blinkt.openvpn.core.VpnStatus;
import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus;
import de.blinkt.openvpn.core.VpnStatus.LogItem;
@@ -38,7 +39,9 @@ import java.util.Date;
import java.util.Locale;
import java.util.Vector;
-public class LogWindow extends ListActivity implements StateListener, SeekBar.OnSeekBarChangeListener, RadioGroup.OnCheckedChangeListener {
+import static de.blinkt.openvpn.core.OpenVpnService.humanReadableByteCount;
+
+public class LogWindow extends ListActivity implements StateListener, SeekBar.OnSeekBarChangeListener, RadioGroup.OnCheckedChangeListener, VpnStatus.ByteCountListener {
private static final String LOGTIMEFORMAT = "logtimeformat";
private static final int START_VPN_CONFIG = 0;
private static final String VERBOSITYLEVEL = "verbositylevel";
@@ -63,11 +66,13 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
private SeekBar mLogLevelSlider;
private LinearLayout mOptionsLayout;
private RadioGroup mTimeRadioGroup;
+ private TextView mUpStatus;
+ private TextView mDownStatus;
+ private TextView mConnectStatus;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
ladapter.setLogLevel(progress+1);
- Toast.makeText(this,"Loglevel set to " + ladapter.mLogLevel,Toast.LENGTH_SHORT).show();
}
@Override
@@ -96,6 +101,24 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
}
}
+ @Override
+ public void updateByteCount(long in, long out, long diffin, long diffout) {
+ //%2$s/s %1$s - ↑%4$s/s %3$s
+ final String down = String.format("%s/s %s", humanReadableByteCount(in, false), humanReadableByteCount(diffin / OpenVPNManagement.mBytecountInterval, true));
+ final String up = String.format("%s/s %s", humanReadableByteCount(out, false), humanReadableByteCount(diffout / OpenVPNManagement.mBytecountInterval, true));
+
+ if(mUpStatus!=null && mDownStatus!=null) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mUpStatus.setText(up);
+ mDownStatus.setText(down);
+ }
+ });
+ }
+
+ }
+
class LogWindowListAdapter implements ListAdapter, LogListener, Callback {
@@ -179,7 +202,7 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
@Override
public long getItemId(int position) {
- return currentLevelEntries.get(position).hashCode();
+ return ((Object)currentLevelEntries.get(position)).hashCode();
}
@Override
@@ -457,6 +480,9 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.logmenu, menu);
+ if (getResources().getBoolean(R.bool.logSildersAlwaysVisible))
+ menu.removeItem(R.id.toggle_time);
+
return true;
}
@@ -465,6 +491,7 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
protected void onResume() {
super.onResume();
VpnStatus.addStateListener(this);
+ VpnStatus.addByteCountListener(this);
Intent intent = new Intent(this, OpenVpnService.class);
intent.setAction(OpenVpnService.START_SERVICE);
@@ -520,6 +547,7 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
protected void onStop() {
super.onStop();
VpnStatus.removeStateListener(this);
+ VpnStatus.removeByteCountListener(this);
unbindService(mConnection);
getPreferences(0).edit().putInt(LOGTIMEFORMAT, ladapter.mTimeFormat)
.putInt(VERBOSITYLEVEL, ladapter.mLogLevel).apply();
@@ -578,22 +606,31 @@ public class LogWindow extends ListActivity implements StateListener, SeekBar.On
mLogLevelSlider.setOnSeekBarChangeListener(this);
+ if(getResources().getBoolean(R.bool.logSildersAlwaysVisible))
+ mOptionsLayout.setVisibility(View.VISIBLE);
+ mUpStatus = (TextView) findViewById(R.id.speedUp);
+ mDownStatus = (TextView) findViewById(R.id.speedDown);
+ mConnectStatus = (TextView) findViewById(R.id.speedStatus);
}
@Override
- public void updateState(final String status,final String logmessage, final int resid, final ConnectionStatus level) {
+ public void updateState(final String status,final String logMessage, final int resId, final ConnectionStatus level) {
runOnUiThread(new Runnable() {
@Override
public void run() {
- String prefix=getString(resid) + ":";
+ String prefix=getString(resId) + ":";
if (status.equals("BYTECOUNT") || status.equals("NOPROCESS") )
prefix="";
- if (resid==R.string.unknown_state)
+ if (resId==R.string.unknown_state)
prefix+=status;
- mSpeedView.setText(prefix + logmessage);
+ if(mSpeedView!=null)
+ mSpeedView.setText(prefix + logMessage);
+
+ if(mConnectStatus!=null)
+ mConnectStatus.setText(getString(resId));
}
});
diff --git a/src/de/blinkt/openvpn/fragments/SeekbarTicks.java b/src/de/blinkt/openvpn/fragments/SeekbarTicks.java
new file mode 100644
index 00000000..1e289529
--- /dev/null
+++ b/src/de/blinkt/openvpn/fragments/SeekbarTicks.java
@@ -0,0 +1,63 @@
+package de.blinkt.openvpn.fragments;
+
+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;
+
+
+ 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.white);
+ 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();
+ int tickSpacing = available / (getMax() );
+
+ for (int i = 1; i < getMax(); i++) {
+ final float x = getPaddingLeft() + i * tickSpacing;
+ canvas.drawLine(x, getPaddingTop(), x, getHeight()-getPaddingBottom(), mTickPaint);
+ }
+ }
+}
diff --git a/vpndialogxposed/vpndialogxposed.iml b/vpndialogxposed/vpndialogxposed.iml
index 11def943..7b46333d 100644
--- a/vpndialogxposed/vpndialogxposed.iml
+++ b/vpndialogxposed/vpndialogxposed.iml
@@ -1,26 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="android" name="Android">
- <configuration>
- <option name="SELECTED_BUILD_VARIANT" value="Debug" />
- <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
- <option name="COMPILE_JAVA_TASK_NAME" value="compileDebug" />
- <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleTest" />
- <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
- <option name="ALLOW_USER_CONFIGURATION" value="false" />
- <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
- <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
- <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
- <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
- </configuration>
- </facet>
- <facet type="android-gradle" name="Android-Gradle">
- <configuration>
- <option name="GRADLE_PROJECT_PATH" value=":vpndialogxposed" />
- </configuration>
- </facet>
- </component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/debug" />
<exclude-output />