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

Commit 0c00b205 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

change implementation of application sync feature

parent 41ca4035
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <!-- needed for PersistedJob -->


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_eelo"
+17 −0
Original line number Diff line number Diff line
package io.eelo.drive.fileFilters;

import java.io.File;
import java.io.FileFilter;

import io.eelo.drive.utils.AppConstants;

/**
 * Created by Vincent on 20/07/2018.
 */

public class AppListFileFilter implements FileFilter {
    @Override
    public boolean accept(File pathName) {
        return ( pathName.isFile() && pathName.getName().equals( AppConstants.APPLICATIONS_LIST_FILE_NAME ) );
    }
}
+1 −12
Original line number Diff line number Diff line
@@ -14,26 +14,15 @@ import io.eelo.drive.utils.AppConstants;

public class FileFilterFactory {
    private static FileFilterFactory sInstance;
    private SharedPreferences prefs;

    private Context mContext;
    public static FileFilterFactory getInstance(){
        if(sInstance == null){
            return new FileFilterFactory();
        }
        return sInstance;
    }

    private FileFilterFactory(){};

    /**
     * NB: I added this methods because I make this factory to be a singleton
     * @param mContext
     */
   public void setContext(Context mContext){
        this.mContext = mContext;
        this.prefs = mContext.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
   }
    public FileFilter getFileFilter(String categorie){
        FileFilter filter;
        switch (categorie){
@@ -41,7 +30,7 @@ public class FileFilterFactory {
                filter = new SettingsFileFilter();
                break;
            case "Applications":
                filter = new PackageNameFileFilter(this.prefs);
                filter = new AppListFileFilter();
                break;
            default:
                filter = new NoCacheFileFilter();
+0 −49
Original line number Diff line number Diff line
package io.eelo.drive.fileFilters;

import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.ArraySet;
import android.util.Log;

import com.owncloud.android.lib.resources.files.FileUtils;

import java.io.File;
import java.util.Set;

import io.eelo.drive.utils.CommonUtils;

/**
 * Created by Vincent on 10/07/2018.
 */

public class PackageNameFileFilter extends NoCacheFileFilter {
    public static String TAG = PackageNameFileFilter.class.getSimpleName();
    SharedPreferences sharedPreferences;

    public PackageNameFileFilter(SharedPreferences prefs) {
        this.sharedPreferences = prefs;
    }

    @Override
    public boolean accept(File pathname) {
        /*Set<String> appToSync = this.sharedPreferences.getStringSet("AppToSync", new ArraySet<String>());
        //get Local path to this
        String localPath = CommonUtils.getLocalPath(pathname);

        Log.d(TAG, "accept("+localPath+")");
        boolean found = false;

        //Check if there is a correspondance
        for(String appPath : appToSync){
            if( localPath.contains(appPath) ){
                found = true;
                break;
            }
        }

        Log.d(TAG, "Package name is in acceptable list: "+found );
        return ( super.accept(pathname) && found);*/
        return (pathname.isFile() && pathname.getName().equals("installed_packages.xml") );
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -11,7 +11,10 @@ public class SettingsFileFilter implements FileFilter {
    @Override
    public boolean accept(File pathName) {

        return ( pathName.isFile() && pathName.getName().startsWith("settings_")
                && pathName.getName().endsWith(".xml") );
        boolean corresponds = false;
        if(  pathName.getName().startsWith("settings_") && pathName.getName().endsWith(".xml" )  ) {
            corresponds = true;
        }
        return ( pathName.isFile() &&  corresponds );
    }
}
Loading