From b7f3b4333e637d56787182afff83195034259414 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 12 Jun 2020 08:26:33 +0200 Subject: [PATCH] show help button on certain error conditions in RTP session. fixes #3770 --- .../res/menu/activity_rtp_session.xml | 11 ++++ .../java/eu/siacs/conversations/Config.java | 2 + .../conversations/ui/RtpSessionActivity.java | 54 +++++++++++++++++- .../res/drawable-hdpi/ic_help_white_24dp.png | Bin 0 -> 476 bytes .../res/drawable-mdpi/ic_help_white_24dp.png | Bin 0 -> 304 bytes .../res/drawable-xhdpi/ic_help_white_24dp.png | Bin 0 -> 585 bytes .../drawable-xxhdpi/ic_help_white_24dp.png | Bin 0 -> 842 bytes .../drawable-xxxhdpi/ic_help_white_24dp.png | Bin 0 -> 1132 bytes src/main/res/values/attrs.xml | 1 + src/main/res/values/strings.xml | 1 + src/main/res/values/themes.xml | 2 + 11 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/conversations/res/menu/activity_rtp_session.xml create mode 100644 src/main/res/drawable-hdpi/ic_help_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_help_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_help_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_help_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_help_white_24dp.png diff --git a/src/conversations/res/menu/activity_rtp_session.xml b/src/conversations/res/menu/activity_rtp_session.xml new file mode 100644 index 000000000..540a9def9 --- /dev/null +++ b/src/conversations/res/menu/activity_rtp_session.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 68a158d98..f22561722 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -1,6 +1,7 @@ package eu.siacs.conversations; import android.graphics.Bitmap; +import android.net.Uri; import java.util.Collections; import java.util.List; @@ -35,6 +36,7 @@ public final class Config { public static final String LOGTAG = BuildConfig.LOGTAG; public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im"); + public static final Uri HELP = Uri.parse("https://help.conversations.im"); public static final String DOMAIN_LOCK = null; //only allow account creation for this domain diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 848c447a1..a11f5b053 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -3,6 +3,7 @@ package eu.siacs.conversations.ui; import android.Manifest; import android.annotation.SuppressLint; import android.app.PictureInPictureParams; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -17,6 +18,8 @@ import android.support.annotation.RequiresApi; import android.support.annotation.StringRes; import android.util.Log; import android.util.Rational; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.WindowManager; import android.widget.Toast; @@ -81,6 +84,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe RtpEndUserState.CONNECTIVITY_LOST_ERROR, RtpEndUserState.RETRACTED ); + private static final List STATES_SHOWING_HELP_BUTTON = Arrays.asList( + RtpEndUserState.APPLICATION_ERROR, + RtpEndUserState.CONNECTIVITY_ERROR + ); private static final String PROXIMITY_WAKE_LOCK_TAG = "conversations:in-rtp-session"; private static final int REQUEST_ACCEPT_CALL = 0x1111; private WeakReference rtpConnectionReference; @@ -124,6 +131,45 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe setSupportActionBar(binding.toolbar); } + @Override + public boolean onCreateOptionsMenu(final Menu menu) { + getMenuInflater().inflate(R.menu.activity_rtp_session, menu); + final MenuItem help = menu.findItem(R.id.action_help); + help.setVisible(isHelpButtonVisible()); + return super.onCreateOptionsMenu(menu); + } + + private boolean isHelpButtonVisible() { + try { + return STATES_SHOWING_HELP_BUTTON.contains(requireRtpConnection().getEndUserState()); + } catch (IllegalStateException e) { + final Intent intent = getIntent(); + final String state = intent != null ? intent.getStringExtra(EXTRA_LAST_REPORTED_STATE) : null; + if (state != null) { + return STATES_SHOWING_HELP_BUTTON.contains(RtpEndUserState.valueOf(state)); + } else { + return false; + } + } + } + + public boolean onOptionsItemSelected(final MenuItem item) { + if (item.getItemId() == R.id.action_help) { + launchHelpInBrowser(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void launchHelpInBrowser() { + final Intent intent = new Intent(Intent.ACTION_VIEW, Config.HELP); + try { + startActivity(intent); + } catch (final ActivityNotFoundException e) { + Toast.makeText(this, R.string.no_application_found_to_open_link, Toast.LENGTH_LONG).show(); + } + } + private void endCall(View view) { endCall(); } @@ -302,6 +348,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateButtonConfiguration(state); updateStateDisplay(state); updateProfilePicture(state); + invalidateOptionsMenu(); } binding.with.setText(account.getRoster().getContact(with).getDisplayName()); } @@ -456,11 +503,12 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateStateDisplay(currentState, media); updateButtonConfiguration(currentState, media); updateProfilePicture(currentState); + invalidateOptionsMenu(); return false; } private void initializeWithTerminatedSessionState(final Account account, final Jid with, final JingleConnectionManager.TerminatedRtpSession terminatedRtpSession) { - Log.d(Config.LOGTAG,"initializeWithTerminatedSessionState()"); + Log.d(Config.LOGTAG, "initializeWithTerminatedSessionState()"); if (terminatedRtpSession.state == RtpEndUserState.ENDED) { finish(); return; @@ -470,6 +518,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateButtonConfiguration(state); updateStateDisplay(state); updateProfilePicture(state); + updateCallDuration(); + invalidateOptionsMenu(); binding.with.setText(account.getRoster().getContact(with).getDisplayName()); } @@ -956,6 +1006,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateButtonConfiguration(state, media); updateVideoViews(state); updateProfilePicture(state, contact); + invalidateOptionsMenu(); }); if (END_CARD.contains(state)) { final JingleRtpConnection rtpConnection = requireRtpConnection(); @@ -1004,6 +1055,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateStateDisplay(state); updateButtonConfiguration(state); updateProfilePicture(state); + invalidateOptionsMenu(); }); resetIntent(account, with, state, actionToMedia(currentIntent.getAction())); } diff --git a/src/main/res/drawable-hdpi/ic_help_white_24dp.png b/src/main/res/drawable-hdpi/ic_help_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..5664f9532e7894e749472cd81b678d7a988eba19 GIT binary patch literal 476 zcmV<20VDp2P)FS}u8eRGnR8$o7*^pdpI`;)Zh3C*_?imPqNz#SSTLSv(_UTP{{f$uStd zlCmrp4Mto>!JK>;E@M+6nhc1^F&J`Uj+oatTErMx7-H5HN0)I%7KU*hrI4{tD92#P z34NrdG%|LXMTeTEp~Zknj#$@hXtKqKn1W5_brIBAp+k=$B_%_8Y_rUquAaa1Br%** SC%+K@0000-x$b8_O`@KYB7mZ1_t`D2EOuDo_@yjD$TZ zuk0-YN(a1xHiF17 zH=rnle~NOx`lvWzlMkqR|@d}>rEGRFv6-4y*SaX^%P zKGLT~(Zd=(E*^Qhl^zrPBB>hVN`qFukXD|YlA(i58d0J{ZnUzA%{EgE&_)|inPvx@ z5;?i>nXn5c^&c`!aY*NOHJ60FRWy1yCTvm>m?rFqE=6IDux-^b#0KY_ z@tr{#WY{5WRd)2_6E-D-A%64E34=2DK$yov*|3DofDAUc?wbq-u~}3YSq`vilfgOH zoywpcn>{iLVw5yaWzde@3k5Mx8ee7b47*tcQ6#xz24t{^T|q%qNa~p9GI-1>c4Y-o zBbgJ1WzfkEQK|~UCy6s&%HRQ8MDrAcPZIBBaGxK<@f1W2w=LDNPQ0pusNnWq25)dF zD~KX)Ph_xxOF==*;npgHpSa8@h!LDr#~)mV6-1VOnq`-a!uUk9EXamFe462kUfGeS z8I~1=Zfe9(9dQonR5Zqkp*rG>DIR$usg7tXav?{F2&yB>IxTXegA$Ec=bn-wN1n7+ zXi*xBb3{^yj43_3SjEHTie)<0C?2uM9#M8#pjS6VmKV%YpiC7Hk1Ayf%rHzwcW!~d XljjaTd^%zk00000NkvXXu0mjfI|1}c literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxhdpi/ic_help_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_help_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d49181785bf9d1d1135c6b4cd89f635999741f14 GIT binary patch literal 842 zcmV-Q1GW5#P)DHci#T4?D(6E&bG z6+H+Fs|kjXZiKcTq||kLD}*KF((X>u{CayCB=gSu&P)~$`#e%dN5>nAA}5$-fmP}> z2nlIWXO#tJnWUihq09`+gxIuL;v8>jzcJ2zc5t=LJw~-(IL1@bSY}LlV~AU1vB;qE z!)dn2YLhADfgXM$FP90F4Tq?Zr-vL=dX#uZ-l~+84u^O~l9$Xe!C?XdhM3@MUXi3q zzx>fd1-lv_)1}wY#i!J8H zvq@R5xQR`Tf*f#=zp%M3Hyp$66GhO=4C^#$Qspc?ir_QsM&*L1*u11m2Ji5ksNWct zK^Jvwo+ugP*v-kHm*>3hR{|Ma#BM}MxR2e03})ENmok{d?yl@8vxD7X8LYFHUu5t$ zcH5L>!wg9R88q3;KQibc$r;(OOm_dupqnI*6^|kz*{#Xo2uYgsDGn#d!?X-OC)shu zVV3OH31o1aWET{N1+sdo*qzCHUwNIFW=FvJTS#3Sv5GR{7~iw>FqL4NqJ+GC!|qfMEivi z?y`-mkUJdJext-09@E06NrhoLf4U_M U1!|y=uK)l507*qoM6N<$f*NFcH2?qr literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_help_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_help_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..8eb7241da221d5ae26d010433b34e5a5e5ed5908 GIT binary patch literal 1132 zcmV-y1e5!TP)cs4Zm^ya z%ni^?O3y)>L;Qoe0$D{ziaVH^;TS8l2v%~OCz$FXsi^oKQ-f@i0k)IJ)EPxXGp7Ee zR))y(7p4v>JT@_nnL%o0fh>8xQ>}3+hmFDJi$!2!l4OM#}oo>m}-!%vtxB6BQf1XC^YU?(s3lpXTm6HE<}kSTJQ ztCt5IEaqEz@D}D8WQxm}TO$t!Sxlci$YSoI%uvk?=Bnhu9E+Ki2QOjnF=?4#Kk=E9 z2P?3#S0?BpK7I0FJvKUIf&%gRMjpJ2jR6H?9r0PQxYK;Kn3Ld2op6t||y;apOmM zkYI@DPAdrQxX~;R-p7Sj1tEtUJLSPwxX_>=ti_F20000 + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a6d951b56..75d839f0b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -917,6 +917,7 @@ Missed call Audio call Video call + Help Your microphone is unavailable You can only have one call at a time. Return to ongoing call diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 3a19be555..50262913f 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -114,6 +114,7 @@ @drawable/ic_delete_black_24dp @drawable/ic_search_white_24dp + @drawable/ic_help_white_24dp @drawable/ic_lock_open_white_24dp @drawable/ic_settings_black_24dp @drawable/ic_share_white_24dp @@ -267,6 +268,7 @@ @drawable/ic_delete_white_24dp @drawable/ic_search_white_24dp + @drawable/ic_help_white_24dp @drawable/ic_lock_open_white_24dp @drawable/ic_settings_white_24dp @drawable/ic_share_white_24dp