diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-11-07 22:40:51 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-11-07 22:40:51 +0100 |
commit | 8ced9f378613425efb9949196e967dbe2f03a63a (patch) | |
tree | 37eb4395b3d04463f63916b1cdb7498bf6ebb828 | |
parent | e66b35409cff37433af11693673145406029356f (diff) |
Fine tune log window.
--HG--
rename : res/layout-w720dp/log_fragment.xml => res/layout-sw600dp/log_fragment.xml
rename : res/values-w600dp/dimens.xml => res/values-sw600dp/dimens.xml
-rw-r--r-- | res/layout-sw600dp-port/log_fragment.xml | 42 | ||||
-rw-r--r-- | res/layout-sw600dp/log_fragment.xml | 37 | ||||
-rw-r--r-- | res/layout-w720dp/log_fragment.xml | 73 | ||||
-rw-r--r-- | res/layout/log_fragment.xml | 7 | ||||
-rw-r--r-- | res/layout/log_silders.xml | 2 | ||||
-rw-r--r-- | res/layout/vpnstatus.xml | 46 | ||||
-rw-r--r-- | res/values-sw600dp/dimens.xml (renamed from res/values-w600dp/dimens.xml) | 0 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/MainActivity.java | 12 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/fragments/LogFragment.java | 11 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/fragments/SeekbarTicks.java | 10 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/fragments/VPNProfileList.java | 16 |
12 files changed, 168 insertions, 90 deletions
diff --git a/res/layout-sw600dp-port/log_fragment.xml b/res/layout-sw600dp-port/log_fragment.xml new file mode 100644 index 00000000..ddf0506b --- /dev/null +++ b/res/layout-sw600dp-port/log_fragment.xml @@ -0,0 +1,42 @@ +<?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:layout_height="wrap_content" + android:layout_width="match_parent"> + + <include layout="@layout/log_silders"/> + + <Space + android:layout_weight="5" + android:layout_height="wrap_content" + android:layout_width="wrap_content"/> + <LinearLayout + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:orientation="vertical"> + <include layout="@layout/vpnstatus"/> + </LinearLayout> + <Space + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_weight="1"/> + </LinearLayout> + + <Space + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:minHeight="5dp"/> + + <ListView + android:id="@android:id/list" + android:transcriptMode="normal" + android:layout_width="fill_parent" + android:layout_height="fill_parent"/> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout-sw600dp/log_fragment.xml b/res/layout-sw600dp/log_fragment.xml new file mode 100644 index 00000000..d8e8562f --- /dev/null +++ b/res/layout-sw600dp/log_fragment.xml @@ -0,0 +1,37 @@ +<?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"/> + + <include layout="@layout/vpnstatus"/> + </LinearLayout> + + <Space + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:minWidth="5dp"/> + + <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-w720dp/log_fragment.xml b/res/layout-w720dp/log_fragment.xml deleted file mode 100644 index 07502e15..00000000 --- a/res/layout-w720dp/log_fragment.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?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_fragment.xml b/res/layout/log_fragment.xml index d1e467b1..bcc3f9af 100644 --- a/res/layout/log_fragment.xml +++ b/res/layout/log_fragment.xml @@ -5,7 +5,12 @@ android:layout_height="match_parent" android:orientation="vertical"> - <include layout="@layout/log_silders"/> + <LinearLayout + android:layout_height="wrap_content" + android:layout_width="match_parent"> + + <include layout="@layout/log_silders"/> + </LinearLayout> <TextView android:text="@string/speed_waiting" diff --git a/res/layout/log_silders.xml b/res/layout/log_silders.xml index 9aadd4d1..5df97490 100644 --- a/res/layout/log_silders.xml +++ b/res/layout/log_silders.xml @@ -8,7 +8,7 @@ android:id="@+id/logOptionsLayout" android:visibility="gone" tools:visibility="visible" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView diff --git a/res/layout/vpnstatus.xml b/res/layout/vpnstatus.xml new file mode 100644 index 00000000..0c765fe6 --- /dev/null +++ b/res/layout/vpnstatus.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<merge xmlns:tools="http://schemas.android.com/tools" + xmlns:android="http://schemas.android.com/apk/res/android"> + + <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"/> + + +</merge>
\ No newline at end of file diff --git a/res/values-w600dp/dimens.xml b/res/values-sw600dp/dimens.xml index b83bb856..b83bb856 100644 --- a/res/values-w600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml diff --git a/src/de/blinkt/openvpn/MainActivity.java b/src/de/blinkt/openvpn/MainActivity.java index 75cfa689..e1d417ca 100644 --- a/src/de/blinkt/openvpn/MainActivity.java +++ b/src/de/blinkt/openvpn/MainActivity.java @@ -20,21 +20,24 @@ public class MainActivity extends Activity { Tab generalTab = bar.newTab().setText(R.string.generalsettings); Tab faqtab = bar.newTab().setText(R.string.faq); Tab abouttab = bar.newTab().setText(R.string.about); - Tab logtab = bar.newTab().setText("Log"); vpnListTab.setTabListener(new TabListener<VPNProfileList>("profiles", VPNProfileList.class)); generalTab.setTabListener(new TabListener<GeneralSettings>("settings", GeneralSettings.class)); faqtab.setTabListener(new TabListener<FaqFragment>("faq", FaqFragment.class)); abouttab.setTabListener(new TabListener<AboutFragment>("about", AboutFragment.class)); - logtab.setTabListener(new TabListener<LogFragment>("log",LogFragment.class)); bar.addTab(vpnListTab); - bar.addTab(logtab); bar.addTab(generalTab); bar.addTab(faqtab); bar.addTab(abouttab); - if(SendDumpFragment.getLastestDump(this)!=null) { + if (false) { + Tab logtab = bar.newTab().setText("Log"); + logtab.setTabListener(new TabListener<LogFragment>("log", LogFragment.class)); + bar.addTab(logtab); + } + + if(SendDumpFragment.getLastestDump(this)!=null) { Tab sendDump = bar.newTab().setText(R.string.crashdump); sendDump.setTabListener(new TabListener<SendDumpFragment>("crashdump",SendDumpFragment.class)); bar.addTab(sendDump); @@ -48,7 +51,6 @@ public class MainActivity extends Activity { private String mTag; private Class<T> mClass; - public TabListener(String tag, Class<T> clz) { mTag = tag; mClass = clz; diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index ce2aab37..7b5faae3 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -642,6 +642,8 @@ public class VpnProfile implements Serializable { exp=e; } catch (NoCertReturnedException e) { exp =e; + } catch (IllegalArgumentException e) { + exp =e; } catch (AssertionError e) { if (tries ==0) return null; diff --git a/src/de/blinkt/openvpn/fragments/LogFragment.java b/src/de/blinkt/openvpn/fragments/LogFragment.java index 9508f158..750b5703 100644 --- a/src/de/blinkt/openvpn/fragments/LogFragment.java +++ b/src/de/blinkt/openvpn/fragments/LogFragment.java @@ -60,6 +60,7 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar. } }; + private SeekBar mLogLevelSlider; private LinearLayout mOptionsLayout; private RadioGroup mTimeRadioGroup; @@ -74,12 +75,10 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar. @Override public void onStartTrackingTouch(SeekBar seekBar) { - } @Override public void onStopTrackingTouch(SeekBar seekBar) { - } @Override @@ -225,10 +224,10 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar. timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.getDefault()); else timeformat = DateFormat.getTimeFormat(getActivity()); - time = timeformat.format(d); + time = timeformat.format(d) + " "; } - msg = time + " " + le.getVerbosityLevel() + " " + msg; + msg = time + msg; int spanStart = time.length(); @@ -518,7 +517,9 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar. super.onStop(); VpnStatus.removeStateListener(this); VpnStatus.removeByteCountListener(this); - getActivity().unbindService(mConnection); + + if(mService!=null) + getActivity().unbindService(mConnection); getActivity().getPreferences(0).edit().putInt(LOGTIMEFORMAT, ladapter.mTimeFormat) .putInt(VERBOSITYLEVEL, ladapter.mLogLevel).apply(); diff --git a/src/de/blinkt/openvpn/fragments/SeekbarTicks.java b/src/de/blinkt/openvpn/fragments/SeekbarTicks.java index 1e289529..ec68e7e4 100644 --- a/src/de/blinkt/openvpn/fragments/SeekbarTicks.java +++ b/src/de/blinkt/openvpn/fragments/SeekbarTicks.java @@ -14,6 +14,7 @@ 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); @@ -37,7 +38,7 @@ public class SeekBarTicks extends SeekBar { new int[] { android.R.attr.secondaryProgress }, defStyle, 0); - int tickColor = a.getColor(0, android.R.color.white); + int tickColor = a.getColor(0, android.R.color.black); mTickPaint = new Paint(); mTickPaint.setColor( context.getResources().getColor(tickColor)); a.recycle(); @@ -53,11 +54,16 @@ public class SeekBarTicks extends SeekBar { 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(), x, getHeight()-getPaddingBottom(), mTickPaint); + + canvas.drawLine(x, getPaddingTop()+extrapadding, x, getHeight()-getPaddingBottom()-extrapadding, mTickPaint); } } } diff --git a/src/de/blinkt/openvpn/fragments/VPNProfileList.java b/src/de/blinkt/openvpn/fragments/VPNProfileList.java index 2b03048f..447ed1e0 100644 --- a/src/de/blinkt/openvpn/fragments/VPNProfileList.java +++ b/src/de/blinkt/openvpn/fragments/VPNProfileList.java @@ -33,10 +33,12 @@ public class VPNProfileList extends ListFragment { private static final int START_VPN_CONFIG = 92; private static final int SELECT_PROFILE = 43; private static final int IMPORT_PROFILE = 231; + private static final int FILE_PICKER_RESULT = 392; private static final int MENU_IMPORT_PROFILE = Menu.FIRST +1; - class VPNArrayAdapter extends ArrayAdapter<VpnProfile> { + + class VPNArrayAdapter extends ArrayAdapter<VpnProfile> { public VPNArrayAdapter(Context context, int resource, int textViewResourceId) { @@ -199,14 +201,22 @@ public class VPNProfileList extends ListFragment { onAddProfileClicked(); return true; } else if (itemId == MENU_IMPORT_PROFILE) { - startImportConfig(); + //startImportConfig(); + startFilePicker(); return true; } else { return super.onOptionsItemSelected(item); } } - private void startImportConfig() { + private void startFilePicker() { + Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("application/x-openvpn-profile"); + startActivityForResult(i,FILE_PICKER_RESULT); + } + + private void startImportConfig() { Intent intent = new Intent(getActivity(),FileSelect.class); intent.putExtra(FileSelect.NO_INLINE_SELECTION, true); intent.putExtra(FileSelect.WINDOW_TITLE, R.string.import_configuration_file); |