Skip to content

Commit

Permalink
fixed search where it creates new instance of the activity, added res…
Browse files Browse the repository at this point in the history
…tore count to be showing in the drawer menu. fixed restore tasker to show the app name
  • Loading branch information
kosh committed Sep 12, 2015
1 parent cb896dd commit 8737c01
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 45 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
buildToolsVersion '23.0.1'

defaultConfig {
applicationId "com.fast.access.kam"
Expand Down Expand Up @@ -39,11 +39,11 @@ repositories {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:palette-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'cat.ereza:customactivityoncrash:1.2.0'
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<activity
android:name=".activities.Home"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name">
android:label="@string/app_name"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand All @@ -45,16 +46,19 @@
android:name=".activities.AppDetailsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_details"
android:launchMode="singleTop"
android:screenOrientation="user"/>
<activity
android:name=".activities.TeamActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/the_team"
android:launchMode="singleTop"
android:theme="@style/AboutActivity"/>
<activity
android:name=".activities.SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/action_settings"
android:launchMode="singleTop"
android:theme="@style/AboutActivity"/>

<service
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/fast/access/kam/activities/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ protected void onCreate(Bundle savedInstanceState) {
mHelper = new IabHelper(this, getString(R.string.base64));
mHelper.startSetup(mPurchaseFinishedListener);
showWhatsNew();
countBackup();
}

private void countBackup() {
if (navigationView.getMenu() != null) {
if (navigationView.getMenu().findItem(R.id.restore) != null) {
int count = AppHelper.getRestoreApksCount();
if (count != 0) {
navigationView.getMenu().findItem(R.id.restore).setTitle(getString(R.string.restore_title) + " ( " + count + " )");
} else {
navigationView.getMenu().findItem(R.id.restore).setTitle(getString(R.string.restore_title));
}
}
}
}

private void onSuccessPaid() {
Expand Down Expand Up @@ -266,6 +280,9 @@ public void run() {
case THEME:
recreate();
break;
case FOLDER_LISTENER:
countBackup();
break;
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fast.access.kam.fragments;

import android.Manifest;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
Expand Down Expand Up @@ -102,7 +101,7 @@ public boolean onPreferenceClick(Preference preference) {
case "size":
new AlertDialog.Builder(getActivity())
.setTitle("Delete Folder?")
.setMessage("After deleting this file you won't be able to restore any app")
.setMessage("The Backup File will be deleted!\nAre you sure?")
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/fast/access/kam/global/helper/AppHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.fast.access.kam.R;
import com.fast.access.kam.global.model.AppsModel;

import net.lingala.zip4j.core.ZipFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -240,4 +242,17 @@ public static void actionModeColor(Context context) {
} catch (Exception ignored) {}
}


public static int getRestoreApksCount() {
try {
FileUtil fileUtil = new FileUtil();
File zipFileName = new File(fileUtil.getBaseFolderName() + "backup.zip");
ZipFile zipFile = new ZipFile(zipFileName);
return zipFile.getFileHeaders().size();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class EventsModel {

public enum EventType {
DELETE, NEW, THEME
DELETE, NEW, THEME, FOLDER_LISTENER
}

private String packageName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import android.support.v7.app.NotificationCompat;
import android.widget.Toast;

import com.fast.access.kam.AppController;
import com.fast.access.kam.R;
import com.fast.access.kam.global.helper.AppHelper;
import com.fast.access.kam.global.model.AppsModel;
import com.fast.access.kam.global.model.EventsModel;
import com.fast.access.kam.global.model.ProgressModel;
import com.fast.access.kam.global.model.helper.OperationType;
import com.fast.access.kam.global.task.backup.BackupAppsTasker;
Expand Down Expand Up @@ -103,6 +105,9 @@ public void onPreExecute() { /*do nothing.*/ }
@Override
public void onPostExecute(boolean isBackup) {
generateNotification(isBackup);
EventsModel eventsModel = new EventsModel();
eventsModel.setEventType(EventsModel.EventType.FOLDER_LISTENER);
AppController.getController().getBus().post(eventsModel);
stopSelf();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@ protected ProgressModel doInBackground(Void... params) {
progressModel.setProgress(count);
progressModel.setFileName(fileToSave.getName());
publishProgress(progressModel);
// if (withData) {
// withData(model, packageInfo, file, fileUtil, count);
// Result r = RootManager.getInstance().runCommand("ls -ld " + packageInfo.dataDir);
// if (r.getMessage() != null) {
// String[] p = r.getMessage().split("\\s+");
// if (p.length == 6) {
//// String permissions, String owner, String group, String date, String fileName
// } else if (p.length == 7) {
//// String permissions, String owner, String group, String size, String date, String fileName
// }
// }
// Log.e("TAG", r.getMessage() + " " + r.getResult());
//
// }
}
}
}
Expand All @@ -145,7 +131,6 @@ protected ProgressModel doInBackground(Void... params) {
return null;
}


private void withData(AppsModel model, ApplicationInfo packageInfo, File file, FileUtil fileUtil, int count) throws Exception {
File dataFolder = new File(packageInfo.dataDir);
File dataFile = new File(fileUtil.getBaseFolderName() + model.getPackageName());
Expand All @@ -165,7 +150,6 @@ private void withData(AppsModel model, ApplicationInfo packageInfo, File file, F
publishProgress(progressModel);
}


private ProgressModel onError(String msg) {
ProgressModel error = new ProgressModel();
error.setMsg(msg);
Expand All @@ -182,7 +166,6 @@ public void onStop() {
}
}
if (zipData != null) {
RootManager.getInstance().runCommand("\nexit\n");
if (zipData.getProgressMonitor() != null) {
zipData.getProgressMonitor().cancelAllTasks();
if (zipData.getFile() != null && zipData.getFile().exists())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;

import com.chrisplus.rootmanager.RootManager;
import com.chrisplus.rootmanager.container.Result;
Expand Down Expand Up @@ -81,28 +80,19 @@ protected ProgressModel doInBackground(Context... params) {
FileHeader fileHeader = (FileHeader) fileHeaderList.get(i);
zFile.extractFile(fileHeader, fileUtil.getBaseFolderName());
progressModel = new ProgressModel();
progressModel.setProgress(i);
progressModel.setFileName(fileHeader.getFileName());
publishProgress(progressModel);
if (AppHelper.isRoot()) {
Result result = AppHelper.installApkSilently(new File(fileUtil.getBaseFolderName() + fileHeader.getFileName()).getPath());
if (result != null && result.getStatusCode() == Result.ResultEnum.INSTALL_SUCCESS.getStatusCode()) {
boolean deleteApk = new File(fileUtil.getBaseFolderName() + fileHeader.getFileName()).delete();
Log.e("Result", result.getMessage() + " deleteApk: " + Boolean.toString(deleteApk));
} else {
if (result != null) {
Log.e("Result Error", result.getMessage() + " " + result.getStatusCode());
}
}
} else {
// install manually via intent.
progressModel.setFilePath(fileUtil.getBaseFolderName() + fileHeader.getFileName());
}
progressModel.setProgress(i);
progressModel.setFileName(fileHeader.getFileName());
publishProgress(progressModel);
}
zipFile.delete();
// if (withData) {
// withData();
// }
} catch (Exception e) {
e.printStackTrace();
return error(e.getMessage());
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/res/menu/drawer_menu.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="none">
<item
android:id="@+id/backup"
android:icon="@drawable/ic_backup"
android:title="Backup"/>
android:title="@string/backup_title"/>
<item
android:id="@+id/restore"
android:icon="@drawable/ic_restore"
android:title="Restore"/>
android:title="@string/restore_title"/>
</group>
<item
android:icon="@drawable/ic_backup"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
<string name="app_details">Application Details</string>
<string name="the_team">The Team</string>
<string name="whats_new">1- Improved Caching, no more LAG!.\n2- LongPress any apps to backup.</string>
<string name="backup_title">Backup</string>
<string name="restore_title">Restore</string>
</resources>

0 comments on commit 8737c01

Please sign in to comment.