Browse Source

Ajout FLoatActionButton

master
Samuel Vermeulen 2 months ago
parent
commit
37ed83810a
  1. 2
      .idea/misc.xml
  2. 30
      app/src/main/java/fr/svpro/radiomercure/MainActivity.java
  3. 16
      app/src/main/res/layout/activity_main.xml
  4. 4
      app/src/main/res/menu/option.xml

2
.idea/misc.xml

@ -5,7 +5,7 @@
<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.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/layout/activity_main.xml" value="0.33" />
<entry key="..\:/Users/samue/GIT/RadioMercure/app/src/main/res/menu/option.xml" value="0.33" />
</map>
</option>

30
app/src/main/java/fr/svpro/radiomercure/MainActivity.java

@ -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();
;
}
}

16
app/src/main/res/layout/activity_main.xml

@ -1,10 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fbtn_live"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:backgroundTint="#FF5722"
android:clickable="true"
android:contentDescription="@string/menu_live"
android:src="@android:drawable/ic_media_play"
app:tint="@null"
android:focusable="true" />
<WebView
android:id="@+id/wv"
android:layout_width="match_parent"

4
app/src/main/res/menu/option.xml

@ -10,11 +10,11 @@
android:id="@+id/refresh"
android:title="@string/menu_reload" />
<item
<!-- <item
android:id="@+id/live"
android:icon="@android:drawable/ic_media_play"
app:showAsAction="ifRoom"
android:title="@string/menu_live" />
android:title="@string/menu_live" /> -->
<item
android:id="@+id/tel"

Loading…
Cancel
Save