Java Code Examples for com.danimahardhika.android.helpers.core.FileHelper#createZip()

The following examples show how to use com.danimahardhika.android.helpers.core.FileHelper#createZip() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReportBugsTask.java    From candybar with Apache License 2.0 5 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            List<String> files = new ArrayList<>();

            mStringBuilder.append(DeviceHelper.getDeviceInfo(mContext.get()))
                    .append("\n").append(mDescription).append("\n");

            File brokenAppFilter = ReportBugsHelper.buildBrokenAppFilter(mContext.get());
            if (brokenAppFilter != null) files.add(brokenAppFilter.toString());

            File brokenDrawables = ReportBugsHelper.buildBrokenDrawables(mContext.get());
            if (brokenDrawables != null) files.add(brokenDrawables.toString());

            File activityList = ReportBugsHelper.buildActivityList(mContext.get());
            if (activityList != null) files.add(activityList.toString());

            String stackTrace = Preferences.get(mContext.get()).getLatestCrashLog();
            File crashLog = ReportBugsHelper.buildCrashLog(mContext.get(), stackTrace);
            if (crashLog != null) files.add(crashLog.toString());

            mZipPath = FileHelper.createZip(files, new File(mContext.get().getCacheDir(),
                    RequestHelper.getGeneratedZipName(ReportBugsHelper.REPORT_BUGS)));
            return true;
        } catch (Exception e) {
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}
 
Example 2
Source File: ReportBugsTask.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            List<String> files = new ArrayList<>();

            mStringBuilder.append(DeviceHelper.getDeviceInfo(mContext.get()))
                    .append("\n").append(mDescription).append("\n");

            File brokenAppFilter = ReportBugsHelper.buildBrokenAppFilter(mContext.get());
            if (brokenAppFilter != null) files.add(brokenAppFilter.toString());

            File brokenDrawables = ReportBugsHelper.buildBrokenDrawables(mContext.get());
            if (brokenDrawables != null) files.add(brokenDrawables.toString());

            File activityList = ReportBugsHelper.buildActivityList(mContext.get());
            if (activityList != null) files.add(activityList.toString());

            String stackTrace = Preferences.get(mContext.get()).getLatestCrashLog();
            File crashLog = ReportBugsHelper.buildCrashLog(mContext.get(), stackTrace);
            if (crashLog != null) files.add(crashLog.toString());

            mZipPath = FileHelper.createZip(files, new File(mContext.get().getCacheDir(),
                    RequestHelper.getGeneratedZipName(ReportBugsHelper.REPORT_BUGS)));
            return true;
        } catch (Exception e) {
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}
 
Example 3
Source File: SettingsFragment.java    From candybar with Apache License 2.0 4 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            File directory = getActivity().getCacheDir();
            requests = Database.get(getActivity()).getPremiumRequest(null);
            if (requests.size() == 0) return true;

            File appFilter = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPFILTER);
            File appMap = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPMAP);
            File themeResources = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);
            List<String> files = new ArrayList<>();

            for (int i = 0; i < requests.size(); i++) {
                Drawable drawable = getReqIcon(getActivity(), requests.get(i).getActivity());
                String icon = IconsHelper.saveIcon(files, directory, drawable, requests.get(i).getName());
                if (icon != null) files.add(icon);
            }

            if (appFilter != null) {
                files.add(appFilter.toString());
            }

            if (appMap != null) {
                files.add(appMap.toString());
            }

            if (themeResources != null) {
                files.add(themeResources.toString());
            }
            CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
                    RequestHelper.getGeneratedZipName(RequestHelper.REBUILD_ZIP)));
            return true;
        } catch (Exception e) {
            log = e.toString();
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}
 
Example 4
Source File: SettingsFragment.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            File directory = getActivity().getCacheDir();
            requests = Database.get(getActivity()).getPremiumRequest(null);
            if (requests.size() == 0) return true;

            File appFilter = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPFILTER);
            File appMap = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPMAP);
            File themeResources = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);
            List<String> files = new ArrayList<>();

            for (int i = 0; i < requests.size(); i++) {
                Drawable drawable = DrawableHelper.getHighQualityIcon(
                        getActivity(), requests.get(i).getPackageName());
                String icon = IconsHelper.saveIcon(files, directory, drawable, requests.get(i).getName());
                if (icon != null) files.add(icon);
            }

            if (appFilter != null) {
                files.add(appFilter.toString());
            }

            if (appMap != null) {
                files.add(appMap.toString());
            }

            if (themeResources != null) {
                files.add(themeResources.toString());
            }
            CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
                    RequestHelper.getGeneratedZipName(RequestHelper.REBUILD_ZIP)));
            return true;
        } catch (Exception e) {
            log = e.toString();
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}
 
Example 5
Source File: RequestFragment.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
@Override
protected Boolean doInBackground(Void... voids) {
    while (!isCancelled()) {
        try {
            Thread.sleep(1);
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                    getResources().getString(R.string.dev_email),
                    null));
            List<ResolveInfo> resolveInfos = getActivity().getPackageManager()
                    .queryIntentActivities(intent, 0);
            if (resolveInfos.size() == 0) {
                noEmailClientError = true;
                return false;
            }

            if (Preferences.get(getActivity()).isPremiumRequest()) {
                TransactionDetails details = InAppBillingProcessor.get(getActivity())
                        .getProcessor().getPurchaseTransactionDetails(
                        Preferences.get(getActivity()).getPremiumRequestProductId());
                if (details == null) return false;

                CandyBarApplication.sRequestProperty = new Request.Property(null,
                        details.purchaseInfo.purchaseData.orderId,
                        details.purchaseInfo.purchaseData.productId);
            }

            RequestFragment.sSelectedRequests = mAdapter.getSelectedItems();
            List<Request> requests = mAdapter.getSelectedApps();
            File appFilter = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPFILTER);
            File appMap = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.APPMAP);
            File themeResources = RequestHelper.buildXml(getActivity(), requests, RequestHelper.XmlType.THEME_RESOURCES);

            File directory = getActivity().getCacheDir();
            List<String> files = new ArrayList<>();

            for (Request request : requests) {
                Drawable drawable = getHighQualityIcon(getActivity(), request.getPackageName());
                String icon = IconsHelper.saveIcon(files, directory, drawable, request.getName());
                if (icon != null) files.add(icon);
            }

            if (appFilter != null) {
                files.add(appFilter.toString());
            }

            if (appMap != null) {
                files.add(appMap.toString());
            }

            if (themeResources != null) {
                files.add(themeResources.toString());
            }

            CandyBarApplication.sZipPath = FileHelper.createZip(files, new File(directory.toString(),
                    RequestHelper.getGeneratedZipName(RequestHelper.ZIP)));
            return true;
        } catch (Exception e) {
            LogUtil.e(Log.getStackTraceString(e));
            return false;
        }
    }
    return false;
}