Added notification when execution is running.
[artf417724]
This commit is contained in:
parent
2941e5d3cc
commit
1cd7ca6578
3 changed files with 70 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
|
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
|
||||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
||||||
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
||||||
|
import com.ericsson.uecontrol.gui.fragments.ExecNotification;
|
||||||
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog;
|
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog;
|
||||||
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog.OnFileSelectionListener;
|
import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog.OnFileSelectionListener;
|
||||||
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
||||||
|
|
@ -244,6 +245,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
if(action_execute != null) {
|
if(action_execute != null) {
|
||||||
if (currentExecutor.isRunning()) {
|
if (currentExecutor.isRunning()) {
|
||||||
action_execute.setTitle(R.string.action_stop);
|
action_execute.setTitle(R.string.action_stop);
|
||||||
|
ExecNotification.create();
|
||||||
if(action_mark != null && csvLogger != null)
|
if(action_mark != null && csvLogger != null)
|
||||||
action_mark.setEnabled(true);
|
action_mark.setEnabled(true);
|
||||||
if(prefs.getBoolean("screen_on", false))
|
if(prefs.getBoolean("screen_on", false))
|
||||||
|
|
@ -251,6 +253,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action_execute.setTitle(R.string.action_run);
|
action_execute.setTitle(R.string.action_run);
|
||||||
|
ExecNotification.dismiss();
|
||||||
action_mark.setEnabled(false);
|
action_mark.setEnabled(false);
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
66
app/src/main/java/com/ericsson/uecontrol/gui/fragments/ExecNotification.java
Executable file
66
app/src/main/java/com/ericsson/uecontrol/gui/fragments/ExecNotification.java
Executable file
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.ericsson.uecontrol.gui.fragments;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
|
|
||||||
|
import com.ericsson.uecontrol.R;
|
||||||
|
import com.ericsson.uecontrol.core.util.ThroughputCalculator;
|
||||||
|
import com.ericsson.uecontrol.gui.MainActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ezivkoc on 2014-09-29.
|
||||||
|
*/
|
||||||
|
public class ExecNotification {
|
||||||
|
private static final int NOTIFICATION_ID = 1;
|
||||||
|
private static NotificationCompat.Builder mBuilder;
|
||||||
|
|
||||||
|
public static void create(){
|
||||||
|
mBuilder = createNotification();
|
||||||
|
setNotification(mBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void update(double downThroughput, double upThroughput){
|
||||||
|
if(mBuilder != null) {
|
||||||
|
mBuilder.setContentTitle("Exec Behaviour: " + MainActivity.getExecutor().getRunningBehaviour().getName());
|
||||||
|
mBuilder.setContentText(" Down: " + ThroughputCalculator.getBitThroughputString(downThroughput)
|
||||||
|
+ " Up: " + ThroughputCalculator.getBitThroughputString(upThroughput));
|
||||||
|
setNotification(mBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dismiss(){
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) MainActivity.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
mNotificationManager.cancel(NOTIFICATION_ID);
|
||||||
|
mBuilder = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static NotificationCompat.Builder createNotification(){
|
||||||
|
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(MainActivity.getContext())
|
||||||
|
.setSmallIcon(R.drawable.icon)
|
||||||
|
.setContentTitle("UeControl Executing")
|
||||||
|
.setContentText("Starting up...")
|
||||||
|
.setOngoing(true);
|
||||||
|
|
||||||
|
// Creates an explicit intent for an Activity in your app
|
||||||
|
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainActivity.getContext());
|
||||||
|
stackBuilder.addParentStack(MainActivity.class);
|
||||||
|
stackBuilder.addNextIntent(new Intent(MainActivity.getContext(), MainActivity.class));
|
||||||
|
PendingIntent resultPendingIntent =
|
||||||
|
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
mBuilder.setContentIntent(resultPendingIntent);
|
||||||
|
|
||||||
|
return mBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setNotification(NotificationCompat.Builder mBuilder){
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) MainActivity.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -94,6 +94,7 @@ public class StatusFragment extends Fragment {
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
MainActivity.logThroughput(downThroughput, upThroughput);
|
MainActivity.logThroughput(downThroughput, upThroughput);
|
||||||
|
ExecNotification.update(downThroughput, upThroughput);
|
||||||
startActivityTimer();
|
startActivityTimer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue