From 035ce2c75695ef4de750e1f134dd6763d34b7ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96nnerby?= Date: Tue, 25 Aug 2009 06:16:59 +0000 Subject: [PATCH] Stop playback when there are incoming phonecalls. Larger text in categoryView. --- src/android/AndroidManifest.xml | 2 ++ src/android/res/layout/category_list_item.xml | 2 +- src/android/src/org/musikcube/Service.java | 21 +++++++++++++++++++ .../src/org/musikcube/core/Library.java | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml index 75d40e1f0..8aa3130ac 100644 --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -26,4 +26,6 @@ + + \ No newline at end of file diff --git a/src/android/res/layout/category_list_item.xml b/src/android/res/layout/category_list_item.xml index f158cf710..21fdb1477 100644 --- a/src/android/res/layout/category_list_item.xml +++ b/src/android/res/layout/category_list_item.xml @@ -7,6 +7,6 @@ + android:layout_height="wrap_content" android:textSize="28sp" android:fadingEdge="horizontal" android:maxLines="1" android:fadingEdgeLength="10sp"/> \ No newline at end of file diff --git a/src/android/src/org/musikcube/Service.java b/src/android/src/org/musikcube/Service.java index ec620fb0b..792ec32f9 100644 --- a/src/android/src/org/musikcube/Service.java +++ b/src/android/src/org/musikcube/Service.java @@ -14,6 +14,10 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.IBinder; +import android.telephony.PhoneStateListener; +import android.telephony.TelephonyManager; +import android.view.View; +import android.view.View.OnClickListener; /** * @author doy @@ -49,7 +53,24 @@ public class Service extends android.app.Service { this.player.service = this; this.library = org.musikcube.core.Library.GetInstance(); this.library.Startup(this); + + TelephonyManager telephony = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); + telephony.listen(phoneStateListener,PhoneStateListener.LISTEN_CALL_STATE); } + + private PhoneStateListener phoneStateListener = new PhoneStateListener() { + public void onCallStateChanged(int state,String incomingNumber){ + switch(state) + { + case TelephonyManager.CALL_STATE_RINGING: + Intent intent = new Intent(Service.this, org.musikcube.Service.class); + intent.putExtra("org.musikcube.Service.action", "stop"); + startService(intent); + break; + } + } + }; + /* (non-Javadoc) * @see android.app.Service#onStart(android.content.Intent, int) diff --git a/src/android/src/org/musikcube/core/Library.java b/src/android/src/org/musikcube/core/Library.java index 2722b7752..88dbe9c63 100644 --- a/src/android/src/org/musikcube/core/Library.java +++ b/src/android/src/org/musikcube/core/Library.java @@ -206,7 +206,6 @@ public class Library implements Runnable{ } //Log.v("Library::socket","Successfully connected to "+this.host+":"+this.queryPort); - this.SetStatus(STATUS_AUTHENTICATING); doep.xml.Reader reader = new doep.xml.Reader(this.socket.getInputStream()); //Log.v("Library::run","Reader started"); @@ -318,6 +317,8 @@ public class Library implements Runnable{ public void WriteThread(WriterThreadHelper thread){ //Log.v("Library::WriteThread","Started"); + this.SetStatus(STATUS_AUTHENTICATING); + try{ doep.xml.Writer writer = new doep.xml.Writer(this.socket.getOutputStream()); {