Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple changes as per the commits. #1174

Merged
merged 24 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4ea1fe6
Refining the lRecyclerView in adapter for the null view
vdbhb59 Sep 30, 2023
d55aabd
Commented out Preference.OnPreferenceClickListener as deprecated
vdbhb59 Sep 30, 2023
5951369
Using Local Index as a fall back for stations
vdbhb59 Sep 30, 2023
9477dc0
Recording status
vdbhb59 Sep 30, 2023
0ab65dc
Corrected the log option changed in error
vdbhb59 Sep 30, 2023
3d4b013
Lenient in query length
vdbhb59 Sep 30, 2023
653f9dd
Create ic_expand_more_white_24dp.xml
vdbhb59 Sep 30, 2023
98a27b3
View changes
vdbhb59 Sep 30, 2023
a67362d
Extra space removed
vdbhb59 Sep 30, 2023
60749fb
Corrected layout code
vdbhb59 Sep 30, 2023
93772ca
Countries/Regions
vdbhb59 Sep 30, 2023
023c8b0
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
058397d
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
ac3b926
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
21ce679
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
8eb1e00
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
c6a6269
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
6868748
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
d8f57bf
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
d8106d7
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
565b3fd
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
59fa6c3
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
53f72ea
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
c43af44
Fix media browser service and enable android auto support
vdbhb59 Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>

<!-- Use this intent filter to get voice searches, like "Play The Beatles" -->
<!--<intent-filter>-->
<!--<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />-->
<!--<category android:name="android.intent.category.DEFAULT" />-->
<!--</intent-filter>-->
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service
android:name="net.programmierecke.radiodroid2.service.PlayerService"
Expand All @@ -77,14 +76,14 @@
</intent-filter>
</service>

<!-- <service-->
<!-- android:name="net.programmierecke.radiodroid2.service.RadioDroidBrowserService"-->
<!-- android:exported="true"-->
<!-- tools:ignore="ExportedService">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.media.browse.MediaBrowserService" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service
<!-- android:name="net.programmierecke.radiodroid2.service.RadioDroidBrowserService"
<!-- android:exported="true"
<!-- tools:ignore="ExportedService">
<!-- <intent-filter>
<!-- <action android:name="android.media.browse.MediaBrowserService" />
<!-- </intent-filter>
<!-- </service>

<receiver
android:name="net.programmierecke.radiodroid2.alarm.AlarmReceiver"
Expand Down Expand Up @@ -113,13 +112,13 @@
</intent-filter>
</receiver>

<!--<meta-data-->
<!--android:name="com.google.android.gms.car.application"-->
<!--android:resource="@xml/automotive_app_desc" />-->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />

<!--<meta-data-->
<!--android:name="com.google.android.gms.car.notification.SmallIcon"-->
<!--android:resource="@mipmap/ic_launcher" />-->
<meta-data
android:name="com.google.android.gms.car.notification.SmallIcon"
android:resource="@mipmap/ic_launcher" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.programmierecke.radiodroid2

import android.content.Context
import net.programmierecke.radiodroid2.station.DataRadioStation

class FallbackStationsManager(ctx: Context?) : StationSaveManager(ctx) {
override fun Load() {
listStations.clear()
val str = context.resources
.openRawResource(R.raw.fallback_stations)
.bufferedReader()
.use { it.readText() }
val arr = DataRadioStation.DecodeJson(str)
listStations.addAll(arr)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public void RefreshListGui() {

if (BuildConfig.DEBUG) Log.d(TAG, "stations count:" + historyManager.listStations.size());

adapter.updateList(null, historyManager.listStations);
if( adapter != null )
adapter.updateList(null, historyManager.listStations);
}

@Override
Expand Down Expand Up @@ -214,4 +215,4 @@ public void onDestroyView() {
super.onDestroyView();
rvStations.setAdapter(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ public boolean onPreferenceClick(Preference preference) {
}
});

findPreference("show_about").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
((ActivityMain) getActivity()).getToolbar().setTitle(R.string.settings_about);
FragmentAbout f = new FragmentAbout();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.containerView, f).addToBackStack(String.valueOf(FRAGMENT_FROM_BACKSTACK)).commit();
return false;
}
});
// findPreference("show_about").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
// @Override
// public boolean onPreferenceClick(Preference preference) {
// ((ActivityMain) getActivity()).getToolbar().setTitle(R.string.settings_about);
// FragmentAbout f = new FragmentAbout();
// FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
// fragmentTransaction.replace(R.id.containerView, f).addToBackStack(String.valueOf(FRAGMENT_FROM_BACKSTACK)).commit();
// return false;
// }
// });
}

Preference batPref = getPreferenceScreen().findPreference(getString(R.string.key_ignore_battery_optimization));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private String getCountryCode() {
return countryCode;
}
countryCode = ctx.getResources().getConfiguration().locale.getCountry();
addresses[IDX_LOCAL] = "json/stations/bycountrycodeexact/?order=clickcount&reverse=true";
Log.d("MAIN", "Locale: '" + countryCode + "'");
if (countryCode != null && countryCode.length() == 2) {
return countryCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class RadioDroidApp extends MultiDexApplication {
private HistoryManager historyManager;
private FavouriteManager favouriteManager;
private RecordingsManager recordingsManager;
private FallbackStationsManager fallbackStationsManager;
private RadioAlarmManager alarmManager;
private TvChannelManager tvChannelManager;

Expand Down Expand Up @@ -95,6 +96,7 @@ public void onCreate() {

historyManager = new HistoryManager(this);
favouriteManager = new FavouriteManager(this);
fallbackStationsManager = new FallbackStationsManager(this);
recordingsManager = new RecordingsManager();
alarmManager = new RadioAlarmManager(this);

Expand Down Expand Up @@ -129,6 +131,10 @@ public void rebuildHttpClient() {
httpClient = builder.build();
}

public FallbackStationsManager getFallbackStationsManager() {
return fallbackStationsManager;
}

public HistoryManager getHistoryManager() {
return historyManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.collection.ArraySet;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import net.programmierecke.radiodroid2.station.DataRadioStation;
Expand Down Expand Up @@ -59,6 +60,8 @@ protected void setStationStatusListener(StationStatusListener stationStatusListe
}

public void add(DataRadioStation station) {
if (station.queue == null)
station.queue = this;
listStations.add(station);
Save();

Expand Down Expand Up @@ -93,6 +96,8 @@ public void replaceList(List<DataRadioStation> stations_new) {
}

public void addFront(DataRadioStation station) {
if (station.queue == null)
station.queue = this;
listStations.add(0, station);
Save();

Expand All @@ -103,6 +108,15 @@ public void addFront(DataRadioStation station) {
}
}

public void addAll(List<DataRadioStation> stations) {
if (stations == null)
return;
for (DataRadioStation station : stations) {
station.queue = this;
}
listStations.addAll(stations);
}

public DataRadioStation getLast() {
if (!listStations.isEmpty()) {
return listStations.get(listStations.size() - 1);
Expand Down Expand Up @@ -199,6 +213,7 @@ public int remove(String id) {
}

public void restore(DataRadioStation station, int pos) {
station.queue = this;
listStations.add(pos, station);
Save();

Expand Down Expand Up @@ -301,6 +316,9 @@ void Load() {
String str = sharedPref.getString(getSaveId(), null);
if (str != null) {
List<DataRadioStation> arr = DataRadioStation.DecodeJson(str);
for (DataRadioStation station : arr) {
station.queue = this;
}
listStations.addAll(arr);
if (hasInvalidUuids() && Utils.hasAnyConnection(context)) {
refreshStationsFromServer();
Expand Down Expand Up @@ -496,6 +514,7 @@ public boolean SaveM3UWriter(Writer bw) {
List<DataRadioStation> LoadM3UInternal(String filePath, String fileName) {
try {
File f = new File(filePath, fileName);
ArraySet<DataRadioStation> loadedItems = null;
FileReader fr = new FileReader(f);
return LoadM3UReader(fr);
} catch (Exception e) {
Expand All @@ -518,7 +537,11 @@ List<DataRadioStation> LoadM3UReader(Reader reader) {
if (line.startsWith(M3U_PREFIX)) {
try {
String uuid = line.substring(M3U_PREFIX.length()).trim();
listUuids.add(uuid);
DataRadioStation station = Utils.getStationByUuid(httpClient, context, uuid);
if (station != null) {
station.queue = this;
loadedItems.add(station);
}
} catch (Exception e) {
Log.e("LOAD", e.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public int getItemCount() {
}

void openRecording(DataRecording theData) {
ProgressDialog dialog = ProgressDialog.show(context, "Loading...", "Please wait...", true, false);
String path = RecordingsManager.getRecordDir() + "/" + theData.Name;
if (BuildConfig.DEBUG) {
Log.d(TAG, "play: " + path);
Expand All @@ -121,9 +122,11 @@ void openRecording(DataRecording theData) {
String packageName = resolveInfo.activityInfo.packageName;
context.grantUriPermission(packageName, fileUri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
dialog.dismiss();
}
}

context.startActivity(i);
dialog.dismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ public void onPlayFromMediaId(String mediaId, Bundle extras) {

@Override
public void onPlayFromSearch(String query, Bundle extras) {
// remove voice search residues like " with radiodroid"
query = query.replaceAll("(?i) \\w+ radio\\s*droid.*", "");

DataRadioStation station = ((RadioDroidApp) context.getApplicationContext()).getFavouriteManager().getBestNameMatch(query);
if (station == null)
station = ((RadioDroidApp) context.getApplicationContext()).getHistoryManager().getBestNameMatch(query);
if (station != null) {
GetRealLinkAndPlayTask playTask = new GetRealLinkAndPlayTask(context, station, playerService);
playTask.execute();
}
if (station == null)
station = ((RadioDroidApp) context.getApplicationContext()).getFallbackStationsManager().getBestNameMatch(query);
GetRealLinkAndPlayTask playTask = new GetRealLinkAndPlayTask(context, station, playerService);
playTask.execute();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public void onCreate() {
Intent startActivityIntent = new Intent(itsContext.getApplicationContext(), ActivityMain.class);
mediaSession.setSessionActivity(PendingIntent.getActivity(itsContext.getApplicationContext(), 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT | pendingIntentFlag));

mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
setMediaPlaybackState(PlaybackStateCompat.STATE_NONE);

RadioDroidApp radioDroidApp = (RadioDroidApp) getApplication();
trackHistoryRepository = radioDroidApp.getTrackHistoryRepository();
Expand Down Expand Up @@ -660,8 +660,8 @@ public void next() {
return;
}

RadioDroidApp radioDroidApp = (RadioDroidApp) getApplication();
DataRadioStation station = radioDroidApp.getFavouriteManager().getNextById(currentStation.StationUuid);
setMediaPlaybackState(PlaybackStateCompat.STATE_SKIPPING_TO_NEXT);
DataRadioStation station = currentStation.queue.getNextById(currentStation.StationUuid);

if (station != null) {
if (radioPlayer.isPlaying()) {
Expand All @@ -679,8 +679,7 @@ public void previous() {
return;
}

RadioDroidApp radioDroidApp = (RadioDroidApp) getApplication();
DataRadioStation station = radioDroidApp.getFavouriteManager().getPreviousById(currentStation.StationUuid);
DataRadioStation station = currentStation.queue.getPreviousById(currentStation.StationUuid);
if (station != null) {
if (radioPlayer.isPlaying()) {
playWithoutWarnings(station);
Expand Down Expand Up @@ -794,19 +793,22 @@ private void setMediaPlaybackState(int state) {
playbackStateBuilder.setErrorMessage(PlaybackStateCompat.ERROR_CODE_ACTION_ABORTED, error);
}

playbackStateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 0);
playbackStateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);
mediaSession.setPlaybackState(playbackStateBuilder.build());
}

private void enableMediaSession() {
if (BuildConfig.DEBUG) Log.d(TAG, "enabling media session.");
if (!mediaSession.isActive()) {
if (BuildConfig.DEBUG) Log.d(TAG, "enabling media session.");

IntentFilter becomingNoisyFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
registerReceiver(becomingNoisyReceiver, becomingNoisyFilter);
IntentFilter becomingNoisyFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
registerReceiver(becomingNoisyReceiver, becomingNoisyFilter);

mediaSession.setActive(true);
mediaSession.setActive(true);

setMediaPlaybackState(PlaybackStateCompat.STATE_NONE);
setMediaPlaybackState(PlaybackStateCompat.STATE_NONE);
}
}

private void disableMediaSession() {
Expand Down Expand Up @@ -1007,6 +1009,7 @@ private void updateNotification(PlayState playState) {

if (mediaSession != null) {
final MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, -1);
builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, currentStation.Name);
builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, liveInfo.getArtist());
builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, liveInfo.getTrack());
Expand Down
Loading
Loading