mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 19:34:55 +01:00
replaced statuseditor mediabutton with icon list, bug fix, permission fix, code cleanup
This commit is contained in:
parent
943b59b030
commit
aa919d8351
@ -7,6 +7,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
|
@ -104,6 +104,30 @@ public class IconAdapter extends Adapter<IconHolder> implements OnHolderClickLis
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* add a single image icon
|
||||
*/
|
||||
public void addImageItem() {
|
||||
items.add(IconHolder.TYPE_IMAGE);
|
||||
notifyItemInserted(items.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a single gif item
|
||||
*/
|
||||
public void addGifItem() {
|
||||
items.add(IconHolder.TYPE_GIF);
|
||||
notifyItemInserted(items.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a single video item
|
||||
*/
|
||||
public void addVideoItem() {
|
||||
items.add(IconHolder.TYPE_VIDEO);
|
||||
notifyItemInserted(items.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* add media iconsdepending on type
|
||||
*/
|
||||
|
@ -126,14 +126,16 @@ public class StatusAdapter extends Adapter<ViewHolder> implements OnHolderClickL
|
||||
long sinceId = 0;
|
||||
long maxId = 0;
|
||||
if (position == 0) {
|
||||
Status status = items.get(position + 1);
|
||||
if (status != null) {
|
||||
sinceId = status.getId();
|
||||
if (items.size() > 1) {
|
||||
Status status = items.get(1);
|
||||
if (status != null) {
|
||||
sinceId = status.getId();
|
||||
}
|
||||
}
|
||||
} else if (position == items.size() - 1) {
|
||||
Status status = items.get(position - 1);
|
||||
if (status != null) {
|
||||
maxId = status.getId() - 1;
|
||||
maxId = status.getId() - 1L;
|
||||
}
|
||||
} else {
|
||||
Status status = items.get(position + 1);
|
||||
@ -142,7 +144,7 @@ public class StatusAdapter extends Adapter<ViewHolder> implements OnHolderClickL
|
||||
}
|
||||
status = items.get(position - 1);
|
||||
if (status != null) {
|
||||
maxId = status.getId() - 1;
|
||||
maxId = status.getId() - 1L;
|
||||
}
|
||||
}
|
||||
boolean success = listener.onPlaceholderClick(sinceId, maxId, position);
|
||||
|
@ -57,7 +57,9 @@ public class IconHolder extends ViewHolder implements OnClickListener {
|
||||
*/
|
||||
public IconHolder(ViewGroup parent, GlobalSettings settings) {
|
||||
super(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_attachment, parent, false));
|
||||
button = (ImageButton) itemView;
|
||||
button = itemView.findViewById(R.id.item_status_media);
|
||||
itemView.getLayoutParams().width = parent.getMeasuredHeight();
|
||||
itemView.getLayoutParams().height = parent.getMeasuredHeight();
|
||||
button.setOnClickListener(this);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
@ -1250,7 +1250,7 @@ public class Twitter implements Connection {
|
||||
params.add(LocationV2.FIELDS_PLACE);
|
||||
// add metrics information if the author is the current user and the tweet is not older than 28 days and not a retweet/quote
|
||||
if (statusCompat.getAuthor().isCurrentUser() && System.currentTimeMillis() - statusCompat.getTimestamp() < 2419200000L
|
||||
&& (statusCompat.getEmbeddedStatus() == null || statusCompat.getEmbeddedStatus().getRepostId() <= 0)) {
|
||||
&& (statusCompat.getEmbeddedStatus() == null || statusCompat.getEmbeddedStatus().getRepostId() <= 0L)) {
|
||||
params.add(TweetV2.FIELDS_TWEET_PRIVATE);
|
||||
} else {
|
||||
params.add(TweetV2.FIELDS_TWEET);
|
||||
|
@ -25,7 +25,6 @@ public class UserV1 implements User {
|
||||
public static final String PARAM_INCLUDE_ENTITIES = "include_entities=true";
|
||||
|
||||
|
||||
|
||||
private long id;
|
||||
private long createdAt;
|
||||
private String username;
|
||||
|
@ -19,14 +19,60 @@ import java.util.List;
|
||||
*/
|
||||
public class StatusUpdate {
|
||||
|
||||
/**
|
||||
* returned if attaching media failed
|
||||
*/
|
||||
public static final int MEDIA_ERROR = -1;
|
||||
|
||||
/**
|
||||
* indicates that there is no media attached
|
||||
*/
|
||||
public static final int MEDIA_NONE = 0;
|
||||
|
||||
/**
|
||||
* returned if image is attached
|
||||
*/
|
||||
public static final int MEDIA_IMAGE = 1;
|
||||
|
||||
/**
|
||||
* returned if video is attached
|
||||
*/
|
||||
public static final int MEDIA_VIDEO = 2;
|
||||
|
||||
/**
|
||||
* returned if an animated image is attached
|
||||
*/
|
||||
public static final int MEDIA_GIF = 3;
|
||||
|
||||
/**
|
||||
* image limit of a status
|
||||
*/
|
||||
private static final int MAX_IMAGES = 4;
|
||||
|
||||
/**
|
||||
* video limit of a status
|
||||
*/
|
||||
private static final int MAX_VIDEOS = 1;
|
||||
|
||||
/**
|
||||
* gif limit of a status
|
||||
*/
|
||||
private static final int MAX_GIF = 1;
|
||||
|
||||
private static final String MIME_GIF = "image/gif";
|
||||
private static final String MIME_IMAGE_ALL = "image/";
|
||||
private static final String MIME_VIDEO_ALL = "video/";
|
||||
|
||||
private String text;
|
||||
private long replyId;
|
||||
private double longitude;
|
||||
private double latitude;
|
||||
|
||||
private int mediaType = MEDIA_NONE;
|
||||
private List<Uri> mediaUris = new ArrayList<>(5);
|
||||
private MediaStatus[] mediaUpdates = {};
|
||||
private boolean hasLocation = false;
|
||||
private boolean mediaLimitReached = false;
|
||||
|
||||
/**
|
||||
* set ID of the replied status
|
||||
@ -51,12 +97,66 @@ public class StatusUpdate {
|
||||
* @return number of media attached to this holder or -1 if file is invalid
|
||||
*/
|
||||
public int addMedia(Context context, Uri mediaUri) {
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, mediaUri);
|
||||
if (file != null && file.length() > 0) {
|
||||
mediaUris.add(mediaUri);
|
||||
return mediaUris.size();
|
||||
String mime = context.getContentResolver().getType(mediaUri);
|
||||
if (mime == null) {
|
||||
return MEDIA_ERROR;
|
||||
}
|
||||
return -1;
|
||||
// check if file is a 'gif' image
|
||||
else if (mime.equals(MIME_GIF)) {
|
||||
switch (mediaType) {
|
||||
case MEDIA_NONE:
|
||||
mediaType = MEDIA_GIF;
|
||||
|
||||
case MEDIA_GIF:
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, mediaUri);
|
||||
if (file != null && file.length() > 0) {
|
||||
mediaUris.add(mediaUri);
|
||||
if (mediaUris.size() == MAX_GIF) {
|
||||
mediaLimitReached = true;
|
||||
}
|
||||
return MEDIA_GIF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// check if file is an image
|
||||
else if (mime.startsWith(MIME_IMAGE_ALL)) {
|
||||
switch (mediaType) {
|
||||
case MEDIA_NONE:
|
||||
mediaType = MEDIA_IMAGE;
|
||||
|
||||
case MEDIA_IMAGE:
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, mediaUri);
|
||||
if (file != null && file.length() > 0) {
|
||||
mediaUris.add(mediaUri);
|
||||
if (mediaUris.size() == MAX_IMAGES) {
|
||||
mediaLimitReached = true;
|
||||
}
|
||||
return MEDIA_IMAGE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// check if file is a video
|
||||
else if (mime.startsWith(MIME_VIDEO_ALL)) {
|
||||
switch (mediaType) {
|
||||
case MEDIA_NONE:
|
||||
mediaType = MEDIA_VIDEO;
|
||||
|
||||
case MAX_VIDEOS:
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, mediaUri);
|
||||
if (file != null && file.length() > 0) {
|
||||
mediaUris.add(mediaUri);
|
||||
if (mediaUris.size() == MAX_VIDEOS) {
|
||||
mediaLimitReached = true;
|
||||
}
|
||||
return MEDIA_VIDEO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return MEDIA_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,6 +170,25 @@ public class StatusUpdate {
|
||||
hasLocation = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* get type of attached media
|
||||
* currently there is only one type of media used at once
|
||||
*
|
||||
* @return media type {@link #MEDIA_NONE,#MEDIA_VIDEO,#MEDIA_IMAGE,#MEDIA_GIF}
|
||||
*/
|
||||
public int getMediaType() {
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if media limit is reached
|
||||
*
|
||||
* @return true if media limit is reached
|
||||
*/
|
||||
public boolean mediaLimitReached() {
|
||||
return mediaLimitReached;
|
||||
}
|
||||
|
||||
/**
|
||||
* get status text
|
||||
*
|
||||
|
@ -152,7 +152,7 @@ public abstract class MediaActivity extends AppCompatActivity implements Locatio
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults.length > 0 && permissions.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
|
||||
// read storage permission granted
|
||||
switch(permissions[0]) {
|
||||
switch (permissions[0]) {
|
||||
case ACCESS_FINE_LOCATION:
|
||||
startLocating();
|
||||
break;
|
||||
|
@ -491,7 +491,7 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
if (v.getId() == R.id.following) {
|
||||
if (relation != null) {
|
||||
if ((settings.getLogin().getApiType() != Account.API_TWITTER || !user.isProtected())
|
||||
|| user.isCurrentUser() || relation.isFollowing()) {
|
||||
|| user.isCurrentUser() || relation.isFollowing()) {
|
||||
Intent usersIntent = new Intent(this, UsersActivity.class);
|
||||
usersIntent.putExtra(KEY_USERS_ID, user.getId());
|
||||
usersIntent.putExtra(KEY_USERS_MODE, USERS_FRIENDS);
|
||||
@ -503,7 +503,7 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
|
||||
else if (v.getId() == R.id.follower) {
|
||||
if (relation != null) {
|
||||
if ((settings.getLogin().getApiType() != Account.API_TWITTER || !user.isProtected())
|
||||
|| user.isCurrentUser() || relation.isFollowing()) {
|
||||
|| user.isCurrentUser() || relation.isFollowing()) {
|
||||
Intent usersIntent = new Intent(this, UsersActivity.class);
|
||||
usersIntent.putExtra(KEY_USERS_ID, user.getId());
|
||||
usersIntent.putExtra(KEY_USERS_MODE, USERS_FOLLOWER);
|
||||
|
@ -20,11 +20,14 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.adapter.IconAdapter;
|
||||
import org.nuclearfog.twidda.adapter.IconAdapter.OnMediaClickListener;
|
||||
import org.nuclearfog.twidda.backend.api.ConnectionException;
|
||||
import org.nuclearfog.twidda.backend.async.StatusUpdater;
|
||||
import org.nuclearfog.twidda.backend.update.StatusUpdate;
|
||||
@ -42,7 +45,7 @@ import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
||||
*
|
||||
* @author nuclearfog
|
||||
*/
|
||||
public class StatusEditor extends MediaActivity implements OnClickListener, OnProgressStopListener, OnConfirmListener {
|
||||
public class StatusEditor extends MediaActivity implements OnClickListener, OnProgressStopListener, OnConfirmListener, OnMediaClickListener {
|
||||
|
||||
/**
|
||||
* key to add a statusd ID to reply
|
||||
@ -56,47 +59,23 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
*/
|
||||
public static final String KEY_STATUS_EDITOR_TEXT = "status_text";
|
||||
|
||||
private static final String MIME_GIF = "image/gif";
|
||||
private static final String MIME_IMAGE_ALL = "image/";
|
||||
private static final String MIME_VIDEO_ALL = "video/";
|
||||
|
||||
/**
|
||||
* image limit of a status
|
||||
*/
|
||||
private static final int MAX_IMAGES = 4;
|
||||
|
||||
/**
|
||||
* video limit of a status
|
||||
*/
|
||||
private static final int MAX_VIDEOS = 1;
|
||||
|
||||
/**
|
||||
* gif limit of a status
|
||||
*/
|
||||
private static final int MAX_GIF = 1;
|
||||
|
||||
/**
|
||||
* mention limit of a status
|
||||
*/
|
||||
private static final int MAX_MENTIONS = 10;
|
||||
|
||||
private static final int MEDIA_NONE = 0;
|
||||
private static final int MEDIA_IMAGE = 1;
|
||||
private static final int MEDIA_VIDEO = 2;
|
||||
private static final int MEDIA_GIF = 3;
|
||||
|
||||
private StatusUpdater uploaderAsync;
|
||||
private GlobalSettings settings;
|
||||
|
||||
private ConfirmDialog confirmDialog;
|
||||
private ProgressDialog loadingCircle;
|
||||
private IconAdapter adapter;
|
||||
|
||||
private ImageButton mediaBtn, previewBtn, locationBtn;
|
||||
private ImageButton mediaBtn, locationBtn;
|
||||
private EditText statusText;
|
||||
private View locationPending;
|
||||
|
||||
private StatusUpdate statusUpdate = new StatusUpdate();
|
||||
private int selectedFormat = MEDIA_NONE;
|
||||
|
||||
|
||||
@Override
|
||||
@ -113,13 +92,13 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
ImageView background = findViewById(R.id.popup_status_background);
|
||||
ImageButton statusButton = findViewById(R.id.popup_status_send);
|
||||
ImageButton closeButton = findViewById(R.id.popup_status_close);
|
||||
RecyclerView iconList = findViewById(R.id.popup_status_media_icons);
|
||||
locationBtn = findViewById(R.id.popup_status_add_location);
|
||||
mediaBtn = findViewById(R.id.popup_status_add_media);
|
||||
previewBtn = findViewById(R.id.popup_status_prev_media);
|
||||
statusText = findViewById(R.id.popup_status_input);
|
||||
locationPending = findViewById(R.id.popup_status_location_loading);
|
||||
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
loadingCircle = new ProgressDialog(this);
|
||||
confirmDialog = new ConfirmDialog(this);
|
||||
AppStyles.setEditorTheme(root, background);
|
||||
@ -131,14 +110,18 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
if (prefix != null) {
|
||||
statusText.append(prefix);
|
||||
}
|
||||
adapter = new IconAdapter(settings);
|
||||
adapter.addOnMediaClickListener(this);
|
||||
iconList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));
|
||||
iconList.setAdapter(adapter);
|
||||
|
||||
closeButton.setOnClickListener(this);
|
||||
statusButton.setOnClickListener(this);
|
||||
mediaBtn.setOnClickListener(this);
|
||||
previewBtn.setOnClickListener(this);
|
||||
locationBtn.setOnClickListener(this);
|
||||
confirmDialog.setConfirmListener(this);
|
||||
loadingCircle.addOnProgressStopListener(this);
|
||||
adapter.addOnMediaClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +181,7 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
}
|
||||
// Add media to the status
|
||||
else if (v.getId() == R.id.popup_status_add_media) {
|
||||
if (selectedFormat == MEDIA_NONE) {
|
||||
if (statusUpdate.getMediaType() == StatusUpdate.MEDIA_NONE) {
|
||||
// request images/videos
|
||||
getMedia(REQUEST_IMG_VID);
|
||||
} else {
|
||||
@ -206,32 +189,6 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
getMedia(REQUEST_IMAGE);
|
||||
}
|
||||
}
|
||||
// open media preview
|
||||
else if (v.getId() == R.id.popup_status_prev_media) {
|
||||
Uri[] uris = statusUpdate.getMediaUris();
|
||||
//
|
||||
if (selectedFormat == MEDIA_VIDEO) {
|
||||
Intent mediaViewer = new Intent(this, VideoViewer.class);
|
||||
mediaViewer.putExtra(VideoViewer.VIDEO_URI, uris[0]);
|
||||
mediaViewer.putExtra(VideoViewer.ENABLE_VIDEO_CONTROLS, true);
|
||||
startActivity(mediaViewer);
|
||||
}
|
||||
//
|
||||
else if (selectedFormat == MEDIA_IMAGE) {
|
||||
Intent mediaViewer = new Intent(this, ImageViewer.class);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_URIS, uris);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_DOWNLOAD, false);
|
||||
startActivity(mediaViewer);
|
||||
}
|
||||
//
|
||||
else if (selectedFormat == MEDIA_GIF) {
|
||||
// todo add support for local gif animation
|
||||
Intent mediaViewer = new Intent(this, ImageViewer.class);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_URIS, uris);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_DOWNLOAD, false);
|
||||
startActivity(mediaViewer);
|
||||
}
|
||||
}
|
||||
// add location to the status
|
||||
else if (v.getId() == R.id.popup_status_add_location) {
|
||||
locationPending.setVisibility(VISIBLE);
|
||||
@ -256,41 +213,26 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
|
||||
@Override
|
||||
protected void onMediaFetched(int resultType, @NonNull Uri uri) {
|
||||
int mediaCount = 0;
|
||||
String mime = getContentResolver().getType(uri);
|
||||
if (mime == null) {
|
||||
Toast.makeText(this, R.string.error_file_format, LENGTH_SHORT).show();
|
||||
int mediaType = statusUpdate.addMedia(this, uri);
|
||||
switch (mediaType) {
|
||||
case StatusUpdate.MEDIA_IMAGE:
|
||||
adapter.addImageItem();
|
||||
break;
|
||||
|
||||
case StatusUpdate.MEDIA_GIF:
|
||||
adapter.addGifItem();
|
||||
break;
|
||||
|
||||
case StatusUpdate.MEDIA_VIDEO:
|
||||
adapter.addVideoItem();
|
||||
break;
|
||||
|
||||
case StatusUpdate.MEDIA_ERROR:
|
||||
Toast.makeText(this, R.string.error_adding_media, LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
// check if file is a 'gif' image
|
||||
else if (mime.equals(MIME_GIF)) {
|
||||
if (selectedFormat == MEDIA_NONE || selectedFormat == MEDIA_GIF) {
|
||||
mediaCount = addStatusMedia(uri, R.drawable.gif, MAX_GIF);
|
||||
if (mediaCount > 0) {
|
||||
selectedFormat = MEDIA_GIF;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if file is an image
|
||||
else if (mime.startsWith(MIME_IMAGE_ALL)) {
|
||||
if (selectedFormat == MEDIA_NONE || selectedFormat == MEDIA_IMAGE) {
|
||||
mediaCount = addStatusMedia(uri, R.drawable.image, MAX_IMAGES);
|
||||
if (mediaCount > 0) {
|
||||
selectedFormat = MEDIA_IMAGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if file is a video
|
||||
else if (mime.startsWith(MIME_VIDEO_ALL)) {
|
||||
if (selectedFormat == MEDIA_NONE || selectedFormat == MEDIA_VIDEO) {
|
||||
mediaCount = addStatusMedia(uri, R.drawable.video, MAX_VIDEOS);
|
||||
if (mediaCount > 0) {
|
||||
selectedFormat = MEDIA_VIDEO;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if media was successfully added
|
||||
if (mediaCount <= 0) {
|
||||
Toast.makeText(this, R.string.error_adding_media, LENGTH_SHORT).show();
|
||||
if (statusUpdate.mediaLimitReached()) {
|
||||
mediaBtn.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,6 +257,28 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMediaClick(int index) {
|
||||
Uri[] uris = statusUpdate.getMediaUris();
|
||||
switch (statusUpdate.getMediaType()) {
|
||||
case StatusUpdate.MEDIA_IMAGE:
|
||||
case StatusUpdate.MEDIA_GIF:
|
||||
Intent mediaViewer = new Intent(this, ImageViewer.class);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_URIS, uris);
|
||||
mediaViewer.putExtra(ImageViewer.IMAGE_DOWNLOAD, false);
|
||||
startActivity(mediaViewer);
|
||||
break;
|
||||
|
||||
case StatusUpdate.MEDIA_VIDEO:
|
||||
mediaViewer = new Intent(this, VideoViewer.class);
|
||||
mediaViewer.putExtra(VideoViewer.VIDEO_URI, uris[0]);
|
||||
mediaViewer.putExtra(VideoViewer.ENABLE_VIDEO_CONTROLS, true);
|
||||
startActivity(mediaViewer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called if status was updated successfully
|
||||
*/
|
||||
@ -343,27 +307,6 @@ public class StatusEditor extends MediaActivity implements OnClickListener, OnPr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* attach media to the status
|
||||
*
|
||||
* @param uri Uri link of the media
|
||||
* @param icon icon of the preview button
|
||||
* @param limit limit of the media count
|
||||
* @return media count or -1 if adding failed
|
||||
*/
|
||||
private int addStatusMedia(Uri uri, @DrawableRes int icon, int limit) {
|
||||
previewBtn.setImageResource(icon);
|
||||
AppStyles.setDrawableColor(previewBtn, settings.getIconColor());
|
||||
int mediaCount = statusUpdate.addMedia(this, uri);
|
||||
if (mediaCount > 0)
|
||||
previewBtn.setVisibility(VISIBLE);
|
||||
// if limit reached, remove mediaselect button
|
||||
if (mediaCount == limit) {
|
||||
mediaBtn.setVisibility(GONE);
|
||||
}
|
||||
return mediaCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* start uploading status and media files
|
||||
*/
|
||||
|
@ -1,9 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16sp"
|
||||
android:height="16sp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M17,1h-2c-0.552,0 -1,0.447 -1,1v16.992h4V2C18,1.447 17.553,1 17,1zM11,7H9C8.448,7 8,7.447 8,8v10.992h4V8C12,7.447 11.553,7 11,7zM5,13H3c-0.552,0 -1,0.447 -1,1v4.992h4V14C6,13.447 5.553,13 5,13z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
android:width="16sp"
|
||||
android:height="16sp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M17,1h-2c-0.552,0 -1,0.447 -1,1v16.992h4V2C18,1.447 17.553,1 17,1zM11,7H9C8.448,7 8,7.447 8,8v10.992h4V8C12,7.447 11.553,7 11,7zM5,13H3c-0.552,0 -1,0.447 -1,1v4.992h4V14C6,13.447 5.553,13 5,13z"
|
||||
android:fillColor="#FFFFFF" />
|
||||
</vector>
|
||||
|
@ -1,10 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/item_status_media"
|
||||
android:layout_width="@dimen/item_attachment_indicator_size"
|
||||
android:layout_height="@dimen/item_attachment_indicator_size"
|
||||
android:background="@drawable/round"
|
||||
android:layout_margin="@dimen/item_status_indicator_margin"
|
||||
android:padding="@dimen/item_status_indicator_padding"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@string/description_attachment_icon" />
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/item_status_media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/round"
|
||||
android:layout_margin="@dimen/item_attachment_indicator_margin"
|
||||
android:padding="@dimen/item_status_indicator_padding"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@string/description_attachment_icon" />
|
||||
|
||||
</FrameLayout>
|
@ -26,7 +26,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/tiem_poll_text_size"
|
||||
android:lines="1"/>
|
||||
android:lines="1" />
|
||||
|
||||
<!--todo add vote button here-->
|
||||
|
||||
|
@ -174,7 +174,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/item_status_attachment_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/item_status_indicator_size"
|
||||
android:layout_marginTop="@dimen/item_status_layout_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/item_status_text"
|
||||
|
@ -42,26 +42,18 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:constraint_referenced_ids="popup_status_prev_media,popup_status_add_media,popup_status_add_location,popup_status_send,popup_status_close" />
|
||||
app:constraint_referenced_ids="popup_status_media_icons,popup_status_add_media,popup_status_add_location,popup_status_send,popup_status_close" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/popup_status_prev_media"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/popup_status_media_icons"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="invisible"
|
||||
android:padding="@dimen/popup_status_button_padding"
|
||||
android:layout_marginBottom="@dimen/popup_status_margin_layout"
|
||||
android:layout_marginEnd="@dimen/popup_status_button_margin"
|
||||
android:contentDescription="@string/image_preview"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_marginStart="@dimen/popup_status_icon_list_margin"
|
||||
android:layout_marginEnd="@dimen/popup_status_icon_list_margin"
|
||||
app:layout_constraintStart_toStartOf="@id/popup_status_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
|
||||
app:layout_constraintEnd_toStartOf="@id/popup_status_add_media"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintDimensionRatio="1.0"
|
||||
app:layout_constraintWidth_percent="0.1"
|
||||
style="@style/RoundButton" />
|
||||
app:layout_constraintTop_toTopOf="@id/popup_status_send"
|
||||
app:layout_constraintBottom_toBottomOf="@id/popup_status_send"
|
||||
app:layout_constraintEnd_toStartOf="@id/popup_status_add_media" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/popup_status_add_media"
|
||||
@ -73,7 +65,7 @@
|
||||
android:contentDescription="@string/tweet_add_image"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/attachment"
|
||||
app:layout_constraintStart_toEndOf="@id/popup_status_prev_media"
|
||||
app:layout_constraintStart_toEndOf="@id/popup_status_media_icons"
|
||||
app:layout_constraintBottom_toBottomOf="@id/popup_status_background"
|
||||
app:layout_constraintEnd_toStartOf="@id/popup_status_add_location"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
|
@ -80,8 +80,8 @@
|
||||
<dimen name="item_status_textsize_button">12sp</dimen>
|
||||
<dimen name="item_status_textsize_date">12sp</dimen>
|
||||
<dimen name="item_status_icon_size">14sp</dimen>
|
||||
<dimen name="item_status_indicator_margin">3dp</dimen>
|
||||
<dimen name="item_status_indicator_padding">6sp</dimen>
|
||||
<dimen name="item_status_indicator_size">30sp</dimen>
|
||||
|
||||
<!--dimens of item_trend.xml-->
|
||||
<dimen name="trenditem_layout_padding">5dp</dimen>
|
||||
@ -156,6 +156,7 @@
|
||||
<!--dimens of popup_status.xml-->
|
||||
<dimen name="popup_status_margin_layout">10dp</dimen>
|
||||
<dimen name="popup_status_button_margin">7dp</dimen>
|
||||
<dimen name="popup_status_icon_list_margin">7dp</dimen>
|
||||
<dimen name="popup_status_button_padding">7dp</dimen>
|
||||
|
||||
<!--dimens of popup_message.xml-->
|
||||
@ -259,7 +260,7 @@
|
||||
<dimen name="tiem_poll_text_size">11sp</dimen>
|
||||
|
||||
<!-- dimens of item_attachment.xml -->
|
||||
<dimen name="item_attachment_indicator_size">28sp</dimen>
|
||||
<dimen name="item_attachment_indicator_margin">2dp</dimen>
|
||||
|
||||
<!-- dimens of item_option -->
|
||||
<dimen name="item_option_icon_size">12sp</dimen>
|
||||
|
Loading…
x
Reference in New Issue
Block a user