From 44ee7466816378eb4fc6b2bff2e4fa001c3b08a0 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Tue, 10 Feb 2015 17:13:34 +0100 Subject: [PATCH] added actions to error notification --- .../services/NotificationService.java | 24 +++++++++++++++++- .../services/XmppConnectionService.java | 24 ++++++++++++++++++ .../conversations/xmpp/XmppConnection.java | 5 ++++ .../drawable-hdpi/ic_autorenew_white_24dp.png | Bin 0 -> 489 bytes .../res/drawable-hdpi/ic_block_white_24dp.png | Bin 0 -> 606 bytes .../drawable-mdpi/ic_autorenew_white_24dp.png | Bin 0 -> 353 bytes .../res/drawable-mdpi/ic_block_white_24dp.png | Bin 0 -> 428 bytes .../ic_autorenew_white_24dp.png | Bin 0 -> 604 bytes .../drawable-xhdpi/ic_block_white_24dp.png | Bin 0 -> 796 bytes .../ic_autorenew_white_24dp.png | Bin 0 -> 869 bytes .../drawable-xxhdpi/ic_block_white_24dp.png | Bin 0 -> 1194 bytes .../ic_autorenew_white_24dp.png | Bin 0 -> 1114 bytes .../drawable-xxxhdpi/ic_block_white_24dp.png | Bin 0 -> 1497 bytes src/main/res/values/strings.xml | 1 + 14 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/main/res/drawable-hdpi/ic_autorenew_white_24dp.png create mode 100644 src/main/res/drawable-hdpi/ic_block_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_autorenew_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_block_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_autorenew_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_block_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_autorenew_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_block_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_autorenew_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_block_white_24dp.png diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 2ea0904f3..203cda49d 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -41,6 +41,7 @@ import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.ManageAccountActivity; import eu.siacs.conversations.ui.TimePreference; import eu.siacs.conversations.utils.UIHelper; +import eu.siacs.conversations.xmpp.XmppConnection; public class NotificationService { @@ -395,7 +396,20 @@ public class NotificationService { final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_DISABLE_FOREGROUND); - return PendingIntent.getService(mXmppConnectionService, 0, intent, 0); + return PendingIntent.getService(mXmppConnectionService, 34, intent, 0); + } + + private PendingIntent createTryAgainIntent() { + final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); + intent.setAction(XmppConnectionService.ACTION_TRY_AGAIN); + return PendingIntent.getService(mXmppConnectionService, 45, intent, 0); + } + + private PendingIntent createDisableAccountIntent(final Account account) { + final Intent intent = new Intent(mXmppConnectionService,XmppConnectionService.class); + intent.setAction(XmppConnectionService.ACTION_DISABLE_ACCOUNT); + intent.putExtra("account",account.getJid().toBareJid().toString()); + return PendingIntent.getService(mXmppConnectionService,0,intent,PendingIntent.FLAG_UPDATE_CURRENT); } private boolean wasHighlightedOrPrivate(final Message message) { @@ -492,6 +506,14 @@ public class NotificationService { mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.problem_connecting_to_accounts)); mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_fix)); } + mBuilder.addAction(R.drawable.ic_autorenew_white_24dp, + mXmppConnectionService.getString(R.string.try_again), + createTryAgainIntent()); + if (errors.size() == 1) { + mBuilder.addAction(R.drawable.ic_block_white_24dp, + mXmppConnectionService.getString(R.string.disable_account), + createDisableAccountIntent(errors.get(0))); + } mBuilder.setOngoing(true); //mBuilder.setLights(0xffffffff, 2000, 4000); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index e34f9bd77..c08e2c026 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -102,6 +102,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public static final String ACTION_CLEAR_NOTIFICATION = "clear_notification"; public static final String ACTION_DISABLE_FOREGROUND = "disable_foreground"; private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts"; + public static final String ACTION_TRY_AGAIN = "try_again"; + public static final String ACTION_DISABLE_ACCOUNT = "disable_account"; private ContentObserver contactObserver = new ContentObserver(null) { @Override public void onChange(boolean selfChange) { @@ -398,6 +400,28 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa getPreferences().edit().putBoolean("keep_foreground_service",false).commit(); toggleForegroundService(); break; + case ACTION_TRY_AGAIN: + for(Account account : accounts) { + if (account.hasErrorStatus()) { + final XmppConnection connection = account.getXmppConnection(); + if (connection != null) { + connection.resetAttemptCount(); + } + } + } + break; + case ACTION_DISABLE_ACCOUNT: + try { + String jid = intent.getStringExtra("account"); + Account account = jid == null ? null : findAccountByJid(Jid.fromString(jid)); + if (account != null) { + account.setOption(Account.OPTION_DISABLED,true); + updateAccount(account); + } + } catch (final InvalidJidException ignored) { + break; + } + break; } } this.wakeLock.acquire(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 5c2520976..4d6695a5e 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1028,6 +1028,11 @@ public class XmppConnection implements Runnable { this.sendPacket(new InactivePacket()); } + public void resetAttemptCount() { + this.attempt = 0; + this.lastConnect = 0; + } + public class Features { XmppConnection connection; private boolean carbonsEnabled = false; diff --git a/src/main/res/drawable-hdpi/ic_autorenew_white_24dp.png b/src/main/res/drawable-hdpi/ic_autorenew_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b1ee297444526f827a2514a48d87b967ba13d5aa GIT binary patch literal 489 zcmV004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00Ci1L_t(Y$Gz4)N&`U@0N@CcAO!5JG??fath|Rs2%f>h zA95RuG};Cg1qmL)B2_@tUa(MCKZ~rGjoF>uY;d+(nE9BW_ufoJWiemAZkvmOMqw%+ zBuwRnf>eGeKxGYY>ALacoiLS#G@bkOw+)Ix9j|7!f-^dfhkd!w)>NHuk2>+Ndpl)L ztr;)sRy{M0R;*=1XYp+6nUTHX+G!Tl@`004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00GuXL_t(Y$JN$BN*qBH#_>vzGlC$EkVO;^6M`Zrx(LaT z(W{7v#27ch!7*f&g)0$q4Dl36)DY1z7tlq1Sxh;xXL>r_kd0N#{`z0_-mCXj1>yh9 z@Q6SSD>_bf-MQ0sYTvSYHPDnTzvPV@o6@qNmad|4rTK4A&8PkkUu~N+t)b?b7vA~a z|JG3}0@Zwp!f#$lhSp8AoJYlR7L^s=@8;0N$RebEM%BS6P%8@F7nC{i`9Zdtd7!D7 z;=@vyA2IFeFla00W}*bN#s-^q6P!y+VJ2h$ zuMc;B>I(X{RfGwSz@^DNV{1OJtYXZEsCqfdYCC<~N(+KIimG;z`5#Bog|!?@sacJN z#!>eBu=JoG-kBZqW{ep(Yr$^+2BAH;Oy1_3G3}$q<-^<*U)iaRc&-LV*ZSW|m3u_g sEonP(?bfYpC-yAfAHT=_KB_qX0GDS^7@du<0RR9107*qoM6N<$g2#0Or~m)} literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_autorenew_white_24dp.png b/src/main/res/drawable-mdpi/ic_autorenew_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..86b71938b67aaff79edb11c2689f7b5201e4d693 GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1g=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G&@^*J&_}|`tWO=~G=WkKx z)6>N<#NzbSD;vEI2Z*pe@VVCTgF`mP)#T{DcsBOwdbvmWYQ@;)7kLy;XgYs^ZQ=aM zrVr;ypWPdL;{U;&_B%C24wwB4wH4{`l;`l2TC*m{^vIIm5mB$##RXIyy?5rw3w!0Y z8;fOSei<=|ep_C#`O=~G=WkOt zsN(737-DgH?G;C_!ww9s4?7cz7!L03R+2l^8ZMxt>t(LAbc^|l_5h6v_NBI7q6c%m zSHwByh}Y@$s4VkzElKuJWRtAFZoiEFzGn!}$j?U;DlN0U=`k5$a?6S4l0TP81>P?4DXRsYXH0q#P*5`(oz z%U$FOW^oIbWPen6@la1Z$i(cyLAz%=H#{;<d9pt&=-*ON;ApJvAX@i?_xRIKy$1q9xGsNhd%dcv zf0J$1x1&PrY;p%fL-#g6IFj_1X=!}os`VLfuFT!Jbm`3KxB0w3`rRKK|H){qclP@t T8;?9-AToHm`njxgN@xNApLVFX literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xhdpi/ic_autorenew_white_24dp.png b/src/main/res/drawable-xhdpi/ic_autorenew_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e846222339c04fe177944519c5855978a53d4506 GIT binary patch literal 604 zcmV-i0;BzjP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00GoVL_t(o!_AmMO9D|4$3;WQvTGP#lJppKlAv3XUmywn zEFB(*k|3Qm!-FTkiC~16t_jsaEW1gtR{T3Sy*AwS&D*yNuD508|C8C7|IXVGLc#t* z>jw})1E7cS0?B+yO2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F?BHG(cTq~gsaU8(*BY^|wL;URK}*fIOKX3Zm%R7xe!qL~ z6?~3zzx!~xyWj8by%bW(`b%AdA_J+UfgnSY1c{JjK>{Rc5St_qVv<~dSR^+f2FVr3 zn#3Utp@b@SQNtO20x~2!N)}7_fZ#_(0UAaXErflPTTmJ+_yLp0DX4&tfLo3UXc`Uo zobaHhxa`tp4eOZ0I5J2_yX+S{-TlHQCgR!{r#+*ygVFd>N1G#cQ&9QZT?KKK~p4J8+Xh>B`s(1OWYe* za|i%t%|Ud9t&3FMuSmo-bI>knJ|_YylZbE3K{e8RTmLU>^%|UI_{H6$KfJD472hl2MPz01C5l_uQN2K|f2&l-L)Ne`iCnBJE5^tKtROBD#WoQn3|Nl%Y_Ezmr9XZrPa{NG#a85W4+~ph;OCdSE zLHF@h8=qyjx3KD}qh6z>~@d!9R`$1d-wRY!L; zNlap^%Z*#b<;A)3bT@z;ikQcSmb3niP9wLS|bIkNXQm00000NkvXXu0mjfkJx*4 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxhdpi/ic_block_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_block_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d2be2d616f54b98921b2e109be2643908621e630 GIT binary patch literal 1194 zcmV;b1XcTqP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00bgQL_t(&-tC&-Yg9)R$G?eolkATml9*r-1S@$Fp{_=V zA%>v!Q7{z$guXNpwb1`S1fwCv)CXS#6)f~2F+M~Tt{MXpmc9vDFhyEw7TXxw6v+?C z*9TGN+R|n5=hU-j{H9p~4?ntjaZHIo|<2#zl2B+BP4`_h1w2>Je zbq}BCl{Mrso6ZYcW|ne~GC4okMIfGIR@vxftnRV!JI+ zYXoPF7nn`u#(7@kMg*x~1Jo2T);#yqCXgQDi;$*=%%lgp7EK95bIK=_MOX6v7b)b79DrX(zfO%HL^D00cV*54h90vr? z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lyDqCwU~1lK)sxH7C@(=aTGwOrF0ZPr>S=oK+jfj5Kk gl@DW704e~#0rOvmcsD(KfdBvi07*qoM6N<$f@vP~_5c6? literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_block_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_block_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b538af617958e4d1f580c9e7ae1c647caf057cc1 GIT binary patch literal 1497 zcmV;~1t$85P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00mJ=L_t(|+U=W9Xcb2s$ESI;racG|JPSeWGfl9z;K_q6=s^+_BQ02~jaLt9A_x_gUPIFoVr+~yyr?lT zB|?%<50V~cW_M@*&8F~XZ^`~J`+XJX(fH=x^HrN0-$SiS{7qrF;kmg5E5r1)+ zPMX~P4TMor!YlaWXN>h_V2ET_yesBPn(_lV?O`48Hzb12fJ_#QucTQ+>%0?6O=F5C&k|M1{jt?wk9ZFP%lLfc?0C7kg5db3)V^T zlimRHQb;;M`GSmcvgQe}D21dFlrKmr%POA$ONq)41R!^zHxrZ}s0-!2CU1-K1?&C4 z#PTruL4xuH+x!os@;-4>g7Ve1$qjFSzJROYIOGeCOZA=epUnN7pnP?8o{J})j!V9p zPB(Z1R477f5|bZjK_eJ3+Y^gjzPdkXw4@aDNMXMwBwr{8;%ChO_9}wjO+6b+TeGtq*G(Q$XbzK zrc9-p9LO7>gmI;sK@0K)KPfFdblzHUt7yN`A#~L8bDB232x>LBZe9N88vE0=;9iLh zF21%n-&qER=UGGwu-r@1sEV3nfOx8$OCYP zx1uopl{=X7#@HFrv^C=Jp~RY~Y?n1Wc5v(Vh5V#s4c!j5%L#XJ9m-omM?gNMehDN<0W!nFT zC_!GnjRrYVkaEpEX^0Nsb*4HVsrWIsj57`ZK?z?m6^Zyfx!``tuqnV{m%-JfjM5g) z4HiBTD58N&y!0)7mWzC%-)XQ5u-u{c(8Zrd(uX-qQ&c8eL9|ynyEsY@HyL7*ITl!8 zj!A~N!8vj?_&hYU4q*K%02BZU00n>oK&b0q9C_z!q?e1F00000NkvXXu0mjf*T=0t literal 0 HcmV?d00001 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9d3300d8d..ebf256045 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -444,4 +444,5 @@ Sending %s Offering %s Hide offline + Disable Account