[Android] Video/Audio: Button to open Medialibrary settings
Geoffrey Métais
git at videolan.org
Wed Feb 20 16:37:48 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 20 16:37:11 2019 +0100| [62ad90207bd7da92f923d1017a12d065c0911c53] | committer: Geoffrey Métais
Video/Audio: Button to open Medialibrary settings
> https://code.videolan.org/videolan/vlc-android/commit/62ad90207bd7da92f923d1017a12d065c0911c53
---
vlc-android/res/layout/audio_browser.xml | 15 ++++++++++++++-
vlc-android/res/layout/video_grid.xml | 15 +++++++++++++--
vlc-android/res/values/strings.xml | 1 +
.../videolan/vlc/gui/audio/AudioBrowserFragment.java | 17 ++++++++++++++++-
.../org/videolan/vlc/gui/video/VideoGridFragment.java | 13 +++++++++++++
5 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 8298dd902..757e82e67 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -54,7 +54,8 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/button_nomedia"
+ app:layout_constraintVertical_chainStyle="packed"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_no_media"
android:drawablePadding="@dimen/default_margin"
@@ -63,4 +64,16 @@
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="gone"/>
+
+ <Button
+ android:id="@+id/button_nomedia"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/Widget.MaterialComponents.Button.OutlinedButton"
+ android:text="@string/button_medialibrary_preferences"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/no_media"
+ app:layout_constraintBottom_toBottomOf="parent"
+ android:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/vlc-android/res/layout/video_grid.xml b/vlc-android/res/layout/video_grid.xml
index 7d4418b22..cde346768 100644
--- a/vlc-android/res/layout/video_grid.xml
+++ b/vlc-android/res/layout/video_grid.xml
@@ -58,7 +58,18 @@
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
- android:visibility="@{empty ? View.VISIBLE : View.GONE}" />
+ android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}" />
+
+ <Button
+ android:id="@+id/button_nomedia"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/Widget.MaterialComponents.Button.OutlinedButton"
+ android:text="@string/button_medialibrary_preferences"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/textview_nomedia"
+ android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}" />
<TextView
android:id="@+id/loading_title"
@@ -66,7 +77,7 @@
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/loading_flipper"
- app:layout_constraintTop_toBottomOf="@+id/textview_nomedia"
+ app:layout_constraintTop_toBottomOf="@+id/button_nomedia"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
android:layout_weight="1"
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index b59160934..193288ba9 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -685,4 +685,5 @@
<string name="onboarding_scanning_enable">Let VLC scan my device for media content</string>
<string name="onboarding_scan_whole">VLC will scan my whole SDCard</string>
<string name="onboarding_scan_customize">Let me choose which folders VLC will scan</string>
+ <string name="button_medialibrary_preferences">Go to Medialibrary preferences</string>
</resources>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index a871fdbed..e56e246dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -30,6 +30,7 @@ import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.TextView;
import com.google.android.material.appbar.AppBarLayout;
@@ -42,6 +43,7 @@ import org.videolan.vlc.MediaParsingServiceKt;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.PlaylistActivity;
import org.videolan.vlc.gui.SecondaryActivity;
+import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.view.FastScroller;
import org.videolan.vlc.gui.view.RecyclerSectionItemDecoration;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
@@ -60,6 +62,7 @@ import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.paging.PagedList;
@@ -80,6 +83,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
private PagedGenresModel genresModel;
private TextView mEmptyView;
+ private Button mMedialibrarySettingsBtn;
private final RecyclerView[] mLists = new RecyclerView[MODE_TOTAL];
private MLPagedModel<MediaLibraryItem>[] models;
private SharedPreferences mSettings;
@@ -120,9 +124,19 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mEmptyView = view.findViewById(R.id.no_media);
+ mMedialibrarySettingsBtn = view.findViewById(R.id.button_nomedia);
mFastScroller = view.getRootView().findViewById(R.id.songs_fast_scroller);
mFastScroller.attachToCoordinator((AppBarLayout) view.getRootView().findViewById(R.id.appbar), (CoordinatorLayout) view.getRootView().findViewById(R.id.coordinator), (FloatingActionButton) view.getRootView().findViewById(R.id.fab));
-
+ mMedialibrarySettingsBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final FragmentActivity activity = requireActivity();
+ final Intent intent = new Intent(activity.getApplicationContext(), SecondaryActivity.class);
+ intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER);
+ startActivity(intent);
+ activity.setResult(PreferencesActivity.RESULT_RESTART);
+ }
+ });
}
@Override
@@ -253,6 +267,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
private void updateEmptyView() {
mEmptyView.setVisibility(getCurrentAdapter().isEmpty() ? View.VISIBLE : View.GONE);
+ mMedialibrarySettingsBtn.setVisibility(getCurrentAdapter().isEmpty() ? View.VISIBLE : View.GONE);
setFabPlayShuffleAllVisibility();
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 98646f22d..8513f9fcf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -22,6 +22,7 @@ package org.videolan.vlc.gui.video;
import android.annotation.TargetApi;
import android.app.Activity;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -52,6 +53,7 @@ import org.videolan.vlc.gui.dialogs.CtxActionReceiver;
import org.videolan.vlc.gui.dialogs.SavePlaylistDialog;
import org.videolan.vlc.gui.helpers.ItemOffsetDecoration;
import org.videolan.vlc.gui.helpers.UiTools;
+import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.interfaces.IEventsHandler;
import org.videolan.vlc.media.MediaGroup;
@@ -68,6 +70,7 @@ import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ActionMode;
+import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.RecyclerView;
@@ -128,6 +131,16 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
mBinding.loadingFlipper.setVisibility(empty ? View.VISIBLE : View.GONE);
mBinding.loadingTitle.setVisibility(empty ? View.VISIBLE : View.GONE);
mBinding.setEmpty(empty);
+ mBinding.buttonNomedia.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final FragmentActivity activity = requireActivity();
+ final Intent intent = new Intent(activity.getApplicationContext(), SecondaryActivity.class);
+ intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER);
+ startActivity(intent);
+ activity.setResult(PreferencesActivity.RESULT_RESTART);
+ }
+ });
}
@Override
More information about the Android
mailing list