Last changes
This commit is contained in:
parent
a1fe5c8cc1
commit
15f9f03e8e
|
@ -85,7 +85,6 @@ dependencies {
|
|||
implementation "com.google.code.gson:gson:$gsonLibraryVersion"
|
||||
implementation "com.google.guava:guava:$guavaLibraryVersion"
|
||||
implementation "com.github.chrisbanes:PhotoView:$photoViewLibraryVersion"
|
||||
implementation "com.github.stom79:SwipeBackLayout:$swipebackLibraryVersion"
|
||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
||||
implementation 'com.github.stom79:mytransl:1.5'
|
||||
|
|
|
@ -307,12 +307,6 @@
|
|||
android:name="app.fedilab.android.activities.WebviewActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||
<activity
|
||||
android:name="app.fedilab.android.activities.MediaActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/TransparentDark"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:noHistory="true" />
|
||||
<activity
|
||||
android:name="app.fedilab.android.activities.SlideMediaActivity"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -1,833 +0,0 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Fedilab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package app.fedilab.android.activities;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.RectF;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.cleveroad.audiovisualization.DbmHandler;
|
||||
import com.cleveroad.audiovisualization.GLAudioVisualizationView;
|
||||
import com.github.chrisbanes.photoview.OnMatrixChangedListener;
|
||||
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.ExtractorMediaSource;
|
||||
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.gw.swipeback.SwipeBackLayout;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import app.fedilab.android.client.Entities.Attachment;
|
||||
import app.fedilab.android.client.Entities.Error;
|
||||
import app.fedilab.android.client.HttpsConnection;
|
||||
import app.fedilab.android.client.TLSSocketFactory;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.webview.MastalabWebChromeClient;
|
||||
import app.fedilab.android.webview.MastalabWebViewClient;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.interfaces.OnDownloadInterface;
|
||||
import cafe.adriel.androidaudiorecorder.VisualizerHandler;
|
||||
import omrecorder.AudioChunk;
|
||||
import omrecorder.PullTransport;
|
||||
|
||||
import static app.fedilab.android.helper.Helper.changeDrawableColor;
|
||||
import static cafe.adriel.androidaudiorecorder.Util.formatSeconds;
|
||||
import static cafe.adriel.androidaudiorecorder.Util.getDarkerColor;
|
||||
import static cafe.adriel.androidaudiorecorder.Util.isBrightColor;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 25/06/2017.
|
||||
* Media Activity
|
||||
*/
|
||||
|
||||
public class MediaActivity extends BaseActivity implements OnDownloadInterface, MediaPlayer.OnCompletionListener {
|
||||
|
||||
|
||||
private RelativeLayout loader;
|
||||
private ArrayList<Attachment> attachments;
|
||||
private PhotoView imageView;
|
||||
private SimpleExoPlayerView videoView;
|
||||
private float downX;
|
||||
private float downY;
|
||||
private int mediaPosition;
|
||||
MediaActivity.actionSwipe currentAction;
|
||||
static final int MIN_DISTANCE = 100;
|
||||
private String finalUrlDownload;
|
||||
private String preview_url;
|
||||
private ImageView prev, next;
|
||||
private boolean isControlElementShown = true;
|
||||
private Bitmap downloadedImage;
|
||||
private File fileVideo;
|
||||
private TextView progress;
|
||||
private ProgressBar pbar_inf;
|
||||
private TextView message_ready;
|
||||
private boolean canSwipe;
|
||||
private TextView media_description;
|
||||
private Attachment attachment;
|
||||
SwipeBackLayout mSwipeBackLayout;
|
||||
private float imageScale = 0;
|
||||
private RelativeLayout action_bar_container;
|
||||
private VisualizerHandler visualizerHandler;
|
||||
private TextView statusView;
|
||||
private TextView timerView;
|
||||
private ImageButton playView;
|
||||
private GLAudioVisualizationView visualizerView;
|
||||
|
||||
private enum actionSwipe {
|
||||
RIGHT_TO_LEFT,
|
||||
LEFT_TO_RIGHT,
|
||||
POP
|
||||
}
|
||||
|
||||
private WebView webview_video;
|
||||
private ImageButton media_save, media_share, media_close;
|
||||
private boolean scheduleHidden, scheduleHiddenDescription;
|
||||
private SimpleExoPlayer player;
|
||||
private boolean isSHaring;
|
||||
private String instance;
|
||||
private RelativeLayout content_audio;
|
||||
private MediaPlayer playeraudio;
|
||||
private Timer timer;
|
||||
private int playerSecondsElapsed;
|
||||
private static final Handler HANDLER = new Handler();
|
||||
private String url;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
if (theme == Helper.THEME_BLACK)
|
||||
setTheme(R.style.TransparentBlack);
|
||||
super.onCreate(savedInstanceState);
|
||||
hideSystemUI();
|
||||
setContentView(R.layout.activity_media);
|
||||
action_bar_container = findViewById(R.id.action_bar_container);
|
||||
mSwipeBackLayout = new SwipeBackLayout(MediaActivity.this);
|
||||
mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_TOP);
|
||||
mSwipeBackLayout.setMaskAlpha(125);
|
||||
mSwipeBackLayout.setSwipeBackFactor(0.5f);
|
||||
mSwipeBackLayout.setSwipeBackListener(new SwipeBackLayout.OnSwipeBackListener() {
|
||||
@Override
|
||||
public void onViewPositionChanged(View mView, float swipeBackFraction, float SWIPE_BACK_FACTOR) {
|
||||
canSwipe = swipeBackFraction < 0.1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewSwipeFinished(View mView, boolean isEnd) {
|
||||
if (!isEnd)
|
||||
canSwipe = true;
|
||||
else {
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
instance = Helper.getLiveInstance(MediaActivity.this);
|
||||
mSwipeBackLayout.attachToActivity(this);
|
||||
attachments = getIntent().getParcelableArrayListExtra("mediaArray");
|
||||
if (getIntent().getExtras() != null)
|
||||
mediaPosition = getIntent().getExtras().getInt("position", 1);
|
||||
if (attachments == null || attachments.size() == 0)
|
||||
finish();
|
||||
|
||||
RelativeLayout main_container_media = findViewById(R.id.main_container_media);
|
||||
if (theme == Helper.THEME_LIGHT) {
|
||||
main_container_media.setBackgroundResource(R.color.mastodonC2);
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
main_container_media.setBackgroundResource(R.color.black);
|
||||
} else if (theme == Helper.THEME_DARK) {
|
||||
main_container_media.setBackgroundResource(R.color.mastodonC1_);
|
||||
}
|
||||
media_description = findViewById(R.id.media_description);
|
||||
message_ready = findViewById(R.id.message_ready);
|
||||
media_save = findViewById(R.id.media_save);
|
||||
media_share = findViewById(R.id.media_share);
|
||||
media_close = findViewById(R.id.media_close);
|
||||
progress = findViewById(R.id.loader_progress);
|
||||
webview_video = findViewById(R.id.webview_video);
|
||||
content_audio = findViewById(R.id.content_audio);
|
||||
media_save.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
isSHaring = false;
|
||||
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio") || attachment.getType().toLowerCase().equals("gifv") || attachment.getType().toLowerCase().equals("web")) {
|
||||
if (attachment != null) {
|
||||
progress.setText("0 %");
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
new HttpsConnection(MediaActivity.this, instance).download(attachment.getUrl(), MediaActivity.this);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, false);
|
||||
}
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
media_share.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
isSHaring = true;
|
||||
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio") || attachment.getType().toLowerCase().equals("gifv")) {
|
||||
if (attachment != null) {
|
||||
progress.setText("0 %");
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
new HttpsConnection(MediaActivity.this, instance).download(attachment.getUrl(), MediaActivity.this);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, true);
|
||||
}
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
media_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
canSwipe = true;
|
||||
loader = findViewById(R.id.loader);
|
||||
imageView = findViewById(R.id.media_picture);
|
||||
videoView = findViewById(R.id.media_video);
|
||||
prev = findViewById(R.id.media_prev);
|
||||
next = findViewById(R.id.media_next);
|
||||
if (theme == Helper.THEME_BLACK) {
|
||||
changeDrawableColor(getApplicationContext(), prev, R.color.dark_icon);
|
||||
changeDrawableColor(getApplicationContext(), next, R.color.dark_icon);
|
||||
} else if (theme == Helper.THEME_LIGHT) {
|
||||
changeDrawableColor(getApplicationContext(), prev, R.color.mastodonC4);
|
||||
changeDrawableColor(getApplicationContext(), next, R.color.mastodonC4);
|
||||
} else {
|
||||
changeDrawableColor(getApplicationContext(), prev, R.color.white);
|
||||
changeDrawableColor(getApplicationContext(), next, R.color.white);
|
||||
}
|
||||
prev.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mediaPosition--;
|
||||
displayMediaAtPosition(actionSwipe.POP);
|
||||
}
|
||||
});
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mediaPosition++;
|
||||
displayMediaAtPosition(actionSwipe.POP);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
imageView.setOnMatrixChangeListener(new OnMatrixChangedListener() {
|
||||
@Override
|
||||
public void onMatrixChanged(RectF rect) {
|
||||
imageScale = imageView.getScale();
|
||||
canSwipe = (imageView.getScale() == 1);
|
||||
mSwipeBackLayout.isDisabled(imageView.getScale() != 1);
|
||||
}
|
||||
});
|
||||
if (attachments != null && attachments.size() > 1) {
|
||||
prev.setVisibility(View.VISIBLE);
|
||||
next.setVisibility(View.VISIBLE);
|
||||
}
|
||||
pbar_inf = findViewById(R.id.pbar_inf);
|
||||
setTitle("");
|
||||
|
||||
//isHiding = false;
|
||||
setTitle("");
|
||||
displayMediaAtPosition(actionSwipe.POP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
outState.putFloat("scale", imageScale);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
stopPlaying();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage touch event
|
||||
* Allows to swipe from timelines
|
||||
*
|
||||
* @param event MotionEvent
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
Boolean thisControllShown = isControlElementShown;
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
downX = event.getX();
|
||||
downY = event.getY();
|
||||
//Displays navigation left/right buttons
|
||||
if (attachments != null && attachments.size() > 1) {
|
||||
if (thisControllShown) {
|
||||
prev.setVisibility(View.GONE);
|
||||
next.setVisibility(View.GONE);
|
||||
} else {
|
||||
prev.setVisibility(View.VISIBLE);
|
||||
next.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
case MotionEvent.ACTION_UP: {
|
||||
float upX = event.getX();
|
||||
float deltaX = downX - upX;
|
||||
float upY = event.getY();
|
||||
float deltaY = downY - upY;
|
||||
// swipe horizontal
|
||||
if (downX > MIN_DISTANCE & (Math.abs(deltaX) > MIN_DISTANCE)) {
|
||||
if (!canSwipe || mediaPosition > attachments.size() || mediaPosition < 1 || attachments.size() <= 1)
|
||||
return super.dispatchTouchEvent(event);
|
||||
if (deltaX < 0) {
|
||||
switchOnSwipe(MediaActivity.actionSwipe.LEFT_TO_RIGHT);
|
||||
return true;
|
||||
}
|
||||
if (deltaX > 0) {
|
||||
switchOnSwipe(MediaActivity.actionSwipe.RIGHT_TO_LEFT);
|
||||
return true;
|
||||
}
|
||||
} else if (downY > MIN_DISTANCE & (Math.abs(deltaY) > MIN_DISTANCE)) {
|
||||
if (deltaY > 0 && canSwipe) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
if (deltaY < 0 && canSwipe) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
currentAction = MediaActivity.actionSwipe.POP;
|
||||
isControlElementShown = !isControlElementShown;
|
||||
if (thisControllShown) {
|
||||
if (event.getY() > action_bar_container.getHeight()) {
|
||||
hideSystemUI();
|
||||
action_bar_container.setVisibility(View.GONE);
|
||||
if (media_description.getVisibility() == View.VISIBLE) {
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
if (videoView.getVisibility() == View.VISIBLE)
|
||||
videoView.hideController();
|
||||
}
|
||||
} else {
|
||||
action_bar_container.setVisibility(View.VISIBLE);
|
||||
FullScreencall(thisControllShown);
|
||||
if (attachment != null && attachment.getDescription() != null && !attachment.getDescription().equals("null")) {
|
||||
media_description.setText(attachment.getDescription());
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
imageView.setContentDescription(attachment.getDescription());
|
||||
} else {
|
||||
media_description.setText("");
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
if (videoView.getVisibility() == View.VISIBLE)
|
||||
videoView.showController();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
|
||||
private void switchOnSwipe(actionSwipe action) {
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
mediaPosition = (action == actionSwipe.LEFT_TO_RIGHT) ? mediaPosition - 1 : mediaPosition + 1;
|
||||
displayMediaAtPosition(action);
|
||||
}
|
||||
|
||||
private void displayMediaAtPosition(actionSwipe action) {
|
||||
if (mediaPosition > attachments.size())
|
||||
mediaPosition = 1;
|
||||
if (mediaPosition < 1)
|
||||
mediaPosition = attachments.size();
|
||||
currentAction = action;
|
||||
attachment = attachments.get(mediaPosition - 1);
|
||||
String type = attachment.getType();
|
||||
String url = attachment.getUrl();
|
||||
finalUrlDownload = url;
|
||||
videoView.setVisibility(View.GONE);
|
||||
|
||||
imageView.setVisibility(View.GONE);
|
||||
|
||||
if (attachment.getDescription() != null && !attachment.getDescription().equals("null")) {
|
||||
media_description.setText(attachment.getDescription());
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
media_description.setText("");
|
||||
media_description.setVisibility(View.GONE);
|
||||
}
|
||||
preview_url = attachment.getPreview_url();
|
||||
if (type.equals("unknown")) {
|
||||
preview_url = attachment.getRemote_url();
|
||||
if (preview_url.endsWith(".png") || preview_url.endsWith(".jpg") || preview_url.endsWith(".jpeg") || preview_url.endsWith(".gif")) {
|
||||
type = "image";
|
||||
} else if (preview_url.endsWith(".mp4") || preview_url.endsWith(".mp3")) {
|
||||
type = "video";
|
||||
}
|
||||
url = attachment.getRemote_url();
|
||||
attachment.setType(type);
|
||||
}
|
||||
final String finalUrl = url;
|
||||
switch (type.toLowerCase()) {
|
||||
case "image":
|
||||
pbar_inf.setScaleY(1f);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
fileVideo = null;
|
||||
pbar_inf.setIndeterminate(true);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
fileVideo = null;
|
||||
if (!finalUrl.endsWith(".gif")) {
|
||||
Glide.with(getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(preview_url).into(
|
||||
new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(MediaActivity.this, resource);
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
Glide.with(getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(finalUrl).into(
|
||||
new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
loader.setVisibility(View.GONE);
|
||||
Bitmap imageCompressed = Helper.compressImageIfNeeded(MediaActivity.this, resource);
|
||||
if (imageView.getScale() < 1.1) {
|
||||
downloadedImage = resource;
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
} else {
|
||||
message_ready.setVisibility(View.VISIBLE);
|
||||
}
|
||||
message_ready.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
downloadedImage = resource;
|
||||
imageView.setImageBitmap(imageCompressed);
|
||||
message_ready.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
loader.setVisibility(View.GONE);
|
||||
Glide.with(getApplicationContext())
|
||||
.load(finalUrl).into(imageView);
|
||||
}
|
||||
break;
|
||||
case "video":
|
||||
case "gifv":
|
||||
pbar_inf.setIndeterminate(false);
|
||||
pbar_inf.setScaleY(3f);
|
||||
try {
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
videoView.setVisibility(View.VISIBLE);
|
||||
Uri uri = Uri.parse(url);
|
||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
|
||||
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
|
||||
ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(uri);
|
||||
player = ExoPlayerFactory.newSimpleInstance(MediaActivity.this);
|
||||
if (type.toLowerCase().equals("gifv"))
|
||||
player.setRepeatMode(Player.REPEAT_MODE_ONE);
|
||||
videoView.setPlayer(player);
|
||||
loader.setVisibility(View.GONE);
|
||||
player.prepare(videoSource);
|
||||
player.setPlayWhenReady(true);
|
||||
break;
|
||||
case "web":
|
||||
loader.setVisibility(View.GONE);
|
||||
webview_video = Helper.initializeWebview(MediaActivity.this, R.id.webview_video);
|
||||
webview_video.setVisibility(View.VISIBLE);
|
||||
FrameLayout webview_container = findViewById(R.id.main_media_frame);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
|
||||
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(MediaActivity.this, webview_video, webview_container, videoLayout);
|
||||
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
||||
@Override
|
||||
public void toggledFullscreen(boolean fullscreen) {
|
||||
|
||||
if (fullscreen) {
|
||||
videoLayout.setVisibility(View.VISIBLE);
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
getWindow().setAttributes(attrs);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
} else {
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
getWindow().setAttributes(attrs);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
videoLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
webview_video.getSettings().setAllowFileAccess(true);
|
||||
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
||||
webview_video.getSettings().setDomStorageEnabled(true);
|
||||
webview_video.getSettings().setAppCacheEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
webview_video.setWebViewClient(new MastalabWebViewClient(MediaActivity.this));
|
||||
webview_video.loadUrl(attachment.getUrl());
|
||||
break;
|
||||
case "audio":
|
||||
loader.setVisibility(View.GONE);
|
||||
content_audio.setVisibility(View.VISIBLE);
|
||||
int color = getResources().getColor(R.color.mastodonC1);
|
||||
visualizerView = new GLAudioVisualizationView.Builder(MediaActivity.this)
|
||||
.setLayersCount(1)
|
||||
.setWavesCount(6)
|
||||
.setWavesHeight(R.dimen.aar_wave_height)
|
||||
.setWavesFooterHeight(R.dimen.aar_footer_height)
|
||||
.setBubblesPerLayer(20)
|
||||
.setBubblesSize(R.dimen.aar_bubble_size)
|
||||
.setBubblesRandomizeSize(true)
|
||||
.setBackgroundColor(getDarkerColor(color))
|
||||
.setLayerColors(new int[]{color})
|
||||
.build();
|
||||
|
||||
statusView = findViewById(R.id.status);
|
||||
timerView = findViewById(R.id.timer);
|
||||
playView = findViewById(R.id.play);
|
||||
content_audio.setBackgroundColor(getDarkerColor(color));
|
||||
content_audio.addView(visualizerView, 0);
|
||||
playView.setVisibility(View.INVISIBLE);
|
||||
this.url = attachment.getUrl();
|
||||
|
||||
startPlaying();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void togglePlaying(View v) {
|
||||
|
||||
HANDLER.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isPlaying()) {
|
||||
stopPlaying();
|
||||
} else {
|
||||
startPlaying();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private void startPlaying() {
|
||||
try {
|
||||
|
||||
playeraudio = new MediaPlayer();
|
||||
playeraudio.setDataSource(url);
|
||||
playeraudio.prepare();
|
||||
playeraudio.start();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) ==
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
visualizerView.linkTo(DbmHandler.Factory.newVisualizerHandler(MediaActivity.this, playeraudio));
|
||||
}
|
||||
|
||||
}
|
||||
visualizerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playeraudio.setOnCompletionListener(MediaActivity.this);
|
||||
}
|
||||
});
|
||||
|
||||
timerView.setText("00:00:00");
|
||||
playView.setVisibility(View.VISIBLE);
|
||||
statusView.setText(R.string.aar_playing);
|
||||
statusView.setVisibility(View.VISIBLE);
|
||||
playView.setImageResource(R.drawable.aar_ic_stop);
|
||||
|
||||
playerSecondsElapsed = 0;
|
||||
startTimer();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void stopPlaying() {
|
||||
statusView.setText("");
|
||||
statusView.setVisibility(View.INVISIBLE);
|
||||
playView.setImageResource(R.drawable.aar_ic_play);
|
||||
|
||||
visualizerView.release();
|
||||
if (visualizerHandler != null) {
|
||||
visualizerHandler.stop();
|
||||
}
|
||||
|
||||
if (playeraudio != null) {
|
||||
try {
|
||||
playeraudio.pause();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
private void startTimer() {
|
||||
stopTimer();
|
||||
timer = new Timer();
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTimer();
|
||||
}
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
private void updateTimer() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playerSecondsElapsed++;
|
||||
timerView.setText(formatSeconds(playerSecondsElapsed));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void stopTimer() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPlaying() {
|
||||
try {
|
||||
return playeraudio != null && playeraudio.isPlaying();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloaded(String path, String originUrl, Error error) {
|
||||
|
||||
if (path != null) {
|
||||
File response = new File(path);
|
||||
File dir = getCacheDir();
|
||||
File from = new File(dir, response.getName());
|
||||
File to = new File(dir, Helper.md5(originUrl) + ".mp4");
|
||||
if (from.exists())
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
from.renameTo(to);
|
||||
fileVideo = to;
|
||||
downloadedImage = null;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, isSHaring);
|
||||
}
|
||||
} else {
|
||||
Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo, isSHaring);
|
||||
}
|
||||
if (progress != null)
|
||||
progress.setVisibility(View.GONE);
|
||||
if (loader != null)
|
||||
loader.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (player != null) {
|
||||
player.setPlayWhenReady(false);
|
||||
}
|
||||
if (playeraudio != null) {
|
||||
playeraudio.pause();
|
||||
}
|
||||
try {
|
||||
visualizerView.onPause();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
try {
|
||||
if (visualizerView != null) {
|
||||
visualizerView.release();
|
||||
}
|
||||
if (player != null) {
|
||||
player.release();
|
||||
}
|
||||
if (playeraudio != null) {
|
||||
playeraudio.release();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (player != null) {
|
||||
player.setPlayWhenReady(true);
|
||||
}
|
||||
if (playeraudio != null) {
|
||||
playeraudio.start();
|
||||
}
|
||||
try {
|
||||
visualizerView.onResume();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
FullScreencall(false);
|
||||
}
|
||||
|
||||
public void FullScreencall(Boolean shouldFullscreen) {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
View v = this.getWindow().getDecorView();
|
||||
if (shouldFullscreen) {
|
||||
v.setSystemUiVisibility(View.GONE);
|
||||
} else {
|
||||
v.setSystemUiVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
View decorView = getWindow().getDecorView();
|
||||
if (shouldFullscreen) {
|
||||
decorView.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
// Set the content to appear under the system bars so that the
|
||||
// content doesn't resize when the system bars hide and show.
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
// Hide the nav bar and status bar
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
} else {
|
||||
decorView.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateProgress(int progressPercentage) {
|
||||
progress.setText(String.format("%s%%", String.valueOf(progressPercentage)));
|
||||
pbar_inf.setProgress(progressPercentage);
|
||||
}
|
||||
|
||||
|
||||
private void hideSystemUI() {
|
||||
View mDecorView = getWindow().getDecorView();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
mDecorView.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -143,20 +143,16 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
public void onClick(View view) {
|
||||
int position = mPager.getCurrentItem();
|
||||
Attachment attachment = attachments.get(position);
|
||||
if (attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio") || attachment.getType().toLowerCase().equals("gifv") || attachment.getType().toLowerCase().equals("web")) { ;
|
||||
new HttpsConnection(getApplicationContext(), Helper.getLiveInstance(getApplicationContext())).download(attachment.getUrl(), SlideMediaActivity.this);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(SlideMediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SlideMediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
|
||||
} else {
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
} else {
|
||||
Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
|
||||
downloadID = -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -202,7 +198,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
registerReceiver(onDownloadComplete,new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||
String description = attachments.get(mediaPosition-1).getDescription();
|
||||
handler = new Handler();
|
||||
if( description != null && description.trim().length() > 0 ){
|
||||
if( description != null && description.trim().length() > 0 && description.trim().compareTo("null") != 0 ){
|
||||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -226,7 +222,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
handler = new Handler();
|
||||
if( description != null && description.trim().length() > 0 ){
|
||||
if( description != null && description.trim().length() > 0 && description.trim().compareTo("null") != 0){
|
||||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -280,7 +276,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
|
|||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
handler = new Handler();
|
||||
if( description != null && description.trim().length() > 0 ){
|
||||
if( description != null && description.trim().length() > 0 && description.trim().compareTo("null") != 0){
|
||||
media_description.setText(description);
|
||||
media_description.setVisibility(View.VISIBLE);
|
||||
|
||||
|
|
|
@ -36,16 +36,11 @@ import net.gotev.uploadservice.UploadStatusDelegate;
|
|||
import org.apache.poi.util.IOUtils;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -70,20 +65,13 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.MediaActivity;
|
||||
import app.fedilab.android.activities.SlideMediaActivity;
|
||||
import app.fedilab.android.activities.TootActivity;
|
||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import app.fedilab.android.client.Entities.Account;
|
||||
import app.fedilab.android.client.Entities.Attachment;
|
||||
import app.fedilab.android.client.Entities.Error;
|
||||
import app.fedilab.android.fragments.DisplayPlaylistsFragment;
|
||||
|
||||
import app.fedilab.android.helper.FileNameCleaner;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.interfaces.OnDownloadInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveAttachmentInterface;
|
||||
import app.fedilab.android.sqlite.AccountDAO;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -718,9 +706,9 @@ public class HttpsConnection {
|
|||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
downloadedFileSize += bytesRead;
|
||||
if (context instanceof MediaActivity) {
|
||||
if (context instanceof SlideMediaActivity) {
|
||||
final int currentProgress = (downloadedFileSize * 100) / contentSize;
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onUpdateProgress(currentProgress > 0 ? currentProgress : 101);
|
||||
}
|
||||
|
@ -735,8 +723,8 @@ public class HttpsConnection {
|
|||
listener.onDownloaded(saveFilePath, downloadUrl, null);
|
||||
}
|
||||
});
|
||||
if (context instanceof MediaActivity)
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
if (context instanceof SlideMediaActivity)
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onDownloaded(saveFilePath, downloadUrl, null);
|
||||
}
|
||||
|
@ -750,8 +738,8 @@ public class HttpsConnection {
|
|||
listener.onDownloaded(null, downloadUrl, error);
|
||||
}
|
||||
});
|
||||
if (context instanceof MediaActivity)
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
if (context instanceof SlideMediaActivity)
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onDownloaded(null, downloadUrl, error);
|
||||
}
|
||||
|
@ -806,9 +794,9 @@ public class HttpsConnection {
|
|||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
downloadedFileSize += bytesRead;
|
||||
if (context instanceof MediaActivity) {
|
||||
if (context instanceof SlideMediaActivity) {
|
||||
final int currentProgress = (downloadedFileSize * 100) / contentSize;
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onUpdateProgress(currentProgress > 0 ? currentProgress : 101);
|
||||
}
|
||||
|
@ -823,8 +811,8 @@ public class HttpsConnection {
|
|||
listener.onDownloaded(saveFilePath, downloadUrl, null);
|
||||
}
|
||||
});
|
||||
if (context instanceof MediaActivity)
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
if (context instanceof SlideMediaActivity)
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onDownloaded(saveFilePath, downloadUrl, null);
|
||||
}
|
||||
|
@ -838,8 +826,8 @@ public class HttpsConnection {
|
|||
listener.onDownloaded(null, downloadUrl, error);
|
||||
}
|
||||
});
|
||||
if (context instanceof MediaActivity)
|
||||
((MediaActivity) context).runOnUiThread(new Runnable() {
|
||||
if (context instanceof SlideMediaActivity)
|
||||
((SlideMediaActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onDownloaded(null, downloadUrl, error);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ package app.fedilab.android.drawers;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
@ -32,11 +31,9 @@ import android.os.Handler;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -98,7 +95,6 @@ import es.dmoral.toasty.Toasty;
|
|||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.CustomSharingActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.MediaActivity;
|
||||
import app.fedilab.android.activities.ShowAccountActivity;
|
||||
import app.fedilab.android.activities.ShowConversationActivity;
|
||||
import app.fedilab.android.activities.TootActivity;
|
||||
|
|
|
@ -23,20 +23,16 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -52,7 +48,6 @@ import android.widget.AdapterView;
|
|||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -80,7 +75,6 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.activities.MediaActivity;
|
||||
import app.fedilab.android.activities.PixelfedComposeActivity;
|
||||
import app.fedilab.android.activities.SlideMediaActivity;
|
||||
import app.fedilab.android.activities.TootActivity;
|
||||
|
|
|
@ -16,7 +16,6 @@ package app.fedilab.android.drawers;
|
|||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -36,7 +35,6 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
|
@ -45,10 +43,8 @@ import com.smarteist.autoimageslider.SliderViewAdapter;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MediaActivity;
|
||||
import app.fedilab.android.activities.PixelfedComposeActivity;
|
||||
import app.fedilab.android.activities.SlideMediaActivity;
|
||||
import app.fedilab.android.asynctasks.UpdateDescriptionAttachmentAsyncTask;
|
||||
|
|
|
@ -38,12 +38,9 @@ import androidx.annotation.NonNull;
|
|||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -90,7 +87,6 @@ import android.widget.Toast;
|
|||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.FitCenter;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
@ -128,7 +124,6 @@ import app.fedilab.android.client.Entities.Account;
|
|||
import app.fedilab.android.client.Entities.Application;
|
||||
import app.fedilab.android.client.Entities.Attachment;
|
||||
import app.fedilab.android.client.Entities.Card;
|
||||
import app.fedilab.android.client.Entities.Conversation;
|
||||
import app.fedilab.android.client.Entities.Emojis;
|
||||
import app.fedilab.android.client.Entities.Error;
|
||||
import app.fedilab.android.client.Entities.ManageTimelines;
|
||||
|
@ -145,7 +140,6 @@ import app.fedilab.android.helper.Helper;
|
|||
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
|
||||
import app.fedilab.android.interfaces.OnPostStatusActionInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveImageInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveRelationshipInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveRelationshipQuickReplyInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface;
|
||||
import app.fedilab.android.interfaces.OnRetrieveSearchInterface;
|
||||
|
@ -165,7 +159,6 @@ import app.fedilab.android.R;
|
|||
import app.fedilab.android.activities.BaseMainActivity;
|
||||
import app.fedilab.android.activities.CustomSharingActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.MediaActivity;
|
||||
import app.fedilab.android.activities.PeertubeActivity;
|
||||
import app.fedilab.android.activities.ShowAccountActivity;
|
||||
import app.fedilab.android.activities.ShowConversationActivity;
|
||||
|
@ -190,7 +183,6 @@ import static android.content.Context.MODE_PRIVATE;
|
|||
import static app.fedilab.android.activities.BaseMainActivity.mPageReferenceMap;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.mutedAccount;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.social;
|
||||
import static app.fedilab.android.activities.MainActivity.currentLocale;
|
||||
import static app.fedilab.android.helper.Helper.changeDrawableColor;
|
||||
|
||||
|
||||
|
|
|
@ -1,282 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Fedilab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<com.gw.swipeback.SwipeBackLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/swipeBackLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:directionMode="bottom"
|
||||
app:isSwipeFromEdge="true"
|
||||
app:maskAlpha="125"
|
||||
app:swipeBackFactor="0.5">
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_container_media">
|
||||
|
||||
|
||||
<!-- Main Loader -->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/loader"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<ProgressBar
|
||||
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:indeterminate="false"
|
||||
android:id="@+id/pbar_inf"
|
||||
android:layout_width="match_parent"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loader_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@color/dark_text"
|
||||
android:gravity="center"
|
||||
android:textSize="12sp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_height="wrap_content" />
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/media_webview_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/webview_video"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/media_picture_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!-- Description is set dynamically -->
|
||||
<com.github.chrisbanes.photoview.PhotoView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/media_picture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true" />
|
||||
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
android:id="@+id/media_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="62dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:padding="12dp"
|
||||
android:background="#AA000000"
|
||||
android:textColor="#ffffffff" />
|
||||
</FrameLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/content_audio"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<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:textSize="20sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="60sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:fontFamily="sans-serif-thin"
|
||||
android:text="00:00:00" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/aar_footer_height"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:padding="10dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/aar_ic_play"
|
||||
android:onClick="togglePlaying"
|
||||
style="@style/Widget.AppCompat.Button.Borderless" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/media_video"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent_grey"
|
||||
android:id="@+id/action_bar_container"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/media_close"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/transparent"
|
||||
android:contentDescription="@string/close"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_close"
|
||||
app:layout_anchorGravity="top|left" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
app:layout_anchorGravity="top|left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/media_save"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_marginStart="20dp"
|
||||
android:background="@color/transparent"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_save_white"
|
||||
android:contentDescription="@string/download" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/media_share"
|
||||
app:layout_anchorGravity="top|left"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@color/transparent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/ic_share_media"
|
||||
android:scaleType="fitXY"
|
||||
android:contentDescription="@string/share" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_prev"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="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:tint="@color/white"
|
||||
android:contentDescription="@string/previous"
|
||||
android:src="@drawable/ic_first_page"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_next"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="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:visibility="gone"
|
||||
android:background="@drawable/media_message_border"
|
||||
android:id="@+id/message_ready"
|
||||
android:textColor="@color/dark_text"
|
||||
android:text="@string/media_ready"
|
||||
android:gravity="center"
|
||||
android:textSize="14sp"
|
||||
|
||||
android:layout_alignBottom="@+id/media_picture_container"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp" />
|
||||
</RelativeLayout>
|
||||
</com.gw.swipeback.SwipeBackLayout>
|
Loading…
Reference in New Issue