Skip to content

Commit

Permalink
APK: Implement loaders for app manager
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalNehra committed Mar 7, 2017
1 parent 095e8da commit 0d1b8c2
Show file tree
Hide file tree
Showing 19 changed files with 468 additions and 258 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'com.android.application'
Expand All @@ -17,7 +17,7 @@ repositories {

android {
compileSdkVersion 25
buildToolsVersion '23.0.3'
buildToolsVersion '25.0.0'

packagingOptions {
exclude 'proguard-project.txt'
Expand Down
2 changes: 1 addition & 1 deletion libs/StickyHeadersRecyclerView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
buildToolsVersion '25.0.0'

defaultConfig {
minSdkVersion 14
Expand Down
3 changes: 0 additions & 3 deletions libs/StickyHeadersRecyclerView/gradle.properties

This file was deleted.

48 changes: 25 additions & 23 deletions src/main/java/com/amaze/filemanager/adapters/AppsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -52,33 +51,32 @@
import com.amaze.filemanager.utils.Futils;
import com.amaze.filemanager.utils.OpenMode;
import com.amaze.filemanager.utils.PreferenceUtils;
import com.amaze.filemanager.utils.ServiceWatcherUtil;
import com.amaze.filemanager.utils.provider.UtilitiesProviderInterface;
import com.amaze.filemanager.utils.theme.AppTheme;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class AppsAdapter extends ArrayAdapter<Layoutelements> {

private UtilitiesProviderInterface utilsProvider;
Context context;
List<Layoutelements> items;
public SparseBooleanArray myChecked = new SparseBooleanArray();
AppsList app;
ArrayList<PackageInfo> c = new ArrayList<>();

public AppsAdapter(Context context, UtilitiesProviderInterface utilsProvider, int resourceId,
List<Layoutelements> items, AppsList app, ArrayList<PackageInfo> c) {
super(context, resourceId, items);
AppsList app) {
super(context, resourceId);
this.utilsProvider = utilsProvider;
this.context = context;
this.items = items;
this.app = app;
this.c = c;
for (int i = 0; i < items.size(); i++) {

/*for (int i = 0; i < items.size(); i++) {
myChecked.put(i, false);
}
}*/
}

public void toggleChecked(int position) {
Expand Down Expand Up @@ -124,6 +122,15 @@ public boolean areAllChecked() {
return b;
}

public void setData(List<Layoutelements> data) {
clear();

if (data != null) {
this.items = data;
addAll(data);
}
}

private class ViewHolder {
ImageView apkIcon;
TextView txtTitle;
Expand Down Expand Up @@ -224,16 +231,9 @@ public boolean onMenuItemClick(MenuItem item) {
case R.id.unins:
final BaseFile f1 = new BaseFile(rowItem.getDesc());
f1.setMode(OpenMode.ROOT);
ApplicationInfo info1=null;
for(PackageInfo info:c){
if(info.applicationInfo.publicSourceDir.equals(rowItem.getDesc())) {
info1=info.applicationInfo;
}
}
int color= Color.parseColor(PreferenceUtils.getAccentString(app.Sp));
//arrayList.add(utils.newElement(Icons.loadMimeIcon(getActivity(), f1.getPath(), false), f1.getPath(), null, null, utils.getSize(f1),"", false));
//utils.deleteFiles(arrayList, null, arrayList1);
if ((info1.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {

if ((Integer.valueOf(rowItem.getSymlink()) & ApplicationInfo.FLAG_SYSTEM) != 0) {
// system package
if(app.Sp.getBoolean("rootmode",false)) {
MaterialDialog.Builder builder1 = new MaterialDialog.Builder(app.getActivity());
Expand Down Expand Up @@ -297,16 +297,18 @@ public void onPositive(MaterialDialog materialDialog) {
BaseFile baseFile=RootHelper.generateBaseFile(f,true);
baseFile.setName(rowItem.getTitle() + "_" + rowItem.getSymlink() + ".apk");
ab.add(baseFile);
intent.putExtra("FILE_PATHS", ab);
intent.putExtra("COPY_DIRECTORY", dst.getPath());
intent.putExtra("MODE",0);
app.getActivity().startService(intent);
return true;

intent.putParcelableArrayListExtra(CopyService.TAG_COPY_SOURCES, ab);
intent.putExtra(CopyService.TAG_COPY_TARGET, dst.getPath());
intent.putExtra(CopyService.TAG_COPY_OPEN_MODE, 0);

ServiceWatcherUtil.runService(app.getActivity(), intent);
return true;
}
return false;
}
});

popupMenu.inflate(R.menu.app_options);
popupMenu.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,9 @@ else if (Icons.isGeneric(rowItem.getDesc())) {
gradientDrawable.setColor(main.icon_skin_color);
}
} else gradientDrawable.setColor((main.icon_skin_color));

if (rowItem.getSize().equals(main.goback))
gradientDrawable.setColor(c1);


}
if (main.SHOW_PERMISSIONS)
holder.perm.setText(rowItem.getPermissions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public String getPermisson() {
public void setPermisson(String permisson) {
this.permisson = permisson;
}

protected BaseFile(Parcel in) {
super(OpenMode.getOpenMode(in.readInt()),in.readString());
permisson = in.readString();
Expand Down
41 changes: 35 additions & 6 deletions src/main/java/com/amaze/filemanager/filesystem/Operations.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,43 @@ public class Operations {
private static final String QUOTE = "\"";
private static final String GREATER_THAN = ">";
private static final String LESS_THAN = "<";

private static final String FAT = "FAT";

public interface ErrorCallBack{
public interface ErrorCallBack {

/**
* Callback fired when file being created in process already exists
* @param file
*/
void exists(HFile file);

/**
* Callback fired when creating new file/directory and required storage access framework permission
* to access SD Card is not available
* @param file
*/
void launchSAF(HFile file);
void launchSAF(HFile file,HFile file1);
void done(HFile hFile,boolean b);

/**
* Callback fired when renaming file and required storage access framework permission to access
* SD Card is not available
* @param file
* @param file1
*/
void launchSAF(HFile file, HFile file1);

/**
* Callback fired when we're done processing the operation
* @param hFile
* @param b defines whether operation was successful
*/
void done(HFile hFile, boolean b);

/**
* Callback fired when an invalid file name is found.
* @param file
*/
void invalidName(HFile file);
}

Expand Down Expand Up @@ -107,9 +137,8 @@ protected Void doInBackground(Void... params) {
errorCallBack.done(file, file.exists());
return null;
}
errorCallBack.done(file, file.exists());


errorCallBack.done(file, file.exists());
}
return null;
}
Expand Down Expand Up @@ -244,7 +273,7 @@ protected Void doInBackground(Void... params) {
case FILE:
int mode = checkFolder(file.getParentFile(), context);
if (mode == 2) {
errorCallBack.launchSAF(oldFile,newFile);
errorCallBack.launchSAF(oldFile, newFile);
} else if (mode == 1 || mode==0) {
try {
FileUtil.renameFolder(file, file1, context);
Expand Down
Loading

0 comments on commit 0d1b8c2

Please sign in to comment.