Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
131c6417
Commit
131c6417
authored
11 years ago
by
Maxime Graulich
Browse files
Options
Downloads
Patches
Plain Diff
Android: add notification when compute is finished and application is in background
parent
3814a672
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
+35
-1
35 additions, 1 deletion
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
with
35 additions
and
1 deletion
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
+
35
−
1
View file @
131c6417
...
@@ -6,6 +6,10 @@ import android.app.ActionBar;
...
@@ -6,6 +6,10 @@ import android.app.ActionBar;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.app.Notification
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.graphics.Color
;
...
@@ -23,7 +27,7 @@ import android.view.WindowManager;
...
@@ -23,7 +27,7 @@ import android.view.WindowManager;
public
class
MainActivity
extends
Activity
{
public
class
MainActivity
extends
Activity
{
private
Gmsh
_gmsh
;
private
Gmsh
_gmsh
;
private
boolean
_compute
,
_twoPane
;
private
boolean
_compute
,
_twoPane
,
_notify
;
private
MenuItem
_runStopMenuItem
,
_switchFragmentMenuItem
;
private
MenuItem
_runStopMenuItem
,
_switchFragmentMenuItem
;
private
ModelFragment
_modelFragment
;
private
ModelFragment
_modelFragment
;
private
OptionsFragment
_optionsFragment
;
private
OptionsFragment
_optionsFragment
;
...
@@ -40,6 +44,7 @@ public class MainActivity extends Activity{
...
@@ -40,6 +44,7 @@ public class MainActivity extends Activity{
getWindow
().
requestFeature
(
Window
.
FEATURE_ACTION_BAR_OVERLAY
);
getWindow
().
requestFeature
(
Window
.
FEATURE_ACTION_BAR_OVERLAY
);
setContentView
(
R
.
layout
.
main_activity_layout
);
setContentView
(
R
.
layout
.
main_activity_layout
);
_gmsh
=
new
Gmsh
(
""
,
mainHandler
);
_gmsh
=
new
Gmsh
(
""
,
mainHandler
);
_notify
=
false
;
ActionBar
actionBar
=
getActionBar
();
ActionBar
actionBar
=
getActionBar
();
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
actionBar
.
setBackgroundDrawable
(
new
ColorDrawable
(
Color
.
parseColor
(
"#64000000"
)));
actionBar
.
setBackgroundDrawable
(
new
ColorDrawable
(
Color
.
parseColor
(
"#64000000"
)));
...
@@ -157,6 +162,7 @@ public class MainActivity extends Activity{
...
@@ -157,6 +162,7 @@ public class MainActivity extends Activity{
_runStopMenuItem
.
setTitle
(
R
.
string
.
menu_run
);
_runStopMenuItem
.
setTitle
(
R
.
string
.
menu_run
);
if
(
_modelFragment
!=
null
)
_modelFragment
.
hideProgress
();
if
(
_modelFragment
!=
null
)
_modelFragment
.
hideProgress
();
_compute
=
false
;
_compute
=
false
;
if
(
_notify
)
notifyEndOfCompute
();
super
.
onPostExecute
(
result
);
super
.
onPostExecute
(
result
);
}
}
...
@@ -183,6 +189,34 @@ public class MainActivity extends Activity{
...
@@ -183,6 +189,34 @@ public class MainActivity extends Activity{
.
show
();
.
show
();
}
}
}
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
_notify
=
true
;
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
_notify
=
false
;
}
private
void
notifyEndOfCompute
()
{
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
intent
,
PendingIntent
.
FLAG_CANCEL_CURRENT
);
Notification
.
Builder
mBuilder
=
new
Notification
.
Builder
(
this
)
.
setSmallIcon
(
R
.
drawable
.
ic_launcher
)
.
setContentIntent
(
pendingIntent
)
.
setContentTitle
(
"ONELAB"
)
.
setDefaults
(
Notification
.
DEFAULT_ALL
)
.
setContentText
(
"The compute is finished"
);
NotificationManager
mNotificationManager
=
(
NotificationManager
)
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
mNotificationManager
.
notify
(
1337
,
mBuilder
.
getNotification
());
}
private
final
Handler
mainHandler
=
new
Handler
(){
private
final
Handler
mainHandler
=
new
Handler
(){
public
void
handleMessage
(
android
.
os
.
Message
msg
)
{
public
void
handleMessage
(
android
.
os
.
Message
msg
)
{
switch
(
msg
.
what
)
{
switch
(
msg
.
what
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment