Replaced logo with status images, combined start and stop buttons

This commit is contained in:
str4d
2013-12-06 02:20:32 +00:00
parent c6aeb79944
commit 42649e02ea
6 changed files with 111 additions and 88 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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>

View File

@ -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:id="@+id/main_lights"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/desc_i2p_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/i2plogo" />
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"
>
<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"
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_height="fill_parent"
android:fillViewport="true"
android:padding="10dp"
android:scrollbarStyle="outsideInset" >
</LinearLayout>
</ScrollView>
</LinearLayout>
<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>

View File

@ -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>

View File

@ -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?!