mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Add gallery button to MediaPreview
// FREEBIE
This commit is contained in:
parent
43e1d452c7
commit
09ff8d5865
@ -308,6 +308,7 @@
|
|||||||
|
|
||||||
<activity android:name=".MediaOverviewActivity"
|
<activity android:name=".MediaOverviewActivity"
|
||||||
android:windowSoftInputMode="stateHidden"
|
android:windowSoftInputMode="stateHidden"
|
||||||
|
android:launchMode="singleTask"
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||||
|
|
||||||
<activity android:name=".DummyActivity"
|
<activity android:name=".DummyActivity"
|
||||||
|
BIN
res/drawable-hdpi/ic_photo_library_white_24dp.png
Normal file
BIN
res/drawable-hdpi/ic_photo_library_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 249 B |
BIN
res/drawable-mdpi/ic_photo_library_white_24dp.png
Normal file
BIN
res/drawable-mdpi/ic_photo_library_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 193 B |
BIN
res/drawable-xhdpi/ic_photo_library_white_24dp.png
Normal file
BIN
res/drawable-xhdpi/ic_photo_library_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 309 B |
BIN
res/drawable-xxhdpi/ic_photo_library_white_24dp.png
Normal file
BIN
res/drawable-xxhdpi/ic_photo_library_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 431 B |
BIN
res/drawable-xxxhdpi/ic_photo_library_white_24dp.png
Normal file
BIN
res/drawable-xxxhdpi/ic_photo_library_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 553 B |
@ -9,4 +9,8 @@
|
|||||||
android:title="@string/media_preview__save_title"
|
android:title="@string/media_preview__save_title"
|
||||||
android:icon="@drawable/ic_save_white_24dp"
|
android:icon="@drawable/ic_save_white_24dp"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
|
<item android:id="@+id/media_preview__overview"
|
||||||
|
android:title="@string/media_preview__overview_title"
|
||||||
|
android:icon="@drawable/ic_photo_library_white_24dp"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -1245,6 +1245,7 @@
|
|||||||
<!-- media_preview -->
|
<!-- media_preview -->
|
||||||
<string name="media_preview__save_title">Save</string>
|
<string name="media_preview__save_title">Save</string>
|
||||||
<string name="media_preview__forward_title">Forward</string>
|
<string name="media_preview__forward_title">Forward</string>
|
||||||
|
<string name="media_preview__overview_title">All images</string>
|
||||||
|
|
||||||
<!-- media_overview -->
|
<!-- media_overview -->
|
||||||
<string name="media_overview__save_all">Save all</string>
|
<string name="media_overview__save_all">Save all</string>
|
||||||
|
@ -542,6 +542,7 @@ public class ConversationItem extends LinearLayout
|
|||||||
if (!messageRecord.isOutgoing()) intent.putExtra(MediaPreviewActivity.RECIPIENT_EXTRA, recipient.getRecipientId());
|
if (!messageRecord.isOutgoing()) intent.putExtra(MediaPreviewActivity.RECIPIENT_EXTRA, recipient.getRecipientId());
|
||||||
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp());
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp());
|
||||||
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
||||||
|
intent.putExtra(MediaPreviewActivity.THREAD_ID_EXTRA, messageRecord.getThreadId());
|
||||||
|
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,6 +41,7 @@ public class ImageMediaAdapter extends CursorRecyclerViewAdapter<ViewHolder> {
|
|||||||
private static final String TAG = ImageMediaAdapter.class.getSimpleName();
|
private static final String TAG = ImageMediaAdapter.class.getSimpleName();
|
||||||
|
|
||||||
private final MasterSecret masterSecret;
|
private final MasterSecret masterSecret;
|
||||||
|
private final long threadId;
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
public ThumbnailView imageView;
|
public ThumbnailView imageView;
|
||||||
@ -51,9 +52,10 @@ public class ImageMediaAdapter extends CursorRecyclerViewAdapter<ViewHolder> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageMediaAdapter(Context context, MasterSecret masterSecret, Cursor c) {
|
public ImageMediaAdapter(Context context, MasterSecret masterSecret, Cursor c, long threadId) {
|
||||||
super(context, c);
|
super(context, c);
|
||||||
this.masterSecret = masterSecret;
|
this.masterSecret = masterSecret;
|
||||||
|
this.threadId = threadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,6 +89,7 @@ public class ImageMediaAdapter extends CursorRecyclerViewAdapter<ViewHolder> {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(getContext(), MediaPreviewActivity.class);
|
Intent intent = new Intent(getContext(), MediaPreviewActivity.class);
|
||||||
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, imageRecord.getDate());
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, imageRecord.getDate());
|
||||||
|
intent.putExtra(MediaPreviewActivity.THREAD_ID_EXTRA, threadId);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(imageRecord.getAddress())) {
|
if (!TextUtils.isEmpty(imageRecord.getAddress())) {
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(),
|
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(),
|
||||||
|
@ -135,14 +135,19 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
final long recipientId = getIntent().getLongExtra(RECIPIENT_EXTRA, -1);
|
final long recipientId = getIntent().getLongExtra(RECIPIENT_EXTRA, -1);
|
||||||
if (recipientId > -1) {
|
if (recipientId > -1) {
|
||||||
recipient = RecipientFactory.getRecipientForId(this, recipientId, true);
|
recipient = RecipientFactory.getRecipientForId(this, recipientId, true);
|
||||||
|
} else if (threadId > -1){
|
||||||
|
recipient = DatabaseFactory.getThreadDatabase(this).getRecipientsForThreadId(threadId).getPrimaryRecipient();
|
||||||
|
} else {
|
||||||
|
recipient = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recipient != null) {
|
||||||
recipient.addListener(new RecipientModifiedListener() {
|
recipient.addListener(new RecipientModifiedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onModified(Recipient recipient) {
|
public void onModified(Recipient recipient) {
|
||||||
initializeActionBar();
|
initializeActionBar();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
recipient = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +220,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||||
Log.w(TAG, "onLoadFinished()");
|
Log.w(TAG, "onLoadFinished()");
|
||||||
gridView.setAdapter(new ImageMediaAdapter(this, masterSecret, cursor));
|
gridView.setAdapter(new ImageMediaAdapter(this, masterSecret, cursor, threadId));
|
||||||
noImages.setVisibility(gridView.getAdapter().getItemCount() > 0 ? View.GONE : View.VISIBLE);
|
noImages.setVisibility(gridView.getAdapter().getItemCount() > 0 ? View.GONE : View.VISIBLE);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
private final static String TAG = MediaPreviewActivity.class.getSimpleName();
|
private final static String TAG = MediaPreviewActivity.class.getSimpleName();
|
||||||
|
|
||||||
public static final String RECIPIENT_EXTRA = "recipient";
|
public static final String RECIPIENT_EXTRA = "recipient";
|
||||||
|
public static final String THREAD_ID_EXTRA = "thread_id";
|
||||||
public static final String DATE_EXTRA = "date";
|
public static final String DATE_EXTRA = "date";
|
||||||
public static final String SIZE_EXTRA = "size";
|
public static final String SIZE_EXTRA = "size";
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
private Uri mediaUri;
|
private Uri mediaUri;
|
||||||
private String mediaType;
|
private String mediaType;
|
||||||
private Recipient recipient;
|
private Recipient recipient;
|
||||||
|
private long threadId;
|
||||||
private long date;
|
private long date;
|
||||||
private long size;
|
private long size;
|
||||||
|
|
||||||
@ -148,6 +150,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
mediaType = getIntent().getType();
|
mediaType = getIntent().getType();
|
||||||
date = getIntent().getLongExtra(DATE_EXTRA, System.currentTimeMillis());
|
date = getIntent().getLongExtra(DATE_EXTRA, System.currentTimeMillis());
|
||||||
size = getIntent().getLongExtra(SIZE_EXTRA, 0);
|
size = getIntent().getLongExtra(SIZE_EXTRA, 0);
|
||||||
|
threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
|
||||||
|
|
||||||
if (recipientId > -1) {
|
if (recipientId > -1) {
|
||||||
recipient = RecipientFactory.getRecipientForId(this, recipientId, true);
|
recipient = RecipientFactory.getRecipientForId(this, recipientId, true);
|
||||||
@ -188,6 +191,12 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
video.cleanup();
|
video.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showOverview() {
|
||||||
|
Intent intent = new Intent(this, MediaOverviewActivity.class);
|
||||||
|
intent.putExtra(MediaOverviewActivity.THREAD_ID_EXTRA, threadId);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
private void forward() {
|
private void forward() {
|
||||||
Intent composeIntent = new Intent(this, ShareActivity.class);
|
Intent composeIntent = new Intent(this, ShareActivity.class);
|
||||||
composeIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);
|
composeIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);
|
||||||
@ -212,6 +221,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
menu.clear();
|
menu.clear();
|
||||||
MenuInflater inflater = this.getMenuInflater();
|
MenuInflater inflater = this.getMenuInflater();
|
||||||
inflater.inflate(R.menu.media_preview, menu);
|
inflater.inflate(R.menu.media_preview, menu);
|
||||||
|
if (threadId == -1) menu.findItem(R.id.media_overview).setVisible(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -221,9 +231,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
super.onOptionsItemSelected(item);
|
super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.media_preview__forward: forward(); return true;
|
case R.id.media_preview__overview: showOverview(); return true;
|
||||||
case R.id.save: saveToDisk(); return true;
|
case R.id.media_preview__forward: forward(); return true;
|
||||||
case android.R.id.home: finish(); return true;
|
case R.id.save: saveToDisk(); return true;
|
||||||
|
case android.R.id.home: finish(); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user