Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nextcloud/android into re…
Browse files Browse the repository at this point in the history
…sizedImages

# Conflicts:
#	src/main/res/values-cs-rCZ/strings.xml
#	src/main/res/values-de-rDE/strings.xml
#	src/main/res/values-de/strings.xml
#	src/main/res/values-el/strings.xml
#	src/main/res/values-en-rGB/strings.xml
#	src/main/res/values-es-rMX/strings.xml
#	src/main/res/values-es/strings.xml
#	src/main/res/values-fi-rFI/strings.xml
#	src/main/res/values-fr/strings.xml
#	src/main/res/values-is/strings.xml
#	src/main/res/values-it/strings.xml
#	src/main/res/values-nb-rNO/strings.xml
#	src/main/res/values-nl/strings.xml
#	src/main/res/values-pl/strings.xml
#	src/main/res/values-pt-rBR/strings.xml
#	src/main/res/values-ru/strings.xml
#	src/main/res/values-sq/strings.xml
#	src/main/res/values-tr/strings.xml
#	src/main/res/values-zh-rCN/strings.xml
#	src/main/res/values/strings.xml
  • Loading branch information
AndyScherzinger committed Aug 10, 2017
2 parents 9c9f877 + 46ff928 commit 65c4b33
Show file tree
Hide file tree
Showing 77 changed files with 465 additions and 2,494 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
}
}
Expand All @@ -30,7 +30,7 @@ configurations.all {
}

ext {
supportLibraryVersion = '25.2.0'
supportLibraryVersion = '25.4.0'
googleLibraryVersion = '10.2.4'

travisBuild = System.getenv("TRAVIS") == "true"
Expand Down Expand Up @@ -184,7 +184,7 @@ dependencies {
/// dependencies for app building
implementation name: 'touch-image-view'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.github.nextcloud:android-library:1.0.23'
implementation 'com.github.nextcloud:android-library:1.0.24'
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation 'com.jakewharton:disklrucache:2.0.2'
Expand Down Expand Up @@ -212,13 +212,13 @@ dependencies {
testImplementation 'org.mockito:mockito-core:1.10.19'
/// dependencies for instrumented tests
// JUnit4 Rules
androidTestImplementation 'com.android.support.test:rules:0.5'
androidTestImplementation 'com.android.support.test:rules:1.0.0'
// Android JUnit Runner
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
// Android Annotation Support
androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
// Espresso core
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
//androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 3 errors and 653 warnings</span>
<span class="mdl-layout-title">Lint Report: 1 error and 608 warnings</span>
23 changes: 16 additions & 7 deletions scripts/lint/lint-up.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Script from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017
# adapts to drone, use git username / token as parameter

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

puts "=================== starting Android Lint Entropy Reducer ===================="

# get args
Expand Down Expand Up @@ -73,17 +76,23 @@
# find error/warning count string in HTML report
error_warning_string = ""
File.open lint_report do |file|
error_warning_string = file.find { |line| line =~ /[0-9]* errors and [0-9]* warnings/ }
error_warning_string = file.find { |line| line =~ /([0-9]* error[s]? and )?[0-9]* warning[s]?/ }
end

# find number of errors
error_string = error_warning_string.match(/[0-9]* errors/)[0]
current_error_count = error_string.match(/[0-9]*/)[0].to_i
error_string = error_warning_string.match(/[0-9]* error[s]?/)

if (error_string.nil?)
current_error_count = 0
else
current_error_count = error_string[0].match(/[0-9]*/)[0].to_i
end

puts "found errors: " + current_error_count.to_s

# find number of warnings
if CHECK_WARNINGS == true
warning_string = error_warning_string.match(/[0-9]* warnings/)[0]
warning_string = error_warning_string.match(/[0-9]* warning[s]?/)[0]
current_warning_count = warning_string.match(/[0-9]*/)[0].to_i
puts "found warnings: " + current_warning_count.to_s
end
Expand All @@ -102,18 +111,18 @@

previous_error_warning_string = ""
File.open previous_lint_report do |file|
previous_error_warning_string = file.find { |line| line =~ /[0-9]* errors and [0-9]* warnings/ }
previous_error_warning_string = file.find { |line| line =~ /([0-9]* error[s]? and )?[0-9]* warning[s]?/ }
end

unless previous_error_warning_string.nil?
previous_results = true

previous_error_string = previous_error_warning_string.match(/[0-9]* errors/)[0]
previous_error_string = previous_error_warning_string.match(/[0-9]* error[s]?/)[0]
previous_error_count = previous_error_string.match(/[0-9]*/)[0].to_i
puts "previous errors: " + previous_error_count.to_s

if CHECK_WARNINGS == true
previous_warning_string = previous_error_warning_string.match(/[0-9]* warnings/)[0]
previous_warning_string = previous_error_warning_string.match(/[0-9]* warning[s]?/)[0]
previous_warning_count = previous_warning_string.match(/[0-9]*/)[0].to_i
puts "previous warnings: " + previous_warning_count.to_s
end
Expand Down
4 changes: 2 additions & 2 deletions src/gplay/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.owncloud.android"
android:versionCode="10040399"
android:versionName="1.4.3">
android:versionCode="20000001"
android:versionName="2.0.0RC1">

<application
android:name=".MainApp"
Expand Down
4 changes: 2 additions & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owncloud.android"
android:versionCode="10040399"
android:versionName="1.4.3">
android:versionCode="20000001"
android:versionName="2.0.0RC1">

<uses-sdk
android:minSdkVersion="14"
Expand Down
65 changes: 54 additions & 11 deletions src/main/java/com/owncloud/android/jobs/FilesSyncJob.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Nextcloud Android client application
*
* @author Mario Danic
Expand All @@ -24,6 +24,7 @@
import android.accounts.Account;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.os.PowerManager;
import android.support.annotation.NonNull;
import android.support.media.ExifInterface;
Expand All @@ -32,14 +33,17 @@
import com.evernote.android.job.Job;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.FilesystemDataProvider;
import com.owncloud.android.datamodel.MediaFolderType;
import com.owncloud.android.datamodel.SyncedFolder;
import com.owncloud.android.datamodel.SyncedFolderProvider;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.ui.activity.Preferences;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.FilesSyncHelper;
import com.owncloud.android.utils.MimeTypeUtil;
Expand Down Expand Up @@ -78,6 +82,9 @@ protected Result onRunJob(Params params) {
PersistableBundleCompat bundle = params.getExtras();
final boolean skipCustom = bundle.getBoolean(SKIP_CUSTOM, false);

Resources resources = MainApp.getAppContext().getResources();
boolean lightVersion = resources.getBoolean(R.bool.syncedFolder_light);

FilesSyncHelper.restartJobsIfNeeded();
FilesSyncHelper.insertAllDBEntries(skipCustom);

Expand All @@ -95,9 +102,9 @@ protected Result onRunJob(Params params) {
final Locale currentLocale = context.getResources().getConfiguration().locale;

if (MediaFolderType.IMAGE == syncedFolder.getType()) {
String mimetypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());
if ("image/jpeg".equalsIgnoreCase(mimetypeString) || "image/tiff".
equalsIgnoreCase(mimetypeString)) {
String mimeTypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());
if ("image/jpeg".equalsIgnoreCase(mimeTypeString) || "image/tiff".
equalsIgnoreCase(mimeTypeString)) {
try {
ExifInterface exifInterface = new ExifInterface(file.getAbsolutePath());
String exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
Expand All @@ -116,23 +123,46 @@ protected Result onRunJob(Params params) {
}
}

boolean needsCharging = syncedFolder.getChargingOnly();
boolean needsWifi = syncedFolder.getWifiOnly();

String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.getAbsolutePath());

Account account = AccountUtils.getOwnCloudAccountByName(context, syncedFolder.getAccount());

String remotePath;
boolean subfolderByDate;
Integer uploadAction;
boolean needsCharging;
boolean needsWifi;

if (lightVersion) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(
context.getContentResolver());

needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
Preferences.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
uploadAction = getUploadAction(uploadActionString);

subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders);

remotePath = resources.getString(R.string.syncedFolder_remote_folder);
} else {
needsCharging = syncedFolder.getChargingOnly();
needsWifi = syncedFolder.getWifiOnly();
uploadAction = syncedFolder.getUploadAction();
subfolderByDate = syncedFolder.getSubfolderByDate();
remotePath = syncedFolder.getRemotePath();
}

requester.uploadFileWithOverwrite(
context,
account,
file.getAbsolutePath(),
FileStorageUtils.getInstantUploadFilePath(
currentLocale,
syncedFolder.getRemotePath(), file.getName(),
lastModificationTime,
syncedFolder.getSubfolderByDate()),
syncedFolder.getUploadAction(),
remotePath, file.getName(),
lastModificationTime, subfolderByDate),
uploadAction,
mimeType,
true, // create parent folder if not existent
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
Expand All @@ -150,4 +180,17 @@ protected Result onRunJob(Params params) {
wakeLock.release();
return Result.SUCCESS;
}

private Integer getUploadAction(String action) {
switch (action) {
case "LOCAL_BEHAVIOUR_FORGET":
return FileUploader.LOCAL_BEHAVIOUR_FORGET;
case "LOCAL_BEHAVIOUR_MOVE":
return FileUploader.LOCAL_BEHAVIOUR_MOVE;
case "LOCAL_BEHAVIOUR_DELETE":
return FileUploader.LOCAL_BEHAVIOUR_DELETE;
default:
return FileUploader.LOCAL_BEHAVIOUR_FORGET;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ownCloud Android client application
/* ownCloud Android client application
* Copyright (C) 2012-2014 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -17,8 +17,6 @@

package com.owncloud.android.operations;

import android.accounts.Account;

import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
Expand Down Expand Up @@ -47,9 +45,8 @@ public class CopyFileOperation extends SyncOperation {
*
* @param srcPath Remote path of the {@link OCFile} to move.
* @param targetParentPath Path to the folder where the file will be copied into.
* @param account OwnCloud account containing both the file and the target folder
*/
public CopyFileOperation(String srcPath, String targetParentPath, Account account) {
public CopyFileOperation(String srcPath, String targetParentPath) {
mSrcPath = srcPath;
mTargetParentPath = targetParentPath;
if (!mTargetParentPath.endsWith(OCFile.PATH_SEPARATOR)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
/*
* ownCloud Android client application
*
* @author Bartek Przybylski
* @author David A. Velasco
* @author masensio
* Copyright (C) 2011 Bartek Przybylski
* Copyright (C) 2016 ownCloud Inc.
* <p>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
* <p>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -1387,47 +1387,5 @@ private void updateDownloadedFiles(SQLiteDatabase db, String newAccountName,
} finally {
c.close();
}

}

/**
* Grants that total count of successful uploads stored is not greater than MAX_SUCCESSFUL_UPLOADS.
*
* Removes older uploads if needed.
*/
private void trimSuccessfulUploads(SQLiteDatabase db) {
Cursor c = null;
try {
String MAX_SUCCESSFUL_UPLOADS = "30";
c = db.rawQuery(
"delete from " + ProviderTableMeta.UPLOADS_TABLE_NAME +
" where " + ProviderTableMeta.UPLOADS_STATUS + " == "
+ UploadsStorageManager.UploadStatus.UPLOAD_SUCCEEDED.getValue() +
" and " + ProviderTableMeta._ID +
" not in (select " + ProviderTableMeta._ID +
" from " + ProviderTableMeta.UPLOADS_TABLE_NAME +
" where " + ProviderTableMeta.UPLOADS_STATUS + " == "
+ UploadsStorageManager.UploadStatus.UPLOAD_SUCCEEDED.getValue() +
" order by " + ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP +
" desc limit " + MAX_SUCCESSFUL_UPLOADS +
")",
null
);
c.moveToFirst(); // do something with the cursor, or deletion doesn't happen; true story

} catch (Exception e) {
Log_OC.e(
TAG,
"Something wrong trimming successful uploads, database could grow more than expected",
e
);

} finally {
if (c != null) {
c.close();
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ remotePath, account, syncFileContents, getApplicationContext()
// Copy file/folder
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
operation = new CopyFileOperation(remotePath, newParentPath, account);
operation = new CopyFileOperation(remotePath, newParentPath);

} else if (action.equals(ACTION_CHECK_CURRENT_CREDENTIALS)) {
// Check validity of currently stored credentials for a given account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private Fragment chooseInitialSecondFragment(OCFile file) {
if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay);
secondFragment = PreviewMediaFragment.newInstance(file, getAccount(), startPlaybackPosition, autoplay);
} else if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
secondFragment = null;
} else {
Expand Down Expand Up @@ -1996,8 +1996,7 @@ public void startImagePreview(OCFile file, VirtualFolderType type) {
* interactions.
*/
public void startMediaPreview(OCFile file, int startPlaybackPosition, boolean autoplay) {
Fragment mediaFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition,
autoplay);
Fragment mediaFragment = PreviewMediaFragment.newInstance(file, getAccount(), startPlaybackPosition, autoplay);
setSecondFragment(mediaFragment);
updateFragmentsVisibility(true);
updateActionBarTitleAndHomeButton(file);
Expand Down
Loading

0 comments on commit 65c4b33

Please sign in to comment.