Moved speaker and mic buttons to the top of the dialer.
This commit is contained in:
parent
ac9b15ad1a
commit
0e2a868694
3 changed files with 119 additions and 40 deletions
|
@ -15,14 +15,25 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout android:layout_height="wrap_content"
|
<FrameLayout android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout">
|
android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout" android:background="@drawable/clavier_bg">
|
||||||
|
|
||||||
<EditText android:text="@+id/EditText01"
|
<EditText android:text="@+id/EditText01"
|
||||||
android:layout_height="wrap_content" android:lines="1"
|
android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
android:id="@+id/DisplayNameView" android:clickable="false"
|
android:id="@+id/DisplayNameView" android:clickable="false"
|
||||||
android:cursorVisible="false" android:gravity="center"
|
android:cursorVisible="false" android:layout_gravity="center"
|
||||||
android:layout_width="fill_parent"></EditText>
|
></EditText>
|
||||||
</LinearLayout>
|
<org.linphone.component.ToggleImageButton android:id="@+id/mic_mute_button"
|
||||||
|
android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||||
|
toggled="@drawable/mic_muted" untoggled="@drawable/mic_active"
|
||||||
|
android:layout_gravity="left|center_vertical"/>
|
||||||
|
<org.linphone.component.ToggleImageButton android:id="@+id/speaker_button"
|
||||||
|
android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||||
|
toggled="@drawable/speaker_32_on" untoggled="@drawable/speaker_32_off"
|
||||||
|
android:layout_gravity="right|center_vertical"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
|
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
|
||||||
|
@ -95,9 +106,8 @@
|
||||||
|
|
||||||
|
|
||||||
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
||||||
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1" android:background="@drawable/clavier_bg"></ToggleButton>
|
|
||||||
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
|
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
|
||||||
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:drawableTop="@drawable/speaker_32_off"></ToggleButton>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
|
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
|
||||||
|
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import org.linphone.component.ToggleImageButton;
|
||||||
|
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
|
@ -28,7 +30,6 @@ import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -45,18 +46,14 @@ import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnFocusChangeListener;
|
|
||||||
import android.view.View.OnLongClickListener;
|
import android.view.View.OnLongClickListener;
|
||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
||||||
|
|
||||||
public class DialerActivity extends Activity implements LinphoneCoreListener {
|
public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
@ -82,13 +79,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
private Button mStar;
|
private Button mStar;
|
||||||
private Button mHash;
|
private Button mHash;
|
||||||
|
|
||||||
private ToggleButton mMute;
|
private ToggleImageButton mMute;
|
||||||
private ToggleButton mSpeaker;
|
private ToggleImageButton mSpeaker;
|
||||||
|
|
||||||
private LinearLayout mCallControlRow;
|
private LinearLayout mCallControlRow;
|
||||||
private TableRow mInCallControlRow;
|
private TableRow mInCallControlRow;
|
||||||
private LinearLayout mAddressLayout;
|
private View mAddressLayout;
|
||||||
private LinearLayout mInCallAddressLayout;
|
private View mInCallAddressLayout;
|
||||||
|
|
||||||
private static DialerActivity theDialer;
|
private static DialerActivity theDialer;
|
||||||
|
|
||||||
|
@ -193,10 +190,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow);
|
mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow);
|
||||||
mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
|
mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
|
||||||
mAddressLayout = (LinearLayout) findViewById(R.id.Addresslayout);
|
mAddressLayout = (View) findViewById(R.id.Addresslayout);
|
||||||
mInCallAddressLayout = (LinearLayout) findViewById(R.id.IncallAddressLayout);
|
mInCallAddressLayout = (View) findViewById(R.id.IncallAddressLayout);
|
||||||
mMute = (ToggleButton)findViewById(R.id.mic_mute_button);
|
mMute = (ToggleImageButton)findViewById(R.id.mic_mute_button);
|
||||||
mSpeaker = (ToggleButton)findViewById(R.id.speaker_button);
|
mSpeaker = (ToggleImageButton)findViewById(R.id.speaker_button);
|
||||||
|
|
||||||
mInCallControlRow.setVisibility(View.GONE);
|
mInCallControlRow.setVisibility(View.GONE);
|
||||||
mInCallAddressLayout.setVisibility(View.GONE);
|
mInCallAddressLayout.setVisibility(View.GONE);
|
||||||
|
@ -218,11 +215,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mAddressLayout.setVisibility(View.GONE);
|
mAddressLayout.setVisibility(View.GONE);
|
||||||
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
||||||
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
||||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0
|
|
||||||
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
|
|
||||||
, 0
|
|
||||||
, 0);
|
|
||||||
|
|
||||||
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
||||||
if (DisplayName!=null) {
|
if (DisplayName!=null) {
|
||||||
mDisplayNameView.setText(DisplayName);
|
mDisplayNameView.setText(DisplayName);
|
||||||
|
@ -241,35 +233,25 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
public void onCheckedChanged(ToggleImageButton button, boolean isChecked) {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
lc.muteMic(false);
|
lc.muteMic(false);
|
||||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.mic_active, 0, 0);
|
|
||||||
} else {
|
} else {
|
||||||
lc.muteMic(true);
|
lc.muteMic(true);
|
||||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.mic_muted, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
public void onCheckedChanged(ToggleImageButton buttonView, boolean isChecked) {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
routeAudioToSpeaker();
|
routeAudioToSpeaker();
|
||||||
mSpeaker.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.speaker_32_on, 0, 0);
|
|
||||||
} else {
|
} else {
|
||||||
routeAudioToReceiver();
|
routeAudioToReceiver();
|
||||||
mSpeaker.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.speaker_32_off, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mZero = (Button) findViewById(R.id.Button00) ;
|
mZero = (Button) findViewById(R.id.Button00) ;
|
||||||
|
|
87
src/org/linphone/component/ToggleImageButton.java
Normal file
87
src/org/linphone/component/ToggleImageButton.java
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
ToggleImageButton.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone.component;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Image button storing a checked state to display alternating drawables.
|
||||||
|
* The "toggled" drawable is displayed when button is down / checked.
|
||||||
|
* The "untoggled" drawable is displayed when button is up / unchecked.
|
||||||
|
*
|
||||||
|
* @author Guillaume Beraudo
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ToggleImageButton extends ImageButton implements OnClickListener {
|
||||||
|
private static final String namespace = null;
|
||||||
|
private boolean checked;
|
||||||
|
private Drawable on;
|
||||||
|
private Drawable off;
|
||||||
|
private OnCheckedChangeListener onCheckedChangeListener;
|
||||||
|
|
||||||
|
public ToggleImageButton(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
on = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "toggled", -1));
|
||||||
|
off = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "untoggled", -1));
|
||||||
|
setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
|
||||||
|
setOnClickListener(this);
|
||||||
|
handleCheckChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setChecked(boolean checked) {
|
||||||
|
this.checked = checked;
|
||||||
|
handleCheckChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChecked() {
|
||||||
|
return checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handleCheckChanged() {
|
||||||
|
setImageDrawable(checked?on:off);
|
||||||
|
requestLayout();
|
||||||
|
invalidate();
|
||||||
|
if (onCheckedChangeListener != null) onCheckedChangeListener.onCheckedChanged(this, checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
|
||||||
|
onCheckedChangeListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface OnCheckedChangeListener {
|
||||||
|
void onCheckedChanged(ToggleImageButton button, boolean checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
checked = !checked;
|
||||||
|
handleCheckChanged();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue