summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2020-05-16 11:32:09 +0200
committerThomas <tschneider.ac@gmail.com>2020-05-16 11:32:09 +0200
commitdd26a6aeb50f8f18c6e5080b1e6097361fca6fe0 (patch)
tree630fd02667e2adcea9e479bf2416ee8d25fe9d0a /app
parentd5ef4f05a1506d85481ef68d1198fd471782c055 (diff)
video cache
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java10
-rw-r--r--app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java134
-rw-r--r--app/src/main/java/app/fedilab/android/activities/SettingsActivity.java2
-rw-r--r--app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java2
-rw-r--r--app/src/main/java/app/fedilab/android/asynctasks/DownloadTrackingDomainsAsyncTask.java1
-rw-r--r--app/src/main/java/app/fedilab/android/client/API.java20
-rw-r--r--app/src/main/java/app/fedilab/android/client/Entities/ManageTimelines.java9
-rw-r--r--app/src/main/java/app/fedilab/android/client/Entities/Status.java55
-rw-r--r--app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java11
-rw-r--r--app/src/main/java/app/fedilab/android/fragments/ColorSettingsFragment.java2
-rw-r--r--app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java148
-rw-r--r--app/src/main/java/app/fedilab/android/fragments/MediaSliderFragment.java32
-rw-r--r--app/src/main/java/app/fedilab/android/helper/CacheDataSourceFactory.java48
-rw-r--r--app/src/main/java/app/fedilab/android/helper/Helper.java31
-rw-r--r--app/src/main/java/app/fedilab/android/helper/ThemeHelper.java23
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/ColorPickerAdapter.java22
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/EmojiBSFragment.java16
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/PropertiesBSFragment.java11
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/StickerBSFragment.java18
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/TextEditorDialogFragment.java61
-rw-r--r--app/src/main/java/app/fedilab/android/imageeditor/tools/EditingToolsAdapter.java9
-rw-r--r--app/src/main/java/app/fedilab/android/services/BackupNotificationInDataBaseService.java27
-rw-r--r--app/src/main/java/app/fedilab/android/services/BackupStatusInDataBaseService.java27
-rw-r--r--app/src/main/java/app/fedilab/android/services/BackupStatusService.java22
-rw-r--r--app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java65
-rw-r--r--app/src/main/java/app/fedilab/android/services/LiveNotificationService.java1
-rw-r--r--app/src/main/java/app/fedilab/android/services/StreamingFederatedTimelineService.java43
-rw-r--r--app/src/main/java/app/fedilab/android/services/StreamingHomeTimelineService.java43
-rw-r--r--app/src/main/java/app/fedilab/android/services/StreamingLocalTimelineService.java41
-rw-r--r--app/src/main/java/app/fedilab/android/sqlite/DomainBlockDAO.java3
-rw-r--r--app/src/main/res/layout-sw600dp/activity_show_account.xml14
-rw-r--r--app/src/main/res/layout-sw600dp/drawer_account.xml14
-rw-r--r--app/src/main/res/layout/activity_edit_profile.xml2
-rw-r--r--app/src/main/res/layout/activity_login.xml10
-rw-r--r--app/src/main/res/layout/activity_manage_accounts_list.xml2
-rw-r--r--app/src/main/res/layout/activity_peertube.xml2
-rw-r--r--app/src/main/res/layout/activity_peertube_upload.xml2
-rw-r--r--app/src/main/res/layout/activity_show_account.xml14
-rw-r--r--app/src/main/res/layout/add_blocked_instance.xml2
-rw-r--r--app/src/main/res/layout/add_filter.xml2
-rw-r--r--app/src/main/res/layout/add_list.xml2
-rw-r--r--app/src/main/res/layout/add_playlist.xml2
-rw-r--r--app/src/main/res/layout/dialog_create_folder.xml2
-rw-r--r--app/src/main/res/layout/dialog_profile.xml2
-rw-r--r--app/src/main/res/layout/domains_blocked.xml2
-rw-r--r--app/src/main/res/layout/drawer_account.xml14
-rw-r--r--app/src/main/res/layout/drawer_account_admin.xml8
-rw-r--r--app/src/main/res/layout/drawer_account_follow_request.xml4
-rw-r--r--app/src/main/res/layout/drawer_account_list.xml4
-rw-r--r--app/src/main/res/layout/drawer_account_main_search.xml12
-rw-r--r--app/src/main/res/layout/drawer_account_reply.xml2
-rw-r--r--app/src/main/res/layout/drawer_account_search.xml4
-rw-r--r--app/src/main/res/layout/drawer_emoji_search.xml3
-rw-r--r--app/src/main/res/layout/drawer_notification.xml4
-rw-r--r--app/src/main/res/layout/drawer_report.xml6
-rw-r--r--app/src/main/res/layout/drawer_status.xml19
-rw-r--r--app/src/main/res/layout/drawer_status_compact.xml18
-rw-r--r--app/src/main/res/layout/drawer_status_console.xml20
-rw-r--r--app/src/main/res/layout/drawer_status_focused.xml20
-rw-r--r--app/src/main/res/layout/drawer_status_main_search.xml6
-rw-r--r--app/src/main/res/layout/drawer_suggestions.xml2
-rw-r--r--app/src/main/res/layout/filter_regex.xml2
-rw-r--r--app/src/main/res/layout/fragment_settings_reveal.xml94
-rw-r--r--app/src/main/res/layout/fragment_slide_media.xml2
-rw-r--r--app/src/main/res/layout/nav_header_main.xml2
-rw-r--r--app/src/main/res/layout/popup_contact.xml3
-rw-r--r--app/src/main/res/layout/search_instance.xml2
-rw-r--r--app/src/main/res/layout/search_toot.xml2
-rw-r--r--app/src/main/res/layout/simple_bar.xml2
-rw-r--r--app/src/main/res/layout/simple_bar_add.xml2
-rw-r--r--app/src/main/res/layout/simple_bar_muted_instance.xml2
-rw-r--r--app/src/main/res/layout/simple_bar_search.xml2
-rw-r--r--app/src/main/res/layout/tags_all.xml2
-rw-r--r--app/src/main/res/layout/tags_any.xml2
-rw-r--r--app/src/main/res/layout/tags_instance.xml2
-rw-r--r--app/src/main/res/layout/tags_name.xml2
-rw-r--r--app/src/main/res/layout/webview_actionbar.xml2
-rw-r--r--app/src/main/res/values/strings.xml6
78 files changed, 741 insertions, 547 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
index c1928b179..f22ff876b 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
@@ -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)
diff --git a/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
index c188ecc4e..7d67984e1 100644
--- a/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
@@ -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() {