Skip to content

Commit

Permalink
Make On/Off button pleasing to the eyes
Browse files Browse the repository at this point in the history
1. Use proper images

2. Make it actually reflect the state
  • Loading branch information
hawkinswnaf committed Jan 3, 2014
1 parent b591a27 commit a925a53
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<service
android:name=".MeshService"
android:icon="@drawable/comlogo_sm_on"
android:icon="@drawable/comlogo_sm"
android:label="Barnacle Wifi Tether" />

<receiver
Expand Down
Binary file removed res/drawable-hdpi/comlogo_sm_off.png
Binary file not shown.
Binary file removed res/drawable-hdpi/comlogo_sm_on.png
Binary file not shown.
Binary file added res/drawable-hdpi/commotion_power_off_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/commotion_power_on_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/drawable-ldpi/comlogo_sm_off.png
Binary file not shown.
Binary file removed res/drawable-ldpi/comlogo_sm_on.png
Binary file not shown.
Binary file added res/drawable-ldpi/commotion_power_off_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/commotion_power_on_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/drawable-mdpi/comlogo_sm_off.png
Binary file not shown.
Binary file removed res/drawable-mdpi/comlogo_sm_on.png
Binary file not shown.
Binary file added res/drawable-mdpi/commotion_power_off_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/commotion_power_on_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/drawable-xhdpi/comlogo_sm_off.png
Binary file not shown.
Binary file removed res/drawable-xhdpi/comlogo_sm_on.png
Binary file not shown.
Binary file added res/drawable-xhdpi/commotion_power_off_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/commotion_power_on_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion res/layout/control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/comlogo_sm_off"
android:src="@drawable/commotion_power_off_icon"
/>

</LinearLayout>
2 changes: 1 addition & 1 deletion src/net/commotionwireless/meshtether/MeshTetherApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void onCreate() {

notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
toast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
notification = new Notification(R.drawable.comlogo_sm_on, getString(R.string.notify_running), 0);
notification = new Notification(R.drawable.comlogo_sm, getString(R.string.notify_running), 0);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notificationClientAdded = new Notification(android.R.drawable.stat_sys_warning,
getString(R.string.notify_client), 0);
Expand Down
40 changes: 37 additions & 3 deletions src/net/commotionwireless/meshtether/StatusActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import net.commotionwireless.olsrd.OlsrdService;
import net.commotionwireless.profiles.Profile;
import net.commotionwireless.profiles.Profiles;
import net.commotionwireless.route.EWifiConfiguration;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
Expand All @@ -55,7 +57,7 @@ public class StatusActivity extends android.app.TabActivity implements OnItemSel
private MeshTetherApp app;

private TabHost tabs;
private ImageButton onoff;
private ImageButton mOnOffButton;
private Spinner chooseProfile;
private AlertDialog.Builder profileDialogBuilder;

Expand All @@ -75,6 +77,8 @@ public class StatusActivity extends android.app.TabActivity implements OnItemSel
private final static String INFO = "info";
private final static String ABOUT = "about";

private BroadcastReceiver mOlsrdStateReceiver;


static NumberFormat nf = NumberFormat.getInstance();
static {
Expand Down Expand Up @@ -141,6 +145,9 @@ public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminate(true);
setContentView(R.layout.main);


mOnOffButton = (ImageButton)findViewById(R.id.onoff);

profileDialogBuilder = new AlertDialog.Builder(this);
profileDialogBuilder.setTitle(R.string.choose_profile);
Expand All @@ -153,7 +160,7 @@ public void onCreate(Bundle savedInstanceState) {
.setIndicator(INFO, getResources().getDrawable(R.drawable.ic_tab_recent))
.setContent(new Intent(this, InfoActivity.class)));
tabs.addTab(tabs.newTabSpec(ABOUT)
.setIndicator(ABOUT, getResources().getDrawable(R.drawable.comlogo_sm_on))
.setIndicator(ABOUT, getResources().getDrawable(R.drawable.comlogo_sm))
.setContent(new Intent(this, AboutActivity.class)));
tabs.setOnTabChangedListener(new OnTabChangeListener() {
@Override
Expand Down Expand Up @@ -195,6 +202,8 @@ protected void onDestroy() {
protected void onPause() {
super.onPause();
paused = true;
unregisterReceiver(mOlsrdStateReceiver);
mOlsrdStateReceiver = null;
}
@Override
protected void onResume() {
Expand All @@ -214,6 +223,31 @@ protected void onResume() {
/*
app.cleanUpNotifications();
*/
IntentFilter olsrdIntentFilter = new IntentFilter("net.commotionwireless.meshtether.OLSRD_TRANSITION");
registerReceiver(mOlsrdStateReceiver = new BroadcastReceiver() {

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
OlsrdService.OlsrdState olsrdRunningState = OlsrdService.OlsrdState.RUNNING;
int currentState = intent.getIntExtra("state", OlsrdService.OlsrdState.STOPPED.ordinal());
if (currentState == olsrdRunningState.ordinal()) {
/*
* running!
*/
mOnOffButton.setImageResource(R.drawable.commotion_power_on_icon);
} else {
/*
* not running
*/
mOnOffButton.setImageResource(R.drawable.commotion_power_off_icon);
}
}

}, olsrdIntentFilter);
if (app.getOlsrdService() != null && app.getOlsrdService().isOlsrdRunning()) {
mOnOffButton.setImageResource(R.drawable.commotion_power_on_icon);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down
7 changes: 5 additions & 2 deletions src/net/commotionwireless/olsrd/OlsrdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void handleMessage(Message msg) {
}
};

private enum OlsrdState { STOPPED, RUNNING;
public enum OlsrdState { STOPPED, RUNNING;
int mTransitions[][] = {
/* STOPPED */ {/* CONNECTING */ TO_NOTHING, /* CONNECTED */ TO_RUNNING, /* DISCONNECTED */ TO_NOTHING, /* NEWPROFILE */ TO_NOTHING},
/* RUNNING */ {/* CONNECTING */ TO_NOTHING, /* CONNECTED */ TO_NOTHING, /* DISCONNECTED */ TO_STOPPED, /* NEWPROFILE */ TO_RESTART}
Expand Down Expand Up @@ -257,7 +257,7 @@ public String getFallbackInterfaceName() {
}

public void transition(int message) {

Intent transitionNotificationIntent = new Intent("net.commotionwireless.meshtether.OLSRD_TRANSITION");
if (!(message>=OLSRDSERVICE_MESSAGE_MIN && message<=OLSRDSERVICE_MESSAGE_MAX)) {
Log.e("OlsrdControl", "Transition message not appropriate");
return;
Expand All @@ -272,6 +272,9 @@ public void transition(int message) {
mState = mState.preTransition(message, this);
oldState.transition(message, this);
Log.i("OlsrdControl", "Transitioned from " + oldState + " to " + mState + " on message " + message);

transitionNotificationIntent.putExtra("state", mState.ordinal());
sendBroadcast(transitionNotificationIntent);
}
}

Expand Down

0 comments on commit a925a53

Please sign in to comment.