~singpolyma/cheogram-android

3ae8ada44aed35c1855bb2bd5011813971766e30 — root21 2 years ago 227dd8d
Cleaned up DTMF click handling.

Min API version change was required for user interface lambdas.
M build.gradle => build.gradle +1 -1
@@ 91,7 91,7 @@ android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 21
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 42015
        versionName "2.9.13"

M src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java => src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +4 -22
@@ 54,6 54,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.utils.PermissionUtils;


@@ 140,21 141,9 @@ 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));
        ((DialpadView)findViewById(R.id.dialpad)).setClickConsumer(tag -> {
            requireRtpConnection().applyDtmfTone(tag);
        });

        if (savedInstanceState != null) {
            int dialpad_visibility = savedInstanceState.getInt("dialpad_visibility");


@@ 163,13 152,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
        }
    }



    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);

M src/main/java/eu/siacs/conversations/ui/widget/DialpadView.java => src/main/java/eu/siacs/conversations/ui/widget/DialpadView.java +7 -4
@@ 27,6 27,8 @@ 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 44,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 70,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());
    }

}