Improve media activity

This commit is contained in:
Thomas 2020-05-16 17:06:13 +02:00
parent e755dc79ec
commit a1e0d13663
20 changed files with 319 additions and 408 deletions

View File

@ -1,153 +1,26 @@
package app.fedilab.android.activities;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.ActionMode;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import com.franmontiel.localechanger.LocaleChanger;
import com.google.android.material.snackbar.Snackbar;
import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.one.EmojiOneProvider;
import org.jetbrains.annotations.NotNull;
import java.util.Timer;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.helper.Helper;
import es.dmoral.toasty.Toasty;
/**
* Created by Thomas on 12/12/2017.
* Base activity which updates security provider
* Created by Thomas on 16/05/2020.
* Fragment base activity which updates security provider
*/
@SuppressLint("Registered")
public class BaseFragmentActivity extends CyaneaAppCompatActivity {
public class BaseFragmentActivity extends AppCompatActivity {
public static final int READ_WRITE_STORAGE = 52;
public static Timer timer;
public static boolean canShowActionMode = true;
static {
Helper.installProvider();
EmojiManager.install(new EmojiOneProvider());
}
private ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.detectActivityLeaks()
.penaltyLog()
// .penaltyDeath()
.build());
}
canShowActionMode = true;
super.onCreate(savedInstanceState);
}
@Override
public void onDestroy() {
super.onDestroy();
if (timer != null) {
timer.cancel();
timer = null;
}
}
@Override
public void onConfigurationChanged(@NotNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
LocaleChanger.onConfigurationChanged();
}
@Override
protected void attachBaseContext(@NotNull Context newBase) {
newBase = LocaleChanger.configureBaseContext(newBase);
super.attachBaseContext(newBase);
}
public boolean requestPermission(String permission) {
boolean isGranted = ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED;
if (!isGranted) {
ActivityCompat.requestPermissions(
this,
new String[]{permission},
READ_WRITE_STORAGE);
}
return isGranted;
}
public void isPermissionGranted(boolean isGranted, String permission) {
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == READ_WRITE_STORAGE) {
isPermissionGranted(grantResults[0] == PackageManager.PERMISSION_GRANTED, permissions[0]);
}
}
protected void showLoading(@NonNull String message) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(message);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
}
protected void hideLoading() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
}
protected void showSnackbar(@NonNull String message) {
View view = findViewById(android.R.id.content);
if (view != null) {
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
} else {
Toasty.info(BaseFragmentActivity.this, message, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onActionModeStarted(ActionMode mode) {
if (!canShowActionMode) {
mode.finish();
}
super.onActionModeStarted(mode);
}
}

View File

@ -411,52 +411,6 @@ 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;
}
@ -601,12 +555,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
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) {
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{
} 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())));
@ -684,7 +638,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
});
}
@Override
public void onConfigurationChanged(@NotNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@ -767,7 +720,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
}
@Override
public void onResume() {
super.onResume();
@ -811,12 +763,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
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) {
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{
} 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())));
@ -839,7 +791,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
private void initFullscreenDialog() {
fullScreenDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
@ -860,7 +811,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
fullScreenDialog.show();
}
private void closeFullscreenDialog() {
((ViewGroup) playerView.getParent()).removeView(playerView);
@ -890,7 +840,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
resolution.setOnClickListener(v -> displayResolution());
}
private void changeColor() {
if (peertube.getMyRating() != null && peertube.getMyRating().equals("like")) {
changeDrawableColor(PeertubeActivity.this, R.drawable.ic_thumb_up_peertube, R.color.positive_thumbs);
@ -912,4 +861,49 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
playlists = apiResponse.getPlaylists();
}
}
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);
}
}
}

View File

@ -737,6 +737,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
attachments.add(attachment);
intent.putParcelableArrayListExtra("mediaArray", attachments);
b.putInt("position", 1);
b.putInt("bgcolor", getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
startActivity(intent);
});

View File

@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
@ -49,11 +48,6 @@ import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrConfig;
import com.r0adkll.slidr.model.SlidrInterface;
import com.r0adkll.slidr.model.SlidrPosition;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -72,7 +66,7 @@ import es.dmoral.toasty.Toasty;
* Media Activity
*/
public class SlideMediaActivity extends BaseActivity implements OnDownloadInterface {
public class SlideMediaActivity extends BaseFragmentActivity implements OnDownloadInterface {
int flags;
private ArrayList<Attachment> attachments;
@ -80,13 +74,13 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
private ViewPager mPager;
private long downloadID;
private boolean fullscreen;
private SlidrInterface slidrInterface;
private TextView media_description;
private Handler handler;
private boolean swipeEnabled;
private int minTouch, maxTouch;
private float startX;
private float startY;
private int bgColor;
private BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@ -131,21 +125,24 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
media_description = findViewById(R.id.media_description);
final int med_desc_timeout = sharedpreferences.getInt(Helper.SET_MED_DESC_TIMEOUT, 3) * 1000;
flags = getWindow().getDecorView().getSystemUiVisibility();
if (getIntent().getExtras() != null) {
mediaPosition = getIntent().getExtras().getInt("position", 1);
bgColor = getIntent().getExtras().getInt("bgcolor", -1);
}
swipeEnabled = true;
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
//actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary)));
actionBar.setBackgroundDrawable(new ColorDrawable(bgColor));
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null;
View view = inflater.inflate(R.layout.media_action_bar, new LinearLayout(SlideMediaActivity.this), false);
view.setBackground(new ColorDrawable(ContextCompat.getColor(SlideMediaActivity.this, R.color.cyanea_primary)));
view.setBackgroundColor(bgColor);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
ImageView media_save = getSupportActionBar().getCustomView().findViewById(R.id.media_save);
ImageView media_share = getSupportActionBar().getCustomView().findViewById(R.id.media_share);
ImageView media_save = actionBar.getCustomView().findViewById(R.id.media_save);
ImageView media_share = actionBar.getCustomView().findViewById(R.id.media_share);
toolbar_close.setOnClickListener(v -> finish());
media_save.setOnClickListener(view12 -> {
int position = mPager.getCurrentItem();
@ -198,8 +195,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
}
attachments = getIntent().getParcelableArrayListExtra("mediaArray");
if (getIntent().getExtras() != null)
mediaPosition = getIntent().getExtras().getInt("position", 1);
if (attachments == null || attachments.size() == 0)
finish();
@ -246,19 +242,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
}
});
SlidrConfig config = new SlidrConfig.Builder()
.sensitivity(1f)
.scrimColor(Color.BLACK)
.scrimStartAlpha(0.8f)
.scrimEndAlpha(0f)
.position(SlidrPosition.VERTICAL)
.velocityThreshold(2400)
.distanceThreshold(0.25f)
.edgeSize(0.18f)
.build();
slidrInterface = Slidr.attach(SlideMediaActivity.this, config);
setFullscreen(true);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
@ -352,15 +336,6 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
super.onPostResume();
}
public void enableSliding(boolean enable) {
if (enable && !swipeEnabled) {
slidrInterface.unlock();
swipeEnabled = true;
} else if (!enable && swipeEnabled) {
slidrInterface.lock();
swipeEnabled = false;
}
}
public boolean getFullScreen() {
return this.fullscreen;
@ -419,6 +394,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
MediaSliderFragment mediaSliderFragment = new MediaSliderFragment();
bundle.putInt("position", position);
bundle.putParcelable("attachment", attachments.get(position));
bundle.putInt("bgcolor", bgColor);
mediaSliderFragment.setArguments(bundle);
return mediaSliderFragment;
}

View File

@ -3708,7 +3708,8 @@ public class API {
newStatus.setArt_attachment(attachment);
apiResponseReply.getStatuses().add(newStatus);
}
}catch (Exception ignored){}
} catch (Exception ignored) {
}
}
}
}

View File

@ -173,6 +173,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
attachments.add(status.getMedia_attachments().get(0));
intent.putParcelableArrayListExtra("mediaArray", attachments);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
b.putInt("position", 1);
intent.putExtras(b);
context.startActivity(intent);

View File

@ -84,6 +84,7 @@ public class ImageAdapter extends RecyclerView.Adapter {
}
intent.putParcelableArrayListExtra("mediaArray", attachmentsTmp);
b.putInt("position", (viewHolder.getAdapterPosition() + 1));
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
context.startActivity(intent);
});

View File

@ -1184,6 +1184,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", notification.getStatus().getMedia_attachments());
b.putInt("position", finalPosition);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
context.startActivity(intent);
});

View File

@ -397,6 +397,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments());
b.putInt("position", 1);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
context.startActivity(intent);
});

View File

@ -134,6 +134,7 @@ public class PixelfedStoriesListAdapter extends RecyclerView.Adapter {
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", attachments);
b.putInt("position", 1);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
context.startActivity(intent);
});

View File

@ -107,6 +107,7 @@ public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapter
intent.putParcelableArrayListExtra("mediaArray", attachments);
b.putInt("position", (position + 1));
b.putInt("bgcolor", contextWeakReference.get().getResources().getColor(R.color.cyanea_primary_dark));
intent.putExtras(b);
contextWeakReference.get().startActivity(intent);
});

View File

@ -3404,6 +3404,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
Intent intent = new Intent(context, SlideMediaActivity.class);
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", attachmentArrayList);
b.putInt("bgcolor", context.getResources().getColor(R.color.cyanea_primary_dark));
b.putInt("position", finalPosition);
intent.putExtras(b);
context.startActivity(intent);

View File

@ -21,7 +21,6 @@ import android.app.TimePickerDialog;
import android.content.ComponentName;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@ -470,7 +469,7 @@ 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()
new DownloadTrackingDomainsAsyncTask(Objects.requireNonNull(getActivity()), update_tracking_domains).execute()
);
@ -1028,7 +1027,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
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.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));
@ -1051,7 +1050,6 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
});
int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
SeekBar set_truncate_size = rootView.findViewById(R.id.set_truncate_size);
set_truncate_size.setMax(20);

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
@ -51,12 +52,16 @@ import com.github.chrisbanes.photoview.PhotoView;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
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;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrConfig;
import com.r0adkll.slidr.model.SlidrInterface;
import com.r0adkll.slidr.model.SlidrListener;
import com.r0adkll.slidr.model.SlidrPosition;
import org.jetbrains.annotations.NotNull;
@ -107,6 +112,9 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
private ImageButton playView;
private GLAudioVisualizationView visualizerView;
private View rootView;
private SlidrInterface slidrInterface;
private boolean swipeEnabled;
private int bgColor;
public MediaSliderFragment() {
}
@ -120,8 +128,10 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (bundle != null) {
attachment = bundle.getParcelable("attachment");
}
bgColor = bundle.getInt("bgcolor", R.color.black);
}
swipeEnabled = true;
message_ready = rootView.findViewById(R.id.message_ready);
RelativeLayout content_audio = rootView.findViewById(R.id.content_audio);
@ -154,9 +164,9 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
if (!((SlideMediaActivity) context).getFullScreen()) {
((SlideMediaActivity) context).setFullscreen(true);
}
((SlideMediaActivity) context).enableSliding(false);
enableSliding(false);
} else {
((SlideMediaActivity) context).enableSliding(true);
enableSliding(true);
}
});
ProgressBar pbar_inf = rootView.findViewById(R.id.pbar_inf);
@ -173,6 +183,11 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
attachment.setType(type);
}
if (bgColor != -1) {
RelativeLayout media_fragment_container = rootView.findViewById(R.id.media_fragment_container);
media_fragment_container.setBackgroundColor(bgColor);
}
switch (type.toLowerCase()) {
case "image":
pbar_inf.setScaleY(1f);
@ -242,12 +257,12 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
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) {
if (video_cache == 0) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
Util.getUserAgent(context, userAgent), null);
videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
}else{
} else {
CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(context, video_cache * 1024 * 1024, 5 * 1024 * 1024);
videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
.createMediaSource(uri);
@ -291,9 +306,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
webview_video.getSettings().setDomStorageEnabled(true);
webview_video.getSettings().setAppCacheEnabled(true);
String user_agent = sharedpreferences.getString(Helper.SET_CUSTOM_USER_AGENT, Helper.USER_AGENT);
if (user_agent != null) {
webview_video.getSettings().setUserAgentString(user_agent);
}
webview_video.getSettings().setUserAgentString(user_agent);
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
webview_video.setWebViewClient(new MastalabWebViewClient((Activity) context));
webview_video.loadUrl(attachment.getUrl());
@ -491,8 +504,49 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
visualizerView.onResume();
} catch (Exception ignored) {
}
if (slidrInterface == null && rootView != null) {
slidrInterface = Slidr.replace(rootView.findViewById(R.id.media_fragment_container), new SlidrConfig.Builder().sensitivity(1f)
.scrimColor(Color.BLACK)
.scrimStartAlpha(0.8f)
.scrimEndAlpha(0f)
.position(SlidrPosition.VERTICAL)
.velocityThreshold(2400)
.distanceThreshold(0.25f)
.edgeSize(0.18f)
.listener(new SlidrListener() {
@Override
public void onSlideStateChanged(int state) {
}
@Override
public void onSlideChange(float percent) {
((SlideMediaActivity) context).setFullscreen(true);
}
@Override
public void onSlideOpened() {
}
@Override
public boolean onSlideClosed() {
return false;
}
})
.build());
}
}
private void enableSliding(boolean enable) {
if (enable && !swipeEnabled) {
slidrInterface.unlock();
swipeEnabled = true;
} else if (!enable && swipeEnabled) {
slidrInterface.lock();
swipeEnabled = false;
}
}
@Override
public void onCompletion(MediaPlayer mp) {

View File

@ -472,8 +472,6 @@ public class Helper {
public static final String EP_AUTHORIZE = "/oauth/authorize";
//Proxy
public static final String SET_PROXY_ENABLED = "set_proxy_enabled";
public static final String SET_PROXY_TYPE = "set_proxy_type";

View File

@ -81,7 +81,7 @@ public class TextEditorDialogFragment extends DialogFragment {
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mAddTextEditText = view.findViewById(R.id.add_text_edit_text);
if( getActivity() != null) {
if (getActivity() != null) {
mInputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
TextView mAddTextDoneTextView = view.findViewById(R.id.add_text_done_tv);

View File

@ -17,6 +17,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:animateLayoutChanges="true">
<androidx.viewpager.widget.ViewPager

View File

@ -1,178 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
android:id="@+id/main_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main Loader -->
<RelativeLayout
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center">
<ProgressBar
android:id="@+id/pbar_inf"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="false"
android:max="100"
android:progress="0" />
<TextView
android:id="@+id/loader_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/dark_text"
android:textSize="12sp" />
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webview_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
<FrameLayout
android:id="@+id/media_picture_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<!-- Description is set dynamically -->
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/media_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:visibility="gone" />
</FrameLayout>
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:id="@+id/content_audio"
android:background="@color/black"
android:id="@+id/media_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<!-- Main Loader -->
<RelativeLayout
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:orientation="vertical">
android:gravity="center">
<ProgressBar
android:id="@+id/pbar_inf"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="false"
android:max="100"
android:progress="0" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:id="@+id/loader_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="invisible" />
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:text="00:00:00"
android:textColor="@android:color/white"
android:textSize="60sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/aar_footer_height"
android:layout_alignParentBottom="true">
<ImageButton
android:id="@+id/play"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginTop="50dp"
android:contentDescription="@string/play_video"
android:onClick="togglePlaying"
android:padding="10dp"
android:scaleType="fitCenter"
android:src="@drawable/aar_ic_play" />
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/dark_text"
android:textSize="12sp" />
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webview_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
<FrameLayout
android:id="@+id/media_picture_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<!-- Description is set dynamically -->
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/media_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:visibility="gone" />
</FrameLayout>
<RelativeLayout
android:id="@+id/content_audio"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:orientation="vertical">
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:textSize="20sp"
android:visibility="invisible" />
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:text="00:00:00"
android:textColor="@android:color/white"
android:textSize="60sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/aar_footer_height"
android:layout_alignParentBottom="true">
<ImageButton
android:id="@+id/play"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginTop="50dp"
android:contentDescription="@string/play_video"
android:onClick="togglePlaying"
android:padding="10dp"
android:scaleType="fitCenter"
android:src="@drawable/aar_ic_play" />
</RelativeLayout>
</RelativeLayout>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/media_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:visibility="gone" />
<ImageView
android:id="@+id/media_prev"
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@color/transparent_grey"
android:contentDescription="@string/previous"
android:src="@drawable/ic_first_page"
android:tint="@color/white"
android:visibility="gone" />
<ImageView
android:id="@+id/media_next"
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@color/transparent_grey"
android:contentDescription="@string/next"
android:src="@drawable/ic_last_page"
android:visibility="gone" />
<TextView
android:id="@+id/message_ready"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignBottom="@+id/media_picture_container"
android:layout_marginBottom="40dp"
android:background="@drawable/media_message_border"
android:gravity="center"
android:text="@string/media_ready"
android:textColor="@color/dark_text"
android:textSize="14sp"
android:visibility="gone" />
</RelativeLayout>
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/media_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:visibility="gone" />
<ImageView
android:id="@+id/media_prev"
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@color/transparent_grey"
android:contentDescription="@string/previous"
android:src="@drawable/ic_first_page"
android:tint="@color/white"
android:visibility="gone" />
<ImageView
android:id="@+id/media_next"
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@color/transparent_grey"
android:contentDescription="@string/next"
android:src="@drawable/ic_last_page"
android:visibility="gone" />
<TextView
android:id="@+id/message_ready"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignBottom="@+id/media_picture_container"
android:layout_marginBottom="40dp"
android:background="@drawable/media_message_border"
android:gravity="center"
android:text="@string/media_ready"
android:textColor="@color/dark_text"
android:textSize="14sp"
android:visibility="gone" />
</RelativeLayout>
</FrameLayout>

View File

@ -20,7 +20,6 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimary"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"

View File

@ -152,27 +152,28 @@
<item name="android:textColor">@color/black</item>
<item name="linkColor">@color/light_link_toot</item>
<item name="android:itemBackground">@drawable/menu_selector</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="TransparentDark" parent="Theme.Cyanea.Dark">
<item name="iconColor">@color/dark_icon_theme</item>
<item name="iconColorMenu">@color/dark_icon_theme</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:textColor">@color/dark_text</item>
<item name="linkColor">@color/dark_link_toot</item>
<item name="android:itemBackground">@drawable/menu_selector</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="TransparentBlack" parent="Theme.Cyanea.Dark">
<item name="iconColor">@color/black_icon_theme</item>
<item name="iconColorMenu">@color/dark_icon_theme</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:textColor">@color/dark_text</item>
<item name="linkColor">@color/black_link_toot</item>
<item name="android:itemBackground">@drawable/menu_selector</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Fedilab.PopupMenu.Light" parent="Cyanea.PopupMenu.Light">