Commit dd26a6ae authored by Thomas's avatar Thomas
Browse files

video cache

parent d5ef4f05
......@@ -1258,7 +1258,7 @@ public abstract class BaseMainActivity extends BaseActivity
int lastReleaseNoteRead = sharedpreferences.getInt(Helper.SET_POPUP_RELEASE_NOTES, 0);
int versionCode = BuildConfig.VERSION_CODE;
if (lastReleaseNoteRead != versionCode ) { //Need to push release notes
if (lastReleaseNoteRead != versionCode) { //Need to push release notes
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, BaseMainActivity.this).execute();
}
......@@ -1279,12 +1279,12 @@ public abstract class BaseMainActivity extends BaseActivity
Button liberapay_support = dialogReleaseNoteView.findViewById(R.id.liberapay_support);
release_title.setText(getString(R.string.release_note_title, BuildConfig.VERSION_NAME));
release_notes.setText(finalContent);
if( BuildConfig.DONATIONS) {
if (BuildConfig.DONATIONS) {
liberapay_support.setVisibility(View.VISIBLE);
}else{
} else {
liberapay_support.setVisibility(View.GONE);
}
liberapay_support.setOnClickListener(v->{
liberapay_support.setOnClickListener(v -> {
Intent intentLiberapay = new Intent(Intent.ACTION_VIEW);
intentLiberapay.setData(Uri.parse("https://liberapay.com/tom79"));
try {
......@@ -1693,7 +1693,7 @@ public abstract class BaseMainActivity extends BaseActivity
}
});
}
if( trackingDomains != null){
if (trackingDomains != null) {
trackingDomains = null;
}
if (hidde_menu != null)
......
......@@ -60,10 +60,10 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.PlaybackControlView;
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
......@@ -96,6 +96,7 @@ import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StatusDrawerParams;
import app.fedilab.android.client.TLSSocketFactory;
import app.fedilab.android.drawers.StatusListAdapter;
import app.fedilab.android.helper.CacheDataSourceFactory;
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.FullScreenMediaController;
import app.fedilab.android.helper.Helper;
......@@ -130,7 +131,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
private ScrollView peertube_information_container;
private Peertube peertube;
private TextView toolbar_title;
private SimpleExoPlayerView playerView;
private PlayerView playerView;
private SimpleExoPlayer player;
private boolean fullScreenMode;
private Dialog fullScreenDialog;
......@@ -278,7 +279,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
peertube_information_container.setVisibility(View.VISIBLE);
}
});
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) {
webview_video.getSettings().setUserAgentString(user_agent);
}
......@@ -369,40 +370,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
case R.id.action_comment:
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
Toasty.info(PeertubeActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
new AsyncTask<Void, Void, Void>() {
private List<app.fedilab.android.client.Entities.Status> remoteStatuses;
private WeakReference<Context> contextReference = new WeakReference<>(PeertubeActivity.this);
@Override
protected Void doInBackground(Void... voids) {
if (peertube != null) {
APIResponse search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
if (search != null && search.getResults() != null) {
remoteStatuses = search.getResults().getStatuses();
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
Intent intent = new Intent(contextReference.get(), TootActivity.class);
Bundle b = new Bundle();
if (remoteStatuses == null || remoteStatuses.size() == 0) {
Toasty.error(contextReference.get(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
return;
}
if (remoteStatuses.get(0).getReblog() != null) {
b.putParcelable("tootReply", remoteStatuses.get(0).getReblog());
} else {
b.putParcelable("tootReply", remoteStatuses.get(0));
}
intent.putExtras(b); //Put your id to your next Intent
contextReference.get().startActivity(intent);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new commentTask(new WeakReference<>(PeertubeActivity.this), peertube).execute();
} else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
if (!peertube.isCommentsEnabled()) {
Toasty.info(PeertubeActivity.this, getString(R.string.comment_no_allowed_peertube), Toast.LENGTH_LONG).show();
......@@ -443,6 +411,52 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
}
private static class commentTask extends AsyncTask<Void, Void, app.fedilab.android.client.Entities.Status>{
private WeakReference<Context> contextReference;
private Peertube peertube;
commentTask(WeakReference<Context> contextReference, Peertube peertube){
this.peertube = peertube;
this.contextReference = contextReference;
}
@Override
protected app.fedilab.android.client.Entities.Status doInBackground(Void... voids) {
List<app.fedilab.android.client.Entities.Status> remoteStatuses = null;
if (peertube != null) {
APIResponse search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
if (search != null && search.getResults() != null) {
remoteStatuses = search.getResults().getStatuses();
}
}
if( remoteStatuses != null && remoteStatuses.size() > 0) {
return remoteStatuses.get(0);
}else {
return null;
}
}
@Override
protected void onPostExecute(app.fedilab.android.client.Entities.Status remoteStatuses) {
Intent intent = new Intent(contextReference.get(), TootActivity.class);
Bundle b = new Bundle();
if (remoteStatuses == null) {
Toasty.error(contextReference.get(), contextReference.get().getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
return;
}
if (remoteStatuses.getReblog() != null) {
b.putParcelable("tootReply", remoteStatuses.getReblog());
} else {
b.putParcelable("tootReply", remoteStatuses);
}
intent.putExtras(b); //Put your id to your next Intent
contextReference.get().startActivity(intent);
}
}
public FullScreenMediaController.fullscreen getFullscreen() {
return fullscreen;
}
......@@ -583,16 +597,24 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (mode == Helper.VIDEO_MODE_DIRECT) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService())));
String userAgent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
ProgressiveMediaSource videoSource;
if( video_cache == 0) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(PeertubeActivity.this, userAgent), null);
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService())));
}else{
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this, video_cache * 1024 * 1024, 5 * 1024 * 1024);
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, apiResponse.getPeertubes().get(0).isStreamService())));
}
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
playerView.setPlayer(player);
loader.setVisibility(View.GONE);
player.prepare(videoSource);
player.setPlayWhenReady(true);
}
......@@ -777,7 +799,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (playerView != null) {
loader.setVisibility(View.VISIBLE);
long position = player.getCurrentPosition();
PlaybackControlView controlView = playerView.findViewById(R.id.exo_controller);
PlayerControlView controlView = playerView.findViewById(R.id.exo_controller);
resolution = controlView.findViewById(R.id.resolution);
resolution.setText(String.format("%sp", res));
if (mode == Helper.VIDEO_MODE_DIRECT) {
......@@ -786,11 +808,19 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this);
playerView.setPlayer(player);
loader.setVisibility(View.GONE);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(PeertubeActivity.this, "Mastalab"), null);
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService())));
String userAgent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
ProgressiveMediaSource videoSource;
if( video_cache == 0) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(PeertubeActivity.this, userAgent), null);
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService())));
}else{
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this, video_cache * 1024 * 1024, 5 * 1024 * 1024);
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
.createMediaSource(Uri.parse(peertube.getFileUrl(res, peertube.isStreamService())));
}
player.prepare(videoSource);
player.seekTo(0, position);
player.setPlayWhenReady(true);
......@@ -842,7 +872,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
private void initFullscreenButton() {
PlaybackControlView controlView = playerView.findViewById(R.id.exo_controller);
PlayerControlView controlView = playerView.findViewById(R.id.exo_controller);
fullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
View fullScreenButton = controlView.findViewById(R.id.exo_fullscreen_button);
fullScreenButton.setOnClickListener(v -> {
......@@ -854,7 +884,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
private void initResolution() {
PlaybackControlView controlView = playerView.findViewById(R.id.exo_controller);
PlayerControlView controlView = playerView.findViewById(R.id.exo_controller);
resolution = controlView.findViewById(R.id.resolution);
resolution.setText(String.format("%sp", peertube.getResolution().get(0)));
resolution.setOnClickListener(v -> displayResolution());
......
......@@ -154,7 +154,7 @@ public class SettingsActivity extends BaseActivity {
}
@Override
public void onDestroy(){
public void onDestroy() {
super.onDestroy();
}
......
......@@ -125,7 +125,7 @@ public class WebviewConnectActivity extends BaseActivity {
webView = findViewById(R.id.webviewConnect);
clearCookies(WebviewConnectActivity.this);
webView.getSettings().setJavaScriptEnabled(true);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) {
webView.getSettings().setUserAgentString(user_agent);
}
......
......@@ -33,7 +33,6 @@ import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import app.fedilab.android.R;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.sqlite.DomainBlockDAO;
import app.fedilab.android.sqlite.Sqlite;
import es.dmoral.toasty.Toasty;
......
......@@ -2205,7 +2205,7 @@ public class API {
JSONObject resobj = new JSONObject(response);
JSONObject jsonObject = resobj.getJSONObject("software");
String name = jsonObject.getString("name").toUpperCase();
if( name.compareTo("CORGIDON") == 0 ){
if (name.compareTo("CORGIDON") == 0) {
name = "MASTODON";
}
instanceNodeInfo.setName(name);
......@@ -3699,14 +3699,16 @@ public class API {
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0) {
for (Status status : apiResponse.getStatuses()) {
if (status.getMedia_attachments() != null) {
String statusSerialized = Helper.statusToStringStorage(status);
for (Attachment attachment : status.getMedia_attachments()) {
Status newStatus = Helper.restoreStatusFromString(statusSerialized);
if (newStatus == null)
break;
newStatus.setArt_attachment(attachment);
apiResponseReply.getStatuses().add(newStatus);
}
try {
String statusSerialized = Helper.statusToStringStorage(status);
for (Attachment attachment : status.getMedia_attachments()) {
Status newStatus = Helper.restoreStatusFromString(statusSerialized);
if (newStatus == null)
break;
newStatus.setArt_attachment(attachment);
apiResponseReply.getStatuses().add(newStatus);
}
}catch (Exception ignored){}
}
}
}
......
......@@ -500,10 +500,11 @@ public class ManageTimelines {
if (mPageReferenceMap != null) {
FragmentTransaction fragTransaction = ((MainActivity) context).getSupportFragmentManager().beginTransaction();
DisplayStatusFragment displayStatusFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
assert displayStatusFragment != null;
fragTransaction.detach(displayStatusFragment);
fragTransaction.attach(displayStatusFragment);
fragTransaction.commit();
if (displayStatusFragment != null) {
fragTransaction.detach(displayStatusFragment);
fragTransaction.attach(displayStatusFragment);
fragTransaction.commit();
}
}
}
});
......
......@@ -310,31 +310,42 @@ public class Status implements Parcelable {
}
}
matcher = Helper.bibliogramPattern.matcher(content);
boolean bibliogram = sharedpreferences.getBoolean(Helper.SET_BIBLIOGRAM, false);
if (bibliogram) {
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(Helper.SET_BIBLIOGRAM_HOST, Helper.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
content = content.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + bibliogramHost + bibliogram_directory));
content = content.replaceAll(">" + Pattern.quote(matcher.group()), Matcher.quoteReplacement(">" + bibliogramHost + bibliogram_directory));
}
}
matcher = Helper.ouichesPattern.matcher(content);
while (matcher.find()) {
Attachment attachment = new Attachment();
attachment.setType("audio");
String tag = matcher.group(1);
attachment.setId(tag);
if( tag == null){
continue;
}
attachment.setRemote_url("http://ouich.es/mp3/"+tag+".mp3");
attachment.setUrl("http://ouich.es/mp3/"+tag+".mp3");
if( status.getMedia_attachments() == null) {
status.setMedia_attachments(new ArrayList<>());
}
boolean alreadyAdded = false;
for(Attachment at: status.getMedia_attachments()){
if( tag.compareTo(at.getId()) == 0 ){
alreadyAdded = true;
break;
}
}
if( !alreadyAdded) {
status.getMedia_attachments().add(attachment);
}
Attachment attachment = new Attachment();
attachment.setType("audio");
String tag = matcher.group(1);
attachment.setId(tag);
if (tag == null) {
continue;
}
attachment.setRemote_url("http://ouich.es/mp3/" + tag + ".mp3");
attachment.setUrl("http://ouich.es/mp3/" + tag + ".mp3");
if (status.getMedia_attachments() == null) {
status.setMedia_attachments(new ArrayList<>());
}
boolean alreadyAdded = false;
for (Attachment at : status.getMedia_attachments()) {
if (tag.compareTo(at.getId()) == 0) {
alreadyAdded = true;
break;
}
}
if (!alreadyAdded) {
status.getMedia_attachments().add(attachment);
}
}
Pattern aLink = Pattern.compile("<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!</a).)*)</a>");
......
......@@ -2289,6 +2289,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + nitterHost + nitter_directory));
}
}
boolean bibliogram = sharedpreferences.getBoolean(Helper.SET_BIBLIOGRAM, false);
if (bibliogram) {
Matcher matcher = Helper.bibliogramPattern.matcher(url);
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(Helper.SET_BIBLIOGRAM_HOST, Helper.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
url = url.replaceAll("https://" + Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://" + bibliogramHost + bibliogram_directory));
}
}
Helper.openBrowser(context, url);
});
} else if (card.getType().toLowerCase().equals("video") && (display_video_preview || (type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition))) {
......@@ -2298,7 +2307,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
.into(holder.webview_preview_card);
holder.status_cardview.setVisibility(View.GONE);
holder.status_cardview_video.setVisibility(View.VISIBLE);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) {
holder.status_cardview_webview.getSettings().setUserAgentString(user_agent);
}
......
......@@ -275,7 +275,7 @@ public class ColorSettingsFragment extends PreferenceFragmentCompat implements S
entryValues[2] = String.valueOf(Helper.THEME_BLACK);
pref_theme_picker.setEntries(entries);
int default_theme_value;
switch (theme){
switch (theme) {
case Helper.THEME_LIGHT:
default_theme_value = 1;
break;
......
......@@ -15,6 +15,7 @@ package app.fedilab.android.fragments;
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.TimePickerDialog;
import android.content.ComponentName;
......@@ -54,7 +55,6 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment;
......@@ -345,6 +345,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
}
context = getActivity();
assert context != null;
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
......@@ -468,9 +469,9 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
Button update_tracking_domains = rootView.findViewById(R.id.update_tracking_domains);
update_tracking_domains.setOnClickListener(v -> {
new DownloadTrackingDomainsAsyncTask(Objects.requireNonNull(getActivity()), update_tracking_domains).execute();
});
update_tracking_domains.setOnClickListener(v ->
new DownloadTrackingDomainsAsyncTask(Objects.requireNonNull(getActivity()), update_tracking_domains).execute()
);
Spinner set_attachment_group = rootView.findViewById(R.id.set_attachment_group);
......@@ -837,7 +838,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
TextView set_user_agent = rootView.findViewById(R.id.set_user_agent);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, null);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) {
set_user_agent.setText(user_agent);
......@@ -922,6 +923,55 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
}
});
TextView set_bibliogram_host = rootView.findViewById(R.id.set_bibliogram_host);
boolean bibliogram = sharedpreferences.getBoolean(Helper.SET_BIBLIOGRAM, false);
final SwitchCompat set_bibliogram = rootView.findViewById(R.id.set_bibliogram);
set_bibliogram.setChecked(bibliogram);
set_bibliogram.setOnClickListener(v -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_BIBLIOGRAM, set_bibliogram.isChecked());
editor.apply();
if (set_bibliogram.isChecked()) {
set_bibliogram_host.setVisibility(View.VISIBLE);
} else {
set_bibliogram_host.setVisibility(View.GONE);
}
});
if (bibliogram) {
set_bibliogram_host.setVisibility(View.VISIBLE);
} else {
set_bibliogram_host.setVisibility(View.GONE);
}
String bibliogramHost = sharedpreferences.getString(Helper.SET_BIBLIOGRAM_HOST, null);
if (bibliogramHost != null) {
set_bibliogram_host.setText(bibliogramHost);
}
set_bibliogram_host.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
SharedPreferences.Editor editor = sharedpreferences.edit();
if (s.toString().trim().length() > 0) {
editor.putString(Helper.SET_BIBLIOGRAM_HOST, s.toString().toLowerCase().trim());
} else {
editor.putString(Helper.SET_BIBLIOGRAM_HOST, null);
}
editor.apply();
}
});
boolean long_press_media = sharedpreferences.getBoolean(Helper.SET_LONG_PRESS_MEDIA, true);
final SwitchCompat set_long_press_media = rootView.findViewById(R.id.set_long_press_media);
set_long_press_media.setChecked(long_press_media);
......@@ -976,6 +1026,32 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
getActivity().recreate();
});
int video_cache_size = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
SeekBar set_video_cache_size = rootView.findViewById(R.id.set_video_cache_size);
set_video_cache_size.setMax(5*Helper.DEFAULT_VIDEO_CACHE_MB);
set_video_cache_size.setProgress(video_cache_size);
TextView set_video_cache = rootView.findViewById(R.id.set_video_cache);
set_video_cache.setText(String.valueOf(video_cache_size));
set_video_cache_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
set_video_cache.setText(String.valueOf(progress));
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_VIDEO_CACHE, progress);
editor.apply();
}
});