Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Module #429

Merged
merged 5 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
- name: Check
run: ./gradlew check

- name: Check Binary Compatibility
run: ./gradlew :dropbox-sdk-android:apiCheck

- name: Check Examples
run: cd examples && ./gradlew check

Expand Down
16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
gradlePluginPortal()
}

dependencies {
Expand All @@ -14,3 +14,17 @@ buildscript {
classpath(dropboxJavaSdkLibs.kotlin.gradle.plugin)
}
}


allprojects {
repositories {
google()
mavenCentral()
}

plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}
110 changes: 110 additions & 0 deletions dropbox-sdk-android/api/dropbox-sdk-android.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
public class com/dropbox/core/android/Auth {
public fun <init> ()V
public static fun getDbxCredential ()Lcom/dropbox/core/oauth/DbxCredential;
public static fun getOAuth2Token ()Ljava/lang/String;
public static fun getScope ()Ljava/lang/String;
public static fun getUid ()Ljava/lang/String;
public static fun startOAuth2Authentication (Landroid/content/Context;Ljava/lang/String;)V
public static fun startOAuth2Authentication (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
public static fun startOAuth2Authentication (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public static fun startOAuth2PKCE (Landroid/content/Context;Ljava/lang/String;Lcom/dropbox/core/DbxRequestConfig;)V
public static fun startOAuth2PKCE (Landroid/content/Context;Ljava/lang/String;Lcom/dropbox/core/DbxRequestConfig;Lcom/dropbox/core/DbxHost;)V
public static fun startOAuth2PKCE (Landroid/content/Context;Ljava/lang/String;Lcom/dropbox/core/DbxRequestConfig;Lcom/dropbox/core/DbxHost;Ljava/util/Collection;)V
public static fun startOAuth2PKCE (Landroid/content/Context;Ljava/lang/String;Lcom/dropbox/core/DbxRequestConfig;Lcom/dropbox/core/DbxHost;Ljava/util/Collection;Lcom/dropbox/core/IncludeGrantedScopes;)V
public static fun startOAuth2PKCE (Landroid/content/Context;Ljava/lang/String;Lcom/dropbox/core/DbxRequestConfig;Ljava/util/Collection;)V
}

public class com/dropbox/core/android/AuthActivity : android/app/Activity {
public static final field ACTION_AUTHENTICATE_V1 Ljava/lang/String;
public static final field ACTION_AUTHENTICATE_V2 Ljava/lang/String;
public static final field AUTH_PATH_CONNECT Ljava/lang/String;
public static final field AUTH_VERSION I
public static final field EXTRA_ACCESS_SECRET Ljava/lang/String;
public static final field EXTRA_ACCESS_TOKEN Ljava/lang/String;
public static final field EXTRA_ALREADY_AUTHED_UIDS Ljava/lang/String;
public static final field EXTRA_AUTH_QUERY_PARAMS Ljava/lang/String;
public static final field EXTRA_AUTH_STATE Ljava/lang/String;
public static final field EXTRA_CALLING_CLASS Ljava/lang/String;
public static final field EXTRA_CALLING_PACKAGE Ljava/lang/String;
public static final field EXTRA_CONSUMER_KEY Ljava/lang/String;
public static final field EXTRA_CONSUMER_SIG Ljava/lang/String;
public static final field EXTRA_DESIRED_UID Ljava/lang/String;
public static final field EXTRA_EXPIRES_AT Ljava/lang/String;
public static final field EXTRA_REFRESH_TOKEN Ljava/lang/String;
public static final field EXTRA_SCOPE Ljava/lang/String;
public static final field EXTRA_SESSION_ID Ljava/lang/String;
public static final field EXTRA_UID Ljava/lang/String;
public static field result Landroid/content/Intent;
public fun <init> ()V
public static fun checkAppBeforeAuth (Landroid/content/Context;Ljava/lang/String;Z)Z
public static fun makeIntent (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
public static fun makeIntent (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
protected fun onCreate (Landroid/os/Bundle;)V
protected fun onNewIntent (Landroid/content/Intent;)V
protected fun onResume ()V
protected fun onSaveInstanceState (Landroid/os/Bundle;)V
public fun onTopResumedActivityChanged (Z)V
public static fun setSecurityProvider (Lcom/dropbox/core/android/AuthActivity$SecurityProvider;)V
}

public abstract interface class com/dropbox/core/android/AuthActivity$SecurityProvider {
public abstract fun getSecureRandom ()Ljava/security/SecureRandom;
}

public class com/dropbox/core/android/DbxOfficialAppConnector {
public static final field ACTION_DBXC_EDIT Ljava/lang/String;
public static final field ACTION_DBXC_VIEW Ljava/lang/String;
public static final field ACTION_SHOW_DROPBOX_PREVIEW Ljava/lang/String;
public static final field ACTION_SHOW_UPGRADE Ljava/lang/String;
public static final field EXTRA_CALLING_PACKAGE Ljava/lang/String;
public static final field EXTRA_DROPBOX_PATH Ljava/lang/String;
public static final field EXTRA_DROPBOX_READ_ONLY Ljava/lang/String;
public static final field EXTRA_DROPBOX_REV Ljava/lang/String;
public static final field EXTRA_DROPBOX_SESSION_ID Ljava/lang/String;
public static final field EXTRA_DROPBOX_UID Ljava/lang/String;
protected field uid Ljava/lang/String;
public fun <init> (Ljava/lang/String;)V
protected fun addExtrasToIntent (Landroid/content/Context;Landroid/content/Intent;)V
public static fun generateOpenWithIntentFromUtmContent (Ljava/lang/String;)Landroid/content/Intent;
public static fun getDropboxPlayStoreIntent ()Landroid/content/Intent;
public fun getPreviewFileIntent (Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
public fun getUpgradeAccountIntent (Landroid/content/Context;)Landroid/content/Intent;
public static fun isAnySignedIn (Landroid/content/Context;)Z
public static fun isInstalled (Landroid/content/Context;)Lcom/dropbox/core/android/DbxOfficialAppConnector$DbxOfficialAppInstallInfo;
public fun isSignedIn (Landroid/content/Context;)Z
protected fun launchDropbox (Landroid/content/Context;)Landroid/content/Intent;
}

public class com/dropbox/core/android/DbxOfficialAppConnector$DbxOfficialAppInstallInfo {
public final field supportsOpenWith Z
public final field versionCode I
public fun <init> (ZI)V
public fun toString ()Ljava/lang/String;
}

public class com/dropbox/core/android/DropboxParseException : com/dropbox/core/DbxException {
public fun <init> (Ljava/lang/String;)V
}

public class com/dropbox/core/android/DropboxUidNotInitializedException : com/dropbox/core/DbxException {
public fun <init> (Ljava/lang/String;)V
}

public final class com/dropbox/core/android/FixedSecureRandom : java/security/SecureRandom {
public static fun get ()Ljava/security/SecureRandom;
}

public class com/dropbox/core/android/FixedSecureRandom$LinuxPrngSecureRandomSpi : java/security/SecureRandomSpi {
public fun <init> ()V
protected fun engineGenerateSeed (I)[B
protected fun engineNextBytes ([B)V
protected fun engineSetSeed ([B)V
}

public final class com/dropbox/core/sdk/android/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public fun <init> ()V
}

18 changes: 18 additions & 0 deletions dropbox-sdk-android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id 'org.jetbrains.kotlinx.binary-compatibility-validator' version '0.11.1'
}
apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: 'com.vanniktech.maven.publish'

android {
compileSdk 33
defaultConfig {
minSdk 21
targetSdk 33
}
}

dependencies {
api(project(path: ":dropbox-sdk-java", configuration: "withoutOsgi"))
}
2 changes: 2 additions & 0 deletions dropbox-sdk-android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# POM
POM_ARTIFACT_ID = dropbox-android-sdk
7 changes: 7 additions & 0 deletions dropbox-sdk-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dropbox.core.sdk.android">

<uses-permission android:name="android.permission.INTERNET" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ protected void onResume() {
* See:
* https://developer.android.com/reference/android/app/Activity#onTopResumedActivityChanged(boolean)
*/
protected void onTopResumedActivityChanged(boolean onTop) {
@Override
public void onTopResumedActivityChanged(boolean onTop) {
if (isFinishing() || !onTop) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@

package com.dropbox.core.android;

import java.util.List;

import android.content.*;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.util.Base64;

import java.util.List;

/**
* The DbxOfficialAppConnector is used by an app to communicate with the Official Android Dropbox
* app.
Expand Down Expand Up @@ -163,7 +164,12 @@ private static int getLoggedinState(Context context, String uid) {
return NO_USER;
}
cursor.moveToFirst();
return cursor.getInt(cursor.getColumnIndex("logged_in"));
int columnIndex = cursor.getColumnIndex("logged_in");
if (columnIndex < 0) {
// Column Doesn't Exist
return NO_USER;
}
return cursor.getInt(columnIndex);
}

/**
Expand Down
25 changes: 1 addition & 24 deletions dropbox-sdk-java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'
apply plugin: 'com.github.blindpirate.osgi'
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task

kotlin {
sourceSets {
main.kotlin.srcDirs += 'src/main/java'
}
}
apply plugin: 'com.vanniktech.maven.publish'

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand All @@ -24,8 +18,6 @@ dependencies {
// compatibility
api 'com.fasterxml.jackson.core:jackson-core:2.7.9'

// DO NOT flip this back to implementation, we should split the android code to its own module in the future
compileOnly 'com.google.android:android:4.1.1.4'
compileOnly 'javax.servlet:servlet-api:2.5'
compileOnly 'com.squareup.okhttp:okhttp:2.7.5' // support both v2 and v3 to avoid
compileOnly 'com.squareup.okhttp3:okhttp:4.0.0' // method count bloat
Expand Down Expand Up @@ -226,18 +218,3 @@ dependencyUpdates.resolutionStrategy = {
}

apply from: 'stone.gradle'

apply plugin: 'com.vanniktech.maven.publish'

allprojects {
repositories {
google()
mavenCentral()
}

plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}
2 changes: 2 additions & 0 deletions dropbox-sdk-java/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# POM
POM_ARTIFACT_ID = dropbox-core-sdk
2 changes: 1 addition & 1 deletion examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ android {
}

dependencies {
implementation(project(":dropbox-sdk-java"))
implementation(project(":dropbox-sdk-android"))

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.21"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3'
Expand Down
5 changes: 4 additions & 1 deletion examples/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ include ':upload-file'
include ':web-file-browser'
include ':android'
include ':dropbox-sdk-java'
project(":dropbox-sdk-java").projectDir = file("../dropbox-sdk-java")
include ':dropbox-sdk-android'

project(":dropbox-sdk-android").projectDir = file("../dropbox-sdk-android")
project(":dropbox-sdk-java").projectDir = file("../dropbox-sdk-java")
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
GROUP = com.dropbox.core
VERSION_NAME=5.3.1-SNAPSHOT

POM_ARTIFACT_ID = dropbox-core-sdk
POM_NAME = Dropbox SDK Java
POM_DESCRIPTION = A Java library to access Dropbox's HTTP-based Core API v2.

Expand All @@ -22,3 +21,6 @@ POM_DEVELOPER_EMAIL = [email protected]

# Disable Configuration Cache until we test it in this project
org.gradle.unsafe.configuration-cache=false

# Use AndroidX
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/dropboxJavaSdkLibs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android_min_sdk = "24"
android_target_sdk = "32"
androidx_activity = "1.5.0"
junit_jupiter = "5.8.2"
kotlin = "1.7.10"
kotlin = "1.6.21"
kotlin_coroutines = "1.6.4"

[libraries]
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include ':proguard'
include ':dropbox-sdk-java'
include ':dropbox-sdk-android'
include ':examples:android'

dependencyResolutionManagement {
versionCatalogs {
Expand Down