Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6bc045ba authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

Remove xxxEntry sub class in xxxContract class and replace...

Remove xxxEntry sub class in xxxContract class and replace BootCompleteReceiver by Job.setPersistent(true) in jobUtils
parent a70878d0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ def buildTime() {


android {
    compileSdkVersion 25
    compileSdkVersion 26
    defaultConfig {
        applicationId "io.eelo.drive"
        minSdkVersion 25
        targetSdkVersion 25
        targetSdkVersion 26
        versionCode 1
        //versionName "1.0"
        versionName "alpha-${versionMajor}-build-${buildTime()}"
@@ -49,12 +49,12 @@ repositories {

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:25.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:recyclerview-v7:25.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.github.nextcloud:android-library:1.0.40'
    compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
+1 −6
Original line number Diff line number Diff line
@@ -36,12 +36,7 @@
        <service android:name=".services.LocalObserverService" />
        <service android:name=".services.RemoteObserverService"/>
        <service android:name=".services.OperationManagerService"></service>
        <receiver android:name=".receivers.BootCompleteReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <receiver android:name=".receivers.BatteryStateReceiver" android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BATTERY_LOW"/>
+24 −23
Original line number Diff line number Diff line
@@ -8,28 +8,8 @@ import android.provider.BaseColumns;
 * source: https://developer.android.com/training/data-storage/sqlite.html#java
 */

public final class RootFolderContract {
    public static final String SQL_CREATE_TABLE_ROOTFOLDER = new StringBuilder()
            .append("CREATE TABLE ").append(RootFolderEntry.TABLE_NAME).append(" ( ")
            .append(RootFolderEntry._ID).append(" INTEGER PRIMARY KEY, ")
            .append(RootFolderEntry.CATEGORIE_LABEL).append(" TEXT, ")
            .append(RootFolderEntry.LOCAL_ROOT_FOLDER).append(" TEXT, ")
            .append(RootFolderEntry.REMOTE_ROOT_FOLDER).append(" TEXT, ")
            .append(RootFolderEntry.LAST_ETAG).append(" TEXT, ")
            .append(RootFolderEntry.LAST_MODIFIED).append(" INTEGER, ")
            .append(RootFolderEntry.ENABLED).append(" BOOLEAN, ")
            .append("CONSTRAINT roots_unicity_constraint UNIQUE (")
            .append(RootFolderEntry.CATEGORIE_LABEL).append(", ")
            .append(RootFolderEntry.LOCAL_ROOT_FOLDER).append(", ")
            .append(RootFolderEntry.REMOTE_ROOT_FOLDER)
            .append("))")
            .toString();

public final class RootFolderContract implements BaseColumns{

    public static final String SQL_DELETE_TABLE_ROOTFOLDER = " DROP TABLE IF EXISTS "
            + RootFolderEntry.TABLE_NAME;

    public static class RootFolderEntry implements BaseColumns{
    public static final String TABLE_NAME ="root_folder";
    public static final String CATEGORIE_LABEL ="categorie_label";
    public static final String LOCAL_ROOT_FOLDER ="local_root_path";
@@ -37,5 +17,26 @@ public final class RootFolderContract {
    public static final String LAST_ETAG ="last_etag";
    public static final String LAST_MODIFIED ="last_modified";
    public static final String ENABLED ="enabled";
    }


    public static final String SQL_CREATE_TABLE_ROOTFOLDER = new StringBuilder()
            .append("CREATE TABLE ").append(TABLE_NAME).append(" ( ")
            .append(_ID).append(" INTEGER PRIMARY KEY, ")
            .append(CATEGORIE_LABEL).append(" TEXT, ")
            .append(LOCAL_ROOT_FOLDER).append(" TEXT, ")
            .append(REMOTE_ROOT_FOLDER).append(" TEXT, ")
            .append(LAST_ETAG).append(" TEXT, ")
            .append(LAST_MODIFIED).append(" INTEGER, ")
            .append(ENABLED).append(" BOOLEAN, ")
            .append("CONSTRAINT roots_unicity_constraint UNIQUE (")
            .append(CATEGORIE_LABEL).append(", ")
            .append(LOCAL_ROOT_FOLDER).append(", ")
            .append(REMOTE_ROOT_FOLDER)
            .append("))")
            .toString();


    public static final String SQL_DELETE_TABLE_ROOTFOLDER = " DROP TABLE IF EXISTS "
            + TABLE_NAME;

}
+25 −25
Original line number Diff line number Diff line
@@ -24,12 +24,12 @@ public class RootFolderDAO {
    final public static String TAG = RootFolderDAO.class.getSimpleName(); //Tag for log
    private SQLiteDatabase mDB;
    private DbHelper mHelper;
    private String[] allColumns = { RootFolderContract.RootFolderEntry._ID, RootFolderContract.RootFolderEntry.CATEGORIE_LABEL,
            RootFolderContract.RootFolderEntry.LOCAL_ROOT_FOLDER,
            RootFolderContract.RootFolderEntry.REMOTE_ROOT_FOLDER,
            RootFolderContract.RootFolderEntry.LAST_ETAG,
            RootFolderContract.RootFolderEntry.LAST_MODIFIED,
            RootFolderContract.RootFolderEntry.ENABLED};
    private String[] allColumns = { RootFolderContract._ID, RootFolderContract.CATEGORIE_LABEL,
            RootFolderContract.LOCAL_ROOT_FOLDER,
            RootFolderContract.REMOTE_ROOT_FOLDER,
            RootFolderContract.LAST_ETAG,
            RootFolderContract.LAST_MODIFIED,
            RootFolderContract.ENABLED};

    public RootFolderDAO(Context context){
        this.mHelper = new DbHelper(context);
@@ -60,13 +60,13 @@ public class RootFolderDAO {
     */
    public long insert(RootFolder folder){
        ContentValues values = new ContentValues();
        values.put(RootFolderContract.RootFolderEntry.CATEGORIE_LABEL, folder.getLibelle());
        values.put(RootFolderContract.RootFolderEntry.LOCAL_ROOT_FOLDER, folder.getLocalFolder());
        values.put(RootFolderContract.RootFolderEntry.REMOTE_ROOT_FOLDER, folder.getRemoteFolder());
        values.put(RootFolderContract.RootFolderEntry.LAST_ETAG, folder.getLastEtag() );
        values.put(RootFolderContract.RootFolderEntry.LAST_MODIFIED, folder.getLastEtag() );
        values.put(RootFolderContract.RootFolderEntry.ENABLED, folder.isEnabled());
        long id = mDB.insertWithOnConflict(RootFolderContract.RootFolderEntry.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
        values.put(RootFolderContract.CATEGORIE_LABEL, folder.getLibelle());
        values.put(RootFolderContract.LOCAL_ROOT_FOLDER, folder.getLocalFolder());
        values.put(RootFolderContract.REMOTE_ROOT_FOLDER, folder.getRemoteFolder());
        values.put(RootFolderContract.LAST_ETAG, folder.getLastEtag() );
        values.put(RootFolderContract.LAST_MODIFIED, folder.getLastEtag() );
        values.put(RootFolderContract.ENABLED, folder.isEnabled());
        long id = mDB.insertWithOnConflict(RootFolderContract.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
        return id;
    }

@@ -76,7 +76,7 @@ public class RootFolderDAO {
     */
    public void delete(String label) {
        Log.d(TAG, "root folder deleted with label: " + label);
        mDB.delete(RootFolderContract.RootFolderEntry.TABLE_NAME, RootFolderContract.RootFolderEntry.CATEGORIE_LABEL
        mDB.delete(RootFolderContract.TABLE_NAME, RootFolderContract.CATEGORIE_LABEL
                + " = " + label, null);
    }

@@ -85,7 +85,7 @@ public class RootFolderDAO {
     */
    public void delete() {
        Log.d(TAG, "root folder deleted " );
        mDB.delete(RootFolderContract.RootFolderEntry.TABLE_NAME, null, null);
        mDB.delete(RootFolderContract.TABLE_NAME, null, null);
    }


@@ -98,17 +98,17 @@ public class RootFolderDAO {
        Log.i(TAG, "Update("+folder.getLibelle()+")");
        Log.d(TAG, "Folder id = "+folder.getId());
        ContentValues values = new ContentValues();
        values.put(RootFolderContract.RootFolderEntry.CATEGORIE_LABEL, folder.getLibelle());
        values.put(RootFolderContract.RootFolderEntry.LOCAL_ROOT_FOLDER, folder.getLocalFolder());
        values.put(RootFolderContract.RootFolderEntry.REMOTE_ROOT_FOLDER, folder.getRemoteFolder());
        values.put(RootFolderContract.RootFolderEntry.LAST_ETAG, folder.getLastEtag());
        values.put( RootFolderContract.RootFolderEntry.LAST_MODIFIED, folder.getLastModified() );
        values.put( RootFolderContract.RootFolderEntry.ENABLED, folder.isEnabled() );
        values.put(RootFolderContract.CATEGORIE_LABEL, folder.getLibelle());
        values.put(RootFolderContract.LOCAL_ROOT_FOLDER, folder.getLocalFolder());
        values.put(RootFolderContract.REMOTE_ROOT_FOLDER, folder.getRemoteFolder());
        values.put(RootFolderContract.LAST_ETAG, folder.getLastEtag());
        values.put( RootFolderContract.LAST_MODIFIED, folder.getLastModified() );
        values.put( RootFolderContract.ENABLED, folder.isEnabled() );
        int result = 0;

        try{
            result = mDB.update(RootFolderContract.RootFolderEntry.TABLE_NAME, values,
                    RootFolderContract.RootFolderEntry._ID+" = "+folder.getId(),
            result = mDB.update(RootFolderContract.TABLE_NAME, values,
                    RootFolderContract._ID+" = "+folder.getId(),
                    null);
        }catch(Exception e){
            Log.e(TAG, e.toString());
@@ -126,7 +126,7 @@ public class RootFolderDAO {
     */
    public List<RootFolder> getAllRootFolders() {
        List<RootFolder> folders = new ArrayList<RootFolder>();
        Cursor cursor = mDB.query(RootFolderContract.RootFolderEntry.TABLE_NAME,
        Cursor cursor = mDB.query(RootFolderContract.TABLE_NAME,
                allColumns, null, null, null, null, null);

        cursor.moveToFirst();
@@ -153,7 +153,7 @@ public class RootFolderDAO {
                .setRemoteFolder(cursor.getString(3) )
                .setLastEtag(cursor.getString( 4 ) )
                .setLastModified(cursor.getLong( 5 ) )
                .setEnabled( cursor.getInt(4) != 0 ? true: false); //@TODO: adapt DB to get boolean behaviour
                .setEnabled( cursor.getInt(6) != 0 ? true: false); //@TODO: adapt DB to get boolean behaviour
        return folder;
    }
}
+21 −23
Original line number Diff line number Diff line
@@ -8,28 +8,7 @@ import android.provider.BaseColumns;
 * Some field might be add later
 */

public class SyncedFileStateContract {
    public static final String SQL_CREATE_TABLE_SYNCEDFILESTATE = new StringBuilder()
            .append("CREATE TABLE ").append(SyncedFileStateEntry.TABLE_NAME).append(" ( ")
            .append(SyncedFileStateEntry._ID).append(" INTEGER PRIMARY KEY, ")
            .append(SyncedFileStateEntry.FILE_NAME).append(" TEXT, ")
            .append(SyncedFileStateEntry.LOCAL_PATH).append(" TEXT, ")
            .append(SyncedFileStateEntry.REMOTE_PATH).append(" TEXT, ")
            .append(SyncedFileStateEntry.LAST_ETAG).append(" TEXT, ")
            .append(SyncedFileStateEntry.LOCAL_LAST_MODIFIED).append(" INTEGER, ")
            .append(SyncedFileStateEntry.SYNCING).append(" BOOLEAN, ")
            .append("CONSTRAINT synced_unicity_constraint UNIQUE (")
            .append(SyncedFileStateEntry.FILE_NAME).append(", ")
            .append(SyncedFileStateEntry.LOCAL_PATH).append(", ")
            .append(SyncedFileStateEntry.REMOTE_PATH)
            .append("))")
            .toString();


    public static final String SQL_DELETE_TABLE_SYNCEDFILESTATE = " DROP TABLE IF EXISTS "
            + SyncedFileStateEntry.TABLE_NAME;

    public static class SyncedFileStateEntry implements BaseColumns {
public class SyncedFileStateContract implements BaseColumns{
    public static final String TABLE_NAME ="synced_file_state";
    public static final String FILE_NAME ="file_name";
    public static final String LOCAL_PATH ="local_path";
@@ -37,5 +16,24 @@ public class SyncedFileStateContract {
    public static final String LAST_ETAG = "last_etag";
    public static final String LOCAL_LAST_MODIFIED = "local_last_modified";
    public static final String SYNCING = "syncing";
    }
    
    public static final String SQL_CREATE_TABLE_SYNCEDFILESTATE = new StringBuilder()
            .append("CREATE TABLE ").append(TABLE_NAME).append(" ( ")
            .append(_ID).append(" INTEGER PRIMARY KEY, ")
            .append(FILE_NAME).append(" TEXT, ")
            .append(LOCAL_PATH).append(" TEXT, ")
            .append(REMOTE_PATH).append(" TEXT, ")
            .append(LAST_ETAG).append(" TEXT, ")
            .append(LOCAL_LAST_MODIFIED).append(" INTEGER, ")
            .append(SYNCING).append(" BOOLEAN, ")
            .append("CONSTRAINT synced_unicity_constraint UNIQUE (")
            .append(FILE_NAME).append(", ")
            .append(LOCAL_PATH).append(", ")
            .append(REMOTE_PATH)
            .append("))")
            .toString();


    public static final String SQL_DELETE_TABLE_SYNCEDFILESTATE = " DROP TABLE IF EXISTS "
            + TABLE_NAME;
}
Loading