diff --git a/app/build.gradle b/app/build.gradle index eff2d3ba..b7ff4ea0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply from: 'build-helpers.gradle' android { compileSdkVersion 23 - buildToolsVersion '22.0.0' + buildToolsVersion '23.0.2' useLibrary 'org.apache.http.legacy' @@ -12,6 +12,7 @@ android { minSdkVersion 16 targetSdkVersion 23 multiDexEnabled true + generatedDensities = [] (versionName, versionCode) = project.getGitVersions() } @@ -20,6 +21,10 @@ android { javaMaxHeapSize '4g' } + aaptOptions { + additionalParameters "--no-version-vectors" + } + buildTypes { release { minifyEnabled true @@ -52,8 +57,8 @@ dependencies { // Android backwards-compatibility compile 'com.android.support:multidex:1.0.1' - compile 'com.android.support:support-v4:23.0.1' - compile 'com.android.support:appcompat-v7:23.0.1' + compile 'com.android.support:support-v4:23.2.1' + compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:recyclerview-v7:23.0.1' // Material design dialogs diff --git a/app/src/main/java/fi/aalto/legroup/achso/app/App.java b/app/src/main/java/fi/aalto/legroup/achso/app/App.java index a6d178e8..3468eeeb 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/app/App.java +++ b/app/src/main/java/fi/aalto/legroup/achso/app/App.java @@ -12,7 +12,6 @@ import android.widget.Toast; import com.google.android.gms.analytics.GoogleAnalytics; -import com.google.api.client.repackaged.com.google.common.base.Strings; import com.rollbar.android.Rollbar; import com.squareup.okhttp.OkHttpClient; import com.squareup.otto.Bus; @@ -36,6 +35,7 @@ import fi.aalto.legroup.achso.storage.remote.strategies.AchRailsStrategy; import fi.aalto.legroup.achso.storage.remote.strategies.ClViTra2Strategy; import fi.aalto.legroup.achso.storage.remote.strategies.DumbPhpStrategy; +import fi.aalto.legroup.achso.storage.remote.strategies.GoViTraStrategy; import fi.legroup.aalto.cryptohelper.CryptoHelper; public final class App extends MultiDexApplication @@ -254,16 +254,14 @@ public static void setupUploaders(Context context) { combinedRepository.addHost(achRails); combinedRepository.setCacheRoot(makeCacheVideoDirectory()); - // Temporary uploader until ClViTra2 is fixed in the Layers Box - // TODO: Remove this - String achsoStorageUrlString = context.getString(R.string.achsoStorageUrl); - if (!Strings.isNullOrEmpty(achsoStorageUrlString)) { - UploadService.addUploader(new DumbPhpStrategy(getAchsoStorageUrl(context))); + // HACK: Use Achminup for uploading for now + if (usePublicLayersBox) { + UploadService.addUploader(new DumbPhpStrategy(getAchsoStorageUrl(context), false)); + } else { + UploadService.addUploader(new GoViTraStrategy(jsonSerializer, getAchsoStorageUrl(context))); } Uri clViTra2Url = Uri.parse(context.getString(R.string.clvitra2Url)); - Uri sssUrl = Uri.parse(context.getString(R.string.sssUrl)); - ClViTra2Strategy videoStrategy = new ClViTra2Strategy(clViTra2Url); UploadService.addUploader(videoStrategy); diff --git a/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthenticatedHttpClient.java b/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthenticatedHttpClient.java index 98e6fc73..e85f88be 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthenticatedHttpClient.java +++ b/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthenticatedHttpClient.java @@ -35,11 +35,11 @@ public String getBearerToken(Account account) { AccountManager accountManager = AccountManager.get(context); String token = null; - // Try retrieving an ID token from the account manager + // Try retrieving an access token from the account manager try { - token = accountManager.blockingGetAuthToken(account, Authenticator.TOKEN_TYPE_ID, true); + token = accountManager.blockingGetAuthToken(account, Authenticator.TOKEN_TYPE_ACCESS, true); } catch (Exception e) { - Log.e(TAG, "Could not get ID token from account: " + e.getMessage()); + Log.e(TAG, "Could not get access token from account: " + e.getMessage()); e.printStackTrace(); } return token; diff --git a/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthorizationActivity.java b/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthorizationActivity.java index fd9aa0e4..205a9860 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthorizationActivity.java +++ b/app/src/main/java/fi/aalto/legroup/achso/authentication/AuthorizationActivity.java @@ -9,8 +9,12 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.webkit.CookieManager; +import android.webkit.ValueCallback; +import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -64,11 +68,15 @@ protected void onCreate(Bundle savedInstanceState) { account = extras.getParcelable(KEY_ACCOUNT_OBJECT); // Fetch the authentication URL that was given to us by the calling activity - String authUrl = extras.getString(KEY_AUTH_URL); + final String authUrl = extras.getString(KEY_AUTH_URL); // Initialise the WebView WebView webView = (WebView) findViewById(R.id.WebView); + // JavaScript needs to be enabled for some OAuth2 providers + WebSettings settings = webView.getSettings(); + settings.setJavaScriptEnabled(true); + final Context context = this; webView.setWebViewClient(new WebViewClient() { @Override @@ -78,6 +86,10 @@ public void onPageStarted(WebView view, String urlString, Bitmap favicon) { Uri url = Uri.parse(urlString); Set parameterNames = url.getQueryParameterNames(); + // Our redirect URL:s must start with app:// + if (!url.getScheme().equals("app")) + return; + // The URL will contain a `code` parameter when the user has been authenticated if (parameterNames.contains("code")) { // We won't need to keep loading anymore. This also prevents errors when using @@ -107,7 +119,7 @@ public void onPageStarted(WebView view, String urlString, Bitmap favicon) { // message. // // TODO: Read error codes and provide a more helpful error message - if ( ! error.equals("access_denied")) { + if (!error.equals("access_denied")) { showErrorDialog(String.format("Error code: %s\n\n%s", error, errorDescription)); } @@ -115,6 +127,25 @@ public void onPageStarted(WebView view, String urlString, Bitmap favicon) { } }); + // Delete cookies before authenticating to give the user a chance to switch accounts. + // NOTE: This affects all the cookies in this app globally, if we want to store some other + // WebView session data that should not be removed should be more careful here. + CookieManager cookieManager = CookieManager.getInstance(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + cookieManager.removeAllCookies(new ValueCallback() { + @Override + public void onReceiveValue(Boolean value) { + postCookiesDeleted(authUrl); + } + }); + } else { + cookieManager.removeAllCookie(); + postCookiesDeleted(authUrl); + } + } + + private void postCookiesDeleted(String authUrl) { + WebView webView = (WebView) findViewById(R.id.WebView); webView.loadUrl(authUrl); } @@ -204,11 +235,11 @@ private void createAccount(IdTokenResponse response) { e.printStackTrace(); } - // Get the user information so we can grab the `preferred_username` + // Get the user information so we can grab the `preferred_username` or `name` JsonObject userInfo = new JsonObject(); try { - userInfo = OIDCUtils.getUserInfo(OIDCConfig.getUserInfoUrl(this), response.getIdToken()); + userInfo = OIDCUtils.getUserInfo(OIDCConfig.getUserInfoUrl(this), response.getAccessToken()); } catch (IOException e) { Log.e(TAG, "Could not get UserInfo."); e.printStackTrace(); @@ -216,9 +247,11 @@ private void createAccount(IdTokenResponse response) { if (userInfo.has("preferred_username")) { accountName = userInfo.get("preferred_username").getAsString(); + } else if (userInfo.has("name")) { + accountName = userInfo.get("name").getAsString(); } - account = new Account(String.format("%s (%s)", accountName, App.getLayersBoxUrl()), Authenticator.ACH_SO_ACCOUNT_TYPE); + account = new Account(String.format("%s (%s) [%s]", accountName, App.getLayersBoxUrl(), accountId), Authenticator.ACH_SO_ACCOUNT_TYPE); accountManager.addAccountExplicitly(account, null, null); // Store the tokens in the account diff --git a/app/src/main/java/fi/aalto/legroup/achso/authentication/OIDCUtils.java b/app/src/main/java/fi/aalto/legroup/achso/authentication/OIDCUtils.java index b4c7206d..fd4f6e61 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/authentication/OIDCUtils.java +++ b/app/src/main/java/fi/aalto/legroup/achso/authentication/OIDCUtils.java @@ -167,11 +167,11 @@ public static boolean isValidIdToken(String clientId, String tokenString) throws /** * Gets user information from the UserInfo endpoint. */ - public static JsonObject getUserInfo(String userInfoUrl, String idToken) throws IOException { + public static JsonObject getUserInfo(String userInfoUrl, String accessToken) throws IOException { Request request = new Request.Builder() .url(userInfoUrl) .header("Accept", "application/json") - .header("Authorization", "Bearer " + idToken) + .header("Authorization", "Bearer " + accessToken) .get() .build(); diff --git a/app/src/main/java/fi/aalto/legroup/achso/browsing/BrowserActivity.java b/app/src/main/java/fi/aalto/legroup/achso/browsing/BrowserActivity.java index 147d2de6..89543f47 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/browsing/BrowserActivity.java +++ b/app/src/main/java/fi/aalto/legroup/achso/browsing/BrowserActivity.java @@ -56,6 +56,7 @@ import fi.aalto.legroup.achso.settings.SettingsActivity; import fi.aalto.legroup.achso.sharing.SharingActivity; import fi.aalto.legroup.achso.storage.VideoRepositoryUpdatedEvent; +import fi.aalto.legroup.achso.storage.remote.SyncRequiredEvent; import fi.aalto.legroup.achso.storage.remote.SyncService; import fi.aalto.legroup.achso.storage.remote.UploadStateEvent; import fi.aalto.legroup.achso.utilities.BaseActivity; @@ -520,6 +521,11 @@ public void onVideoCreationState(VideoCreatorService.VideoCreationStateEvent eve } } + @Subscribe + public void onSyncRequired(SyncRequiredEvent event) { + SyncService.syncWithCloudStorage(this); + } + @Override public void onRefresh() { // @Note: This won't be called currently since pull to refresh is disabled (see diff --git a/app/src/main/java/fi/aalto/legroup/achso/entities/OptimizedVideo.java b/app/src/main/java/fi/aalto/legroup/achso/entities/OptimizedVideo.java index b0a9eb7e..a18182e4 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/entities/OptimizedVideo.java +++ b/app/src/main/java/fi/aalto/legroup/achso/entities/OptimizedVideo.java @@ -28,6 +28,7 @@ public class OptimizedVideo { private String videoUri; private String thumbUri; + private String deleteUri; private UUID id; private String title; private String genre; @@ -200,6 +201,11 @@ public OptimizedVideo(Video video) { manifestUri = video.getManifestUri().toString(); videoUri = video.getVideoUri().toString(); thumbUri = video.getThumbUri().toString(); + if (video.getDeleteUri() != null) { + deleteUri = video.getDeleteUri().toString(); + } else { + deleteUri = null; + } repository = video.getRepository(); @@ -313,6 +319,11 @@ public Video inflate(PooledVideo pooled) { video.setManifestUri(Uri.parse(manifestUri)); video.setVideoUri(Uri.parse(videoUri)); video.setThumbUri(Uri.parse(thumbUri)); + if (deleteUri != null) { + video.setDeleteUri(Uri.parse(deleteUri)); + } else { + video.setDeleteUri(null); + } video.setRepository(repository); video.setId(id); diff --git a/app/src/main/java/fi/aalto/legroup/achso/entities/Video.java b/app/src/main/java/fi/aalto/legroup/achso/entities/Video.java index 47544d6e..710e4936 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/entities/Video.java +++ b/app/src/main/java/fi/aalto/legroup/achso/entities/Video.java @@ -29,6 +29,7 @@ public class Video implements JsonSerializable { protected Uri videoUri; protected Uri thumbUri; + protected Uri deleteUri; protected UUID id; protected String title; protected String genre; @@ -233,4 +234,12 @@ public int getFormatVersion() { public void setFormatVersion(int formatVersion) { this.formatVersion = formatVersion; } + + public void setDeleteUri(Uri deleteUri) { + this.deleteUri = deleteUri; + } + + public Uri getDeleteUri() { + return deleteUri; + } } diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java b/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java index 9806e7a8..14704ab3 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java @@ -31,6 +31,8 @@ import fi.aalto.legroup.achso.entities.VideoReference; import fi.aalto.legroup.achso.entities.migration.VideoMigration; import fi.aalto.legroup.achso.entities.serialization.json.JsonSerializer; +import fi.aalto.legroup.achso.storage.remote.SyncRequiredEvent; +import fi.aalto.legroup.achso.storage.remote.SyncService; import fi.aalto.legroup.achso.storage.remote.VideoHost; public class CombinedVideoRepository implements VideoRepository { @@ -535,6 +537,31 @@ protected Video doInBackground(UUID... params) { } } + private class DeleteVideoTask extends AsyncTask { + + @Override + protected Void doInBackground(UUID... params) { + + for (UUID id : params) { + for (VideoHost host : cloudHosts) { + try { + host.deleteVideoManifest(id); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + bus.post(new SyncRequiredEvent(CombinedVideoRepository.this)); + } + } + @Override public void delete(UUID id) throws IOException { OptimizedVideo video = getVideo(id); @@ -552,14 +579,14 @@ public void delete(UUID id) throws IOException { // Doesn't matter if these fail, not necessary operation thumbFile.delete(); videoFile.delete(); + + // Remove the video from memory, if deleting has failed we have thrown before this + allVideos.remove(id); + bus.post(new VideoRepositoryUpdatedEvent(this)); + } else { - // TODO: Delete shared file - throw new IOException("Can't delete remote file"); + new DeleteVideoTask().execute(id); } - - // Remove the video from memory, if deleting has failed we have thrown before this - allVideos.remove(id); - bus.post(new VideoRepositoryUpdatedEvent(this)); } @Override diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/SyncRequiredEvent.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/SyncRequiredEvent.java new file mode 100644 index 00000000..e8a99eed --- /dev/null +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/SyncRequiredEvent.java @@ -0,0 +1,16 @@ +package fi.aalto.legroup.achso.storage.remote; + +import fi.aalto.legroup.achso.storage.VideoRepository; + +public class SyncRequiredEvent { + private final VideoRepository repository; + + public SyncRequiredEvent(VideoRepository repository) { + this.repository = repository; + } + + public VideoRepository getRepository() { + return repository; + } +} + diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/UploadService.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/UploadService.java index 6c316ac8..b7130634 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/UploadService.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/UploadService.java @@ -121,6 +121,7 @@ private boolean tryUpload(Video video) { return false; } video.setVideoUri(videoResult.videoUrl); + video.setDeleteUri(videoResult.deleteUrl); Uri thumbUrl = null; if (videoResult.thumbUrl != null) { @@ -159,7 +160,8 @@ private boolean tryUpload(Video video) { // The uploaded video will have normalized rotation after transcoding, so clear the hacky // rotation compensation property. - video.setRotation(0); + if (videoResult.didNormalizeRotation) + video.setRotation(0); try { // Upload the video manifest. diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/AchRailsStrategy.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/AchRailsStrategy.java index 7f2f949e..3a9cbf73 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/AchRailsStrategy.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/AchRailsStrategy.java @@ -53,9 +53,9 @@ Request.Builder buildVideosRequest(UUID id) { .appendPath(id.toString() + ".json") .toString()); } - Request.Builder buildGroupsRequest() { + Request.Builder buildOwnGroupsRequest() { return new Request.Builder() - .url(endpointUrl.buildUpon().appendPath("groups.json").toString()); + .url(endpointUrl.buildUpon().appendPath("groups").appendPath("own.json").toString()); } private Response executeRequestNoFail(Request request) throws IOException { @@ -91,7 +91,7 @@ public List getIndex() throws IOException { @Override public List getGroups() throws IOException { - Request request = buildGroupsRequest().get().build(); + Request request = buildOwnGroupsRequest().get().build(); Response response = executeRequest(request); JsonGroupList groups = serializer.read(JsonGroupList.class, response.body().byteStream()); return groups.groups; @@ -131,7 +131,7 @@ public Video downloadVideoManifestIfNewerThan(UUID id, int revision, boolean isV @Override public Video uploadVideoManifest(Video video) throws IOException { - + Request.Builder requestBuilder = buildVideosRequest(video.getId()); String serializedVideo = serializer.write(video); @@ -150,7 +150,8 @@ public Video uploadVideoManifest(Video video) throws IOException { @Override public void deleteVideoManifest(UUID id) throws IOException { - + Request request = buildVideosRequest(id).delete().build(); + executeRequest(request); } @Override diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/ClViTra2Strategy.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/ClViTra2Strategy.java index 8c488889..1c90cde4 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/ClViTra2Strategy.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/ClViTra2Strategy.java @@ -97,7 +97,7 @@ private VideoUploadResult doUploadVideo(Video video) throws Exception { // video.setVideoUri(videoUri); // video.setThumbUri(thumbUri); - return new VideoUploadResult(videoUri); + return new VideoUploadResult(videoUri, true); } else { throw new IOException(response.code() + " " + response.message()); diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DumbPhpStrategy.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DumbPhpStrategy.java index 97a0f901..0b7e586e 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DumbPhpStrategy.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DumbPhpStrategy.java @@ -20,9 +20,11 @@ public class DumbPhpStrategy implements VideoUploader, ThumbnailUploader { private final Uri endpointUri; + private final boolean doesNormalizeRotation; - public DumbPhpStrategy(Uri endpointUri) { + public DumbPhpStrategy(Uri endpointUri, boolean doesNormalizeRotation) { this.endpointUri = endpointUri.buildUpon().appendPath("upload.php").build(); + this.doesNormalizeRotation = doesNormalizeRotation; } private Uri uploadFile(UUID id, String type, Uri sourceUri) throws IOException { @@ -54,7 +56,7 @@ public Uri uploadThumb(Video video) throws IOException { @Override public VideoUploadResult uploadVideo(Video video) throws IOException { Uri uri = uploadFile(video.getId(), "video", video.getVideoUri()); - return new VideoUploadResult(uri); + return new VideoUploadResult(uri, doesNormalizeRotation); } @Override diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DummyStrategy.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DummyStrategy.java index 22a64849..ecc9b19a 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DummyStrategy.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/DummyStrategy.java @@ -38,7 +38,7 @@ public VideoUploader.VideoUploadResult uploadVideo(Video video) throws IOExcepti if (uploadsThumbWithVideo) thumbUrl = getUrl("videos/" + video.getId() + "_thumb.jpg"); - return new VideoUploadResult(videoUrl, thumbUrl); + return new VideoUploadResult(videoUrl, thumbUrl, null, false); } @Override diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/GoViTraStrategy.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/GoViTraStrategy.java new file mode 100644 index 00000000..055f6ff9 --- /dev/null +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/strategies/GoViTraStrategy.java @@ -0,0 +1,69 @@ +package fi.aalto.legroup.achso.storage.remote.strategies; + +import android.accounts.Account; +import android.net.Uri; + +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.RequestBody; +import com.squareup.okhttp.Response; + +import java.io.File; +import java.io.IOException; +import java.net.URLConnection; + +import fi.aalto.legroup.achso.app.App; +import fi.aalto.legroup.achso.entities.Video; +import fi.aalto.legroup.achso.entities.serialization.json.JsonSerializable; +import fi.aalto.legroup.achso.entities.serialization.json.JsonSerializer; +import fi.aalto.legroup.achso.storage.remote.upload.VideoUploader; + +public class GoViTraStrategy implements VideoUploader { + + private JsonSerializer serializer; + private final Uri endpointUri; + + private static class JsonResult implements JsonSerializable { + public Uri video; + public Uri thumbnail; + public Uri deleteUrl; + public String title; + } + + public GoViTraStrategy(JsonSerializer serializer, Uri endpointUri) { + this.serializer = serializer; + this.endpointUri = endpointUri.buildUpon().appendPath("uploads").build(); + } + + public VideoUploader.VideoUploadResult uploadVideo(Video video) throws IOException { + File file = new File(video.getVideoUri().getPath()); + String mimeType = URLConnection.guessContentTypeFromName(file.getPath()); + + Request request = new Request.Builder() + .url(endpointUri.toString()) + .post(RequestBody.create(MediaType.parse(mimeType), file)) + .build(); + + Account account = App.loginManager.getAccount(); + Response response = App.authenticatedHttpClient.execute(request, account); + if (!response.isSuccessful()) + throw new IOException(response.body().string()); + JsonResult result = serializer.read(JsonResult.class, response.body().byteStream()); + + return new VideoUploadResult(result.video, result.thumbnail, result.deleteUrl, true); + } + + @Override + public void deleteVideo(Video video) throws IOException { + String token = video.getVideoUri().getLastPathSegment().replaceAll("\\..*", ""); + Request request = new Request.Builder() + .url(endpointUri.buildUpon().appendPath(token).build().toString()) + .delete() + .build(); + + Account account = App.loginManager.getAccount(); + Response response = App.authenticatedHttpClient.execute(request, account); + if (!response.isSuccessful()) + throw new IOException(response.body().string()); + } +} diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/upload/VideoUploader.java b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/upload/VideoUploader.java index 025c418a..bb2fa1e4 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/remote/upload/VideoUploader.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/remote/upload/VideoUploader.java @@ -12,16 +12,20 @@ class VideoUploadResult { public Uri videoUrl; public Uri thumbUrl; + public Uri deleteUrl; + public boolean didNormalizeRotation; public VideoUploadResult() { - this(null, null); + this(null, null, null, false); } - public VideoUploadResult(Uri videoUrl) { - this(videoUrl, null); + public VideoUploadResult(Uri videoUrl, boolean didNormalizeRotation) { + this(videoUrl, null, null, didNormalizeRotation); } - public VideoUploadResult(Uri videoUrl, Uri thumbUrl) { + public VideoUploadResult(Uri videoUrl, Uri thumbUrl, Uri deleteUrl, boolean didNormalizeRotation) { this.videoUrl = videoUrl; this.thumbUrl = thumbUrl; + this.deleteUrl = deleteUrl; + this.didNormalizeRotation = didNormalizeRotation; } }; diff --git a/build.gradle b/build.gradle index 1b7886d1..a6fcfe1f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:1.5.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files