diff --git a/res/layout-land/dialer.xml b/res/layout-land/dialer.xml index cc395e052..30b1d79e9 100644 --- a/res/layout-land/dialer.xml +++ b/res/layout-land/dialer.xml @@ -7,12 +7,12 @@ android:layout_height="wrap_content" android:layout_width="fill_parent"> - - + android:text="<"/> @@ -23,12 +23,12 @@ android:id="@+id/DisplayNameView" android:clickable="false" android:cursorVisible="false" android:gravity="center" android:layout_width="fill_parent"> - - - + - + - @@ -7,11 +9,11 @@ android:layout_height="wrap_content" android:layout_width="fill_parent"> - - + android:textStyle="bold" android:text="<" android:layout_gravity="top" android:textColor="@android:color/black"/> @@ -22,13 +24,12 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" android:lines="1" android:id="@+id/DisplayNameView" android:clickable="false" - android:cursorVisible="false" android:layout_gravity="center" - > - + - @@ -41,39 +42,39 @@ - - - - - - - - - - - - @@ -82,14 +83,14 @@ - + - + diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index f7d4265ee..9ccb8cee4 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone; -import org.linphone.component.ToggleImageButton; -import org.linphone.component.ToggleImageButton.OnCheckedChangeListener; import org.linphone.core.AndroidCameraRecordManager; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; @@ -31,7 +29,11 @@ import org.linphone.core.LinphoneFriend; import org.linphone.core.LinphoneProxyConfig; import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCore.EcCalibratorStatus; +import org.linphone.ui.AddressText; import org.linphone.ui.Digit; +import org.linphone.ui.EraseButton; +import org.linphone.ui.MuteMicButton; +import org.linphone.ui.SpeakerButton; import android.app.Activity; import android.app.AlertDialog; @@ -41,7 +43,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.media.AudioManager; import android.media.MediaPlayer; -import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.os.Vibrator; @@ -51,8 +52,6 @@ import android.text.Html; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; -import android.view.View.OnLongClickListener; -import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TableRow; @@ -61,17 +60,16 @@ import android.widget.Toast; public class DialerActivity extends Activity implements LinphoneCoreListener { - private TextView mAddress; + private AddressText mAddress; private TextView mDisplayNameView; private TextView mStatus; private ImageButton mCall; - private ImageButton mDecline; - private ImageButton mHangup; - private Button mErase; + private View mDecline; + private View mHangup; - private ToggleImageButton mMute; - private ToggleImageButton mSpeaker; + private MuteMicButton mMute; + private SpeakerButton mSpeaker; private LinearLayout mCallControlRow; private TableRow mInCallControlRow; @@ -80,8 +78,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { private static DialerActivity theDialer; - private String mDisplayName; - private AudioManager mAudioManager; private PowerManager.WakeLock mWakeLock; private SharedPreferences mPref; private ImageButton mAddVideo; @@ -105,15 +101,11 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { return theDialer; } - public void setContactAddress(String aContact,String aDisplayName) { - mAddress.setText(aContact); - mDisplayName = aDisplayName; - } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialer); - mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE)); + LinphoneManager.getInstance().setAudioManager(((AudioManager)getSystemService(Context.AUDIO_SERVICE))); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone"); @@ -121,30 +113,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { try { - mAddress = (TextView) findViewById(R.id.SipUri); + mAddress = (AddressText) findViewById(R.id.SipUri); mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView); - mErase = (Button)findViewById(R.id.Erase); + ((EraseButton) findViewById(R.id.Erase)).setAddressView(mAddress); - mErase.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - mDisplayName=null; - if (mAddress.length() >0) { - int lBegin = mAddress.getSelectionStart(); - if (lBegin == -1) { - lBegin = mAddress.getEditableText().length()-1; - } - if (lBegin >0) { - mAddress.getEditableText().delete(lBegin-1,lBegin); - } - } - } - }); - mErase.setOnLongClickListener(new OnLongClickListener() { - public boolean onLongClick(View arg0) { - mAddress.getEditableText().clear(); - return true; - } - }); mAddVideo = (ImageButton) findViewById(R.id.AddVideo); mAddVideo.setOnClickListener(new OnClickListener() { @@ -161,46 +133,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mCall = (ImageButton) findViewById(R.id.Call); mCall.setOnClickListener(new OnClickListener() { public void onClick(View v) { - LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); - if (lLinphoneCore.isInComingInvitePending()) { - try { - lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall()); - } catch (LinphoneCoreException e) { - lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall()); - Toast toast = Toast.makeText(DialerActivity.this - ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString()) - ,Toast.LENGTH_LONG); - toast.show(); - } - return; - } - if (mAddress.getText().length() >0) { - newOutgoingCall(mAddress.getText().toString(),mDisplayName); - } + callOrAcceptIncommingCall(); } - }); - mDecline= (ImageButton) findViewById(R.id.Decline); - mHangup = (ImageButton) findViewById(R.id.HangUp); - - OnClickListener lHangupListener = new OnClickListener() { - - public void onClick(View v) { - LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); - lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall()); - } - - }; - mHangup.setOnClickListener(lHangupListener); - mDecline.setOnClickListener(lHangupListener); + mDecline= findViewById(R.id.Decline); + mDecline.setEnabled(false); + + mHangup = findViewById(R.id.HangUp); mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow); mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow); mAddressLayout = (View) findViewById(R.id.Addresslayout); mInCallAddressLayout = (View) findViewById(R.id.IncallAddressLayout); - mMute = (ToggleImageButton)findViewById(R.id.mic_mute_button); - mSpeaker = (ToggleImageButton)findViewById(R.id.speaker_button); + mMute = (MuteMicButton)findViewById(R.id.mic_mute_button); + mSpeaker = (SpeakerButton)findViewById(R.id.speaker_button); /* if (Hacks.isGalaxyS()) { // Galaxy S doesn't handle audio routing properly // so disabling it totally @@ -208,16 +155,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { }*/ mInCallControlRow.setVisibility(View.GONE); mInCallAddressLayout.setVisibility(View.GONE); - mDecline.setEnabled(false); - if (LinphoneService.isready() && getIntent().getData() != null && !LinphoneService.instance().getLinphoneCore().isIncall()) { + + if (LinphoneService.isready() && getIntent().getData() != null && !LinphoneService.getLc().isIncall()) { newOutgoingCall(getIntent().getData().toString().substring("tel://".length())); getIntent().setData(null); } + if (LinphoneService.isready()) { - LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); - if (lLinphoneCore.isIncall()) { - if(lLinphoneCore.isInComingInvitePending()) { - callPending(lLinphoneCore.getCurrentCall()); + LinphoneCore lc = LinphoneService.getLc(); + if (lc.isIncall()) { + if(lc.isInComingInvitePending()) { + callPending(lc.getCurrentCall()); } else { mCall.setEnabled(false); mHangup.setEnabled(!mCall.isEnabled()); @@ -227,43 +175,19 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mAddressLayout.setVisibility(View.GONE); mInCallAddressLayout.setVisibility(View.VISIBLE); - String DisplayName = lLinphoneCore.getRemoteAddress().getDisplayName(); + String DisplayName = lc.getRemoteAddress().getDisplayName(); if (DisplayName!=null) { mDisplayNameView.setText(DisplayName); } else { - mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName()); + mDisplayNameView.setText(lc.getRemoteAddress().getUserName()); } - configureMuteAndSpeakerButtons(); + loadMicAndSpeakerUiStateFromLibrary(); LinphoneActivity.instance().startProxymitySensor(); mWakeLock.acquire(); } } } - - - mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() { - public void onCheckedChanged(ToggleImageButton button, boolean isChecked) { - LinphoneCore lc = LinphoneService.instance().getLinphoneCore(); - if (isChecked) { - lc.muteMic(true); - } else { - lc.muteMic(false); - } - } - }); - - - mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() { - public void onCheckedChanged(ToggleImageButton buttonView, boolean isChecked) { - if (isChecked) { - LinphoneManager.routeAudioToSpeaker(mAudioManager); - } else { - LinphoneManager.routeAudioToReceiver(mAudioManager); - } - } - }); - initializeDigits(); @@ -280,19 +204,40 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { if (!accountCheckingDone) checkAccountsSettings(); } + private void callOrAcceptIncommingCall() { + LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); + if (lLinphoneCore.isInComingInvitePending()) { + try { + lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall()); + } catch (LinphoneCoreException e) { + lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall()); + Toast toast = Toast.makeText(DialerActivity.this + ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString()) + ,Toast.LENGTH_LONG); + toast.show(); + } + return; + } + if (mAddress.getText().length() >0) { + newOutgoingCall(mAddress.getText().toString(), mAddress.getDisplayedName()); + } + } + private void initializeDigits() { - ((Digit) findViewById(R.id.Button00)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button01)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button02)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button03)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button04)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button05)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button06)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button07)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button08)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.Button09)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.ButtonStar)).setWidgets(mAddress, mDisplayName); - ((Digit) findViewById(R.id.ButtonHash)).setWidgets(mAddress, mDisplayName); + if (findViewById(R.id.Digit00) == null) return; // In landscape view, no keyboard + + ((Digit) findViewById(R.id.Digit00)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit1)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit2)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit3)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit4)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit5)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit6)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit7)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit8)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.Digit9)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.DigitStar)).setAddressWidget(mAddress); + ((Digit) findViewById(R.id.DigitHash)).setAddressWidget(mAddress); } private boolean checkDefined(int ... keys) { @@ -377,7 +322,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); savedInstanceState.putString(CURRENT_ADDRESS, mAddress.getText().toString()); - if (mDisplayName != null) savedInstanceState.putString(CURRENT_DISPLAYNAME,mDisplayName); + if (mAddress.getDisplayedName() != null) + savedInstanceState.putString(CURRENT_DISPLAYNAME,mAddress.getDisplayedName()); } @Override @@ -387,7 +333,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { if (lAddress != null && mAddress != null) { mAddress.setText(lAddress); } - mDisplayName = savedInstanceState.getString(CURRENT_DISPLAYNAME); + mAddress.setDisplayedName(savedInstanceState.getString(CURRENT_DISPLAYNAME)); } @Override protected void onDestroy() { @@ -400,27 +346,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { protected void onResume() { super.onResume(); } - public void authInfoRequested(LinphoneCore lc, String realm, String username) { - // TODO Auto-generated method stub - - } - public void byeReceived(LinphoneCore lc, String from) { - // TODO Auto-generated method stub - - } - public void displayMessage(LinphoneCore lc, String message) { - // TODO Auto-generated method stub - - } + + public void authInfoRequested(LinphoneCore lc, String realm, String username) /*nop*/{} + public void byeReceived(LinphoneCore lc, String from) {/*nop*/} + public void displayMessage(LinphoneCore lc, String message) {/*nop*/} + public void displayWarning(LinphoneCore lc, String message) {/*nop*/} + public void displayStatus(LinphoneCore lc, String message) { mStatus.setText(message); } - public void displayWarning(LinphoneCore lc, String message) { - // TODO Auto-generated method stub - - } - public void globalState(LinphoneCore lc, LinphoneCore.GlobalState state, String message) { + public void globalState(LinphoneCore lc, LinphoneCore.GlobalState state, String message) { if (state == LinphoneCore.GlobalState.GlobalOn) { mCall.setEnabled(!lc.isIncall()); mHangup.setEnabled(!mCall.isEnabled()); @@ -436,6 +372,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } } } + + private void startVideoView(int requestCode) { Intent lIntent = new Intent(); lIntent.setClass(this, VideoCallActivity.class); @@ -447,7 +385,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { if (state == LinphoneCall.State.OutgoingInit) { enterIncalMode(lc); - LinphoneManager.routeAudioToReceiver(mAudioManager); + LinphoneManager.getInstance().routeAudioToReceiver(); } else if (state == LinphoneCall.State.IncomingReceived) { resetCameraFromPreferences(); callPending(call); @@ -469,13 +407,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } } } - } - public void show(LinphoneCore lc) { - // TODO Auto-generated method stub - - } + public void show(LinphoneCore lc) {/*nop*/} private void enterIncalMode(LinphoneCore lc) { mCallControlRow.setVisibility(View.GONE); @@ -496,26 +430,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mDisplayNameView.setText(lc.getRemoteAddress().toString()); } } - configureMuteAndSpeakerButtons(); + loadMicAndSpeakerUiStateFromLibrary(); - if (mSpeaker.isChecked()) { - LinphoneManager.routeAudioToSpeaker(mAudioManager); + if (mSpeaker.isSpeakerOn()) { + LinphoneManager.getInstance().routeAudioToSpeaker(); } else { - LinphoneManager.routeAudioToReceiver(mAudioManager); + LinphoneManager.getInstance().routeAudioToReceiver(); } setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); LinphoneActivity.instance().startProxymitySensor(); if (!mWakeLock.isHeld()) mWakeLock.acquire(); } - private void configureMuteAndSpeakerButtons() { - mMute.setChecked(LinphoneService.instance().getLinphoneCore().isMicMuted()); - if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) - || Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) { - mSpeaker.setChecked(true); - } else { - mSpeaker.setChecked(false); - } + private void loadMicAndSpeakerUiStateFromLibrary() { + mMute.setChecked(LinphoneService.getLc().isMicMuted()); + mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn()); } private void resetCameraFromPreferences() { @@ -539,8 +468,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { finishActivity(VIDEO_VIEW_ACTIVITY); } if (mWakeLock.isHeld())mWakeLock.release(); - mSpeaker.setChecked(false); - LinphoneManager.routeAudioToReceiver(mAudioManager); + mSpeaker.setSpeakerOn(false); + LinphoneManager.getInstance().routeAudioToReceiver(); BandwidthManager.getInstance().setUserRestriction(false); resetCameraFromPreferences(); LinphoneActivity.instance().stopProxymitySensor(); @@ -561,13 +490,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } - public synchronized void newOutgoingCall(String aTo, String displayName) { + private synchronized void newOutgoingCall(String aTo, String displayName) { String lto = aTo; if (aTo.contains(OutgoingCallReceiver.TAG)) { lto = aTo.replace(OutgoingCallReceiver.TAG, ""); } mAddress.setText(lto); - mDisplayName = displayName; + mAddress.setDisplayedName(displayName); LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); if (lLinphoneCore.isIncall()) { Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG); @@ -584,7 +513,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { toast.show(); return; } - lAddress.setDisplayName(mDisplayName); + lAddress.setDisplayName(mAddress.getDisplayedName()); try { boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); @@ -601,28 +530,22 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } } - public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, - String url) { - // TODO Auto-generated method stub - - } - public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) { - // TODO Auto-generated method stub - - } + public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {} + public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {} public void textReceived(LinphoneCore lc, LinphoneChatRoom cr, - LinphoneAddress from, String message) { - // TODO Auto-generated method stub - - } + LinphoneAddress from, String message) {} private AndroidCameraRecordManager getVideoManager() { return AndroidCameraRecordManager.getInstance(); } public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status, - int delay_ms, Object data) { - + int delay_ms, Object data) {} + + public void setContactAddress(String aContact,String aDisplayName) { + mAddress.setText(aContact); + mAddress.setDisplayedName(aDisplayName); } } + diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 5e7c9e3a7..5e9fac29f 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -1,5 +1,5 @@ /* -BigManager.java +LinphoneManager.java Copyright (C) 2010 Belledonne Communications, Grenoble, France This program is free software; you can redistribute it and/or @@ -20,30 +20,33 @@ package org.linphone; import org.linphone.core.LinphoneCore; +import android.content.SharedPreferences; import android.media.AudioManager; import android.os.Build; public class LinphoneManager { private static LinphoneManager instance; + private AudioManager mAudioManager; - public static void routeAudioToSpeaker(AudioManager mAudioManager) { + + public void routeAudioToSpeaker() { if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*4 &&mAudioManager.isSpeakerphoneOn(); + } + + + } diff --git a/src/org/linphone/component/ToggleImageButton.java b/src/org/linphone/component/ToggleImageButton.java index 8cfa1e917..21cd620f2 100644 --- a/src/org/linphone/component/ToggleImageButton.java +++ b/src/org/linphone/component/ToggleImageButton.java @@ -36,7 +36,8 @@ import android.widget.ImageButton; * */ public class ToggleImageButton extends ImageButton implements OnClickListener { - private static final String namespace = null; +// private static final String ns = "http://schemas.android.com/apk/res/linphone"; + private static final String ns = null; private boolean checked; private Drawable stateChecked; private Drawable stateUnChecked; @@ -44,8 +45,8 @@ public class ToggleImageButton extends ImageButton implements OnClickListener { public ToggleImageButton(Context context, AttributeSet attrs) { super(context, attrs); - stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "checked", -1)); - stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "unchecked", -1)); + stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "checked", -1)); + stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "unchecked", -1)); setBackgroundColor(Color.TRANSPARENT); setOnClickListener(this); diff --git a/src/org/linphone/ui/AddressText.java b/src/org/linphone/ui/AddressText.java new file mode 100644 index 000000000..7c70dcb5a --- /dev/null +++ b/src/org/linphone/ui/AddressText.java @@ -0,0 +1,49 @@ +/* +AddressView.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.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.EditText; + +public class AddressText extends EditText { + + private String displayedName; + + public AddressText(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void clearDisplayedName() { + displayedName = ""; + } + + public String getDisplayedName() { + return displayedName; + } + + public void setContactAddress(String uri, String displayedName) { + this.displayedName = displayedName; + setText(uri); + } + + public void setDisplayedName(String displayedName) { + this.displayedName = displayedName; + } +} diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java index ef93b9371..6e70d7d51 100644 --- a/src/org/linphone/ui/Digit.java +++ b/src/org/linphone/ui/Digit.java @@ -26,12 +26,10 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.Button; -import android.widget.TextView; public class Digit extends Button { - private TextView mAddress; - private String mDisplayName; // FIXME not linked with dialeractivity + private AddressText mAddress; private final void createWidget(Context context, AttributeSet attrs) { String ns = "http://schemas.android.com/apk/res/android"; @@ -89,7 +87,7 @@ public class Digit extends Button { if (lBegin >=0) { mAddress.getEditableText().insert(lBegin,mKeyCode); } - mDisplayName=""; + mAddress.clearDisplayedName(); } } public boolean onTouch(View v, MotionEvent event) { @@ -112,8 +110,7 @@ public class Digit extends Button { }; - public void setWidgets(TextView address, String displayName) { + public void setAddressWidget(AddressText address) { mAddress = address; - mDisplayName = displayName; } } diff --git a/src/org/linphone/ui/EraseButton.java b/src/org/linphone/ui/EraseButton.java new file mode 100644 index 000000000..122535062 --- /dev/null +++ b/src/org/linphone/ui/EraseButton.java @@ -0,0 +1,60 @@ +/* +EraseButton.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.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnLongClickListener; +import android.widget.Button; + +public class EraseButton extends Button implements OnClickListener, OnLongClickListener{ + + private AddressText address; + + public EraseButton(Context context, AttributeSet attrs) { + super(context, attrs); + setOnClickListener(this); + setOnLongClickListener(this); + } + + public void onClick(View v) { + address.clearDisplayedName(); + if (address.getText().length() >0) { + int lBegin = address.getSelectionStart(); + if (lBegin == -1) { + lBegin = address.getEditableText().length()-1; + } + if (lBegin >0) { + address.getEditableText().delete(lBegin-1,lBegin); + } + } + } + + public boolean onLongClick(View v) { + address.getEditableText().clear(); + return true; + } + + public void setAddressView(AddressText view) { + address = view; + } + +} diff --git a/src/org/linphone/ui/HangCallButton.java b/src/org/linphone/ui/HangCallButton.java new file mode 100644 index 000000000..9f51741c2 --- /dev/null +++ b/src/org/linphone/ui/HangCallButton.java @@ -0,0 +1,41 @@ +/* +SpeakerButton.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.ui; + +import org.linphone.LinphoneManager; +import org.linphone.core.LinphoneCore; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageButton; + +public class HangCallButton extends ImageButton implements OnClickListener { + + public HangCallButton(Context context, AttributeSet attrs) { + super(context, attrs); + setOnClickListener(this); + } + + public void onClick(View v) { + LinphoneCore lc = LinphoneManager.getLc(); + lc.terminateCall(lc.getCurrentCall()); + } +} diff --git a/src/org/linphone/ui/MuteMicButton.java b/src/org/linphone/ui/MuteMicButton.java new file mode 100644 index 000000000..50e6f9dbc --- /dev/null +++ b/src/org/linphone/ui/MuteMicButton.java @@ -0,0 +1,52 @@ +/* +SpeakerButton.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.ui; + +import org.linphone.LinphoneManager; +import org.linphone.component.ToggleImageButton; +import org.linphone.component.ToggleImageButton.OnCheckedChangeListener; + +import android.content.Context; +import android.util.AttributeSet; + +public class MuteMicButton extends ToggleImageButton implements OnCheckedChangeListener { + + public MuteMicButton(Context context, AttributeSet attrs) { + super(context, attrs); + setOnCheckedChangeListener(this); + } + + + public boolean isMicMuted() { + return isChecked(); + } + + public void setMicMuted(boolean state) { + setChecked(state); + } + + + public void onCheckedChanged(ToggleImageButton button, boolean checked) { + if (checked) { + LinphoneManager.getLc().muteMic(true); + } else { + LinphoneManager.getLc().muteMic(false); + } + } +} diff --git a/src/org/linphone/ui/SpeakerButton.java b/src/org/linphone/ui/SpeakerButton.java new file mode 100644 index 000000000..14bbb8c3c --- /dev/null +++ b/src/org/linphone/ui/SpeakerButton.java @@ -0,0 +1,54 @@ +/* +SpeakerButton.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.ui; + +import org.linphone.LinphoneManager; +import org.linphone.component.ToggleImageButton; +import org.linphone.component.ToggleImageButton.OnCheckedChangeListener; + +import android.content.Context; +import android.util.AttributeSet; + +public class SpeakerButton extends ToggleImageButton implements OnCheckedChangeListener { + + public SpeakerButton(Context context, AttributeSet attrs) { + super(context, attrs); + setOnCheckedChangeListener(this); + } + + + public boolean isSpeakerOn() { + return isChecked(); + } + + public void setSpeakerOn(boolean state) { + setChecked(state); + } + + + public void onCheckedChanged(ToggleImageButton button, boolean checked) { + if (checked) { + LinphoneManager.getInstance().routeAudioToSpeaker(); + } else { + LinphoneManager.getInstance().routeAudioToReceiver(); + } + } + + +}