Commit d4ea94d8 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer 🎼 Committed by Arnau Vàzquez
Browse files

Resolve "add /e/ userAgent in request"

parent 0cb224d1
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/nextcloud-android-lib" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="$USER_HOME$/Android/Sdk/extras/google/m2repository" />
<option name="name" value="$USER_HOME$/Android/Sdk/extras/google/m2repository" />
<option name="url" value="file:$USER_HOME$/Android/Sdk/extras/google/m2repository" />
</remote-repository>
<remote-repository>
<option name="id" value="$USER_HOME$/Android/Sdk/extras/android/m2repository" />
<option name="name" value="$USER_HOME$/Android/Sdk/extras/android/m2repository" />
<option name="url" value="file:$USER_HOME$/Android/Sdk/extras/android/m2repository" />
</remote-repository>
<remote-repository>
<option name="id" value="$USER_HOME$/Android/Sdk/extras/m2repository" />
<option name="name" value="$USER_HOME$/Android/Sdk/extras/m2repository" />
<option name="url" value="file:$USER_HOME$/Android/Sdk/extras/m2repository" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/nextcloud-android-lib" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -7,6 +7,12 @@
*/
package foundation.e.drive.utils;
import android.os.Build;
import java.text.SimpleDateFormat;
import java.util.Locale;
import foundation.e.drive.BuildConfig;
/**
* @author Vincent Bourgmayer
......@@ -27,4 +33,17 @@ public abstract class AppConstants {
public static final String[] MEDIA_SYNCABLE_CATEGORIES = new String[]{"Images", "Movies", "Music", "Ringtones", "Documents", "Podcasts"};
public static final String[] SETTINGS_SYNCABLE_CATEGORIES = new String[] {"Rom settings"};
public static final String USER_AGENT = "eos("+getBuildTime()+")-eDrive("+ BuildConfig.VERSION_NAME +")";
/**
* Get a readable OS's build date String
* @return Os'build date
*/
private static String getBuildTime(){
long ts = Build.TIME;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
return sdf.format(ts);
}
}
......@@ -28,6 +28,7 @@ import android.webkit.MimeTypeMap;
import com.owncloud.android.lib.common.OwnCloudBasicCredentials;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.resources.files.FileUtils;
......@@ -188,8 +189,14 @@ public abstract class CommonUtils {
try {
serverUri = Uri.parse(AccountUtils.getBaseUrlForAccount(context, account));
oc = OwnCloudClientFactory.createOwnCloudClient(serverUri, context, true);
oc.setCredentials(new OwnCloudBasicCredentials(account.name, AccountManager.get(context).getPassword(account)));
Log.d(TAG, "user agent: "+AppConstants.USER_AGENT);
if(!AppConstants.USER_AGENT.equals(OwnCloudClientManagerFactory.getUserAgent())) {
OwnCloudClientManagerFactory.setUserAgent(AppConstants.USER_AGENT);
}
} catch (Exception e) {
Log.e(TAG, "Can\'t parse serverPath to Uri : " + e.toString());
oc = null;
......@@ -197,6 +204,7 @@ public abstract class CommonUtils {
return oc;
}
/** methods relative to file **/
/**
......
Subproject commit c6b717a01c2f84015357cd9dfa8b48155ff01045
Subproject commit 880099c889253f30969b81c5e07750f070bfb65c
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment