Material design
Support Android 12
This commit is contained in:
parent
73138ca9fc
commit
a9ca882531
@ -16,12 +16,12 @@ android {
|
||||
|
||||
}
|
||||
}
|
||||
compileSdk 31
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "fr.svpro.radiomercure"
|
||||
minSdk 22
|
||||
targetSdk 31
|
||||
minSdk 26
|
||||
targetSdk 32
|
||||
versionCode 120
|
||||
versionName '1.2.0'
|
||||
|
||||
@ -44,9 +44,9 @@ android {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
|
@ -2,6 +2,7 @@ package fr.svpro.radiomercure;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DownloadManager;
|
||||
@ -26,16 +27,22 @@ import android.webkit.URLUtil;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@ -57,42 +64,65 @@ public class MainActivity extends AppCompatActivity {
|
||||
versionName = BuildConfig.VERSION_NAME;
|
||||
}
|
||||
|
||||
|
||||
//Navigation
|
||||
private NavigationView navigationView;
|
||||
private DrawerLayout drawerLayout;
|
||||
private Toolbar toolbar;
|
||||
|
||||
@SuppressLint({"SetJavaScriptEnabled", "WrongViewCast", "JavascriptInterface"})
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
getSupportActionBar().hide();
|
||||
|
||||
final SwipeRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
|
||||
refreshLayout.setColorSchemeColors(Color.BLUE);
|
||||
//menu
|
||||
navigationView = findViewById(R.id.navigation_drawer);
|
||||
|
||||
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
|
||||
// Navigation drawer item click listener
|
||||
switch (item.getItemId()) {
|
||||
case R.id.live:
|
||||
Toast.makeText(MainActivity.this, "Vous écoutez Radio Mercure en direct", Toast.LENGTH_SHORT).show();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
lectureAudio("https://live.radiomercure.fr/on-air/live");
|
||||
} else {
|
||||
Toast.makeText(MainActivity.this, "Votre version d'Android n'est pas compatible", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
|
||||
// your action when refresh layout swiped
|
||||
web.clearCache(true);
|
||||
reStart();
|
||||
refreshLayout.setRefreshing(false);
|
||||
case R.id.tel:
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse("tel:" + NUMERO_TEL_RADIO));
|
||||
startActivity(intent);
|
||||
break;
|
||||
|
||||
case R.id.refresh:
|
||||
web.clearCache(true);
|
||||
reStart();
|
||||
break;
|
||||
|
||||
case R.id.exit:
|
||||
System.exit(0);
|
||||
break;
|
||||
}
|
||||
|
||||
drawerLayout.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//toolbar
|
||||
toolbar = findViewById(R.id.toolBar);
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
toolbar.setTitle("Radio Mercure");
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
//------Demande d'autorisation de désactiver l'optimisation de la batterie------//
|
||||
AlertDialog.Builder dialogOptBattery = new AlertDialog.Builder(this);
|
||||
@ -211,51 +241,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.option,menu);
|
||||
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);
|
||||
reStart();
|
||||
//web.reload();
|
||||
//Toast.makeText(this, "Rechargement...", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
||||
case R.id.exit:
|
||||
System.exit(0);
|
||||
return true;
|
||||
|
||||
case R.id.about:
|
||||
|
||||
dialog.show();
|
||||
return true;
|
||||
|
||||
case R.id.tel:
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse("tel:" + NUMERO_TEL_RADIO));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (web.canGoBack()) {
|
||||
|
@ -62,7 +62,7 @@ public class MediaPlayerService extends Service implements MediaPlayer.OnComplet
|
||||
Log.d("MediaPlayer Error", "MEDIA ERROR SERVER DIED " + extra);
|
||||
break;
|
||||
case MediaPlayer.MEDIA_ERROR_UNKNOWN:
|
||||
Toast.makeText(this, "Erreur inconnue", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "Streaming indisponible, veuillez réessayer plus tard", Toast.LENGTH_SHORT).show();
|
||||
Log.d("MediaPlayer Error", "MEDIA ERROR UNKNOWN " + extra);
|
||||
break;
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/logo_menu.png
Normal file
BIN
app/src/main/res/drawable/logo_menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 362 KiB |
@ -1,40 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:openDrawer="start"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/wv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="62dp">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
</WebView>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/wv"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
style="@style/ShapeAppearanceOverlay.Material3.NavigationView.Item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</WebView>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorPrimaryVariant"
|
||||
app:titleTextColor="@color/white"
|
||||
app:popupTheme="@style/Theme.RadioMercure" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fbtn_live"
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/navigation_drawer"
|
||||
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:focusable="true"
|
||||
android:src="@android:drawable/ic_media_play"
|
||||
app:tint="@null" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
android:background="@color/white"
|
||||
app:menu="@menu/menu_drawer">
|
||||
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.navigation.NavigationView>
|
||||
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
9
app/src/main/res/layout/drawer_header.xml
Normal file
9
app/src/main/res/layout/drawer_header.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="170dp"
|
||||
android:background="@drawable/presentation_pstore"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"/>
|
31
app/src/main/res/menu/menu_drawer.xml
Normal file
31
app/src/main/res/menu/menu_drawer.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/live"
|
||||
android:icon="@android:drawable/ic_media_play"
|
||||
android:title="@string/menu_live" />
|
||||
|
||||
<item
|
||||
android:id="@+id/tel"
|
||||
android:icon="@android:drawable/stat_sys_phone_call"
|
||||
android:title="@string/menu_phone" />
|
||||
|
||||
</group>
|
||||
|
||||
<item android:title="Options">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/refresh"
|
||||
android:icon="@android:drawable/ic_popup_sync"
|
||||
android:title="@string/menu_reload" />
|
||||
|
||||
<item
|
||||
android:id="@+id/exit"
|
||||
android:icon="@android:drawable/ic_lock_power_off"
|
||||
android:title="@string/menu_exit" />
|
||||
</menu>
|
||||
|
||||
</item>
|
||||
</menu>
|
5
app/src/main/res/values/style.xml
Normal file
5
app/src/main/res/values/style.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="navigation_drawer_open">Ouvrir le menu</string>
|
||||
<string name="navigation_drawer_close">Fermer le menu</string>
|
||||
</resources>
|
BIN
screenshots/logo-menu.png
Normal file
BIN
screenshots/logo-menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 362 KiB |
Loading…
x
Reference in New Issue
Block a user