Support audio
This commit is contained in:
parent
09c702b2d0
commit
fe0d65efba
|
@ -175,7 +175,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
isSHaring = false;
|
||||
if(attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("gifv") || attachment.getType().toLowerCase().equals("web")) {
|
||||
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);
|
||||
|
@ -198,7 +198,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
isSHaring = true;
|
||||
if(attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("gifv")) {
|
||||
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);
|
||||
|
@ -390,7 +390,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
preview_url = attachment.getRemote_url();
|
||||
if( preview_url.endsWith(".png") || preview_url.endsWith(".jpg")|| preview_url.endsWith(".jpeg")) {
|
||||
type = "image";
|
||||
}else if( preview_url.endsWith(".mp4")) {
|
||||
}else if( preview_url.endsWith(".mp4") || preview_url.endsWith(".mp3")) {
|
||||
type = "video";
|
||||
}
|
||||
url = attachment.getRemote_url();
|
||||
|
@ -443,6 +443,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
);
|
||||
break;
|
||||
case "video":
|
||||
case "audio":
|
||||
case "gifv":
|
||||
pbar_inf.setIndeterminate(false);
|
||||
pbar_inf.setScaleY(3f);
|
||||
|
|
|
@ -30,6 +30,8 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
|
@ -686,11 +688,11 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
intent.setType("*/*");
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
String[] mimetypes = {"image/*", "video/*"};
|
||||
String[] mimetypes = {"image/*", "video/*" , "audio/mpeg", "audio/opus", "audio/flac", "audio/wav" , "audio/ogg"};
|
||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
||||
startActivityForResult(intent, PICK_IMAGE);
|
||||
} else {
|
||||
intent.setType("image/* video/*");
|
||||
intent.setType("image/* video/* audio/mpeg audio/opus audio/flac audio/wav audio/ogg");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
}
|
||||
|
@ -1016,6 +1018,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
}else{
|
||||
upload(TootActivity.this, data.getData(), filename);
|
||||
}
|
||||
}else if(mime != null && mime.toLowerCase().contains("audio")){
|
||||
upload(TootActivity.this, data.getData(), filename);
|
||||
}else {
|
||||
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -1065,7 +1069,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
toot_picture_container.setVisibility(View.GONE);
|
||||
toot_picture.setEnabled(true);
|
||||
toot_it.setEnabled(true);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1098,12 +1101,14 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
final ImageView imageView = new ImageView(getApplicationContext());
|
||||
imageView.setId(Integer.parseInt(attachment.getId()));
|
||||
|
||||
Bitmap musicBtp = BitmapFactory.decodeResource(context.getResources(),
|
||||
R.drawable.music);
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){
|
||||
Uri uri = filesMap.get(attachment.getUrl());
|
||||
Glide.with(imageView.getContext())
|
||||
.asBitmap()
|
||||
.load(uri)
|
||||
.error(Glide.with(imageView).asBitmap().load(musicBtp))
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
|
@ -1115,6 +1120,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
Glide.with(imageView.getContext())
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.error(Glide.with(imageView).asBitmap().load(musicBtp))
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
|
@ -1257,7 +1263,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
String filename = Helper.getFileName(TootActivity.this, imageUri);
|
||||
ContentResolver cr = getContentResolver();
|
||||
String mime = cr.getType(imageUri);
|
||||
if(mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif")) ) {
|
||||
if(mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("audio") || mime.toLowerCase().contains("gif")) ) {
|
||||
upload(TootActivity.this, imageUri, filename);
|
||||
} else if(mime != null && mime.toLowerCase().contains("image")) {
|
||||
new asyncPicture(TootActivity.this, account, intent.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
|
|
|
@ -2869,7 +2869,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
else
|
||||
holder.status_prev1_play.setVisibility(View.GONE);
|
||||
else {
|
||||
if( attachment.getType().toLowerCase().equals("video")) {
|
||||
if( attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("audio")) {
|
||||
holder.status_prev1_play_h.setImageResource(R.drawable.ic_video_preview);
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_video_preview);
|
||||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
|
@ -2891,7 +2891,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
else
|
||||
holder.status_prev2_play.setVisibility(View.GONE);
|
||||
else {
|
||||
if( attachment.getType().toLowerCase().equals("video")) {
|
||||
if( attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("video")) {
|
||||
holder.status_prev2_play_h.setImageResource(R.drawable.ic_video_preview);
|
||||
holder.status_prev2_play.setImageResource(R.drawable.ic_video_preview);
|
||||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
|
@ -2913,7 +2913,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
else
|
||||
holder.status_prev3_play.setVisibility(View.GONE);
|
||||
else {
|
||||
if( attachment.getType().toLowerCase().equals("video")) {
|
||||
if( attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("video")) {
|
||||
holder.status_prev3_play_h.setImageResource(R.drawable.ic_video_preview);
|
||||
holder.status_prev3_play.setImageResource(R.drawable.ic_video_preview);
|
||||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
|
@ -2935,7 +2935,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
else
|
||||
holder.status_prev4_play.setVisibility(View.GONE);
|
||||
else {
|
||||
if( attachment.getType().toLowerCase().equals("video")) {
|
||||
if( attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("video")) {
|
||||
holder.status_prev4_play_h.setImageResource(R.drawable.ic_video_preview);
|
||||
holder.status_prev4_play.setImageResource(R.drawable.ic_video_preview);
|
||||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
|
|
|
@ -15,6 +15,7 @@ package app.fedilab.android.services;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import net.gotev.uploadservice.ServerResponse;
|
||||
import net.gotev.uploadservice.UploadInfo;
|
||||
|
@ -43,7 +44,6 @@ public class PeertubeUploadReceiver extends UploadServiceBroadcastReceiver {
|
|||
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
|
||||
Exception exception) {
|
||||
// your code here
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue