Added double back button press for exit
This commit is contained in:
parent
ff7138bf9d
commit
e5ca4aea34
3 changed files with 26 additions and 14 deletions
|
|
@ -1,18 +1,18 @@
|
|||
package com.ericsson.uecontrol.gui;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ericsson.uecontrol.R;
|
||||
import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourFtp;
|
||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
|
||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
||||
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
||||
|
|
@ -28,6 +28,7 @@ public class MainActivity extends FragmentActivity {
|
|||
*/
|
||||
private NavigationDrawerFragment navigationDrawerFragment;
|
||||
private StatusFragment statusFragment;
|
||||
private boolean backButtonPressed = false;
|
||||
|
||||
private static UeControlExecutor currentExecutor;
|
||||
private static CSVWriter logger;
|
||||
|
|
@ -86,6 +87,7 @@ public class MainActivity extends FragmentActivity {
|
|||
if(currentExecutor.isRunning()){
|
||||
currentExecutor.terminate();
|
||||
item.setTitle(R.string.action_run);
|
||||
logger = null;
|
||||
}
|
||||
else {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
|
@ -120,4 +122,22 @@ public class MainActivity extends FragmentActivity {
|
|||
|
||||
logger.write(currentExecutor.getRunningBehaviour().getName(), downThroughput, upThroughput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (backButtonPressed) {
|
||||
super.onBackPressed();
|
||||
return;
|
||||
}
|
||||
|
||||
this.backButtonPressed = true;
|
||||
Toast.makeText(this, "Press BACK again to Exit", Toast.LENGTH_SHORT).show();
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
backButtonPressed = false;
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,16 +61,6 @@ public class CSVWriter {
|
|||
}
|
||||
|
||||
|
||||
public void write(String behaviour){
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(getTime()).append(DELIMITER);
|
||||
line.append(behaviour).append(DELIMITER);
|
||||
line.append(DELIMITER);
|
||||
line.append(DELIMITER);
|
||||
line.append(getRat()).append(DELIMITER);
|
||||
writeLine(line.toString());
|
||||
}
|
||||
|
||||
public void write(String behaviour, double down, double up){
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(getTime()).append(DELIMITER);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@
|
|||
android:id="@+id/down_speed"
|
||||
android:textColor="#ffffffff"
|
||||
android:typeface="sans"
|
||||
android:layout_weight="0" />
|
||||
android:layout_weight="0"
|
||||
android:layout_marginLeft="3dp" />
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -51,7 +52,8 @@
|
|||
android:id="@+id/up_speed"
|
||||
android:textColor="#ffffffff"
|
||||
android:typeface="sans"
|
||||
android:layout_weight="0.45" />
|
||||
android:layout_weight="0.45"
|
||||
android:layout_marginLeft="3dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue