I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 42649e02 authored by str4d's avatar str4d
Browse files

Replaced logo with status images, combined start and stop buttons

parent c6aeb799
Branches
Tags
No related merge requests found
res/drawable/start_router_icon.png

1.89 KiB

res/drawable/stop_router_icon.png

1.9 KiB

<?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
<?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
......@@ -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>
......
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?!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment