Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
26 changes: 26 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ android {
buildFeatures {
viewBinding true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
signingConfigs {
debug {
v1SigningEnabled true
v2SigningEnabled true
}
release {
v1SigningEnabled true
v2SigningEnabled true
}
}
}

dependencies {
Expand All @@ -51,7 +64,20 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.navigation:navigation-fragment:2.4.2'
implementation 'androidx.navigation:navigation-ui:2.4.2'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

// Google Drive
implementation('com.google.api-client:google-api-client-android:1.33.0') {
exclude group: 'org.apache.httpcomponents'
exclude module: 'guava-jdk5'
}
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.32.1'
implementation('com.google.apis:google-api-services-drive:v3-rev20211107-1.32.1') {
exclude group: 'org.apache.httpcomponents'
exclude module: 'guava-jdk5'
}
implementation 'com.google.http-client:google-http-client-jackson:1.15.0-rc'
}
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:largeHeap="true"
android:persistent="true"

android:name=".MinimaApplication"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/ic_minima"
Expand Down Expand Up @@ -97,6 +98,10 @@

</receiver>

<receiver android:name=".dependencies.backupSync.recurring.BackupRecurringAlarmManager" android:exported="false">

</receiver>

<provider
android:authorities="com.minima.android.provider"
android:name="androidx.core.content.FileProvider"
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/minima/android/MinimaApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.minima.android;

import android.app.Application;

import com.minima.android.dependencies.backupSync.recurring.BackupRecurringAlarmManager;

public class MinimaApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
BackupRecurringAlarmManager.setAlarm(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.minima.android.dependencies.backupSync;

import android.content.Context;
import android.content.Intent;

import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.minima.android.dependencies.backupSync.model.BackupUserStateCallback;
import com.minima.android.dependencies.backupSync.providers.drive.GoogleDriveProvider;

public abstract class BackupSyncProvider {
/**
* @param context Context of the application (resources wise)
* @param oAuth2ResultLauncher [ActivityResultLauncher] that will handle the
* result back when logged in.
*/
public abstract void auth(Context context, @NonNull ActivityResultLauncher<Intent> oAuth2ResultLauncher);

/**
* @param context Context of the application (resources wise)
* @return user's state and possible info depending on the provider injected
*/
public abstract void getUserState(Context context, BackupUserStateCallback backupUserStateCallback);

/**
* @param context Context of the application (resources wise)
* @param fileToUpload File from the file system to upload.
* @param retryResultLauncher [ActivityResultLauncher] that will handle the
* and launch in case the user needs to do any
* further operation.
* <p>
* Example: when the user denies the access of this
* app to Google Drive once accepted before.
* <p>
* This parameter can be null, which means that it
* won't try to retry any OAuth2 further action that
* can be need, and it's usually null when we can to
* do a silent upload.
*/
public abstract void uploadBackup(Context context, java.io.File fileToUpload, @Nullable ActivityResultLauncher<Intent> retryResultLauncher);

/**
* @param context Context of the application (resources wise)
* @param fileToUpload File from the file system to upload.
*/
public void uploadBackup(Context context, java.io.File fileToUpload) {
uploadBackup(context, fileToUpload, null);
}

// Providers
public static BackupSyncProvider getGoogleDriveProvider(Context context) {
return GoogleDriveProvider.getInstance(context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.minima.android.dependencies.backupSync.minima;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has been moved. It was existing before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a file I wrote, but I moved it from another location


import android.content.Context;

import androidx.annotation.Nullable;

import com.minima.android.service.MinimaService;

import org.minima.Minima;
import org.minima.utils.MinimaLogger;

import java.io.File;

public class MinimaBackupUtils {
@Nullable
public static File createBackup(Context context) {
final Minima minima = MinimaService.minima;
if (minima != null) {
//Where are we going to store the file
String filename = "minima-backup.gz.bak";
File backup = new File(context.getFilesDir(), filename);
if (backup.exists()) {
backup.delete();
}

//First run a command On Minima..
String result = minima.runMinimaCMD("backup file:" + backup.getAbsolutePath());

//Now share this..
MinimaLogger.log("Backup : " + result);

if (backup.exists()) {
return backup;
} else {
return null;
}
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.minima.android.dependencies.backupSync.model;

public interface BackupUserStateCallback {
void onUserState(BackupUserStateModel backupUserStateModel);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.minima.android.dependencies.backupSync.model;

public abstract class BackupUserStateModel {
}


Loading