ajout activity infos radios
This commit is contained in:
parent
d24275b396
commit
51438a9a53
@ -2,18 +2,21 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@drawable/baseline_radio_24"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:roundIcon="@drawable/baseline_radio_24"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.JsonTest"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".InfoActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
|
64
app/src/main/java/fr/svpro/rsd/InfoActivity.java
Normal file
64
app/src/main/java/fr/svpro/rsd/InfoActivity.java
Normal file
@ -0,0 +1,64 @@
|
||||
package fr.svpro.rsd;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
public class InfoActivity extends AppCompatActivity {
|
||||
|
||||
TextView nomStation, tags, language;
|
||||
ImageView logoStation;
|
||||
Button bShare, bSite;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_info);
|
||||
setTitle("Infos Radio");
|
||||
|
||||
logoStation = (ImageView) findViewById(R.id.ivLogo);
|
||||
nomStation = (TextView) findViewById(R.id.name);
|
||||
tags = (TextView) findViewById(R.id.tags);
|
||||
language = (TextView) findViewById(R.id.lang);
|
||||
bShare = (Button) findViewById(R.id.share);
|
||||
bSite = (Button) findViewById(R.id.siteWeb);
|
||||
|
||||
String faviconURL = getIntent().getStringExtra("logo");
|
||||
Picasso.get().load(faviconURL).error(R.drawable.baseline_radio_24).into(logoStation);
|
||||
nomStation.setText(getIntent().getStringExtra("name"));
|
||||
tags.setText(getIntent().getStringExtra("tags"));
|
||||
language.setText(getIntent().getStringExtra("lang"));
|
||||
String siteWeb = getIntent().getStringExtra("site");
|
||||
String streamURL = getIntent().getStringExtra("stream");
|
||||
|
||||
bShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse(streamURL),"audio/*");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
bSite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(siteWeb));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -65,10 +65,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
private final static String URL = "https://radiobrowser.weblib.re/json/stations";
|
||||
private ListView listView;
|
||||
private EditText etRecherche;
|
||||
private Button bRecherche, bShare, bSite;
|
||||
private Button bRecherche;
|
||||
public RadioButton rechNom, rechPays;
|
||||
public String siteWeb;
|
||||
private String nomStation, streamURL, byFiltre, faviconURL;
|
||||
private String nomStation, streamURL, byFiltre, faviconURL, tagStation, langStation;
|
||||
public ImageView ivLogo;
|
||||
ArrayList<HashMap<String, String>> arrayList;
|
||||
|
||||
@ -83,8 +83,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
etRecherche = (EditText) findViewById(R.id.etRecherche);
|
||||
listView = (ListView) findViewById(R.id.listView);
|
||||
bRecherche = (Button) findViewById(R.id.recherche);
|
||||
bShare = (Button) findViewById(R.id.share);
|
||||
bSite = (Button) findViewById(R.id.siteWeb);
|
||||
/*bShare = (Button) findViewById(R.id.share);
|
||||
bSite = (Button) findViewById(R.id.siteWeb);*/
|
||||
rechNom = (RadioButton) findViewById(R.id.rech_nom);
|
||||
rechPays = (RadioButton) findViewById(R.id.rech_pays);
|
||||
ivLogo = (ImageView) findViewById(R.id.ivLogo);
|
||||
@ -93,8 +93,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
setTitle("Recherche en cours....");
|
||||
bShare.setVisibility(View.INVISIBLE);
|
||||
bSite.setVisibility(View.INVISIBLE);
|
||||
/*bShare.setVisibility(View.INVISIBLE);
|
||||
bSite.setVisibility(View.INVISIBLE);*/
|
||||
parse();
|
||||
}
|
||||
});
|
||||
@ -178,22 +178,31 @@ public class MainActivity extends AppCompatActivity {
|
||||
siteWeb = arrayList.get(position).get("homepage");
|
||||
streamURL = arrayList.get(position).get("url");
|
||||
faviconURL = arrayList.get(position).get("favicon");
|
||||
if (Objects.requireNonNull(arrayList.get(position).get("favicon")).isEmpty()) {
|
||||
Picasso.get().load(R.drawable.ic_launcher_foreground).into(ivLogo);
|
||||
} else {
|
||||
Picasso.get().load(faviconURL).into(ivLogo);
|
||||
}
|
||||
tagStation = arrayList.get(position).get("tags");
|
||||
langStation = arrayList.get(position).get("language");
|
||||
//Picasso.get().load(faviconURL).error(R.drawable.baseline_radio_24).into(ivLogo);
|
||||
|
||||
setTitle(nomStation);
|
||||
bShare.setVisibility(View.VISIBLE);
|
||||
/*bShare.setVisibility(View.VISIBLE);
|
||||
if (Objects.requireNonNull(arrayList.get(position).get("homepage")).isEmpty()) {
|
||||
bSite.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
bSite.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}*/
|
||||
|
||||
Intent intent = new Intent(MainActivity.this,InfoActivity.class);
|
||||
intent.putExtra("logo",faviconURL);
|
||||
intent.putExtra("name",nomStation);
|
||||
intent.putExtra("tags",tagStation);
|
||||
intent.putExtra("lang",langStation);
|
||||
intent.putExtra("site",siteWeb);
|
||||
intent.putExtra("stream",streamURL);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
bShare.setOnClickListener(new View.OnClickListener() {
|
||||
/* bShare.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
@ -208,7 +217,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
intent.setData(Uri.parse(siteWeb));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
5
app/src/main/res/drawable/baseline_radio_24.xml
Normal file
5
app/src/main/res/drawable/baseline_radio_24.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#AF1515"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M3.24,6.15C2.51,6.43 2,7.17 2,8v12c0,1.1 0.89,2 2,2h16c1.11,0 2,-0.9 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2L8.3,6l8.26,-3.34L15.88,1 3.24,6.15zM7,20c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM20,12h-2v-2h-2v2L4,12L4,8h16v4z"/>
|
||||
</vector>
|
78
app/src/main/res/layout/activity_info.xml
Normal file
78
app/src/main/res/layout/activity_info.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?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="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivLogo"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:src="@drawable/ic_launcher_foreground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:text="Name"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_weight="0.5"
|
||||
android:textSize="30dp"
|
||||
android:textStyle="bold"
|
||||
android:textAlignment="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black" />
|
||||
<TextView
|
||||
android:id="@+id/tags"
|
||||
android:text="tags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#5d5d5d"
|
||||
android:textSize="20dp"
|
||||
android:textAlignment="center"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/lang"
|
||||
android:text="lang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#5d5d5d"
|
||||
android:textSize="20dp"
|
||||
android:textAlignment="center"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/siteWeb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Site WEB..."
|
||||
android:visibility="visible" />
|
||||
<Button
|
||||
android:id="@+id/share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Partager..."
|
||||
android:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -91,13 +91,13 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
<!-- <ImageView
|
||||
android:id="@+id/ivLogo"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_launcher_foreground" />
|
||||
|
||||
android:src="@drawable/baseline_radio_24" />
|
||||
-->
|
||||
<ListView
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user