mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-01 04:17:21 +01:00
renamed classes and packages, AGP update
This commit is contained in:
parent
cee533e573
commit
8988109707
@ -10,10 +10,10 @@ import androidx.annotation.NonNull;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.nuclearfog.twidda.backend.api.holder.MediaStream;
|
||||
import org.nuclearfog.twidda.backend.api.holder.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.holder.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.holder.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.MediaUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.impl.DirectmessageV1;
|
||||
import org.nuclearfog.twidda.backend.api.impl.LocationV1;
|
||||
import org.nuclearfog.twidda.backend.api.impl.RelationV1;
|
||||
@ -1243,21 +1243,21 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
||||
/**
|
||||
* upload media file to twitter and generate a media ID
|
||||
*
|
||||
* @param mediaStream inputstream with MIME type of the media
|
||||
* @param mediaUpdate inputstream with MIME type of the media
|
||||
* @return media ID
|
||||
*/
|
||||
public long uploadMedia(MediaStream mediaStream) throws TwitterException {
|
||||
public long uploadMedia(MediaUpdate mediaUpdate) throws TwitterException {
|
||||
List<String> params = new ArrayList<>();
|
||||
boolean enableChunk;
|
||||
try {
|
||||
// step 1 INIT
|
||||
params.add("command=INIT");
|
||||
params.add("media_type=" + mediaStream.getMimeType());
|
||||
params.add("total_bytes=" + mediaStream.available());
|
||||
if (mediaStream.getMimeType().startsWith("video/")) {
|
||||
params.add("media_type=" + mediaUpdate.getMimeType());
|
||||
params.add("total_bytes=" + mediaUpdate.available());
|
||||
if (mediaUpdate.getMimeType().startsWith("video/")) {
|
||||
params.add("media_category=tweet_video");
|
||||
enableChunk = true;
|
||||
} else if (mediaStream.getMimeType().startsWith("image/gif")) {
|
||||
} else if (mediaUpdate.getMimeType().startsWith("image/gif")) {
|
||||
params.add("media_category=tweet_gif");
|
||||
enableChunk = true;
|
||||
} else {
|
||||
@ -1272,12 +1272,12 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
||||
|
||||
// step 2 APPEND
|
||||
int segmentIndex = 0;
|
||||
while (mediaStream.available() > 0) {
|
||||
while (mediaUpdate.available() > 0) {
|
||||
params.clear();
|
||||
params.add("command=APPEND");
|
||||
params.add("segment_index=" + segmentIndex++);
|
||||
params.add("media_id=" + mediaId);
|
||||
response = post(MEDIA_UPLOAD, params, mediaStream.getStream(), "media", enableChunk);
|
||||
response = post(MEDIA_UPLOAD, params, mediaUpdate.getStream(), "media", enableChunk);
|
||||
if (response.code() < 200 || response.code() >= 300)
|
||||
throw new TwitterException(response);
|
||||
}
|
||||
@ -1304,7 +1304,7 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
||||
* @param link link to the image
|
||||
* @return image bitmap
|
||||
*/
|
||||
public MediaStream downloadImage(String link) throws TwitterException {
|
||||
public MediaUpdate downloadImage(String link) throws TwitterException {
|
||||
try {
|
||||
// this type of link requires authentication
|
||||
if (link.startsWith(DOWNLOAD)) {
|
||||
@ -1314,7 +1314,7 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
||||
if (type != null) {
|
||||
String mime = type.toString();
|
||||
InputStream stream = response.body().byteStream();
|
||||
return new MediaStream(stream, mime);
|
||||
return new MediaUpdate(stream, mime);
|
||||
}
|
||||
}
|
||||
throw new TwitterException(response);
|
||||
@ -1328,7 +1328,7 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
||||
if (type != null) {
|
||||
String mime = type.toString();
|
||||
InputStream stream = response.body().byteStream();
|
||||
return new MediaStream(stream, mime);
|
||||
return new MediaUpdate(stream, mime);
|
||||
}
|
||||
}
|
||||
throw new TwitterException(response);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.backend.api.holder;
|
||||
package org.nuclearfog.twidda.backend.api.update;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -20,7 +20,7 @@ import java.io.InputStream;
|
||||
public class DirectmessageUpdate {
|
||||
|
||||
private Uri uri;
|
||||
private MediaStream mediaStream;
|
||||
private MediaUpdate mediaUpdate;
|
||||
private String name = "";
|
||||
private String text = "";
|
||||
|
||||
@ -63,8 +63,8 @@ public class DirectmessageUpdate {
|
||||
* @return input stream
|
||||
*/
|
||||
@Nullable
|
||||
public MediaStream getMediaStream() {
|
||||
return mediaStream;
|
||||
public MediaUpdate getMediaUpdate() {
|
||||
return mediaUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +111,7 @@ public class DirectmessageUpdate {
|
||||
String mimeType = resolver.getType(uri);
|
||||
InputStream fileStream = resolver.openInputStream(uri);
|
||||
if (fileStream != null && mimeType != null && fileStream.available() > 0) {
|
||||
mediaStream = new MediaStream(fileStream, mimeType);
|
||||
mediaUpdate = new MediaUpdate(fileStream, mimeType);
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -124,14 +124,14 @@ public class DirectmessageUpdate {
|
||||
* close inputstream of media file
|
||||
*/
|
||||
public void close() {
|
||||
if (mediaStream != null) {
|
||||
mediaStream.close();
|
||||
if (mediaUpdate != null) {
|
||||
mediaUpdate.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "to:\"" + name + "\" text:\"" + text + "\" media:" + (mediaStream != null);
|
||||
return "to:\"" + name + "\" text:\"" + text + "\" media:" + (mediaUpdate != null);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.backend.api.holder;
|
||||
package org.nuclearfog.twidda.backend.api.update;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@ -10,7 +10,7 @@ import java.io.InputStream;
|
||||
*
|
||||
* @author nuclearfog
|
||||
*/
|
||||
public class MediaStream {
|
||||
public class MediaUpdate {
|
||||
|
||||
private InputStream inputStream;
|
||||
private String mimeType;
|
||||
@ -19,7 +19,7 @@ public class MediaStream {
|
||||
* @param inputStream stream of the media (local or online)
|
||||
* @param mimeType MIME type e.g. image/jpeg
|
||||
*/
|
||||
public MediaStream(InputStream inputStream, String mimeType) {
|
||||
public MediaUpdate(InputStream inputStream, String mimeType) {
|
||||
this.inputStream = inputStream;
|
||||
this.mimeType = mimeType;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.backend.api.holder;
|
||||
package org.nuclearfog.twidda.backend.api.update;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.backend.api.holder;
|
||||
package org.nuclearfog.twidda.backend.api.update;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -26,7 +26,7 @@ public class TweetUpdate {
|
||||
private double latitude;
|
||||
|
||||
private List<Uri> mediaUris = new ArrayList<>(5);
|
||||
private MediaStream[] mediaStreams = {};
|
||||
private MediaUpdate[] mediaUpdates = {};
|
||||
private boolean hasLocation = false;
|
||||
|
||||
/**
|
||||
@ -97,10 +97,10 @@ public class TweetUpdate {
|
||||
/**
|
||||
* get information about media attached to the tweet
|
||||
*
|
||||
* @return list of mediastream instances
|
||||
* @return list of media updates
|
||||
*/
|
||||
public MediaStream[] getMediaStreams() {
|
||||
return mediaStreams;
|
||||
public MediaUpdate[] getMediaUpdates() {
|
||||
return mediaUpdates;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,13 +158,13 @@ public class TweetUpdate {
|
||||
return true;
|
||||
try {
|
||||
// open input streams
|
||||
mediaStreams = new MediaStream[mediaUris.size()];
|
||||
for (int i = 0; i < mediaStreams.length; i++) {
|
||||
mediaUpdates = new MediaUpdate[mediaUris.size()];
|
||||
for (int i = 0; i < mediaUpdates.length; i++) {
|
||||
InputStream is = resolver.openInputStream(mediaUris.get(i));
|
||||
String mime = resolver.getType(mediaUris.get(i));
|
||||
// check if stream is valid
|
||||
if (is != null && mime != null && is.available() > 0) {
|
||||
mediaStreams[i] = new MediaStream(is, mime);
|
||||
mediaUpdates[i] = new MediaUpdate(is, mime);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -180,8 +180,8 @@ public class TweetUpdate {
|
||||
* close all open streams
|
||||
*/
|
||||
public void close() {
|
||||
for (MediaStream mediaStream : mediaStreams) {
|
||||
mediaStream.close();
|
||||
for (MediaUpdate mediaUpdate : mediaUpdates) {
|
||||
mediaUpdate.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.nuclearfog.twidda.backend.api.holder;
|
||||
package org.nuclearfog.twidda.backend.api.update;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -7,7 +7,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.backend.api.Twitter;
|
||||
import org.nuclearfog.twidda.backend.api.TwitterException;
|
||||
import org.nuclearfog.twidda.backend.api.holder.MediaStream;
|
||||
import org.nuclearfog.twidda.backend.api.update.MediaUpdate;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||
import org.nuclearfog.twidda.ui.activities.ImageViewer;
|
||||
@ -51,9 +51,9 @@ public class ImageLoader extends AsyncTask<Uri, Uri, Boolean> {
|
||||
// download imaged to a local cache folder
|
||||
for (Uri link : links) {
|
||||
// get input stream
|
||||
MediaStream mediaStream = twitter.downloadImage(link.toString());
|
||||
InputStream input = mediaStream.getStream();
|
||||
String mimeType = mediaStream.getMimeType();
|
||||
MediaUpdate mediaUpdate = twitter.downloadImage(link.toString());
|
||||
InputStream input = mediaUpdate.getStream();
|
||||
String mimeType = mediaUpdate.getMimeType();
|
||||
|
||||
// create file
|
||||
String ext = '.' + mimeType.substring(mimeType.indexOf('/') + 1);
|
||||
|
@ -4,7 +4,7 @@ import android.os.AsyncTask;
|
||||
|
||||
import org.nuclearfog.twidda.backend.api.Twitter;
|
||||
import org.nuclearfog.twidda.backend.api.TwitterException;
|
||||
import org.nuclearfog.twidda.backend.api.holder.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.model.UserList;
|
||||
import org.nuclearfog.twidda.ui.activities.UserlistEditor;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import org.nuclearfog.twidda.backend.api.Twitter;
|
||||
import org.nuclearfog.twidda.backend.api.TwitterException;
|
||||
import org.nuclearfog.twidda.backend.api.holder.DirectmessageUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.DirectmessageUpdate;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.ui.activities.MessageEditor;
|
||||
|
||||
@ -46,8 +46,8 @@ public class MessageUpdater extends AsyncTask<Void, Void, Boolean> {
|
||||
long id = twitter.showUser(message.getName()).getId();
|
||||
// upload media if any
|
||||
long mediaId = -1;
|
||||
if (message.getMediaStream() != null) {
|
||||
mediaId = twitter.uploadMedia(message.getMediaStream());
|
||||
if (message.getMediaUpdate() != null) {
|
||||
mediaId = twitter.uploadMedia(message.getMediaUpdate());
|
||||
}
|
||||
// upload message and media ID
|
||||
if (!isCancelled()) {
|
||||
@ -57,7 +57,7 @@ public class MessageUpdater extends AsyncTask<Void, Void, Boolean> {
|
||||
} catch (TwitterException exception) {
|
||||
this.exception = exception;
|
||||
} finally {
|
||||
// close mediastream
|
||||
// close all streams
|
||||
message.close();
|
||||
}
|
||||
return false;
|
||||
|
@ -4,8 +4,8 @@ import android.os.AsyncTask;
|
||||
|
||||
import org.nuclearfog.twidda.backend.api.Twitter;
|
||||
import org.nuclearfog.twidda.backend.api.TwitterException;
|
||||
import org.nuclearfog.twidda.backend.api.holder.MediaStream;
|
||||
import org.nuclearfog.twidda.backend.api.holder.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.MediaUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.ui.activities.TweetEditor;
|
||||
|
||||
@ -40,11 +40,11 @@ public class TweetUpdater extends AsyncTask<TweetUpdate, Void, Void> {
|
||||
TweetUpdate update = tweets[0];
|
||||
try {
|
||||
// upload media first
|
||||
MediaStream[] mediaStreams = update.getMediaStreams();
|
||||
long[] mediaIds = new long[mediaStreams.length];
|
||||
for (int pos = 0; pos < mediaStreams.length; pos++) {
|
||||
MediaUpdate[] mediaUpdates = update.getMediaUpdates();
|
||||
long[] mediaIds = new long[mediaUpdates.length];
|
||||
for (int pos = 0; pos < mediaUpdates.length; pos++) {
|
||||
// upload media file and save media ID
|
||||
mediaIds[pos] = twitter.uploadMedia(mediaStreams[pos]);
|
||||
mediaIds[pos] = twitter.uploadMedia(mediaUpdates[pos]);
|
||||
}
|
||||
// upload tweet
|
||||
if (!isCancelled()) {
|
||||
|
@ -6,7 +6,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.backend.api.Twitter;
|
||||
import org.nuclearfog.twidda.backend.api.TwitterException;
|
||||
import org.nuclearfog.twidda.backend.api.holder.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
import org.nuclearfog.twidda.database.AppDatabase;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
|
@ -22,7 +22,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.api.holder.DirectmessageUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.DirectmessageUpdate;
|
||||
import org.nuclearfog.twidda.backend.async.MessageUpdater;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
|
@ -34,7 +34,7 @@ import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.api.holder.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.ProfileUpdate;
|
||||
import org.nuclearfog.twidda.backend.async.UserUpdater;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
|
@ -25,7 +25,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.api.holder.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.TweetUpdate;
|
||||
import org.nuclearfog.twidda.backend.async.TweetUpdater;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
|
@ -19,7 +19,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
import org.nuclearfog.twidda.backend.api.holder.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.backend.api.update.UserlistUpdate;
|
||||
import org.nuclearfog.twidda.backend.async.ListUpdater;
|
||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||
|
@ -9,7 +9,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||
classpath 'com.android.tools.build:gradle:7.2.2'
|
||||
classpath 'io.michaelrocks:paranoid-gradle-plugin:0.3.7'
|
||||
classpath 'gradle.plugin.ru.cleverpumpkin.proguard-dictionaries-generator:plugin:1.0.8'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user