Compare commits
15 Commits
67026b7e44
...
2ec076c9c9
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ec076c9c9 | |||
| c618afe059 | |||
| 2c7755d6d0 | |||
| df73c3dd0e | |||
| 112b2417d1 | |||
| 20781e17de | |||
| 2502b088e4 | |||
| 7bfb2f0f66 | |||
| 2d1f2aaeb2 | |||
| 3b5c49e078 | |||
| feef41012d | |||
| ce1a6e55c8 | |||
| 905edce2b8 | |||
| 03ff4dbf8e | |||
| 989c979d47 |
17
.idea/deploymentTargetDropDown.xml
generated
17
.idea/deploymentTargetDropDown.xml
generated
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\samue\.android\avd\Nexus_6_API_29.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2022-03-31T21:48:44.877184900Z" />
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@@ -4,8 +4,8 @@
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/drawable/ic_launcher_background.xml" value="0.2355" />
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/layout/about_dialog.xml" value="0.2" />
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/layout/activity_main.xml" value="0.11402623612512613" />
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/layout/about_dialog.xml" value="0.5" />
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/layout/activity_main.xml" value="0.1755050505050505" />
|
||||
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/menu/option.xml" value="0.33" />
|
||||
</map>
|
||||
</option>
|
||||
|
||||
@@ -22,8 +22,8 @@ android {
|
||||
applicationId "fr.svpro.radiomercure"
|
||||
minSdk 22
|
||||
targetSdk 31
|
||||
versionCode 103
|
||||
versionName '1.0.3'
|
||||
versionCode 110
|
||||
versionName '1.1.0'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -23,6 +27,7 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name=".MediaPlayerService"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -2,24 +2,33 @@ package fr.svpro.radiomercure;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.URLUtil;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
@@ -28,27 +37,54 @@ public class MainActivity extends AppCompatActivity {
|
||||
private static final int WRITE_EXTERNAL_STORAGE_RC = 100;
|
||||
private WebView web;
|
||||
private String url, userAgent, contentDisposition, mimeType;
|
||||
private Menu menu;
|
||||
private Dialog dialog;
|
||||
private TextView tv_close;
|
||||
private TextView tv_version;
|
||||
private static String versionName;
|
||||
private static final String NUMERO_TEL_RADIO = "+33375411456";
|
||||
private MediaPlayerService player;
|
||||
boolean serviceBound = false;
|
||||
|
||||
static {
|
||||
versionName = BuildConfig.VERSION_NAME;
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface"})
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
//-------------A revoir-----------//
|
||||
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
//--------------------------------//
|
||||
|
||||
//------Demande d'autorisation de désactiver l'optimisation de la batterie------//
|
||||
AlertDialog.Builder dialogOptBattery = new AlertDialog.Builder(this);
|
||||
dialogOptBattery.setMessage(R.string.dialog_battery_msg)
|
||||
.setTitle(R.string.dialog_battery_titre);
|
||||
|
||||
dialogOptBattery.setPositiveButton(R.string.dialog_button_oui, (dialog12, id) -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
||||
//intent.setData(Uri.parse("package:"+ getApplicationInfo().packageName));
|
||||
startActivity(intent);
|
||||
|
||||
});
|
||||
dialogOptBattery.setNegativeButton(R.string.dialog_button_non, (dialog1, id) -> {
|
||||
// User cancelled the dialog
|
||||
Toast.makeText(this, "Annulation par l'utilisateur", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
AlertDialog alertDialog = dialogOptBattery.create();
|
||||
|
||||
PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
if (!powerManager.isIgnoringBatteryOptimizations(getApplication().getPackageName())) {
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------//
|
||||
|
||||
//WebBiew affichage du site
|
||||
web = findViewById(R.id.wv);
|
||||
web.setWebViewClient(new WebViewClient());
|
||||
web.getSettings().setUserAgentString("Mozilla/5.0 "+ getApplicationInfo().packageName);
|
||||
web.getSettings().setJavaScriptEnabled(true);
|
||||
web.getSettings().setAllowFileAccess(true);
|
||||
@@ -62,11 +98,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
web.getSettings().setUseWideViewPort(true);
|
||||
web.getSettings().setLoadWithOverviewMode(true);
|
||||
web.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
|
||||
//Log.w("AGENT", web.getSettings().getUserAgentString());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
web.getSettings().setAllowFileAccessFromFileURLs(true);
|
||||
}
|
||||
web.loadUrl("https://www.radiomercure.fr");
|
||||
web.loadUrl("https://www.radiomercure.fr/?playerbar-pageinicial");
|
||||
|
||||
web.setDownloadListener((url, userAgent, contentDisposition, mimeType, contentLength) -> {
|
||||
MainActivity.this.url = url;
|
||||
@@ -141,14 +178,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id){
|
||||
case R.id.refresh:
|
||||
web.clearCache(true);
|
||||
web.reload();
|
||||
Toast.makeText(this, "Rechargement...", Toast.LENGTH_SHORT).show();
|
||||
reStart();
|
||||
//web.reload();
|
||||
//Toast.makeText(this, "Rechargement...", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
||||
case R.id.exit:
|
||||
@@ -156,6 +196,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
return true;
|
||||
|
||||
case R.id.about:
|
||||
|
||||
dialog.show();
|
||||
return true;
|
||||
|
||||
@@ -165,6 +206,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
return true;
|
||||
|
||||
case R.id.live:
|
||||
lectureAudio("https://live.radiomercure.fr/on-air/live");
|
||||
//Toast.makeText(this, "Vous écoutez Radio Mercure en direct", Toast.LENGTH_SHORT).show();
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -180,4 +227,67 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void reStart() {
|
||||
Intent intent = getIntent();
|
||||
finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
//Binding this Client to the AudioPlayer Service
|
||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
// We've bound to LocalService, cast the IBinder and get LocalService instance
|
||||
MediaPlayerService.LocalBinder binder = (MediaPlayerService.LocalBinder) service;
|
||||
player = binder.getService();
|
||||
serviceBound = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
serviceBound = false;
|
||||
}
|
||||
};
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private void lectureAudio(String chemin) {
|
||||
//Check is service is active
|
||||
if (!serviceBound) {
|
||||
Intent playerIntent = new Intent(this, MediaPlayerService.class);
|
||||
playerIntent.putExtra("media",chemin);
|
||||
startService(playerIntent);
|
||||
bindService(playerIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||
Toast.makeText(this, "Lecture", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
onDestroy();
|
||||
reStart();
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putBoolean("ServiceState", serviceBound);
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
serviceBound = savedInstanceState.getBoolean("ServiceState");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (serviceBound) {
|
||||
unbindService(serviceConnection);
|
||||
//service is active
|
||||
player.stopSelf();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
268
app/src/main/java/fr/svpro/radiomercure/MediaPlayerService.java
Normal file
268
app/src/main/java/fr/svpro/radiomercure/MediaPlayerService.java
Normal file
@@ -0,0 +1,268 @@
|
||||
package fr.svpro.radiomercure;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public class MediaPlayerService extends Service implements MediaPlayer.OnCompletionListener,
|
||||
MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnSeekCompleteListener,
|
||||
MediaPlayer.OnInfoListener, MediaPlayer.OnBufferingUpdateListener,
|
||||
|
||||
AudioManager.OnAudioFocusChangeListener {
|
||||
|
||||
private AudioManager audioManager;
|
||||
|
||||
// Binder given to clients
|
||||
private final IBinder iBinder = new LocalBinder();
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return iBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBufferingUpdate(MediaPlayer mp, int percent) {
|
||||
//Invoked indicating buffering status of
|
||||
//a media resource being streamed over the network.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
//Invoked when playback of a media source has completed.
|
||||
stopMedia();
|
||||
//stop the service
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
//Handle errors
|
||||
@Override
|
||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||
//Invoked when there has been an error during an asynchronous operation
|
||||
switch (what) {
|
||||
case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
|
||||
Toast.makeText(this, "Données corrompues", Toast.LENGTH_SHORT).show();
|
||||
Log.d("MediaPlayer Error", "MEDIA ERROR NOT VALID FOR PROGRESSIVE PLAYBACK " + extra);
|
||||
break;
|
||||
case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
|
||||
Toast.makeText(this, "Serveur innacessible", Toast.LENGTH_SHORT).show();
|
||||
Log.d("MediaPlayer Error", "MEDIA ERROR SERVER DIED " + extra);
|
||||
break;
|
||||
case MediaPlayer.MEDIA_ERROR_UNKNOWN:
|
||||
Toast.makeText(this, "Erreur inconnue", Toast.LENGTH_SHORT).show();
|
||||
Log.d("MediaPlayer Error", "MEDIA ERROR UNKNOWN " + extra);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInfo(MediaPlayer mp, int what, int extra) {
|
||||
//Invoked to communicate some info.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
playMedia();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSeekComplete(MediaPlayer mp) {
|
||||
//Invoked indicating the completion of a seek operation.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioFocusChange(int focusState) {
|
||||
//Invoked when the audio focus of the system is updated.
|
||||
switch (focusState) {
|
||||
case AudioManager.AUDIOFOCUS_GAIN:
|
||||
// resume playback
|
||||
if (mediaPlayer == null) initMediaPlayer();
|
||||
else if (!mediaPlayer.isPlaying()) mediaPlayer.start();
|
||||
mediaPlayer.setVolume(1.0f, 1.0f);
|
||||
break;
|
||||
case AudioManager.AUDIOFOCUS_LOSS:
|
||||
// Lost focus for an unbounded amount of time: stop playback and release media player
|
||||
if (mediaPlayer.isPlaying()) mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
break;
|
||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
||||
// Lost focus for a short time, but we have to stop
|
||||
// playback. We don't release the media player because playback
|
||||
// is likely to resume
|
||||
if (mediaPlayer.isPlaying()) mediaPlayer.pause();
|
||||
break;
|
||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
||||
// Lost focus for a short time, but it's ok to keep playing
|
||||
// at an attenuated level
|
||||
if (mediaPlayer.isPlaying()) mediaPlayer.setVolume(0.1f, 0.1f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requestAudioFocus() {
|
||||
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
|
||||
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
|
||||
//Focus gained
|
||||
return true;
|
||||
}
|
||||
//Could not gain focus
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeAudioFocus() {
|
||||
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED ==
|
||||
audioManager.abandonAudioFocus(this);
|
||||
}
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
public MediaPlayerService getService() {
|
||||
return MediaPlayerService.this;
|
||||
}
|
||||
}
|
||||
|
||||
private MediaPlayer mediaPlayer;
|
||||
private String fichierMedia;
|
||||
|
||||
private void initMediaPlayer() {
|
||||
mediaPlayer = new MediaPlayer();
|
||||
//Set up MediaPlayer event listeners
|
||||
mediaPlayer.setOnCompletionListener(this);
|
||||
mediaPlayer.setOnErrorListener(this);
|
||||
mediaPlayer.setOnPreparedListener(this);
|
||||
mediaPlayer.setOnBufferingUpdateListener(this);
|
||||
mediaPlayer.setOnSeekCompleteListener(this);
|
||||
mediaPlayer.setOnInfoListener(this);
|
||||
//mediaPlayer.setScreenOnWhilePlaying(true);
|
||||
//Reset so that the MediaPlayer is not pointing to another data source
|
||||
mediaPlayer.reset();
|
||||
|
||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
try {
|
||||
mediaPlayer.setDataSource(fichierMedia);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
stopSelf();
|
||||
}
|
||||
mediaPlayer.prepareAsync();
|
||||
}
|
||||
|
||||
//Used to pause/resume MediaPlayer
|
||||
private int resumePosition;
|
||||
|
||||
private void playMedia() {
|
||||
if (!mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopMedia() {
|
||||
if (mediaPlayer == null) return;
|
||||
if (mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void pauseMedia() {
|
||||
if (mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.pause();
|
||||
resumePosition = mediaPlayer.getCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
private void resumeMedia() {
|
||||
if (!mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.seekTo(resumePosition);
|
||||
mediaPlayer.start();
|
||||
}
|
||||
}
|
||||
|
||||
//The system calls this method when an activity, requests the service be started
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
try {
|
||||
//An audio file is passed to the service through putExtra();
|
||||
fichierMedia = intent.getExtras().getString("media");
|
||||
} catch (NullPointerException e) {
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
//Request audio focus
|
||||
if (requestAudioFocus() == false) {
|
||||
//Could not gain focus
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
if (fichierMedia != null && fichierMedia != "")
|
||||
initMediaPlayer();
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mediaPlayer != null) {
|
||||
stopMedia();
|
||||
mediaPlayer.release();
|
||||
}
|
||||
removeAudioFocus();
|
||||
}
|
||||
|
||||
//Gestion des appels tel entrant : suspension de la lecture
|
||||
private boolean ongoingCall = false;
|
||||
private PhoneStateListener phoneStateListener;
|
||||
private TelephonyManager telephonyManager;
|
||||
|
||||
private void callStateListener() {
|
||||
// Get the telephony manager
|
||||
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
//Starting listening for PhoneState changes
|
||||
phoneStateListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber) {
|
||||
switch (state) {
|
||||
//if at least one call exists or the phone is ringing
|
||||
//pause the MediaPlayer
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
if (mediaPlayer != null) {
|
||||
pauseMedia();
|
||||
ongoingCall = true;
|
||||
}
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
// Phone idle. Start playing.
|
||||
if (mediaPlayer != null) {
|
||||
if (ongoingCall) {
|
||||
ongoingCall = false;
|
||||
resumeMedia();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
// Register the listener with the telephony manager
|
||||
// Listen for changes to the device call state.
|
||||
telephonyManager.listen(phoneStateListener,
|
||||
PhoneStateListener.LISTEN_CALL_STATE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -9,5 +8,8 @@
|
||||
<WebView
|
||||
android:id="@+id/wv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</WebView>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -10,11 +10,18 @@
|
||||
android:id="@+id/refresh"
|
||||
android:title="@string/menu_reload" />
|
||||
|
||||
<item
|
||||
android:id="@+id/live"
|
||||
android:icon="@android:drawable/ic_media_play"
|
||||
app:showAsAction="ifRoom"
|
||||
android:title="@string/menu_live" />
|
||||
|
||||
<item
|
||||
android:id="@+id/tel"
|
||||
android:icon="@android:drawable/stat_sys_phone_call"
|
||||
android:title="@string/menu_phone"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/exit"
|
||||
android:icon="@android:drawable/ic_lock_power_off"
|
||||
|
||||
@@ -2,8 +2,20 @@
|
||||
<string name="app_name">Radio Mercure</string>
|
||||
<string name="menu_exit">Quitter</string>
|
||||
<string name="menu_phone">Appeler la Radio</string>
|
||||
<string name="menu_live">Ecouter en direct</string>
|
||||
<string name="menu_reload">Relancer...</string>
|
||||
<string name="menu_about">A Propos...</string>
|
||||
<string name="dialog_close">Fermer</string>
|
||||
<string name="dialog_version">RADIO MERCURE - Version </string>
|
||||
<string name="dialog_battery_msg"><![CDATA[Dans le cadre d\'une utilisation optimiale de RADIO MERCURE en arrière-plan notamment pour la lecture du direct,
|
||||
il est nécessaire de retirer l\'application de la liste des applications optimisées.
|
||||
En cliquant sur \"Oui\", la fenêtre \"Optimiser la batterie\" apparaît puis :\n
|
||||
- Selectionnez \"Tout\"\n
|
||||
- Recherchez \"Radio Mercure\"\n
|
||||
- Déchochez\n
|
||||
- Revenez en arrière jusqu\'à afficher l\'application
|
||||
]]></string>
|
||||
<string name="dialog_battery_titre">Désactiver l\'optimisation de la batterie ?</string>
|
||||
<string name="dialog_button_oui">Oui</string>
|
||||
<string name="dialog_button_non">Non</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user