diff options
author | tom79 <tschneider.ac@gmail.com> | 2019-06-22 18:45:36 +0200 |
---|---|---|
committer | tom79 <tschneider.ac@gmail.com> | 2019-06-22 18:45:36 +0200 |
commit | fe0d65efbaf7d91961cacc989c935566585419cf (patch) | |
tree | 4b806b4201a113bd88890d42f80861941174f962 | |
parent | 09c702b2d02ac6ee9fd58400729e7fbb88c9162b (diff) |
Support audio
6 files changed, 20 insertions, 14 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/activities/MediaActivity.java index 4d298753f..49e2e1265 100644 --- a/app/src/main/java/app/fedilab/android/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/MediaActivity.java @@ -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); diff --git a/app/src/main/java/app/fedilab/android/activities/TootActivity.java b/app/src/main/java/app/fedilab/android/activities/TootActivity.java index d9e6ce764..422f7ab69 100644 --- a/app/src/main/java/app/fedilab/android/activities/TootActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/TootActivity.java @@ -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); diff --git a/app/src/main/java/app/fedilab/android/client/API.java b/app/src/main/java/app/fedilab/android/client/API.java index 6cf1ed17b..13f25478a 100644 --- a/app/src/main/java/app/fedilab/android/client/API.java +++ b/app/src/main/java/app/fedilab/android/client/API.java @@ -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; diff --git a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java index 247943837..680651370 100644 --- a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -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")) { diff --git a/app/src/main/java/app/fedilab/android/services/PeertubeUploadReceiver.java b/app/src/main/java/app/fedilab/android/services/PeertubeUploadReceiver.java index 093c43190..35387ab67 100644 --- a/app/src/main/java/app/fedilab/android/services/PeertubeUploadReceiver.java +++ b/app/src/main/java/app/fedilab/android/services/PeertubeUploadReceiver.java @@ -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 diff --git a/app/src/main/res/drawable/music.png b/app/src/main/res/drawable/music.png Binary files differnew file mode 100644 index 000000000..060786e92 --- /dev/null +++ b/app/src/main/res/drawable/music.png |