Fix media
This commit is contained in:
parent
124b1698d5
commit
ea86e070ba
|
@ -30,6 +30,10 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
@ -65,6 +69,8 @@ import fr.gouv.etalab.mastodon.client.HttpsConnection;
|
|||
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnDownloadInterface;
|
||||
import fr.gouv.etalab.mastodon.webview.MastalabWebChromeClient;
|
||||
import fr.gouv.etalab.mastodon.webview.MastalabWebViewClient;
|
||||
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK;
|
||||
|
@ -105,7 +111,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
LEFT_TO_RIGHT,
|
||||
POP
|
||||
}
|
||||
|
||||
private WebView webview_video;
|
||||
private ImageButton media_save,media_share, media_close;
|
||||
private boolean scheduleHidden, scheduleHiddenDescription;
|
||||
private SimpleExoPlayer player;
|
||||
|
@ -162,11 +168,12 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
media_share = findViewById(R.id.media_share);
|
||||
media_close = findViewById(R.id.media_close);
|
||||
progress = findViewById(R.id.loader_progress);
|
||||
webview_video = findViewById(R.id.webview_video);
|
||||
media_save.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
isSHaring = false;
|
||||
if(attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("gifv")) {
|
||||
if(attachment.getType().toLowerCase().equals("video") || attachment.getType().toLowerCase().equals("gifv") || attachment.getType().toLowerCase().equals("web")) {
|
||||
if( attachment != null ) {
|
||||
progress.setText("0 %");
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
|
@ -472,6 +479,45 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
|
|||
player.prepare(videoSource);
|
||||
player.setPlayWhenReady(true);
|
||||
break;
|
||||
case "web":
|
||||
loader.setVisibility(View.GONE);
|
||||
webview_video = Helper.initializeWebview(MediaActivity.this, R.id.webview_video);
|
||||
webview_video.setVisibility(View.VISIBLE);
|
||||
FrameLayout webview_container = findViewById(R.id.main_media_frame);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
|
||||
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(MediaActivity.this, webview_video, webview_container, videoLayout);
|
||||
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
||||
@Override
|
||||
public void toggledFullscreen(boolean fullscreen) {
|
||||
|
||||
if (fullscreen) {
|
||||
videoLayout.setVisibility(View.VISIBLE);
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
getWindow().setAttributes(attrs);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
} else {
|
||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
getWindow().setAttributes(attrs);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
videoLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
webview_video.getSettings().setAllowFileAccess(true);
|
||||
webview_video.setWebChromeClient(mastalabWebChromeClient);
|
||||
webview_video.getSettings().setDomStorageEnabled(true);
|
||||
webview_video.getSettings().setAppCacheEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
webview_video.setWebViewClient(new MastalabWebViewClient(MediaActivity.this));
|
||||
webview_video.loadUrl(attachment.getUrl());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
|
||||
import fr.gouv.etalab.mastodon.client.GNUAPI;
|
||||
import fr.gouv.etalab.mastodon.client.PeertubeAPI;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
|
@ -197,6 +198,21 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
statusCode = peertubeAPI.deleteVideo(targetedId);
|
||||
}
|
||||
error = peertubeAPI.getError();
|
||||
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||
GNUAPI gnuapi;
|
||||
if (account != null)
|
||||
gnuapi = new GNUAPI(contextReference.get(), account.getInstance(), account.getToken());
|
||||
else
|
||||
gnuapi = new GNUAPI(contextReference.get());
|
||||
if (apiAction == API.StatusAction.REPORT)
|
||||
statusCode = gnuapi.reportAction(status, comment);
|
||||
else if (apiAction == API.StatusAction.CREATESTATUS)
|
||||
statusCode = gnuapi.statusAction(status);
|
||||
else if (apiAction == API.StatusAction.MUTE_NOTIFICATIONS)
|
||||
statusCode = gnuapi.muteNotifications(targetedId, muteNotifications);
|
||||
else
|
||||
statusCode = gnuapi.postAction(apiAction, targetedId);
|
||||
error = gnuapi.getError();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -84,20 +84,40 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
gnuapi = new GNUAPI(this.contextReference.get());
|
||||
switch (action){
|
||||
case REBLOGGED:
|
||||
assert api != null;
|
||||
apiResponse = api.getRebloggedBy(targetedId, max_id);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||
assert api != null;
|
||||
apiResponse = api.getRebloggedBy(targetedId, max_id);
|
||||
}else {
|
||||
assert gnuapi != null;
|
||||
apiResponse = gnuapi.getRebloggedBy(targetedId, max_id);
|
||||
}
|
||||
break;
|
||||
case FAVOURITED:
|
||||
assert api != null;
|
||||
apiResponse = api.getFavouritedBy(targetedId, max_id);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||
assert api != null;
|
||||
apiResponse = api.getFavouritedBy(targetedId, max_id);
|
||||
}else {
|
||||
assert gnuapi != null;
|
||||
apiResponse = gnuapi.getFavouritedBy(targetedId, max_id);
|
||||
}
|
||||
break;
|
||||
case BLOCKED:
|
||||
assert api != null;
|
||||
apiResponse = api.getBlocks(max_id);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
assert api != null;
|
||||
apiResponse = api.getBlocks(max_id);
|
||||
}else {
|
||||
assert gnuapi != null;
|
||||
apiResponse = gnuapi.getBlocks(max_id);
|
||||
}
|
||||
break;
|
||||
case MUTED:
|
||||
assert api != null;
|
||||
apiResponse = api.getMuted(max_id);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
assert api != null;
|
||||
apiResponse = api.getMuted(max_id);
|
||||
}else {
|
||||
assert gnuapi != null;
|
||||
apiResponse = gnuapi.getMuted(max_id);
|
||||
}
|
||||
break;
|
||||
case FOLLOWING:
|
||||
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
|
|
|
@ -221,7 +221,12 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
break;
|
||||
case FAVOURITES:
|
||||
apiResponse = api.getFavourites(max_id);
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
apiResponse = api.getFavourites(max_id);
|
||||
}else{
|
||||
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
|
||||
apiResponse = gnuapi.getFavourites(max_id);
|
||||
}
|
||||
break;
|
||||
case USER:
|
||||
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
|
|
|
@ -129,6 +129,7 @@ public class Status implements Parcelable{
|
|||
private boolean isBoostAnimated = false, isFavAnimated = false;
|
||||
private String scheduled_at;
|
||||
private String contentType;
|
||||
private boolean isNotice = false;
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
|
@ -184,6 +185,7 @@ public class Status implements Parcelable{
|
|||
dest.writeString(this.scheduled_at);
|
||||
dest.writeString(this.contentType);
|
||||
dest.writeByte(this.showSpoiler ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(this.isNotice ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
protected Status(Parcel in) {
|
||||
|
@ -241,6 +243,7 @@ public class Status implements Parcelable{
|
|||
this.scheduled_at = in.readString();
|
||||
this.contentType = in.readString();
|
||||
this.showSpoiler = in.readByte() != 0;
|
||||
this.isNotice = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<Status> CREATOR = new Creator<Status>() {
|
||||
|
@ -1302,4 +1305,13 @@ public class Status implements Parcelable{
|
|||
public void setShowSpoiler(boolean showSpoiler) {
|
||||
this.showSpoiler = showSpoiler;
|
||||
}
|
||||
|
||||
|
||||
public boolean isNotice() {
|
||||
return isNotice;
|
||||
}
|
||||
|
||||
public void setNotice(boolean notice) {
|
||||
isNotice = notice;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.SharedPreferences;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -240,7 +241,7 @@ public class GNUAPI {
|
|||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("user_id",accountId);
|
||||
try {
|
||||
String response = new HttpsConnection(context).get(getAbsoluteUrl("/friendships/lookup.json"), 60, params, prefKeyOauthTokenT);
|
||||
String response = new HttpsConnection(context).get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
|
||||
relationships = parseRelationshipResponse(new JSONArray(response));
|
||||
if( relationships != null && relationships.size() > 0)
|
||||
relationship = relationships.get(0);
|
||||
|
@ -277,7 +278,7 @@ public class GNUAPI {
|
|||
List<Relationship> relationships = new ArrayList<>();
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/friendships/lookup.json"), 60, params, prefKeyOauthTokenT);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
|
||||
relationships = parseRelationshipResponse(new JSONArray(response));
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
|
@ -381,8 +382,10 @@ public class GNUAPI {
|
|||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/statuses/user_timeline.json"), 60, params, prefKeyOauthTokenT);
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
if( statuses.size() > 0) {
|
||||
apiResponse.setSince_id(statuses.get(0).getId());
|
||||
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -627,9 +630,11 @@ public class GNUAPI {
|
|||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/direct_messages.json"), 60, params, prefKeyOauthTokenT);
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
if( statuses.size() > 0) {
|
||||
apiResponse.setSince_id(statuses.get(0).getId());
|
||||
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -944,9 +949,11 @@ public class GNUAPI {
|
|||
query = URLEncoder.encode(query, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ignored) {}
|
||||
String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/tag/%s",query)), 60, params, prefKeyOauthTokenT);
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
if( statuses.size() > 0) {
|
||||
apiResponse.setSince_id(statuses.get(0).getId());
|
||||
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
@ -969,7 +976,7 @@ public class GNUAPI {
|
|||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getMuted(String max_id){
|
||||
return getAccounts("/mutes",null, max_id, null, accountPerPage);
|
||||
return getAccounts("/mutes/users/list.json",null, max_id, null, accountPerPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -978,7 +985,7 @@ public class GNUAPI {
|
|||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getBlocks(String max_id){
|
||||
return getAccounts("/blocks",null, max_id, null, accountPerPage);
|
||||
return getAccounts("/blocks/list.json",null, max_id, null, accountPerPage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1127,14 +1134,16 @@ public class GNUAPI {
|
|||
params.put("since_id", since_id);
|
||||
if( 0 > limit || limit > 40)
|
||||
limit = 40;
|
||||
params.put("limit",String.valueOf(limit));
|
||||
params.put("count",String.valueOf(limit));
|
||||
statuses = new ArrayList<>();
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/favourites"), 60, params, prefKeyOauthTokenT);
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/favorites.json"), 60, params, prefKeyOauthTokenT);
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
if( statuses.size() > 0) {
|
||||
apiResponse.setSince_id(statuses.get(0).getId());
|
||||
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
@ -1216,19 +1225,25 @@ public class GNUAPI {
|
|||
HashMap<String, String> params = null;
|
||||
switch (statusAction){
|
||||
case FAVOURITE:
|
||||
action = String.format("/statuses/%s/favourite", targetedId);
|
||||
action = "/favorites/create.json";
|
||||
params = new HashMap<>();
|
||||
params.put("id", targetedId);
|
||||
break;
|
||||
case UNFAVOURITE:
|
||||
action = String.format("/statuses/%s/unfavourite", targetedId);
|
||||
action = "/favorites/destroy.json";
|
||||
params = new HashMap<>();
|
||||
params.put("id", targetedId);
|
||||
break;
|
||||
case REBLOG:
|
||||
action = String.format("/statuses/%s/reblog", targetedId);
|
||||
action = String.format("/statuses/retweet/%s.json", targetedId);
|
||||
break;
|
||||
case UNREBLOG:
|
||||
action = String.format("/statuses/%s/unreblog", targetedId);
|
||||
action = String.format("/statuses/unretweet/%s.json", targetedId);
|
||||
break;
|
||||
case FOLLOW:
|
||||
action = "/friendships/create";
|
||||
action = "/friendships/create.json";
|
||||
params = new HashMap<>();
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case REMOTE_FOLLOW:
|
||||
action = "/follows";
|
||||
|
@ -1236,134 +1251,83 @@ public class GNUAPI {
|
|||
params.put("uri", targetedId);
|
||||
break;
|
||||
case UNFOLLOW:
|
||||
action = "/friendships/destroy";
|
||||
action = "/friendships/destroy.json";
|
||||
params = new HashMap<>();
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case BLOCK:
|
||||
action = String.format("/accounts/%s/block", targetedId);
|
||||
break;
|
||||
case BLOCK_DOMAIN:
|
||||
action = "/domain_blocks";
|
||||
action = "/blocks/create.json";
|
||||
params = new HashMap<>();
|
||||
params.put("domain", targetedId);
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case UNBLOCK:
|
||||
action = String.format("/accounts/%s/unblock", targetedId);
|
||||
action ="/blocks/destroy.json";
|
||||
params = new HashMap<>();
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case MUTE:
|
||||
action = String.format("/accounts/%s/mute", targetedId);
|
||||
action = "/mutes/users/create.json";
|
||||
params = new HashMap<>();
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case UNMUTE:
|
||||
action = String.format("/accounts/%s/unmute", targetedId);
|
||||
break;
|
||||
case PIN:
|
||||
action = String.format("/statuses/%s/pin", targetedId);
|
||||
break;
|
||||
case UNPIN:
|
||||
action = String.format("/statuses/%s/unpin", targetedId);
|
||||
break;
|
||||
case ENDORSE:
|
||||
action = String.format("/accounts/%s/pin", targetedId);
|
||||
break;
|
||||
case UNENDORSE:
|
||||
action = String.format("/accounts/%s/unpin", targetedId);
|
||||
break;
|
||||
case SHOW_BOOST:
|
||||
action = "/mutes/users/destroy.json";
|
||||
params = new HashMap<>();
|
||||
params.put("reblogs","true");
|
||||
action = String.format("/accounts/%s/follow", targetedId);
|
||||
break;
|
||||
case HIDE_BOOST:
|
||||
params = new HashMap<>();
|
||||
params.put("reblogs","false");
|
||||
action = String.format("/accounts/%s/follow", targetedId);
|
||||
params.put("user_id", targetedId);
|
||||
break;
|
||||
case UNSTATUS:
|
||||
action = String.format("/statuses/%s", targetedId);
|
||||
break;
|
||||
case AUTHORIZE:
|
||||
action = String.format("/follow_requests/%s/authorize", targetedId);
|
||||
break;
|
||||
case REJECT:
|
||||
action = String.format("/follow_requests/%s/reject", targetedId);
|
||||
break;
|
||||
case REPORT:
|
||||
action = "/reports";
|
||||
params = new HashMap<>();
|
||||
params.put("account_id", status.getAccount().getId());
|
||||
params.put("comment", comment);
|
||||
params.put("status_ids[]", status.getId());
|
||||
action = String.format("/statuses/destroy/%s.json", targetedId);
|
||||
break;
|
||||
case CREATESTATUS:
|
||||
params = new HashMap<>();
|
||||
action = "/statuses";
|
||||
action = "/statuses/update.json";
|
||||
try {
|
||||
params.put("status", URLEncoder.encode(status.getContent(), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
params.put("status", status.getContent());
|
||||
}
|
||||
if( status.getScheduled_at() != null)
|
||||
params.put("scheduled_at", status.getScheduled_at());
|
||||
if( status.getContentType() != null)
|
||||
params.put("content_type", status.getContentType());
|
||||
if( status.getIn_reply_to_id() != null)
|
||||
params.put("in_reply_to_id", status.getIn_reply_to_id());
|
||||
params.put("in_reply_to_status_id", status.getIn_reply_to_id());
|
||||
if( status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0 ) {
|
||||
StringBuilder parameters = new StringBuilder();
|
||||
for(Attachment attachment: status.getMedia_attachments())
|
||||
parameters.append("media_ids[]=").append(attachment.getId()).append("&");
|
||||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(12));
|
||||
params.put("media_ids[]", parameters.toString());
|
||||
parameters.append(attachment.getId()).append(",");
|
||||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1));
|
||||
params.put("media_ids", parameters.toString());
|
||||
}
|
||||
if( status.isSensitive())
|
||||
params.put("sensitive", Boolean.toString(status.isSensitive()));
|
||||
if( status.getSpoiler_text() != null)
|
||||
try {
|
||||
params.put("spoiler_text", URLEncoder.encode(status.getSpoiler_text(), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
params.put("spoiler_text", status.getSpoiler_text());
|
||||
}
|
||||
params.put("visibility", status.getVisibility());
|
||||
params.put("possibly_sensitive", Boolean.toString(status.isSensitive()));
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if(statusAction != API.StatusAction.UNSTATUS ) {
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String resp = httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
|
||||
actionCode = httpsConnection.getActionCode();
|
||||
if( statusAction == API.StatusAction.REBLOG || statusAction == API.StatusAction.UNREBLOG || statusAction == API.StatusAction.FAVOURITE || statusAction == API.StatusAction.UNFAVOURITE) {
|
||||
Bundle b = new Bundle();
|
||||
try {
|
||||
Status status1 = parseStatuses(context, new JSONObject(resp));
|
||||
b.putParcelable("status", status1);
|
||||
b.putSerializable("action", statusAction);
|
||||
} catch (JSONException ignored) {}
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
httpsConnection.delete(getAbsoluteUrl(action), 60, null, prefKeyOauthTokenT);
|
||||
actionCode = httpsConnection.getActionCode();
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String resp = httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
|
||||
actionCode = httpsConnection.getActionCode();
|
||||
if( statusAction == API.StatusAction.REBLOG || statusAction == API.StatusAction.UNREBLOG || statusAction == API.StatusAction.FAVOURITE || statusAction == API.StatusAction.UNFAVOURITE) {
|
||||
Bundle b = new Bundle();
|
||||
try {
|
||||
Status status1 = parseStatuses(context, new JSONObject(resp));
|
||||
b.putParcelable("status", status1);
|
||||
b.putSerializable("action", statusAction);
|
||||
} catch (JSONException ignored) {}
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC);
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return actionCode;
|
||||
}
|
||||
|
@ -1422,35 +1386,6 @@ public class GNUAPI {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Posts a status
|
||||
* @param notificationId String, the current notification id, if null all notifications are deleted
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse postNoticationAction(String notificationId){
|
||||
|
||||
String action;
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
if( notificationId == null)
|
||||
action = "/notifications/clear";
|
||||
else {
|
||||
params.put("id",notificationId);
|
||||
action = "/notifications/dismiss";
|
||||
}
|
||||
try {
|
||||
new HttpsConnection(context).post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves notifications for the authenticated account since an id*synchronously*
|
||||
|
@ -1816,6 +1751,7 @@ public class GNUAPI {
|
|||
}else{
|
||||
status.setMentions(new ArrayList<>());
|
||||
}
|
||||
|
||||
//Retrieves tags
|
||||
status.setTags(null);
|
||||
//Retrieves emjis
|
||||
|
@ -1857,6 +1793,8 @@ public class GNUAPI {
|
|||
try{
|
||||
status.setReblog(parseStatuses(context, resobj.getJSONObject("retweeted_status")));
|
||||
}catch (Exception ignored){ status.setReblog(null);}
|
||||
if( status.getContent().contains(status.getUri()))
|
||||
status.setNotice(true);
|
||||
} catch (JSONException ignored) {ignored.printStackTrace();} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
|
@ -2053,11 +1991,21 @@ public class GNUAPI {
|
|||
static Attachment parseAttachmentResponse(JSONObject resobj){
|
||||
|
||||
Attachment attachment = new Attachment();
|
||||
Log.v(Helper.TAG,resobj.toString());
|
||||
try {
|
||||
if(resobj.has("id") )
|
||||
attachment.setId(resobj.get("id").toString());
|
||||
attachment.setType(resobj.get("mimetype").toString());
|
||||
|
||||
attachment.setUrl(resobj.get("url").toString());
|
||||
if( attachment.getUrl().endsWith("png") || attachment.getUrl().endsWith("jpg") || attachment.getUrl().endsWith("jpeg")){
|
||||
attachment.setType("image");
|
||||
}else if( attachment.getUrl().endsWith("gif") || attachment.getUrl().endsWith("apng") ){
|
||||
attachment.setType("gifv");
|
||||
}else if( attachment.getUrl().endsWith("mp4") ){
|
||||
attachment.setType("video");
|
||||
}else{
|
||||
attachment.setType("web");
|
||||
}
|
||||
try {
|
||||
attachment.setDescription(resobj.get("description").toString());
|
||||
}catch (JSONException ignore){}
|
||||
|
|
|
@ -636,7 +636,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.dark_icon);
|
||||
else
|
||||
changeDrawableColor(context, R.drawable.ic_fiber_new, R.color.mastodonC4);
|
||||
|
||||
changeDrawableColor(context, R.drawable.ic_http, R.color.mastodonC4);
|
||||
if (getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS)
|
||||
holder.status_privacy.setVisibility(View.GONE);
|
||||
else
|
||||
|
@ -1753,6 +1753,12 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
popup.getMenu().findItem(R.id.action_timed_mute).setVisible(false);
|
||||
}
|
||||
}
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||
popup.getMenu().findItem(R.id.action_info).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
MenuItem itemBookmark = popup.getMenu().findItem(R.id.action_bookmark);
|
||||
if (itemBookmark.getActionView() != null)
|
||||
|
@ -2390,6 +2396,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_gif_preview);
|
||||
holder.status_prev1_play_h.setImageResource(R.drawable.ic_gif_preview);
|
||||
}else if(attachment.getType().toLowerCase().equals("web")){
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
|
||||
}
|
||||
if (fullAttachement)
|
||||
holder.status_prev1_play_h.setVisibility(View.VISIBLE);
|
||||
|
@ -2410,6 +2418,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
holder.status_prev2_play_h.setImageResource(R.drawable.ic_gif_preview);
|
||||
holder.status_prev2_play.setImageResource(R.drawable.ic_gif_preview);
|
||||
}else if(attachment.getType().toLowerCase().equals("web")){
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
|
||||
}
|
||||
if (fullAttachement)
|
||||
holder.status_prev2_play_h.setVisibility(View.VISIBLE);
|
||||
|
@ -2430,6 +2440,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
holder.status_prev3_play_h.setImageResource(R.drawable.ic_gif_preview);
|
||||
holder.status_prev3_play.setImageResource(R.drawable.ic_gif_preview);
|
||||
}else if(attachment.getType().toLowerCase().equals("web")){
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
|
||||
}
|
||||
if (fullAttachement)
|
||||
holder.status_prev3_play_h.setVisibility(View.VISIBLE);
|
||||
|
@ -2450,6 +2462,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else if( attachment.getType().toLowerCase().equals("gifv")) {
|
||||
holder.status_prev4_play_h.setImageResource(R.drawable.ic_gif_preview);
|
||||
holder.status_prev4_play.setImageResource(R.drawable.ic_gif_preview);
|
||||
}else if(attachment.getType().toLowerCase().equals("web")){
|
||||
holder.status_prev1_play.setImageResource(R.drawable.ic_http);
|
||||
}
|
||||
if (fullAttachement)
|
||||
holder.status_prev4_play_h.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1347,13 +1347,41 @@ public class Helper {
|
|||
MenuItem itemPCom = menu.findItem(R.id.nav_peertube_comm);
|
||||
if( itemPCom != null)
|
||||
itemPCom.setVisible(false);
|
||||
}else if( BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||
}else if( BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||
MenuItem itemCom = menu.findItem(R.id.nav_peertube_comm);
|
||||
if( itemCom != null)
|
||||
itemCom.setVisible(false);
|
||||
MenuItem itemPFCom = menu.findItem(R.id.nav_pixelfed_comm);
|
||||
if( itemPFCom != null)
|
||||
itemPFCom.setVisible(false);
|
||||
|
||||
if( BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||
MenuItem nav_list = menu.findItem(R.id.nav_list);
|
||||
if( nav_list != null)
|
||||
nav_list.setVisible(false);
|
||||
MenuItem nav_peertube = menu.findItem(R.id.nav_peertube);
|
||||
if( nav_peertube != null)
|
||||
nav_peertube.setVisible(false);
|
||||
MenuItem nav_filters = menu.findItem(R.id.nav_filters);
|
||||
if( nav_filters != null)
|
||||
nav_filters.setVisible(false);
|
||||
MenuItem nav_follow_request = menu.findItem(R.id.nav_follow_request);
|
||||
if( nav_follow_request != null)
|
||||
nav_follow_request.setVisible(false);
|
||||
MenuItem nav_who_to_follow = menu.findItem(R.id.nav_who_to_follow);
|
||||
if( nav_who_to_follow != null)
|
||||
nav_who_to_follow.setVisible(false);
|
||||
MenuItem nav_blocked = menu.findItem(R.id.nav_blocked);
|
||||
if( nav_blocked != null)
|
||||
nav_blocked.setVisible(false);
|
||||
MenuItem nav_muted = menu.findItem(R.id.nav_muted);
|
||||
if( nav_muted != null)
|
||||
nav_muted.setVisible(false);
|
||||
MenuItem nav_blocked_domains = menu.findItem(R.id.nav_blocked_domains);
|
||||
if( nav_blocked_domains != null)
|
||||
nav_blocked_domains.setVisible(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3255,6 +3283,8 @@ public class Helper {
|
|||
}
|
||||
if (timedMute != null && timedMute.size() > 0 && timedMute.contains(status.getAccount().getId()))
|
||||
return false;
|
||||
if( status.isNotice())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M4.5,11h-2L2.5,9L1,9v6h1.5v-2.5h2L4.5,15L6,15L6,9L4.5,9v2zM7,10.5h1.5L8.5,15L10,15v-4.5h1.5L11.5,9L7,9v1.5zM12.5,10.5L14,10.5L14,15h1.5v-4.5L17,10.5L17,9h-4.5v1.5zM21.5,9L18,9v6h1.5v-2h2c0.8,0 1.5,-0.7 1.5,-1.5v-1c0,-0.8 -0.7,-1.5 -1.5,-1.5zM21.5,11.5h-2v-1h2v1z"/>
|
||||
</vector>
|
|
@ -59,7 +59,17 @@
|
|||
android:layout_gravity="center"
|
||||
android:layout_height="wrap_content" />
|
||||
</RelativeLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/media_webview_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/webview_video"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_centerInParent="true"
|
||||
|
|
Loading…
Reference in New Issue