Cleaned up DTMF code and click handling.
Min API version change was required for user interface lambdas.
This commit is contained in:
parent
358271b767
commit
c20a82640e
|
@ -90,7 +90,7 @@ android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 42024
|
versionCode 42024
|
||||||
versionName "2.10.3-beta"
|
versionName "2.10.3-beta"
|
||||||
|
|
|
@ -57,6 +57,7 @@ import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.services.AppRTCAudioManager;
|
import eu.siacs.conversations.services.AppRTCAudioManager;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
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.AvatarWorkerTask;
|
||||||
import eu.siacs.conversations.ui.util.MainThreadExecutor;
|
import eu.siacs.conversations.ui.util.MainThreadExecutor;
|
||||||
import eu.siacs.conversations.ui.util.Rationals;
|
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);
|
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_rtp_session);
|
||||||
setSupportActionBar(binding.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
|
|
||||||
//TODO: remove this - for testing dialpad input
|
binding.dialpad.setClickConsumer(tag -> {
|
||||||
//((DialpadView)findViewById(R.id.action_dialpad)).
|
requireRtpConnection().applyDtmfTone(tag);
|
||||||
|
});
|
||||||
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));
|
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
int dialpad_visibility = savedInstanceState.getInt("dialpad_visibility");
|
int dialpad_visibility = savedInstanceState.getInt("dialpad_visibility");
|
||||||
System.out.println("dialpad_visibility onCreate = " + dialpad_visibility);
|
|
||||||
findViewById(R.id.dialpad).setVisibility(dialpad_visibility);
|
findViewById(R.id.dialpad).setVisibility(dialpad_visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void dialpadPressed(View dialpadKeyHolderView) {
|
|
||||||
JingleRtpConnection rtpConnection = requireRtpConnection();
|
|
||||||
rtpConnection.applyDtmfTone(dialpadKeyHolderView.getTag().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.activity_rtp_session, menu);
|
getMenuInflater().inflate(R.menu.activity_rtp_session, menu);
|
||||||
|
|
|
@ -23,10 +23,11 @@ import android.view.View;
|
||||||
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
|
|
||||||
|
|
||||||
public class DialpadView extends ConstraintLayout implements View.OnClickListener {
|
public class DialpadView extends ConstraintLayout implements View.OnClickListener {
|
||||||
|
|
||||||
|
protected java.util.function.Consumer<String> clickConsumer = null;
|
||||||
|
|
||||||
public DialpadView(Context context) {
|
public DialpadView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
init();
|
init();
|
||||||
|
@ -42,6 +43,10 @@ public class DialpadView extends ConstraintLayout implements View.OnClickListene
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClickConsumer(java.util.function.Consumer<String> clickConsumer) {
|
||||||
|
this.clickConsumer = clickConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
inflate(getContext(), R.layout.dialpad, this);
|
inflate(getContext(), R.layout.dialpad, this);
|
||||||
initViews();
|
initViews();
|
||||||
|
@ -64,10 +69,7 @@ public class DialpadView extends ConstraintLayout implements View.OnClickListene
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
/* TODO: this widget doesn't know anything about the RTP Connection,
|
clickConsumer.accept(v.getTag().toString());
|
||||||
so how to make this widget generic but also able to send touch-tone sounds
|
|
||||||
*/
|
|
||||||
System.out.println("v.getTag() = " + v.getTag());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
public boolean applyDtmfTone(String tone) {
|
||||||
return webRTCWrapper.applyDtmfTone(tone);
|
return webRTCWrapper.applyDtmfTone(tone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void receiveSessionTerminate(final JinglePacket jinglePacket) {
|
private void receiveSessionTerminate(final JinglePacket jinglePacket) {
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason();
|
final JinglePacket.ReasonWrapper wrapper = jinglePacket.getReason();
|
||||||
|
|
|
@ -530,11 +530,6 @@ public class WebRTCWrapper {
|
||||||
return peerConnection;
|
return peerConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: remove - hack to test dtmfSending
|
|
||||||
public DtmfSender getDtmfSender() {
|
|
||||||
return peerConnection.getSenders().get(0).dtmf();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean applyDtmfTone(String tone) {
|
public boolean applyDtmfTone(String tone) {
|
||||||
if (toneManager == null || peerConnection.getSenders().isEmpty()) {
|
if (toneManager == null || peerConnection.getSenders().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -171,7 +171,7 @@
|
||||||
app:elevation="4dp"
|
app:elevation="4dp"
|
||||||
app:fabCustomSize="72dp"
|
app:fabCustomSize="72dp"
|
||||||
app:maxImageSize="36dp"
|
app:maxImageSize="36dp"
|
||||||
tools:visibility="gone" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/accept_call"
|
android:id="@+id/accept_call"
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
app:elevation="4dp"
|
app:elevation="4dp"
|
||||||
app:fabCustomSize="72dp"
|
app:fabCustomSize="72dp"
|
||||||
app:maxImageSize="36dp"
|
app:maxImageSize="36dp"
|
||||||
tools:visibility="gone" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_margin="@dimen/in_call_fab_margin"
|
android:layout_margin="@dimen/in_call_fab_margin"
|
||||||
android:layout_toStartOf="@+id/end_call"
|
android:layout_toStartOf="@+id/end_call"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
app:backgroundTint="?color_background_primary"
|
app:backgroundTint="?color_background_primary"
|
||||||
app:elevation="4dp"
|
app:elevation="4dp"
|
||||||
app:fabSize="mini"
|
app:fabSize="mini"
|
||||||
|
@ -223,7 +223,7 @@
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_margin="@dimen/in_call_fab_margin"
|
android:layout_margin="@dimen/in_call_fab_margin"
|
||||||
android:layout_toEndOf="@+id/end_call"
|
android:layout_toEndOf="@+id/end_call"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
app:backgroundTint="?color_background_primary"
|
app:backgroundTint="?color_background_primary"
|
||||||
app:elevation="4dp"
|
app:elevation="4dp"
|
||||||
app:fabSize="mini"
|
app:fabSize="mini"
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_margin="@dimen/in_call_fab_margin"
|
android:layout_margin="@dimen/in_call_fab_margin"
|
||||||
android:layout_toEndOf="@+id/in_call_action_right"
|
android:layout_toEndOf="@+id/in_call_action_right"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
app:backgroundTint="?color_background_primary"
|
app:backgroundTint="?color_background_primary"
|
||||||
app:elevation="4dp"
|
app:elevation="4dp"
|
||||||
app:fabSize="mini"
|
app:fabSize="mini"
|
||||||
|
|
Loading…
Reference in a new issue