Commit 3a8ab8d2 authored by Alexandre Perraud's avatar Alexandre Perraud

Set seen feature as a preference

parent b0f1e881
......@@ -288,6 +288,8 @@
<string name="video_min_group_length_first">First letter only</string>
<string name="video_min_group_length_short">Short number of letters (6)</string>
<string name="video_min_group_length_long">Long number of letters (9)</string>
<string name="media_seen">Show seen video marker</string>
<string name="media_seen_summary">Mark a video as seen when you play it until the end</string>
<string name="force_list_portrait">No grid in portrait mode</string>
<string name="force_list_portrait_summary">Show videos in list instead of grid in portrait mode</string>
<string name="force_play_all_summary">Play all videos, starting with the one you clicked on</string>
......
......@@ -13,6 +13,11 @@
android:summary="@string/video_min_group_length_summary"
android:title="@string/video_min_group_length_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="media_seen"
android:summary="@string/media_seen_summary"
android:title="@string/media_seen" />
<CheckBoxPreference
android:defaultValue="false"
android:key="force_list_portrait"
......
......@@ -655,6 +655,11 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
finish();
startActivity(intent);
break;
case PreferencesActivity.RESULT_UPDATE_SEEN_MEDIA:
for (Fragment fragment : getSupportFragmentManager().getFragments())
if (fragment instanceof VideoGridFragment)
((VideoGridFragment) fragment).updateSeenMediaMarker();
break;
}
} else if (requestCode == ACTIVITY_RESULT_OPEN && resultCode == RESULT_OK){
MediaUtils.openUri(this, data.getData());
......
......@@ -53,6 +53,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1;
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;
private PlaybackService.Client mClient = new PlaybackService.Client(this, this);
private PlaybackService mService;
......
......@@ -49,6 +49,9 @@ public class PreferencesVideo extends BasePreferenceFragment {
case "force_list_portrait":
((PreferencesActivity) getActivity()).setRestart();
return true;
case "media_seen":
getActivity().setResult(PreferencesActivity.RESULT_UPDATE_SEEN_MEDIA);
break;
}
return super.onPreferenceTreeClick(preference);
}
......
......@@ -591,4 +591,9 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
updateEmptyView();
setFabPlayVisibility(true);
}
public void updateSeenMediaMarker() {
mVideoAdapter.setSeenMediaMarkerVisible(PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("media_seen", true));
mVideoAdapter.notifyItemRangeChanged(0, mVideoAdapter.getItemCount()-1, VideoListAdapter.UPDATE_SEEN);
}
}
......@@ -85,9 +85,12 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
private int mSelectionCount = 0;
private int mGridCardWidth = 0;
private boolean mIsSeenMediaMarkerVisible = true;
VideoListAdapter(IEventsHandler eventsHandler) {
super();
mEventsHandler = eventsHandler;
mIsSeenMediaMarkerVisible = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("media_seen", true);
}
VideoComparator getComparator() {
......@@ -267,7 +270,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
}
}
resolution = Tools.getResolution(media);
seen = media.getSeen();
seen = mIsSeenMediaMarkerVisible ? media.getSeen() : 0L;
}
holder.binding.setVariable(BR.resolution, resolution);
......@@ -568,4 +571,8 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
return UPDATE_SEEN;
}
}
public void setSeenMediaMarkerVisible(boolean seenMediaMarkerVisible) {
mIsSeenMediaMarkerVisible = seenMediaMarkerVisible;
}
}
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