Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4af6235f authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Use lambdas instead of onClick callbacks"

parents 11cea5d9 9fe3adc6
Loading
Loading
Loading
Loading
+13 −23
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ package com.android.bluetooth.opp;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.bluetooth.AlertActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -47,8 +46,7 @@ import com.android.bluetooth.R;
/**
 * This class is designed to show BT enable confirmation dialog;
 */
public class BluetoothOppBtEnableActivity extends AlertActivity
        implements DialogInterface.OnClickListener {
public class BluetoothOppBtEnableActivity extends AlertActivity {
    private BluetoothOppManager mOppManager;

    @Override
@@ -63,8 +61,9 @@ public class BluetoothOppBtEnableActivity extends AlertActivity
        mAlertBuilder.setIconAttribute(android.R.attr.alertDialogIcon);
        mAlertBuilder.setTitle(getString(R.string.bt_enable_title));
        mAlertBuilder.setView(createView());
        mAlertBuilder.setPositiveButton(R.string.bt_enable_ok, this);
        mAlertBuilder.setNegativeButton(R.string.bt_enable_cancel, this);
        mAlertBuilder.setPositiveButton(R.string.bt_enable_ok,
                (dialog, which) -> onEnableBluetooth());
        mAlertBuilder.setNegativeButton(R.string.bt_enable_cancel, (dialog, which) -> finish());
        setupAlert();
    }

@@ -78,10 +77,7 @@ public class BluetoothOppBtEnableActivity extends AlertActivity
        return view;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
    private void onEnableBluetooth() {
        mOppManager.enableBluetooth(); // this is an asyn call
        mOppManager.mSendingFlag = true;

@@ -93,12 +89,6 @@ public class BluetoothOppBtEnableActivity extends AlertActivity
        this.startActivity(in);

        finish();
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                finish();
                break;
        }
    }

    @Override
+2 −11
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ package com.android.bluetooth.opp;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.bluetooth.AlertActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -46,8 +45,7 @@ import com.android.bluetooth.R;
/**
 * This class is designed to show BT error messages;
 */
public class BluetoothOppBtErrorActivity extends AlertActivity
        implements DialogInterface.OnClickListener {
public class BluetoothOppBtErrorActivity extends AlertActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -62,7 +60,7 @@ public class BluetoothOppBtErrorActivity extends AlertActivity
        mAlertBuilder.setIconAttribute(android.R.attr.alertDialogIcon);
        mAlertBuilder.setTitle(errorTitle);
        mAlertBuilder.setView(createView(errorContent));
        mAlertBuilder.setPositiveButton(R.string.bt_error_btn_ok, this);
        mAlertBuilder.setPositiveButton(R.string.bt_error_btn_ok, (dialog, which) -> {});
        setupAlert();
    }

@@ -73,11 +71,4 @@ public class BluetoothOppBtErrorActivity extends AlertActivity
        return view;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                break;
        }
    }
}
+22 −26
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ import com.android.bluetooth.R;
/**
 * This class is designed to ask user to confirm if accept incoming file;
 */
public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity
        implements DialogInterface.OnClickListener {
public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity {
    private static final String TAG = "BluetoothIncomingFileConfirmActivity";
    private static final boolean D = Constants.DEBUG;
    private static final boolean V = Constants.VERBOSE;
@@ -110,8 +109,10 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity

        mAlertBuilder.setTitle(getString(R.string.incoming_file_confirm_content));
        mAlertBuilder.setView(createView());
        mAlertBuilder.setPositiveButton(R.string.incoming_file_confirm_ok, this);
        mAlertBuilder.setNegativeButton(R.string.incoming_file_confirm_cancel, this);
        mAlertBuilder.setPositiveButton(R.string.incoming_file_confirm_ok,
                (dialog, which) -> onIncomingFileConfirmOk());
        mAlertBuilder.setNegativeButton(R.string.incoming_file_confirm_cancel,
                (dialog, which) -> onIncomingFileConfirmCancel());

        setupAlert();
        if (V) {
@@ -140,10 +141,7 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity
        return view;
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
    private void onIncomingFileConfirmOk() {
        if (!mTimeout) {
            // Update database
            mUpdateValues = new ContentValues();
@@ -153,16 +151,14 @@ public class BluetoothOppIncomingFileConfirmActivity extends AlertActivity

            Toast.makeText(this, getString(R.string.bt_toast_1), Toast.LENGTH_SHORT).show();
        }
                break;
    }

            case DialogInterface.BUTTON_NEGATIVE:
    private void onIncomingFileConfirmCancel() {
        // Update database
        mUpdateValues = new ContentValues();
        mUpdateValues.put(BluetoothShare.USER_CONFIRMATION,
                BluetoothShare.USER_CONFIRMATION_DENIED);
        this.getContentResolver().update(mUri, mUpdateValues, null, null);
                break;
        }
    }

    @Override
+9 −22
Original line number Diff line number Diff line
@@ -61,8 +61,7 @@ import com.android.bluetooth.R;
 * remote Bluetooth device.
 */
public class BluetoothPbapActivity extends AlertActivity
        implements DialogInterface.OnClickListener, Preference.OnPreferenceChangeListener,
        TextWatcher {
        implements Preference.OnPreferenceChangeListener, TextWatcher {
    private static final String TAG = "BluetoothPbapActivity";

    private static final boolean V = BluetoothPbapService.VERBOSE;
@@ -126,8 +125,10 @@ public class BluetoothPbapActivity extends AlertActivity
            case DIALOG_YES_NO_AUTH:
                mAlertBuilder.setTitle(getString(R.string.pbap_session_key_dialog_header));
                mAlertBuilder.setView(createView(DIALOG_YES_NO_AUTH));
                mAlertBuilder.setPositiveButton(android.R.string.ok, this);
                mAlertBuilder.setNegativeButton(android.R.string.cancel, this);
                mAlertBuilder.setPositiveButton(android.R.string.ok,
                        (dialog, which) -> onPositive());
                mAlertBuilder.setNegativeButton(android.R.string.cancel,
                        (dialog, which) -> onNegative());
                setupAlert();
                changeButtonEnabled(DialogInterface.BUTTON_POSITIVE, false);
                break;
@@ -164,6 +165,10 @@ public class BluetoothPbapActivity extends AlertActivity
    }

    private void onPositive() {
        if (mCurrentDialog == DIALOG_YES_NO_AUTH) {
            mSessionKey = mKeyView.getText().toString();
        }

        if (!mTimeout) {
            if (mCurrentDialog == DIALOG_YES_NO_AUTH) {
                sendIntentToReceiver(BluetoothPbapService.AUTH_RESPONSE_ACTION,
@@ -194,24 +199,6 @@ public class BluetoothPbapActivity extends AlertActivity
        sendBroadcast(intent);
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                if (mCurrentDialog == DIALOG_YES_NO_AUTH) {
                    mSessionKey = mKeyView.getText().toString();
                }
                onPositive();
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                onNegative();
                break;
            default:
                break;
        }
    }

    private void onTimeout() {
        mTimeout = true;
        if (mCurrentDialog == DIALOG_YES_NO_AUTH) {