Go to home on back key.
This commit is contained in:
parent
1cbb4e265a
commit
427b252651
1 changed files with 44 additions and 22 deletions
|
@ -15,18 +15,19 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.linphone.ui.AddVideoButton;
|
|
||||||
import org.linphone.ui.HangCallButton;
|
import org.linphone.ui.HangCallButton;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -69,9 +70,6 @@ public class IncallActivity extends Activity implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsedTime = (TextView) findViewById(R.id.incallElapsedTime);
|
elapsedTime = (TextView) findViewById(R.id.incallElapsedTime);
|
||||||
|
|
||||||
AddVideoButton addVideoButton = (AddVideoButton) findViewById(R.id.AddVideo);
|
|
||||||
addVideoButton.setOnAlreadyInVideoCallListener(DialerActivity.instance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -97,17 +95,16 @@ public class IncallActivity extends Activity implements OnClickListener {
|
||||||
task = new TimerTask() {
|
task = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (LinphoneManager.getLc().isIncall()) {
|
if (!LinphoneManager.getLc().isIncall()) return;
|
||||||
final int duration = LinphoneManager.getLc().getCurrentCall().getDuration();
|
|
||||||
if (duration != 0) {
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
elapsedTime.setText(String.valueOf(duration));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
final int duration = LinphoneManager.getLc().getCurrentCall().getDuration();
|
||||||
|
if (duration == 0) return;
|
||||||
|
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
elapsedTime.setText(String.valueOf(duration));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,4 +121,29 @@ public class IncallActivity extends Activity implements OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Go to home on Back key
|
||||||
|
@Override
|
||||||
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
|
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||||
|
if (event.getAction() == KeyEvent.ACTION_DOWN
|
||||||
|
&& event.getRepeatCount() == 0) {
|
||||||
|
// Tell the framework to start tracking this event.
|
||||||
|
numpad.getKeyDispatcherState().startTracking(event, this);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||||
|
numpad.getKeyDispatcherState().handleUpEvent(event);
|
||||||
|
if (event.isTracking() && !event.isCanceled()) {
|
||||||
|
startActivity(new Intent()
|
||||||
|
.setAction(Intent.ACTION_MAIN)
|
||||||
|
.addCategory(Intent.CATEGORY_HOME));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.dispatchKeyEvent(event);
|
||||||
|
} else {
|
||||||
|
return super.dispatchKeyEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue