v0.7.4b: restructured initialization logic into new android module

A lot of cleanup is needed for this, but everything works
This commit is contained in:
Evan Debenham
2019-08-01 15:35:27 -04:00
parent 11efd1d0c3
commit 3e815a3165
202 changed files with 483 additions and 313 deletions
@@ -21,13 +21,7 @@
package com.watabou.noosa.audio;
import android.app.Activity;
import android.os.Build;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import com.badlogic.gdx.Gdx;
import com.watabou.noosa.Game;
public enum Music {
@@ -114,29 +108,4 @@ public enum Music {
return enabled;
}
//FIXME android-specific code, that is also broken by being part of this class.
public static void setMuteListener(){
//versions lower than this require READ_PHONE_STATE permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
TelephonyManager mgr =
(TelephonyManager) Game.instance.getSystemService(Activity.TELEPHONY_SERVICE);
mgr.listen(new PhoneStateListener(){
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
if( state == TelephonyManager.CALL_STATE_RINGING ) {
INSTANCE.pause();
} else if( state == TelephonyManager.CALL_STATE_IDLE ) {
if (!Game.instance.isPaused()) {
INSTANCE.resume();
}
}
super.onCallStateChanged(state, incomingNumber);
}
}, PhoneStateListener.LISTEN_CALL_STATE);
}
}
}