diff --git a/app/build.gradle b/app/build.gradle index 4cdf20f1..c723bcf6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,6 +83,7 @@ dependencies { // test libraries testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test:rules:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation project(path: ':unitrackerlibrary') diff --git a/app/src/androidTest/java/de/domjos/unitrackermobile/utils/Helper.java b/app/src/androidTest/java/de/domjos/unitrackermobile/utils/Helper.java index c4e423c0..313f90d2 100644 --- a/app/src/androidTest/java/de/domjos/unitrackermobile/utils/Helper.java +++ b/app/src/androidTest/java/de/domjos/unitrackermobile/utils/Helper.java @@ -34,22 +34,4 @@ public class Helper { static Context getContext() { return InstrumentationRegistry.getInstrumentation().getTargetContext(); } - - public static Authentication getAuthFromRes(int rawID, String bt) throws Exception { - Properties properties = Helper.readPropertiesFromRaw(rawID, Helper.getContext()); - return new Authentication(properties.getProperty(bt + "_server"), properties.getProperty(bt + "_api"), properties.getProperty(bt + "_user"), properties.getProperty(bt + "_pwd")); - } - - private static Properties readPropertiesFromRaw(int rawID, Context context) throws Exception { - Properties properties = new Properties(); - Resources res = context.getResources(); - InputStream in_s = res.openRawResource(rawID); - properties.load(in_s); - return properties; - } - - public static int getVersionCode(Context context) throws Exception { - PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); - return info.versionCode; - } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java index 2026557f..a9dc6d58 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java @@ -29,6 +29,7 @@ import android.widget.Spinner; import androidx.annotation.NonNull; +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; import com.github.angads25.filepicker.model.DialogConfigs; import com.github.angads25.filepicker.model.DialogProperties; @@ -113,7 +114,7 @@ public void onNothingSelected(AdapterView parent) { String file = this.txtExportPath.getText().toString() + "." + this.spExportPath.getSelectedItem().toString(); if (bugService != null && project != null) { - ExportTask exportTask = new ExportTask(ExportActivity.this, bugService, type, project.getId(), file, notify, R.drawable.ic_import_export_black_24dp); + ExportTask exportTask = new ExportTask(ExportActivity.this, bugService, type, project.getId(), file, notify, R.drawable.ic_import_export_black_24dp, VectorDrawableCompat.create(this.getResources(), R.drawable.background, null)); List objects = new LinkedList<>(); switch (type) { case Projects: diff --git a/app/src/main/java/de/domjos/unitrackermobile/custom/SwipeToDeleteCallback.java b/app/src/main/java/de/domjos/unitrackermobile/custom/SwipeToDeleteCallback.java index baab96fd..70e77ebc 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/custom/SwipeToDeleteCallback.java +++ b/app/src/main/java/de/domjos/unitrackermobile/custom/SwipeToDeleteCallback.java @@ -26,12 +26,14 @@ import android.graphics.PorterDuffXfermode; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.view.View; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; import de.domjos.unitrackermobile.R; @@ -49,7 +51,7 @@ public abstract class SwipeToDeleteCallback extends ItemTouchHelper.Callback { backgroundColor = Color.parseColor("#b80f0a"); mClearPaint = new Paint(); mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - deleteDrawable = ContextCompat.getDrawable(context, R.drawable.ic_delete_black_24dp); + deleteDrawable = VectorDrawableCompat.create(context.getResources(), R.drawable.ic_delete_black_24dp, null); assert deleteDrawable != null; intrinsicWidth = deleteDrawable.getIntrinsicWidth(); intrinsicHeight = deleteDrawable.getIntrinsicHeight(); diff --git a/app/src/main/java/de/domjos/unitrackermobile/helper/AdHelper.java b/app/src/main/java/de/domjos/unitrackermobile/helper/AdHelper.java deleted file mode 100644 index af800773..00000000 --- a/app/src/main/java/de/domjos/unitrackermobile/helper/AdHelper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 Domjos - * This file is part of UniTrackerMobile . - * - * UniTrackerMobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * UniTrackerMobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with UniTrackerMobile. If not, see . - */ - -package de.domjos.unitrackermobile.helper; - -import android.app.Activity; - -import com.google.android.gms.ads.AdRequest; -import com.google.android.gms.ads.InterstitialAd; -import com.google.android.gms.ads.MobileAds; - -import de.domjos.unitrackerlibrary.utils.MessageHelper; -import de.domjos.unitrackermobile.settings.Settings; - -public class AdHelper { - private InterstitialAd interstitialAd; - private Settings settings; - private Activity activity; - - public AdHelper(Settings settings, Activity activity) { - this.settings = settings; - this.activity = activity; - - MobileAds.initialize(activity, initializationStatus -> {}); - this.interstitialAd = new InterstitialAd(activity); - // ToDo replace by ca-app-pub-4983888966373182/5163399444 - this.interstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712"); - this.interstitialAd.loadAd(new AdRequest.Builder().build()); - } - - public void show() { - try { - if(!this.settings.showAds()) { - this.interstitialAd.show(); - } - } catch (Exception ex) { - MessageHelper.printException(ex, this.activity); - } - } -} diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index 8a3e8bb6..3dd6164f 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -16,7 +16,8 @@ ~ along with UniTrackerMobile. If not, see . --> - fonts = new LinkedHashMap<>(); fonts.put(H1, new Font(Font.FontFamily.HELVETICA, 18, Font.BOLDITALIC, BaseColor.BLACK)); fonts.put(H2, new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLACK)); @@ -60,6 +64,9 @@ static void saveObjectToPDF(List lst, String path) throws Exception { fonts.put(BODY, new Font(Font.FontFamily.HELVETICA, 14, Font.NORMAL, BaseColor.BLACK)); Document pdfDocument = new Document(); + if(drawable!=null) { + ObjectPDF.addBackground(drawable, pdfDocument); + } PdfWriter writer = PdfWriter.getInstance(pdfDocument, new FileOutputStream(path)); writer.setBoxSize("art", new Rectangle(55, 25, 550, 788)); writer.setPageEvent(new Footer(lst.size())); @@ -72,6 +79,12 @@ static void saveObjectToPDF(List lst, String path) throws Exception { pdfDocument.close(); } + private static void addBackground(Drawable drawable, Document document) throws Exception { + Image image = Image.getInstance(Converter.convertDrawableToByteArray(drawable)); + image.setAbsolutePosition(0, 0); + document.add(image); + } + private static void saveElementToPDF(Object object, Document pdfDocument, Map fonts) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN); if(object instanceof Project) { diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/export/TrackerPDF.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/export/TrackerPDF.java index b4d58619..7de348d6 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/export/TrackerPDF.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/export/TrackerPDF.java @@ -18,6 +18,7 @@ package de.domjos.unitrackerlibrary.export; +import android.graphics.drawable.Drawable; import android.util.Log; import java.util.LinkedList; @@ -29,10 +30,16 @@ import de.domjos.unitrackerlibrary.model.projects.Project; public final class TrackerPDF extends AbstractTracker { - + private Drawable drawable; public TrackerPDF(IBugService bugService, Type type, T pid, List ids, String path) { super(bugService, type, pid, ids, path); + this.drawable = null; + } + + public TrackerPDF(IBugService bugService, Type type, T pid, List ids, String path, Drawable drawable) { + super(bugService, type, pid, ids, path); + this.drawable = drawable; } @Override @@ -43,21 +50,21 @@ public void doExport() throws Exception { for (T id : this.ids) { projects.add(this.bugService.getProject(id)); } - ObjectPDF.saveObjectToPDF(projects, this.path); + ObjectPDF.saveObjectToPDF(projects, this.path, this.drawable); break; case Issues: List issues = new LinkedList<>(); for (T id : this.ids) { issues.add(this.bugService.getIssue(id, this.pid)); } - ObjectPDF.saveObjectToPDF(issues, this.path); + ObjectPDF.saveObjectToPDF(issues, this.path, this.drawable); break; case CustomFields: List customFields = new LinkedList<>(); for (T id : this.ids) { customFields.add(this.bugService.getCustomField(id, this.pid)); } - ObjectPDF.saveObjectToPDF(customFields, this.path); + ObjectPDF.saveObjectToPDF(customFields, this.path, this.drawable); break; default: return; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/ExportTask.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/ExportTask.java index 58d63e91..b6dae79f 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/ExportTask.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/ExportTask.java @@ -19,6 +19,7 @@ package de.domjos.unitrackerlibrary.tasks; import android.app.Activity; +import android.graphics.drawable.Drawable; import java.util.Arrays; import java.util.List; @@ -33,12 +34,18 @@ public final class ExportTask extends AbstractTask { private String path; private TrackerXML.Type type; private Object project_id; + private Drawable drawable; public ExportTask(Activity activity, IBugService bugService, TrackerXML.Type type, Object project_id, String path, boolean showNotifications, int icon) { + this(activity, bugService, type, project_id, path, showNotifications, icon, null); + } + + public ExportTask(Activity activity, IBugService bugService, TrackerXML.Type type, Object project_id, String path, boolean showNotifications, int icon, Drawable drawable) { super(activity, bugService, R.string.task_export_title, R.string.task_export_contet, showNotifications, icon); this.path = path; this.type = type; this.project_id = project_id; + this.drawable = drawable; } @Override @@ -65,7 +72,7 @@ protected Void doInBackground(Object... objects) { buggerCSV.doExport(); break; case "pdf": - TrackerPDF buggerPDF = new TrackerPDF(super.bugService, this.type, this.project_id, objectList, this.path); + TrackerPDF buggerPDF = new TrackerPDF(super.bugService, this.type, this.project_id, objectList, this.path, this.drawable); buggerPDF.doExport(); break; }