Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
24a28399
Commit
24a28399
authored
Nov 16, 2013
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Icon can be specified by name through interface.
parent
faeee22a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
LocalNotificationOptions.java
src/android/LocalNotificationOptions.java
+29
-7
No files found.
src/android/LocalNotificationOptions.java
View file @
24a28399
...
@@ -15,8 +15,6 @@ import java.util.Date;
...
@@ -15,8 +15,6 @@ import java.util.Date;
import
org.apache.cordova.CordovaInterface
;
import
org.apache.cordova.CordovaInterface
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
android.R
;
/**
/**
* Class that helps to store the options that can be specified per alarm.
* Class that helps to store the options that can be specified per alarm.
*/
*/
...
@@ -101,15 +99,20 @@ public class LocalNotificationOptions {
...
@@ -101,15 +99,20 @@ public class LocalNotificationOptions {
* Gibt den Pfad zum Icon der Notification an.
* Gibt den Pfad zum Icon der Notification an.
*/
*/
public
int
getIcon
()
{
public
int
getIcon
()
{
int
icon
=
R
.
drawable
.
ic_menu_info_details
;
int
icon
=
0
;
CordovaInterface
cordova
=
LocalNotification
.
cordova
;
CordovaInterface
cordova
=
LocalNotification
.
cordova
;
String
packageName
=
cordova
.
getActivity
().
getPackageName
();
String
packageName
=
cordova
.
getActivity
().
getPackageName
();
String
iconName
=
options
.
optString
(
"icon"
,
"icon"
);
try
{
icon
=
getIconValue
(
packageName
,
iconName
);
Class
<?>
klass
=
Class
.
forName
(
packageName
+
".R$drawable"
);
icon
=
(
Integer
)
klass
.
getDeclaredField
(
"icon"
).
get
(
Integer
.
class
);
if
(
icon
==
0
)
{
}
catch
(
Exception
e
)
{}
icon
=
getIconValue
(
"android"
,
iconName
);
}
if
(
icon
==
0
)
{
icon
=
android
.
R
.
drawable
.
ic_menu_info_details
;
}
return
options
.
optInt
(
"icon"
,
icon
);
return
options
.
optInt
(
"icon"
,
icon
);
}
}
...
@@ -148,4 +151,22 @@ public class LocalNotificationOptions {
...
@@ -148,4 +151,22 @@ public class LocalNotificationOptions {
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
/**
* Gibt den Zahlwert des Icons an.
*
* @param {String} className
* @param {String} iconName
*/
private
int
getIconValue
(
String
className
,
String
iconName
)
{
int
icon
=
0
;
try
{
Class
<?>
klass
=
Class
.
forName
(
className
+
".R$drawable"
);
icon
=
(
Integer
)
klass
.
getDeclaredField
(
iconName
).
get
(
Integer
.
class
);
}
catch
(
Exception
e
)
{}
return
icon
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment