Extends to notifications

This commit is contained in:
tom79 2017-09-16 12:25:57 +02:00
parent 06707d89b4
commit 63de4970ee
2 changed files with 44 additions and 6 deletions

View File

@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.drawers;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.graphics.Bitmap;
import android.support.v7.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
@ -49,6 +50,7 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
@ -489,10 +491,11 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
});
holder.notification_account_username.setText( String.format("@%s",notification.getAccount().getUsername()));
final View finalConvertView = convertView;
holder.status_more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moreOptionDialog(status);
moreOptionDialog(status, finalConvertView);
}
});
@ -816,7 +819,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
* More option for status (report / remove status / Mute / Block)
* @param status Status current status
*/
private void moreOptionDialog(final Status status){
private void moreOptionDialog(final Status status, final View view){
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
@ -868,13 +871,25 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
Toast.makeText(context,R.string.clipboard,Toast.LENGTH_LONG).show();
dialog.dismiss();
return;
}else {
}else if( which == 2) {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
sendIntent.putExtra(Intent.EXTRA_TEXT, status.getUrl());
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return;
}else if (which == 3){
Bitmap bitmap = Helper.getBitmapFromView(view);
Intent intent = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra("pictureMention", byteArray);
b.putParcelable("tootMention", status);
intent.putExtras(b);
context.startActivity(intent);
return;
}
}else {
if( which < 2 ){
@ -898,13 +913,25 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
Toast.makeText(context,R.string.clipboard,Toast.LENGTH_LONG).show();
dialog.dismiss();
return;
}else {
}else if (which == 4){
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
sendIntent.putExtra(Intent.EXTRA_TEXT, status.getUrl());
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return;
}else if (which == 5){
Bitmap bitmap = Helper.getBitmapFromView(view);
Intent intent = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra("pictureMention", byteArray);
b.putParcelable("tootMention", status);
intent.putExtras(b);
context.startActivity(intent);
return;
}
}
//Text for report

View File

@ -834,10 +834,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_reblog_count.setVisibility(View.VISIBLE);
}
final View finalConvertView = convertView;
holder.status_more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
moreOptionDialog(status, holder.card_status_container);
moreOptionDialog(status, finalConvertView);
}
});
@ -1375,7 +1376,17 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return;
}else if( which == 3) {
Bitmap bitmap = Helper.getBitmapFromView(view);
Intent intent = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra("pictureMention", byteArray);
b.putParcelable("tootMention", status);
intent.putExtras(b);
context.startActivity(intent);
return;
}
}else {
if( which < 2 ){