|
|
|
@ -3,12 +3,11 @@ package org.thoughtcrime.redphone.ui;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.graphics.drawable.LayerDrawable;
|
|
|
|
|
import android.support.v7.internal.view.menu.MenuBuilder;
|
|
|
|
|
import android.support.v7.internal.view.menu.MenuPopupHelper;
|
|
|
|
|
import android.support.v7.widget.PopupMenu;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
|
import android.widget.PopupMenu;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.redphone.util.AudioUtils;
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
@ -30,9 +29,9 @@ import static org.thoughtcrime.redphone.util.AudioUtils.AudioMode.SPEAKER;
|
|
|
|
|
*/
|
|
|
|
|
public class InCallAudioButton {
|
|
|
|
|
private static final String TAG = InCallAudioButton.class.getName();
|
|
|
|
|
private static final int HANDSET_ID = 0x10;
|
|
|
|
|
private static final int HEADSET_ID = 0x20;
|
|
|
|
|
private static final int SPEAKER_ID = 0x30;
|
|
|
|
|
// private static final int HANDSET_ID = 0x10;
|
|
|
|
|
// private static final int HEADSET_ID = 0x20;
|
|
|
|
|
// private static final int SPEAKER_ID = 0x30;
|
|
|
|
|
|
|
|
|
|
private final CompoundButton mAudioButton;
|
|
|
|
|
private boolean headsetAvailable;
|
|
|
|
@ -160,32 +159,62 @@ public class InCallAudioButton {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void displayAudioChoiceDialog() {
|
|
|
|
|
MenuBuilder mb = new MenuBuilder(context);
|
|
|
|
|
mb.add(0, HANDSET_ID, 0, "Handset");
|
|
|
|
|
mb.add(0, HEADSET_ID, 0, "Headset");
|
|
|
|
|
mb.add(0, SPEAKER_ID, 0, "Speaker");
|
|
|
|
|
mb.setCallback(new AudioRoutingPopupListener());
|
|
|
|
|
|
|
|
|
|
View attachmentView = ((View) mAudioButton.getParent()).findViewById(R.id.menuAttachment);
|
|
|
|
|
PopupMenu popupMenu = new PopupMenu(context, attachmentView);
|
|
|
|
|
// MenuBuilder mb = new MenuBuilder(context);
|
|
|
|
|
// mb.add(0, HANDSET_ID, 0, "Handset");
|
|
|
|
|
// mb.add(0, HEADSET_ID, 0, "Headset");
|
|
|
|
|
// mb.add(0, SPEAKER_ID, 0, "Speaker");
|
|
|
|
|
// mb.setCallback(new AudioRoutingPopupListener());
|
|
|
|
|
|
|
|
|
|
// View attachmentView = ((View) mAudioButton.getParent()).findViewById(R.id.menuAttachment);
|
|
|
|
|
Log.w(TAG, "Displaying popup...");
|
|
|
|
|
PopupMenu popupMenu = new PopupMenu(context, mAudioButton);
|
|
|
|
|
popupMenu.getMenuInflater().inflate(R.menu.redphone_audio_popup_menu, popupMenu.getMenu());
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new AudioRoutingPopupListener());
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
// MenuPopupHelper mph = new MenuPopupHelper(context, mb, attachmentView);
|
|
|
|
|
//
|
|
|
|
|
// mph.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class AudioRoutingPopupListener implements MenuBuilder.Callback {
|
|
|
|
|
private class AudioRoutingPopupListener implements PopupMenu.OnMenuItemClickListener {
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
|
|
|
|
|
// switch (item.getItemId()) {
|
|
|
|
|
// case HANDSET_ID:
|
|
|
|
|
// currentMode = DEFAULT;
|
|
|
|
|
// break;
|
|
|
|
|
// case HEADSET_ID:
|
|
|
|
|
// currentMode = HEADSET;
|
|
|
|
|
// break;
|
|
|
|
|
// case SPEAKER_ID:
|
|
|
|
|
// currentMode = SPEAKER;
|
|
|
|
|
// break;
|
|
|
|
|
// default:
|
|
|
|
|
// Log.w(TAG, "Unknown item selected in audio popup menu: " + item.toString());
|
|
|
|
|
// }
|
|
|
|
|
// Log.d(TAG, "Selected: " + currentMode + " -- " + item.getItemId());
|
|
|
|
|
//
|
|
|
|
|
// listener.onAudioChange(currentMode);
|
|
|
|
|
// updateView();
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onMenuModeChange(MenuBuilder menu) {
|
|
|
|
|
// //To change body of implemented methods use File | Settings | File Templates.
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
|
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case HANDSET_ID:
|
|
|
|
|
case R.id.handset:
|
|
|
|
|
currentMode = DEFAULT;
|
|
|
|
|
break;
|
|
|
|
|
case HEADSET_ID:
|
|
|
|
|
case R.id.headset:
|
|
|
|
|
currentMode = HEADSET;
|
|
|
|
|
break;
|
|
|
|
|
case SPEAKER_ID:
|
|
|
|
|
case R.id.speaker:
|
|
|
|
|
currentMode = SPEAKER;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -197,11 +226,5 @@ public class InCallAudioButton {
|
|
|
|
|
updateView();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onMenuModeChange(MenuBuilder menu) {
|
|
|
|
|
//To change body of implemented methods use File | Settings | File Templates.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|