|
|
@ -19,6 +19,7 @@ import android.os.PowerManager; |
|
|
|
import android.provider.Settings; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
|
import android.view.View; |
|
|
|
import android.webkit.CookieManager; |
|
|
|
import android.webkit.URLUtil; |
|
|
|
import android.webkit.WebSettings; |
|
|
@ -32,6 +33,9 @@ import androidx.annotation.RequiresApi; |
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
import androidx.core.app.ActivityCompat; |
|
|
|
|
|
|
|
import com.google.android.material.floatingactionbutton.FloatingActionButton; |
|
|
|
import com.google.android.material.snackbar.Snackbar; |
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
private static final int WRITE_EXTERNAL_STORAGE_RC = 100; |
|
|
@ -44,17 +48,33 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
private static final String NUMERO_TEL_RADIO = "+33375411456"; |
|
|
|
private MediaPlayerService player; |
|
|
|
boolean serviceBound = false; |
|
|
|
private FloatingActionButton fbtn_live; |
|
|
|
|
|
|
|
static { |
|
|
|
versionName = BuildConfig.VERSION_NAME; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface"}) |
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
setContentView(R.layout.activity_main); |
|
|
|
|
|
|
|
fbtn_live = (FloatingActionButton) findViewById(R.id.fbtn_live); |
|
|
|
fbtn_live.setOnClickListener(new View.OnClickListener() { |
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O) |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
Snackbar.make(v, "Vous écoutez Radio Mercure en direct", Snackbar.LENGTH_LONG) |
|
|
|
.setAction("Action", null).show(); |
|
|
|
lectureAudio("https://live.radiomercure.fr/on-air/live"); |
|
|
|
fbtn_live.setImageResource(android.R.drawable.ic_media_pause); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//------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) |
|
|
@ -206,11 +226,11 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
startActivity(intent); |
|
|
|
return true; |
|
|
|
|
|
|
|
case R.id.live: |
|
|
|
lectureAudio("https://live.radiomercure.fr/on-air/live"); |
|
|
|
//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; |
|
|
|
//return true; |
|
|
|
|
|
|
|
default: |
|
|
|
return super.onOptionsItemSelected(item); |
|
|
@ -259,11 +279,11 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
playerIntent.putExtra("media",chemin); |
|
|
|
startService(playerIntent); |
|
|
|
bindService(playerIntent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
|
|
Toast.makeText(this, "Lecture", Toast.LENGTH_SHORT).show(); |
|
|
|
//Toast.makeText(this, "Lecture", Toast.LENGTH_SHORT).show(); |
|
|
|
} else { |
|
|
|
onDestroy(); |
|
|
|
reStart(); |
|
|
|
; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|