Cleaned up DTMF code and click handling.

Min API version change was required for user interface lambdas.
This commit is contained in:
root21 2021-10-11 09:38:13 -06:00 committed by Stephen Paul Weber
parent 358271b767
commit c20a82640e
No known key found for this signature in database
GPG key ID: D11C2911CE519CDE
6 changed files with 17 additions and 46 deletions

View file

@ -90,7 +90,7 @@ android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 29
versionCode 42024
versionName "2.10.3-beta"

View file

@ -57,6 +57,7 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.widget.DialpadView;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.MainThreadExecutor;
import eu.siacs.conversations.ui.util.Rationals;
@ -151,36 +152,16 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_rtp_session);
setSupportActionBar(binding.toolbar);
//TODO: remove this - for testing dialpad input
//((DialpadView)findViewById(R.id.action_dialpad)).
findViewById(R.id.dialpad_1_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_2_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_3_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_4_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_5_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_6_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_7_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_8_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_9_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_0_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_asterisk_holder).setOnClickListener(view -> dialpadPressed(view));
findViewById(R.id.dialpad_pound_holder).setOnClickListener(view -> dialpadPressed(view));
binding.dialpad.setClickConsumer(tag -> {
requireRtpConnection().applyDtmfTone(tag);
});
if (savedInstanceState != null) {
int dialpad_visibility = savedInstanceState.getInt("dialpad_visibility");
System.out.println("dialpad_visibility onCreate = " + dialpad_visibility);
findViewById(R.id.dialpad).setVisibility(dialpad_visibility);
}
}
private void dialpadPressed(View dialpadKeyHolderView) {
JingleRtpConnection rtpConnection = requireRtpConnection();
rtpConnection.applyDtmfTone(dialpadKeyHolderView.getTag().toString());
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.activity_rtp_session, menu);

View file

@ -23,10 +23,11 @@ import android.view.View;
import androidx.constraintlayout.widget.ConstraintLayout;
import eu.siacs.conversations.R;
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
public class DialpadView extends ConstraintLayout implements View.OnClickListener {
protected java.util.function.Consumer<String> clickConsumer = null;
public DialpadView(Context context) {
super(context);
init();
@ -42,6 +43,10 @@ public class DialpadView extends ConstraintLayout implements View.OnClickListene
init();
}
public void setClickConsumer(java.util.function.Consumer<String> clickConsumer) {
this.clickConsumer = clickConsumer;
}
private void init() {
inflate(getContext(), R.layout.dialpad, this);
initViews();
@ -64,10 +69,7 @@ public class DialpadView extends ConstraintLayout implements View.OnClickListene
@Override
public void onClick(View v) {
/* TODO: this widget doesn't know anything about the RTP Connection,
so how to make this widget generic but also able to send touch-tone sounds
*/
System.out.println("v.getTag() = " + v.getTag());
clickConsumer.accept(v.getTag().toString());
}
}

View file

@ -232,17 +232,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
}
//TODO: remove - hack to test dtmfSending
public DtmfSender getDtmfSender() {
return webRTCWrapper.getDtmfSender();
}
//FIXME: possible implementation
public boolean applyDtmfTone(String tone) {
return webRTCWrapper.applyDtmfTone(tone);
}
private void receiveSessionTerminate(final JinglePacket jinglePacket) {
respondOk(jinglePacket);
final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason();

View file

@ -530,11 +530,6 @@ public class WebRTCWrapper {
return peerConnection;
}
//TODO: remove - hack to test dtmfSending
public DtmfSender getDtmfSender() {
return peerConnection.getSenders().get(0).dtmf();
}
public boolean applyDtmfTone(String tone) {
if (toneManager == null || peerConnection.getSenders().isEmpty()) {
return false;

View file

@ -171,7 +171,7 @@
app:elevation="4dp"
app:fabCustomSize="72dp"
app:maxImageSize="36dp"
tools:visibility="gone" />
tools:visibility="visible" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/accept_call"
@ -186,7 +186,7 @@
app:elevation="4dp"
app:fabCustomSize="72dp"
app:maxImageSize="36dp"
tools:visibility="gone" />
tools:visibility="visible" />
</RelativeLayout>
@ -197,7 +197,7 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toStartOf="@+id/end_call"
android:visibility="visible"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"
app:fabSize="mini"
@ -223,7 +223,7 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toEndOf="@+id/end_call"
android:visibility="visible"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"
app:fabSize="mini"
@ -236,7 +236,7 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toEndOf="@+id/in_call_action_right"
android:visibility="visible"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"
app:fabSize="mini"