diff --git a/res/drawable/start_router_icon.png b/res/drawable/start_router_icon.png deleted file mode 100644 index 0fbe32818406471c6358d778d02605a4fc8dce3a..0000000000000000000000000000000000000000 Binary files a/res/drawable/start_router_icon.png and /dev/null differ diff --git a/res/drawable/stop_router_icon.png b/res/drawable/stop_router_icon.png deleted file mode 100644 index 9253d673240423740ba66e0d9c62d6bb228ff7c1..0000000000000000000000000000000000000000 Binary files a/res/drawable/stop_router_icon.png and /dev/null differ diff --git a/res/layout-land/fragment_main.xml b/res/layout-land/fragment_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..882c0f6bdc3ccf3cbc6417dff532c89786413aa2 --- /dev/null +++ b/res/layout-land/fragment_main.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:baselineAligned="false" > + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" > + + <ImageView + android:id="@+id/main_lights" + android:src="@drawable/routerled_r" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:scaleType="centerInside" + android:contentDescription="@string/desc_i2p_logo" /> + + <ToggleButton + android:id="@+id/router_onoff_button" + android:layout_width="match_parent" + android:layout_height="68dp" + android:textOff="@string/button_router_off" + android:textOn="@string/button_router_on" /> + </LinearLayout> + + <ScrollView + android:layout_width="0dp" + android:layout_height="fill_parent" + android:layout_weight="2" + android:fillViewport="true" + android:padding="10dp" + android:scrollbarStyle="outsideInset" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > + + <TextView + android:id="@+id/textView4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/label_statistics" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <TextView + android:id="@+id/main_status_text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + </ScrollView> +</LinearLayout> \ No newline at end of file diff --git a/res/layout/fragment_main.xml b/res/layout/fragment_main.xml index 695f74454c62ab3ea2f724c03c27e480b2f43506..92df3c01d5663591f17f8252cde6cebfa0abb6f9 100644 --- a/res/layout/fragment_main.xml +++ b/res/layout/fragment_main.xml @@ -1,63 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - > + android:orientation="vertical" > <ImageView - android:contentDescription="@string/desc_i2p_logo" + android:id="@+id/main_lights" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:src="@drawable/i2plogo" /> + android:contentDescription="@string/desc_i2p_logo" + android:scaleType="centerInside" + android:src="@drawable/routerled_r" /> - <Button - android:id="@+id/router_start_button" + <ToggleButton + android:id="@+id/router_onoff_button" android:layout_width="match_parent" android:layout_height="68dp" - android:text="@string/action_router_start" - android:drawableLeft="@drawable/start_router_icon" /> + android:textOff="@string/button_router_off" + android:textOn="@string/button_router_on" /> - <Button - android:id="@+id/router_quit_button" - android:layout_width="match_parent" - android:layout_height="68dp" - android:text="@string/action_router_stop" - android:drawableLeft="@drawable/stop_router_icon" /> -<!-- -<Button - android:id="@+id/router_stop_button" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="OLD STOP" - android:drawableLeft="@drawable/stop_router_icon" /> ---> - -<ScrollView - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:fillViewport="true" - android:padding="10dp" - android:scrollbarStyle="outsideInset" - > -<LinearLayout - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - > + <ScrollView + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:fillViewport="true" + android:padding="10dp" + android:scrollbarStyle="outsideInset" > - <TextView - android:id="@+id/textView4" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/label_statistics" - android:textAppearance="?android:attr/textAppearanceLarge" /> + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > - <TextView - android:id="@+id/main_status_text" - android:layout_width="fill_parent" - android:layout_height="wrap_content" /> + <TextView + android:id="@+id/textView4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/label_statistics" + android:textAppearance="?android:attr/textAppearanceLarge" /> -</LinearLayout> -</ScrollView> -</LinearLayout> + <TextView + android:id="@+id/main_status_text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + </ScrollView> +</LinearLayout> \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 061e3d29653a11996792c2d3c140ac02746a6212..18653b227347a14d35177a050d3cc7a328a6da3a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -29,6 +29,9 @@ <string name="label_browse">Browse</string> <string name="label_graphs">Graphs</string> + <string name="button_router_off">Press to start I2P</string> + <string name="button_router_on">I2P is running (press to stop)</string> + <string name="drawer_open">Open nav</string> <string name="drawer_close">Close nav</string> <string name="action_search">Search</string> diff --git a/src/net/i2p/android/router/fragment/MainFragment.java b/src/net/i2p/android/router/fragment/MainFragment.java index 8dd16a920ecf6e42b2970c3c8482eeb3d8c3512f..374776390229c906bde94c76f910487f15e569cb 100644 --- a/src/net/i2p/android/router/fragment/MainFragment.java +++ b/src/net/i2p/android/router/fragment/MainFragment.java @@ -1,12 +1,14 @@ package net.i2p.android.router.fragment; import android.app.Activity; +import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; +import android.widget.ToggleButton; +import android.widget.ImageView; import android.widget.TextView; import java.text.DecimalFormat; import net.i2p.android.router.R; @@ -78,32 +80,26 @@ public class MainFragment extends I2PFragmentBase { Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_main, container, false); - Button b; + final ImageView lightImage = (ImageView) v.findViewById(R.id.main_lights); + lightImage.setImageResource(R.drawable.routerled_r); - /* - * hidden, unused b = (Button) v.findViewById(R.id.router_stop_button); - * b.setOnClickListener(new View.OnClickListener() { public void - * onClick(View view) { RouterService svc = _routerService; if (svc != - * null && _isBound) { setPref(PREF_AUTO_START, false); - * svc.manualStop(); updateOneShot(); } } }); - */ - - b = (Button) v.findViewById(R.id.router_start_button); + ToggleButton b = (ToggleButton) v.findViewById(R.id.router_onoff_button); b.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { - _startPressed = true; - mCallback.onStartRouterClicked(); - updateOneShot(); - } - }); - - b = (Button) v.findViewById(R.id.router_quit_button); - b.setOnClickListener(new View.OnClickListener() { - - public void onClick(View view) { - if(mCallback.onStopRouterClicked()) { + boolean on = ((ToggleButton) view).isChecked(); + if (on) { + _startPressed = true; + lightImage.setImageResource(R.drawable.routerled_ry); + ((AnimationDrawable) lightImage.getDrawable()).start(); + mCallback.onStartRouterClicked(); updateOneShot(); + } else { + if(mCallback.onStopRouterClicked()) { + lightImage.setImageResource(R.drawable.routerled_ry); + ((AnimationDrawable) lightImage.getDrawable()).start(); + updateOneShot(); + } } } }); @@ -152,7 +148,6 @@ public class MainFragment extends I2PFragmentBase { private class OneShotUpdate implements Runnable { public void run() { - updateVisibility(); updateStatus(); } } @@ -163,7 +158,6 @@ public class MainFragment extends I2PFragmentBase { private final int delay = 1000; private final int toloop = delay / 500; public void run() { - updateVisibility(); if(counter++ % toloop == 0) { updateStatus(); } @@ -172,20 +166,6 @@ public class MainFragment extends I2PFragmentBase { } } - private void updateVisibility() { - boolean showStart = mCallback.shouldShowStart(); - Button start = (Button) getActivity().findViewById(R.id.router_start_button); - start.setVisibility(showStart ? View.VISIBLE : View.INVISIBLE); - - boolean showStop = mCallback.shouldShowStop(); - // Old stop but leave in memory. Always hide for now. - // Button stop = (Button) findViewById(R.id.router_stop_button); - // stop.setVisibility( /* showStop ? View.VISIBLE : */ View.INVISIBLE); - - Button quit = (Button) getActivity().findViewById(R.id.router_quit_button); - quit.setVisibility(showStop ? View.VISIBLE : View.INVISIBLE); - } - public boolean onBackPressed() { RouterContext ctx = getRouterContext(); // RouterService svc = _routerService; Which is better to use?!