Skip to content

Commit

Permalink
Merge pull request #2 from reysand/feat/onedrive
Browse files Browse the repository at this point in the history
Implement OneDrive integration
  • Loading branch information
reysand authored Feb 2, 2024
2 parents 742f910 + f17c3bc commit 305827c
Show file tree
Hide file tree
Showing 30 changed files with 1,102 additions and 152 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Android CI

on:
push:
branches: [ "master" ]
branches: [ "master", "dev" ]
pull_request:
branches: [ "master" ]
branches: [ "master", "dev" ]

jobs:
build:
Expand All @@ -13,14 +13,42 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4.0.0
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Generate auth_config_single_account.json
run: |
mkdir ./app/src/main/res/raw
echo "${{ secrets.AUTH_CONFIG_SINGLE_ACCOUNT }}" > ./app/src/main/res/raw/auth_config_single_account.json
- name: Generate secrets.properties
run: |
echo "${{ secrets.SECRETS_PROPERTIES }}" > ./secrets.properties
- name: Generate keystore.properties
run: |
cat <<EOF > keystore.properties
storeFile:${{ vars.KEYSTORE_STORE_FILE_PATH }}
storePassword:${{ secrets.KEYSTORE_STORE_PASSWORD }}
keyAlias:${{ secrets.KEYSTORE_KEY_ALIAS }}
keyPassword:${{ secrets.KEYSTORE_KEY_PASSWORD }}
EOF
- name: Decode keystore and create jks
run: |
echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > keystore.jks
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew assembleRelease

- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: files
path: ./app/build/outputs/apk/release/app-release.apk
5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 0 additions & 71 deletions app/build.gradle

This file was deleted.

123 changes: 123 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright 2023 Andrey Slyusar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
keystoreProperties.load(FileInputStream(keystorePropertiesFile))

val secretsPropertiesFile = rootProject.file("secrets.properties")
val secretsProperties = Properties()
secretsProperties.load(FileInputStream(secretsPropertiesFile))

android {
namespace = "com.reysand.files"
compileSdk = 34

defaultConfig {
applicationId = "com.reysand.files"
minSdk = 33
targetSdk = 34
versionCode = 3
versionName = "0.1.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
create("release") {
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}

buildTypes {
debug {
manifestPlaceholders["signatureHash"] = secretsProperties["DEBUG_SIGNATURE_HASH"] as String
}
release {
manifestPlaceholders["signatureHash"] = secretsProperties["RELEASE_SIGNATURE_HASH"] as String
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.8"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {

implementation(libs.core.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.activity.compose)

implementation(platform(libs.compose.bom))
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.navigation.compose)

implementation(libs.msal) {
exclude(group = "io.opentelemetry")
}
implementation(libs.opentelemetry.api)
implementation(libs.opentelemetry.context)

implementation(libs.retrofit)
implementation(libs.retrofit.gson)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.ui.test.junit4)

debugImplementation(libs.ui.tooling)
debugImplementation(libs.ui.test.manifest)
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<!-- Requesting all-files access due to Android 11 (API level 30) changes. -->
<!-- Requesting all-files access due to Android 11 (API level 30) changes -->
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
Expand All @@ -41,6 +41,24 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- Intent filter to capture authorization code response from the default browser on the
device calling back to our app after interactive sign in -->
<activity
android:name="com.microsoft.identity.client.BrowserTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="com.reysand.files"
android:path="/${signatureHash}"
android:scheme="msauth" />
</intent-filter>
</activity>
</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/java/com/reysand/files/FilesApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class FilesApplication : Application() {

override fun onCreate() {
super.onCreate()
container = DefaultAppContainer()
container = DefaultAppContainer(this)
}
}
18 changes: 17 additions & 1 deletion app/src/main/java/com/reysand/files/data/AppContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,33 @@
*/
package com.reysand.files.data

import android.content.Context
import com.reysand.files.data.local.FileLocalDataSource
import com.reysand.files.data.remote.FileOneDriveDataSource
import com.reysand.files.data.repository.FileRepository
import com.reysand.files.data.repository.OneDriveRepository
import com.reysand.files.data.util.MicrosoftService

interface AppContainer {

val fileRepository: FileRepository

val oneDriveRepository: OneDriveRepository

val microsoftService: MicrosoftService
}

class DefaultAppContainer : AppContainer {
class DefaultAppContainer(context: Context) : AppContainer {

override val fileRepository: FileRepository by lazy {
FileLocalDataSource()
}

override val oneDriveRepository: OneDriveRepository by lazy {
FileOneDriveDataSource(microsoftService)
}

override val microsoftService: MicrosoftService by lazy {
MicrosoftService(context)
}
}
Loading

0 comments on commit 305827c

Please sign in to comment.