Artifact 44b98ac0c853f2478818f52adb765a717ee1a811:
- File android/notify.fs — part of check-in [9de6150452] at 2018-11-15 23:25:52 on branch trunk — Notification+Otrify problems fixed (Otrify only partly) (user: bernd size: 2824)
0000: 5c 20 41 6e 64 6f 69 64 20 73 70 65 63 69 66 69 \ Andoid specifi 0010: 63 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 20 73 c notification s 0020: 74 75 66 66 0a 0a 5c 20 43 6f 70 79 72 69 67 68 tuff..\ Copyrigh 0030: 74 20 28 43 29 20 32 30 31 36 20 20 20 42 65 72 t (C) 2016 Ber 0040: 6e 64 20 50 61 79 73 61 6e 0a 0a 5c 20 54 68 69 nd Paysan..\ Thi 0050: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 s program is fre 0060: 65 20 73 6f 66 74 77 61 72 65 3a 20 79 6f 75 20 e software: you 0070: 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 can redistribute 0080: 20 69 74 20 61 6e 64 2f 6f 72 20 6d 6f 64 69 66 it and/or modif 0090: 79 0a 5c 20 69 74 20 75 6e 64 65 72 20 74 68 65 y.\ it under the 00a0: 20 74 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e terms of the GN 00b0: 55 20 41 66 66 65 72 6f 20 47 65 6e 65 72 61 6c U Affero General 00c0: 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 Public License 00d0: 61 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a as published by. 00e0: 5c 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 \ the Free Softw 00f0: 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 are Foundation, 0100: 65 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20 33 either version 3 0110: 20 6f 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2c of the License, 0120: 20 6f 72 0a 5c 20 28 61 74 20 79 6f 75 72 20 6f or.\ (at your o 0130: 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 72 ption) any later 0140: 20 76 65 72 73 69 6f 6e 2e 0a 0a 5c 20 54 68 69 version...\ Thi 0150: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 s program is dis 0160: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 tributed in the 0170: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c hope that it wil 0180: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 5c 20 62 l be useful,.\ b 0190: 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 ut WITHOUT ANY W 01a0: 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 ARRANTY; without 01b0: 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 even the implie 01c0: 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 5c 20 d warranty of.\ 01d0: 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 MERCHANTABILITY 01e0: 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 or FITNESS FOR A 01f0: 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 PARTICULAR PURP 0200: 4f 53 45 2e 20 20 53 65 65 20 74 68 65 0a 5c 20 OSE. See the.\ 0210: 47 4e 55 20 41 66 66 65 72 6f 20 47 65 6e 65 72 GNU Affero Gener 0220: 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 al Public Licens 0230: 65 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 e for more detai 0240: 6c 73 2e 0a 0a 5c 20 59 6f 75 20 73 68 6f 75 6c ls...\ You shoul 0250: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 d have received 0260: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e a copy of the GN 0270: 55 20 41 66 66 65 72 6f 20 47 65 6e 65 72 61 6c U Affero General 0280: 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 0a Public License. 0290: 5c 20 61 6c 6f 6e 67 20 77 69 74 68 20 74 68 69 \ along with thi 02a0: 73 20 70 72 6f 67 72 61 6d 2e 20 20 49 66 20 6e s program. If n 02b0: 6f 74 2c 20 73 65 65 20 3c 68 74 74 70 3a 2f 2f ot, see <http:// 02c0: 77 77 77 2e 67 6e 75 2e 6f 72 67 2f 6c 69 63 65 www.gnu.org/lice 02d0: 6e 73 65 73 2f 3e 2e 0a 0a 61 6c 73 6f 20 61 6e nses/>...also an 02e0: 64 72 6f 69 64 20 61 6c 73 6f 20 6a 6e 69 0a 0a droid also jni.. 02f0: 30 78 30 31 30 38 30 30 37 37 20 56 61 6c 75 65 0x01080077 Value 0300: 20 6e 65 74 32 6f 2d 69 63 6f 6e 23 20 5c 20 64 net2o-icon# \ d 0310: 65 66 61 75 6c 74 0a 3a 20 67 65 74 2d 6e 65 74 efault.: get-net 0320: 32 6f 2d 69 63 6f 6e 23 20 22 67 6e 75 2e 67 66 2o-icon# "gnu.gf 0330: 6f 72 74 68 3a 64 72 61 77 61 62 6c 65 2f 6e 65 orth:drawable/ne 0340: 74 32 6f 5f 6e 6f 74 69 66 79 22 20 52 2e 69 64 t2o_notify" R.id 0350: 20 3b 0a 67 65 74 2d 6e 65 74 32 6f 2d 69 63 6f ;.get-net2o-ico 0360: 6e 23 20 74 6f 20 6e 65 74 32 6f 2d 69 63 6f 6e n# to net2o-icon 0370: 23 0a 6a 76 61 6c 75 65 20 6e 62 0a 6a 76 61 6c #.jvalue nb.jval 0380: 75 65 20 6e 69 0a 6a 76 61 6c 75 65 20 6e 66 0a ue ni.jvalue nf. 0390: 6a 76 61 6c 75 65 20 6e 6f 74 69 66 69 63 61 74 jvalue notificat 03a0: 69 6f 6e 2d 6d 61 6e 61 67 65 72 0a 0a 3a 20 6e ion-manager..: n 03b0: 6f 74 69 66 79 40 20 28 20 2d 2d 20 61 64 64 72 otify@ ( -- addr 03c0: 20 75 20 29 0a 20 20 20 20 6e 6f 74 69 66 79 2d u ). notify- 03d0: 6f 74 72 3f 20 40 20 30 3e 20 49 46 20 20 22 65 otr? @ 0> IF "e 03e0: 78 70 69 72 65 64 20 6d 65 73 73 61 67 65 22 20 xpired message" 03f0: 20 45 58 49 54 20 20 54 48 45 4e 0a 20 20 20 20 EXIT THEN. 0400: 63 6f 6e 66 69 67 3a 6e 6f 74 69 66 79 2d 74 65 config:notify-te 0410: 78 74 23 20 40 20 49 46 0a 09 6e 6f 74 69 66 79 xt# @ IF..notify 0420: 2d 6f 74 72 3f 20 40 20 63 6f 6e 66 69 67 3a 6e -otr? @ config:n 0430: 6f 74 69 66 79 2d 74 65 78 74 23 20 40 20 30 3e otify-text# @ 0> 0440: 20 61 6e 64 20 49 46 0a 09 20 20 20 20 22 3c 69 and IF.. "<i 0450: 3e 5b 6f 74 72 5d 20 6d 65 73 73 61 67 65 3c 2f >[otr] message</ 0460: 69 3e 22 0a 09 45 4c 53 45 20 20 6e 6f 74 69 66 i>"..ELSE notif 0470: 79 24 20 24 40 20 20 54 48 45 4e 0a 20 20 20 20 y$ $@ THEN. 0480: 45 4c 53 45 20 20 22 65 6e 63 72 79 70 74 65 64 ELSE "encrypted 0490: 20 6d 65 73 73 61 67 65 22 20 20 54 48 45 4e 20 message" THEN 04a0: 3b 0a 3a 20 3f 6e 6d 20 28 20 2d 2d 20 29 0a 20 ;.: ?nm ( -- ). 04b0: 20 20 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 2d notification- 04c0: 6d 61 6e 61 67 65 72 20 30 3d 20 49 46 0a 09 63 manager 0= IF..c 04d0: 6c 61 7a 7a 20 2e 6e 6f 74 69 66 69 63 61 74 69 lazz .notificati 04e0: 6f 6e 4d 61 6e 61 67 65 72 20 74 6f 20 6e 6f 74 onManager to not 04f0: 69 66 69 63 61 74 69 6f 6e 2d 6d 61 6e 61 67 65 ification-manage 0500: 72 0a 20 20 20 20 54 48 45 4e 20 3b 0a 3a 20 3f r. THEN ;.: ? 0510: 6e 69 20 28 20 2d 2d 20 29 0a 20 20 20 20 6e 69 ni ( -- ). ni 0520: 20 30 3d 20 49 46 20 20 63 6c 61 7a 7a 20 2e 67 0= IF clazz .g 0530: 66 6f 72 74 68 69 6e 74 65 6e 74 20 74 6f 20 6e forthintent to n 0540: 69 20 20 54 48 45 4e 20 3b 0a 53 44 4b 5f 49 4e i THEN ;.SDK_IN 0550: 54 20 31 31 20 3e 3d 20 5b 49 46 5d 0a 20 20 20 T 11 >= [IF]. 0560: 20 5b 49 46 44 45 46 5d 20 6e 65 77 4e 6f 74 69 [IFDEF] newNoti 0570: 66 69 63 61 74 69 6f 6e 43 68 61 6e 6e 65 6c 0a ficationChannel. 0580: 09 56 61 72 69 61 62 6c 65 20 63 68 61 6e 6e 65 .Variable channe 0590: 6c 24 20 22 67 6e 75 2e 67 66 6f 72 74 68 2e 6e l$ "gnu.gforth.n 05a0: 6f 74 69 66 69 63 61 74 69 6f 6e 73 22 20 63 68 otifications" ch 05b0: 61 6e 6e 65 6c 24 20 24 21 0a 09 56 61 72 69 61 annel$ $!..Varia 05c0: 62 6c 65 20 63 68 2d 6e 61 6d 65 24 20 22 6e 65 ble ch-name$ "ne 05d0: 74 32 6f 20 6d 65 73 73 61 67 65 73 22 20 63 68 t2o messages" ch 05e0: 2d 6e 61 6d 65 24 20 24 21 0a 09 33 20 56 61 6c -name$ $!..3 Val 05f0: 75 65 20 63 68 61 6e 6e 65 6c 2d 70 72 69 6f 23 ue channel-prio# 0600: 0a 09 4a 56 61 6c 75 65 20 6e 63 0a 09 3a 20 3f ..JValue nc..: ? 0610: 6e 63 20 28 20 2d 2d 20 29 0a 09 20 20 20 20 6e nc ( -- ).. n 0620: 63 20 30 3d 20 49 46 0a 09 09 63 6c 61 7a 7a 20 c 0= IF...clazz 0630: 2e 6e 6f 74 69 66 69 63 61 74 69 6f 6e 43 68 61 .notificationCha 0640: 6e 6e 65 6c 20 74 6f 20 6e 63 0a 09 09 63 68 2d nnel to nc...ch- 0650: 6e 61 6d 65 24 20 24 40 20 6d 61 6b 65 2d 6a 73 name$ $@ make-js 0660: 74 72 69 6e 67 20 6e 63 20 2e 73 65 74 4e 61 6d tring nc .setNam 0670: 65 0a 09 20 20 20 20 54 48 45 4e 20 3b 0a 20 20 e.. THEN ;. 0680: 20 20 5b 54 48 45 4e 5d 0a 20 20 20 20 3a 20 6d [THEN]. : m 0690: 73 67 2d 62 75 69 6c 64 65 72 20 28 20 2d 2d 20 sg-builder ( -- 06a0: 29 20 3f 6e 6d 20 3f 6e 69 20 5b 49 46 44 45 46 ) ?nm ?ni [IFDEF 06b0: 5d 20 3f 6e 63 20 3f 6e 63 0a 09 20 20 20 20 63 ] ?nc ?nc.. c 06c0: 6c 61 7a 7a 20 63 68 61 6e 6e 65 6c 24 20 24 40 lazz channel$ $@ 06d0: 20 6d 61 6b 65 2d 6a 73 74 72 69 6e 67 20 6e 65 make-jstring ne 06e0: 77 4e 6f 74 69 66 69 63 61 74 69 6f 6e 2e 42 75 wNotification.Bu 06f0: 69 6c 64 65 72 2b 49 64 20 3e 6f 0a 09 5b 45 4c ilder+Id >o..[EL 0700: 53 45 5d 0a 09 20 20 20 20 63 6c 61 7a 7a 20 6e SE].. clazz n 0710: 65 77 4e 6f 74 69 66 69 63 61 74 69 6f 6e 2e 42 ewNotification.B 0720: 75 69 6c 64 65 72 20 3e 6f 0a 09 5b 54 48 45 4e uilder >o..[THEN 0730: 5d 0a 09 63 6f 6e 66 69 67 3a 6e 6f 74 69 66 79 ]..config:notify 0740: 2d 72 67 62 23 20 40 20 63 6f 6e 66 69 67 3a 6e -rgb# @ config:n 0750: 6f 74 69 66 79 2d 6f 6e 23 20 40 20 63 6f 6e 66 otify-on# @ conf 0760: 69 67 3a 6e 6f 74 69 66 79 2d 6f 66 66 23 20 40 ig:notify-off# @ 0770: 20 73 65 74 4c 69 67 68 74 73 20 6f 3e 20 3e 6f setLights o> >o 0780: 0a 09 63 6f 6e 66 69 67 3a 6e 6f 74 69 66 79 2d ..config:notify- 0790: 6d 6f 64 65 23 20 40 20 73 65 74 44 65 66 61 75 mode# @ setDefau 07a0: 6c 74 73 20 6f 3e 20 3e 6f 0a 09 6e 69 20 73 65 lts o> >o..ni se 07b0: 74 43 6f 6e 74 65 6e 74 49 6e 74 65 6e 74 20 6f tContentIntent o 07c0: 3e 20 3e 6f 0a 09 6e 65 74 32 6f 2d 69 63 6f 6e > >o..net2o-icon 07d0: 23 20 73 65 74 53 6d 61 6c 6c 49 63 6f 6e 20 6f # setSmallIcon o 07e0: 3e 20 3e 6f 0a 09 31 20 73 65 74 41 75 74 6f 43 > >o..1 setAutoC 07f0: 61 6e 63 65 6c 20 6f 3e 20 74 6f 20 6e 62 20 3b ancel o> to nb ; 0800: 0a 20 20 20 20 6d 73 67 2d 62 75 69 6c 64 65 72 . msg-builder 0810: 0a 20 20 20 20 3a 20 62 75 69 6c 64 2d 6e 6f 74 . : build-not 0820: 69 66 69 63 61 74 69 6f 6e 20 28 20 2d 2d 20 29 ification ( -- ) 0830: 0a 5c 09 31 30 30 30 20 63 6c 61 7a 7a 20 2e 73 .\.1000 clazz .s 0840: 63 72 65 65 6e 5f 6f 6e 0a 09 5b 27 5d 20 6e 6f creen_on..['] no 0850: 74 69 66 79 2d 74 69 74 6c 65 20 24 74 6d 70 20 tify-title $tmp 0860: 64 75 70 20 30 3d 20 49 46 20 20 32 64 72 6f 70 dup 0= IF 2drop 0870: 20 20 45 58 49 54 20 20 54 48 45 4e 0a 09 31 20 EXIT THEN..1 0880: 70 65 6e 64 69 6e 67 2d 6e 6f 74 69 66 69 63 61 pending-notifica 0890: 74 69 6f 6e 73 20 2b 21 0a 09 6d 61 6b 65 2d 6a tions +!..make-j 08a0: 73 74 72 69 6e 67 20 6e 62 20 2e 73 65 74 43 6f string nb .setCo 08b0: 6e 74 65 6e 74 54 69 74 6c 65 0a 09 3e 6f 20 6e ntentTitle..>o n 08c0: 6f 74 69 66 79 40 20 6d 61 6b 65 2d 6a 73 74 72 otify@ make-jstr 08d0: 69 6e 67 20 73 65 74 43 6f 6e 74 65 6e 74 54 65 ing setContentTe 08e0: 78 74 20 6f 3e 0a 09 3e 6f 20 6e 6f 74 69 66 79 xt o>..>o notify 08f0: 40 20 6d 61 6b 65 2d 6a 73 74 72 69 6e 67 20 73 @ make-jstring s 0900: 65 74 54 69 63 6b 65 72 20 6f 3e 0a 09 3e 6f 20 etTicker o>..>o 0910: 70 65 6e 64 69 6e 67 2d 6e 6f 74 69 66 69 63 61 pending-notifica 0920: 74 69 6f 6e 73 20 40 20 73 65 74 4e 75 6d 62 65 tions @ setNumbe 0930: 72 20 6f 3e 0a 09 5b 49 46 44 45 46 5d 20 73 65 r o>..[IFDEF] se 0940: 74 47 72 6f 75 70 0a 09 20 20 20 20 3e 6f 20 6a tGroup.. >o j 0950: 73 22 20 6e 65 74 32 6f 20 6e 6f 74 69 66 69 63 s" net2o notific 0960: 61 74 69 6f 6e 73 22 20 73 65 74 47 72 6f 75 70 ations" setGroup 0970: 20 6f 3e 0a 09 5b 54 48 45 4e 5d 0a 09 2e 62 75 o>..[THEN]...bu 0980: 69 6c 64 20 74 6f 20 6e 66 20 3b 0a 20 20 20 20 ild to nf ;. 0990: 3a 20 73 68 6f 77 2d 6e 6f 74 69 66 69 63 61 74 : show-notificat 09a0: 69 6f 6e 20 28 20 2d 2d 20 29 0a 09 63 6c 61 7a ion ( -- )..claz 09b0: 7a 20 3e 6f 20 31 20 30 20 74 6f 20 61 72 67 6a z >o 1 0 to argj 09c0: 30 0a 09 6e 66 20 74 6f 20 61 72 67 6e 6f 74 69 0..nf to argnoti 09d0: 66 79 20 6f 3e 0a 09 5b 27 5d 20 6e 6f 74 69 66 fy o>..['] notif 09e0: 79 65 72 20 70 6f 73 74 2d 69 74 20 3b 0a 5c 20 yer post-it ;.\ 09f0: 20 20 20 20 20 20 31 20 6e 66 20 6e 6f 74 69 66 1 nf notif 0a00: 69 63 61 74 69 6f 6e 2d 6d 61 6e 61 67 65 72 20 ication-manager 0a10: 2e 6e 6f 74 69 66 79 20 3b 0a 5b 45 4c 53 45 5d .notify ;.[ELSE] 0a20: 0a 20 20 20 20 5c 20 6e 6f 20 6e 6f 74 69 66 69 . \ no notifi 0a30: 63 61 74 69 6f 6e 20 66 6f 72 20 41 6e 64 72 6f cation for Andro 0a40: 69 64 20 32 2e 33 20 66 6f 72 20 6e 6f 77 2e 2e id 2.3 for now.. 0a50: 2e 0a 20 20 20 20 3a 20 6d 73 67 2d 62 75 69 6c .. : msg-buil 0a60: 64 65 72 20 28 20 2d 2d 20 29 20 3b 0a 20 20 20 der ( -- ) ;. 0a70: 20 3a 20 62 75 69 6c 64 2d 6e 6f 74 69 66 69 63 : build-notific 0a80: 61 74 69 6f 6e 20 28 20 2d 2d 20 29 20 3b 0a 20 ation ( -- ) ;. 0a90: 20 20 20 3a 20 73 68 6f 77 2d 6e 6f 74 69 66 69 : show-notifi 0aa0: 63 61 74 69 6f 6e 20 28 20 2d 2d 20 29 20 3b 0a cation ( -- ) ;. 0ab0: 5b 54 48 45 4e 5d 0a 0a 3a 6e 6f 6e 61 6d 65 20 [THEN]..:noname 0ac0: 64 65 66 65 72 73 20 61 6e 64 72 6f 69 64 2d 61 defers android-a 0ad0: 63 74 69 76 65 20 72 65 6e 64 65 72 69 6e 67 20 ctive rendering 0ae0: 40 20 49 46 20 20 6e 6f 74 69 66 79 2d 20 20 54 @ IF notify- T 0af0: 48 45 4e 20 3b 0a 69 73 20 61 6e 64 72 6f 69 64 HEN ;.is android 0b00: 2d 61 63 74 69 76 65 0a -active.