Commit 064699c4 authored by Geoffrey Métais's avatar Geoffrey Métais

Implement option to show all artists

parent 2917d1d1
......@@ -287,9 +287,9 @@ AndroidMediaLibrary::album(int64_t albumId)
}
std::vector<medialibrary::ArtistPtr>
AndroidMediaLibrary::artists()
AndroidMediaLibrary::artists(bool includeAll)
{
return p_ml->artists();
return p_ml->artists(includeAll);
}
medialibrary::ArtistPtr
......
......@@ -65,7 +65,7 @@ public:
std::vector<medialibrary::MediaPtr> audioFiles( medialibrary::SortingCriteria sort = medialibrary::SortingCriteria::Default, bool desc = false );
std::vector<medialibrary::AlbumPtr> albums();
medialibrary::AlbumPtr album(int64_t albumId);
std::vector<medialibrary::ArtistPtr> artists();
std::vector<medialibrary::ArtistPtr> artists(bool includeAll);
medialibrary::ArtistPtr artist(int64_t artistId);
std::vector<medialibrary::GenrePtr> genres();
medialibrary::GenrePtr genre(int64_t genreId);
......
......@@ -450,10 +450,10 @@ getAlbum(JNIEnv* env, jobject thiz, jlong id)
}
jobjectArray
getArtists(JNIEnv* env, jobject thiz)
getArtists(JNIEnv* env, jobject thiz, jboolean all)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
std::vector<medialibrary::ArtistPtr> artists = aml->artists();
std::vector<medialibrary::ArtistPtr> artists = aml->artists(all);
jobjectArray artistRefs = (jobjectArray) env->NewObjectArray(artists.size(), ml_fields.Artist.clazz, NULL);
int index = -1;
for(medialibrary::ArtistPtr const& artist : artists) {
......@@ -793,7 +793,7 @@ static JNINativeMethod methods[] = {
{"nativeGetAudioCount", "()I", (void*)getAudioCount },
{"nativeGetAlbums", "()[Lorg/videolan/medialibrary/media/Album;", (void*)getAlbums },
{"nativeGetAlbum", "(J)Lorg/videolan/medialibrary/media/Album;", (void*)getAlbum },
{"nativeGetArtists", "()[Lorg/videolan/medialibrary/media/Artist;", (void*)getArtists },
{"nativeGetArtists", "(Z)[Lorg/videolan/medialibrary/media/Artist;", (void*)getArtists },
{"nativeGetArtist", "(J)Lorg/videolan/medialibrary/media/Artist;", (void*)getArtist },
{"nativeGetGenres", "()[Lorg/videolan/medialibrary/media/Genre;", (void*)getGenres },
{"nativeGetGenre", "(J)Lorg/videolan/medialibrary/media/Genre;", (void*)getGenre },
......
......@@ -191,8 +191,8 @@ public class Medialibrary {
}
@WorkerThread
public Artist[] getArtists() {
return mIsInitiated ? nativeGetArtists() : new Artist[0];
public Artist[] getArtists(boolean all) {
return mIsInitiated ? nativeGetArtists(all) : new Artist[0];
}
public Artist getArtist(long artistId) {
......@@ -639,7 +639,7 @@ public class Medialibrary {
private native int nativeGetAudioCount();
private native Album[] nativeGetAlbums();
private native Album nativeGetAlbum(long albumtId);
private native Artist[] nativeGetArtists();
private native Artist[] nativeGetArtists(boolean all);
private native Artist nativeGetArtist(long artistId);
private native Genre[] nativeGetGenres();
private native Genre nativeGetGenre(long genreId);
......
......@@ -380,6 +380,8 @@
<string name="casting_quality_lowcpu">Lowest</string>
<string name="cast_performance_warning">Casting this video requires conversion. This conversion can use all the available power and could quickly drain your battery.</string>
<string name="casting_connected_renderer">Connected to renderer \'%1$s\'</string>
<string name="artists_show_all_title">Show all artists</string>
<string name="artists_show_all_summary">Show all artists in Artists listing, not only album artists</string>
<string name="extensions_prefs_category">Extensions</string>
<string name="extensions_enable_category">Chose extensions to enable</string>
......
......@@ -4,6 +4,12 @@
android:key="audio_category"
android:title="@string/audio_prefs_category">
<CheckBoxPreference
android:defaultValue="false"
android:key="artists_show_all"
android:summary="@string/artists_show_all_summary"
android:title="@string/artists_show_all_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="lockscreen_cover"
......
......@@ -493,9 +493,6 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
switch (resultCode) {
case PreferencesActivity.RESULT_RESCAN:
for (Fragment fragment : getSupportFragmentManager().getFragments())
if (fragment instanceof MediaBrowserFragment)
((MediaBrowserFragment) fragment).clear();
startService(new Intent(Constants.ACTION_RELOAD, null,this, MediaParsingService.class));
break;
case PreferencesActivity.RESULT_RESTART:
......@@ -509,6 +506,9 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
if (fragment instanceof VideoGridFragment)
((VideoGridFragment) fragment).updateSeenMediaMarker();
break;
case PreferencesActivity.RESULT_UPDATE_ARTISTS:
final Fragment fragment = getCurrentFragment();
if (fragment instanceof AudioBrowserFragment) ((AudioBrowserFragment) fragment).updateArtists();
}
} else if (requestCode == ACTIVITY_RESULT_OPEN && resultCode == RESULT_OK){
MediaUtils.openUri(this, data.getData());
......
......@@ -588,11 +588,11 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
updatePlaylists();
}
private void updateArtists() {
public void updateArtists() {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final List<MediaLibraryItem> artists = Util.arrayToMediaArrayList(mMediaLibrary.getArtists());
final List<MediaLibraryItem> artists = Util.arrayToMediaArrayList(mMediaLibrary.getArtists(VLCApplication.getSettings().getBoolean(Constants.KEY_ARTISTS_SHOW_ALL, false)));
mArtistsAdapter.update(artists);
}
});
......
......@@ -54,6 +54,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
public final static int RESULT_RESTART_APP = RESULT_FIRST_USER + 3;
public final static int RESULT_UPDATE_SEEN_MEDIA = RESULT_FIRST_USER + 4;
public final static int RESULT_UPDATE_ARTISTS = RESULT_FIRST_USER + 5;
private PlaybackService.Client mClient = new PlaybackService.Client(this, this);
private PlaybackService mService;
......@@ -139,6 +140,10 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
setResult(RESULT_RESTART_APP);
}
public void updateArtists(){
setResult(RESULT_UPDATE_ARTISTS);
}
public void detectHeadset(boolean detect){
if (mService != null)
mService.detectHeadset(detect);
......
......@@ -22,6 +22,7 @@
package org.videolan.vlc.gui.preferences;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.preference.Preference;
......@@ -31,6 +32,7 @@ import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.VLCInstance;
public class PreferencesAudio extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
......@@ -64,8 +66,7 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey() == null)
return false;
if (preference.getKey() == null) return false;
switch (preference.getKey()){
case "enable_headset_detection":
((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
......@@ -79,11 +80,16 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
final Activity activity = getActivity();
if (activity == null) return;
switch (key){
case "aout":
VLCInstance.restart();
if (getActivity() != null )
((PreferencesActivity)getActivity()).restartMediaPlayer();
((PreferencesActivity)activity).restartMediaPlayer();
break;
case Constants.KEY_ARTISTS_SHOW_ALL:
((PreferencesActivity)activity).updateArtists();
break;
}
}
}
\ No newline at end of file
......@@ -64,6 +64,7 @@ import org.videolan.medialibrary.interfaces.MediaUpdatedCb;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.ExternalMonitor;
import org.videolan.vlc.MediaParsingService;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.RecommendationsService;
......@@ -79,6 +80,7 @@ import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.VLCInstance;
......@@ -235,8 +237,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
switch (resultCode) {
case PreferencesActivity.RESULT_RESCAN:
VLCApplication.getMLInstance().reload();
update();
startService(new Intent(Constants.ACTION_RELOAD, null,this, MediaParsingService.class));;
break;
case PreferencesActivity.RESULT_RESTART:
case PreferencesActivity.RESULT_RESTART_APP:
......
......@@ -38,8 +38,10 @@ import org.videolan.medialibrary.media.Genre;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.tv.TvUtil;
import org.videolan.vlc.gui.tv.browser.interfaces.BrowserActivityInterface;
import org.videolan.vlc.util.Constants;
import java.util.Arrays;
import java.util.List;
......@@ -141,8 +143,8 @@ public class MusicFragment extends MediaLibBrowserFragment implements OnItemView
protected String doInBackground(Void... params) {
String title;
if (CATEGORY_ARTISTS == mCategory){
mDataList = mMediaLibrary.getArtists();
if (CATEGORY_ARTISTS == mCategory) {
mDataList = mMediaLibrary.getArtists(VLCApplication.getSettings().getBoolean(Constants.KEY_ARTISTS_SHOW_ALL, false));
title = getString(R.string.artists);
} else if (CATEGORY_ALBUMS == mCategory){
title = mCurrentItem == null ?getString(R.string.albums) : mCurrentItem.getTitle();
......
......@@ -51,6 +51,7 @@ import org.videolan.vlc.extensions.ExtensionManagerService;
import org.videolan.vlc.extensions.ExtensionsManager;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.util.Constants;
import java.util.ArrayList;
import java.util.List;
......@@ -208,7 +209,7 @@ public class BrowserProvider implements ExtensionManagerService.ExtensionManager
list = VLCApplication.getMLInstance().lastMediaPlayed();
break;
case ID_ARTISTS:
list = VLCApplication.getMLInstance().getArtists();
list = VLCApplication.getMLInstance().getArtists(VLCApplication.getSettings().getBoolean(Constants.KEY_ARTISTS_SHOW_ALL, false));
break;
case ID_ALBUMS:
list = VLCApplication.getMLInstance().getAlbums();
......
......@@ -82,4 +82,7 @@ public class Constants {
// AudioPlayer
public final static String PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown";
public final static String PREF_AUDIOPLAYER_TIPS_SHOWN = "audioplayer_tips_shown";
// Preferences
public final static String KEY_ARTISTS_SHOW_ALL = "artists_show_all";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment