diff --git a/app/src/androidTest/java/de/domjos/unitrackermobile/utils/CryptoTest.java b/app/src/androidTest/java/de/domjos/unitrackermobile/utils/CryptoTest.java index abddd157..9276cff1 100644 --- a/app/src/androidTest/java/de/domjos/unitrackermobile/utils/CryptoTest.java +++ b/app/src/androidTest/java/de/domjos/unitrackermobile/utils/CryptoTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import de.domjos.unitrackerlibrary.utils.Crypto; +import de.domjos.customwidgets.utils.Crypto; import static org.junit.Assert.assertEquals; diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/AccountActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/AccountActivity.java index 30b8ff0d..d1bf9fdb 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/AccountActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/AccountActivity.java @@ -43,11 +43,11 @@ import java.util.List; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.services.authentication.GithubTokenProvider; import de.domjos.unitrackerlibrary.services.engine.Authentication; -import de.domjos.unitrackerlibrary.utils.Converter; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -252,7 +252,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { Bitmap bitmap = IntentHelper.getImageFromGallery(requestCode, resultCode, data, this.getApplicationContext()); this.cmdAccountImageGallery.setImageBitmap(bitmap); } catch (Exception ex) { - MessageHelper.printException(ex, AccountActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, AccountActivity.this); } } @@ -291,32 +291,32 @@ protected void initControls() { IBugService bugService = Helper.getCurrentBugService(this.currentAccount, this.getApplicationContext()); if (chkAccountGuest.isChecked() || bugService.testConnection()) { AccountActivity.this.runOnUiThread(() -> { - MessageHelper.printMessage(this.getString(R.string.accounts_connection_successfully), AccountActivity.this); + MessageHelper.printMessage(this.getString(R.string.accounts_connection_successfully), R.mipmap.ic_launcher_round, AccountActivity.this); MainActivity.GLOBALS.getSqLiteGeneral().insertOrUpdateAccount(this.currentAccount); this.manageControls(false, true, false); this.reload(); OnBoardingHelper.tutorialStep3(AccountActivity.this); }); } else { - AccountActivity.this.runOnUiThread(() -> MessageHelper.printMessage(this.getString(R.string.accounts_connection_not_successfully), AccountActivity.this)); + AccountActivity.this.runOnUiThread(() -> MessageHelper.printMessage(this.getString(R.string.accounts_connection_not_successfully), R.mipmap.ic_launcher_round, AccountActivity.this)); } } catch (Exception ex) { Log.v("Exception", ex.toString()); String msg = ex.getMessage(); if(msg!=null) { if (msg.contains("PHP SOAP")) { - AccountActivity.this.runOnUiThread(() -> MessageHelper.printMessage(this.getString(R.string.messages_no_soap), AccountActivity.this)); + AccountActivity.this.runOnUiThread(() -> MessageHelper.printMessage(this.getString(R.string.messages_no_soap), R.mipmap.ic_launcher_round, AccountActivity.this)); } else { - AccountActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, AccountActivity.this)); + AccountActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, AccountActivity.this)); } } } }).start(); } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, AccountActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, AccountActivity.this); } break; } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/AdministrationActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/AdministrationActivity.java index 469f1e2c..2266c0d7 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/AdministrationActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/AdministrationActivity.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.Administration; @@ -43,7 +44,6 @@ import de.domjos.unitrackerlibrary.tasks.FieldTask; import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.ProjectTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.unitrackermobile.helper.ArrayHelper; @@ -94,7 +94,7 @@ public void onItemSelected(AdapterView parent, View view, int position, long } checkPermissions(); } catch (Exception ex) { - MessageHelper.printException(ex, AdministrationActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, AdministrationActivity.this); } } @Override @@ -116,7 +116,7 @@ public void onItemSelected(AdapterView parent, View view, int position, long } checkPermissions(); } catch (Exception ex) { - MessageHelper.printException(ex, AdministrationActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, AdministrationActivity.this); } } @Override @@ -243,7 +243,7 @@ private void reloadData1(int data, int projectPosition) { } } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } @@ -296,9 +296,9 @@ private void writeData(boolean move) { this.getResources().getStringArray(R.array.administration_data)[this.spData1.getSelectedItemPosition()], move ? this.getString(R.string.administration_move) : this.getString(R.string.administration_copy) ); - MessageHelper.printMessage(message, this.ctx); + MessageHelper.printMessage(message, R.mipmap.ic_launcher_round, this.ctx); } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/CalendarActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/CalendarActivity.java index 2ee49d8b..3941cfb3 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/CalendarActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/CalendarActivity.java @@ -10,6 +10,7 @@ import java.util.Date; import java.util.List; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.customwidgets.widgets.calendar.Event; import de.domjos.customwidgets.widgets.calendar.WidgetCalendar; import de.domjos.unitrackerlibrary.interfaces.IBugService; @@ -22,7 +23,6 @@ import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.ProjectTask; import de.domjos.unitrackerlibrary.tasks.VersionTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.unitrackermobile.helper.Helper; @@ -156,7 +156,7 @@ public void onPostExecute(Object o) { projectTask.execute(0); } } catch (Exception ex) { - MessageHelper.printException(ex, CalendarActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, CalendarActivity.this); } } 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 615c70d4..a02660fd 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/ExportActivity.java @@ -41,6 +41,7 @@ import java.util.LinkedList; import java.util.List; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.export.TrackerXML; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.CustomField; @@ -51,8 +52,7 @@ import de.domjos.unitrackerlibrary.tasks.FieldTask; import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.ProjectTask; -import de.domjos.unitrackerlibrary.utils.Converter; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.unitrackermobile.helper.Helper; @@ -109,7 +109,7 @@ public void onItemSelected(AdapterView parent, View view, int position, long List projects = projectTask.execute(0).get(); projectAdapter.addAll(projects); } catch (Exception ex) { - MessageHelper.printException(ex, ExportActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, ExportActivity.this); } } @@ -138,7 +138,7 @@ public void onNothingSelected(AdapterView parent) { this.copyExampleContent(R.raw.example_projects, "example_projects.xslt", download); this.copyExampleContent(R.raw.example_issues, "example_issues.xslt", download); this.copyExampleContent(R.raw.example_custom_fields, "example_custom_fields.xslt", download); - MessageHelper.printMessage(this.getString(R.string.export_extended_xml_xslt_example_success), ExportActivity.this); + MessageHelper.printMessage(this.getString(R.string.export_extended_xml_xslt_example_success), R.mipmap.ic_launcher_round, ExportActivity.this); } }); @@ -204,12 +204,12 @@ public void onNothingSelected(AdapterView parent) { break; } exportTask.execute(objects.toArray()).get(); - MessageHelper.printMessage(this.getString(R.string.export_success), ExportActivity.this); + MessageHelper.printMessage(this.getString(R.string.export_success), R.mipmap.ic_launcher_round, ExportActivity.this); } } catch (Exception ex) { - MessageHelper.printException(ex, ExportActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, ExportActivity.this); } catch (OutOfMemoryError error) { - MessageHelper.printMessage(error.getMessage(), ExportActivity.this); + MessageHelper.printMessage(error.getMessage(), R.mipmap.ic_launcher_round, ExportActivity.this); } }); } @@ -221,7 +221,7 @@ private void copyExampleContent(int resource, String name, String path) { outputStreamWriter.write(content); outputStreamWriter.close(); } catch (Exception ex) { - MessageHelper.printException(ex, ExportActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, ExportActivity.this); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/FieldActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/FieldActivity.java index a6e25ddb..b790dbec 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/FieldActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/FieldActivity.java @@ -28,13 +28,13 @@ import java.util.Objects; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.issues.CustomField; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.FieldTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -84,7 +84,7 @@ public void onDelete(BaseDescriptionObject listObject) { new FieldTask(FieldActivity.this, bugService, currentProject.getId(), true, settings.showNotifications(), R.drawable.ic_text_fields_black_24dp).execute(((CustomField)listObject.getObject()).getId()).get(); manageControls(false, true, false); } catch (Exception ex) { - MessageHelper.printException(ex, FieldActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, FieldActivity.this); } } }); @@ -112,7 +112,7 @@ protected void reload() { } } } catch (Exception ex) { - MessageHelper.printException(ex, FieldActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, FieldActivity.this); } } @@ -136,7 +136,7 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } catch (Exception ex) { - MessageHelper.printException(ex, FieldActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, FieldActivity.this); } break; case R.id.navCancel: @@ -150,10 +150,10 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, FieldActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, FieldActivity.this); } break; } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/IssueActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/IssueActivity.java index eefdbfdd..3aecda7b 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/IssueActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/IssueActivity.java @@ -28,13 +28,13 @@ import java.util.List; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.projects.Version; import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.VersionTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.adapter.PagerAdapter; import de.domjos.customwidgets.model.AbstractActivity; @@ -82,7 +82,7 @@ protected void initControls() { this.issue = new Issue(); } } catch (Exception ex) { - MessageHelper.printException(ex, IssueActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, IssueActivity.this); } // init Navigation-View @@ -141,10 +141,10 @@ protected void initControls() { this.setResult(RESULT_OK); this.finish(); } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } break; } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/LocalSyncActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/LocalSyncActivity.java index c69d90af..047bd110 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/LocalSyncActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/LocalSyncActivity.java @@ -36,12 +36,12 @@ import java.io.File; import java.util.ArrayList; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.LocalSyncTask; import de.domjos.unitrackerlibrary.tasks.ProjectTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.adapter.LocalSyncAdapter; import de.domjos.customwidgets.model.AbstractActivity; @@ -71,7 +71,7 @@ public void onItemSelected(AdapterView parent, View view, int position, long try { reloadProjects(position); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } @@ -139,7 +139,7 @@ protected void initControls() { this.sync(); } } catch (Exception ex) { - MessageHelper.printException(ex, this.activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.activity); } } @@ -165,10 +165,10 @@ private void sync() { } LocalSyncTask localSyncTask = new LocalSyncTask(this.activity, bugService, this.settings.showNotifications(), this.settings.getLocalSyncPath(), pid); - MessageHelper.printMessage(localSyncTask.execute().get(), LocalSyncActivity.this); + MessageHelper.printMessage(localSyncTask.execute().get(), R.mipmap.ic_launcher_round, LocalSyncActivity.this); this.reload(); } catch (Exception ex) { - MessageHelper.printException(ex, this.activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.activity); } } @@ -224,7 +224,7 @@ private void reload(String search) { this.expLvLocalSync.setAdapter(localSyncAdapter); localSyncAdapter.notifyDataSetChanged(); } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/MainActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/MainActivity.java index 4f9905a1..f4cc3bef 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/MainActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/MainActivity.java @@ -48,6 +48,7 @@ import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.model.issues.Attachment; import de.domjos.unitrackerlibrary.model.issues.Note; import de.domjos.unitrackerlibrary.model.issues.Relationship; @@ -65,7 +66,6 @@ import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.ProjectTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -206,7 +206,7 @@ public void onDelete(BaseDescriptionObject listObject) { } } } catch (Exception ex) { - MessageHelper.printException(ex, getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getApplicationContext()); } } }); @@ -347,7 +347,7 @@ public void onClick(List objectList) { } } } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } } }); @@ -368,7 +368,7 @@ public void onClick(List objectList) { Helper.showPasswordDialog(MainActivity.this, this.firstLogIn, false, this::executeOnSuccess); } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } } @@ -462,7 +462,7 @@ public boolean onContextItemSelected(@NonNull MenuItem item) { break; } } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } return super.onContextItemSelected(item); } @@ -492,7 +492,7 @@ public void run() { } OnBoardingHelper.startTutorial(this.firstLogIn, MainActivity.this, this.toolbar, this.drawerLayout, this.navigationView, this.ivMainCover); } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } } @@ -617,7 +617,7 @@ private void reload(String search) { } this.lvMainIssues.getAdapter().notifyDataSetChanged(); } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } } @@ -649,7 +649,7 @@ private void reloadProjects() { } } } catch (Exception ex) { - MessageHelper.printException(ex, MainActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, MainActivity.this); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/ProjectActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/ProjectActivity.java index a6ff1d45..865496ae 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/ProjectActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/ProjectActivity.java @@ -34,13 +34,13 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.ProjectTask; -import de.domjos.unitrackerlibrary.utils.Converter; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.tokenizer.CommaTokenizer; @@ -105,17 +105,17 @@ public void onDelete(BaseDescriptionObject listObject) { task[0] = new ProjectTask(ProjectActivity.this, bugService, true, settings.showNotifications(), R.drawable.ic_apps_black_24dp); task[0].execute(((Project)listObject.getObject()).getId()).get(); if (bugService.getCurrentState() != 200 && bugService.getCurrentState() != 201 && bugService.getCurrentState() != 204) { - MessageHelper.printMessage(bugService.getCurrentMessage(), getApplicationContext()); + MessageHelper.printMessage(bugService.getCurrentMessage(), R.mipmap.ic_launcher_round, getApplicationContext()); } else { manageControls(false, false, false); } } catch (Exception ex) { - MessageHelper.printException(ex, getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getApplicationContext()); } }); builder.create().show(); } catch (Exception ex) { - MessageHelper.printException(ex, getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getApplicationContext()); } } } @@ -163,18 +163,18 @@ protected void initControls() { task[0] = new ProjectTask(ProjectActivity.this, this.bugService, true, this.settings.showNotifications(), R.drawable.ic_apps_black_24dp); task[0].execute(this.currentProject.getId()).get(); if (this.bugService.getCurrentState() != 200 && this.bugService.getCurrentState() != 201 && this.bugService.getCurrentState() != 204) { - MessageHelper.printMessage(this.bugService.getCurrentMessage(), this.getApplicationContext()); + MessageHelper.printMessage(this.bugService.getCurrentMessage(), R.mipmap.ic_launcher_round, this.getApplicationContext()); } else { this.reload(); this.manageControls(false, false, false); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } }); builder.create().show(); } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } break; case R.id.navCancel: @@ -187,16 +187,16 @@ protected void initControls() { task[0] = new ProjectTask(ProjectActivity.this, this.bugService, false, this.settings.showNotifications(), R.drawable.ic_apps_black_24dp); task[0].execute(this.currentProject).get(); if (this.bugService.getCurrentState() != 200 && this.bugService.getCurrentState() != 201) { - MessageHelper.printMessage(this.bugService.getCurrentMessage(), this.getApplicationContext()); + MessageHelper.printMessage(this.bugService.getCurrentMessage(), R.mipmap.ic_launcher_round, this.getApplicationContext()); } else { this.reload(); this.manageControls(false, false, false); } } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } break; } @@ -306,11 +306,11 @@ protected void reload() { baseDescriptionObject.setCover(Converter.convertDrawableToByteArray(this.getResources().getDrawable(R.drawable.ic_apps_black_24dp))); } } catch (Exception ex) { - runOnUiThread(() -> MessageHelper.printException(ex, getApplicationContext())); + runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getApplicationContext())); } }).start(); } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } } @@ -320,7 +320,7 @@ protected void reload() { this.txtProjectsSubProject.setAdapter(subProjects); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/SearchActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/SearchActivity.java index 05c3ff2c..3772e85a 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/SearchActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/SearchActivity.java @@ -32,13 +32,13 @@ import java.util.List; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.model.projects.Version; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.SearchTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.tokenizer.CommaTokenizer; @@ -133,7 +133,7 @@ private void search() { this.lvSearchResults.getAdapter().add(baseDescriptionObject); } } catch (Exception ex) { - MessageHelper.printException(ex, SearchActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, SearchActivity.this); } } @@ -168,7 +168,7 @@ private void loadProjects() { } SearchActivity.this.runOnUiThread(() -> this.txtSearchProjects.setAdapter(projects)); } catch (Exception ex) { - SearchActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, this.getApplicationContext())); + SearchActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext())); } }).start(); } @@ -204,7 +204,7 @@ private void loadVersions() { SearchActivity.this.runOnUiThread(() -> this.txtSearchVersions.setAdapter(versions)); } catch (Exception ex) { - SearchActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, this.getApplicationContext())); + SearchActivity.this.runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext())); } }).start(); } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/StatisticsActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/StatisticsActivity.java index 70ce0416..f1db73e7 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/StatisticsActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/StatisticsActivity.java @@ -49,13 +49,13 @@ import java.util.Locale; import java.util.Map; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.AbstractTask; import de.domjos.unitrackerlibrary.tasks.StatisticsTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.unitrackermobile.helper.DiagramHelper; @@ -117,7 +117,7 @@ public void onNothingSelected(AdapterView adapterView) { @Override public void onValueSelected(Entry e, Highlight h) { String label = bcStatisticsBugsPerProject.getXAxis().getValueFormatter().getFormattedValue(e.getX(), bcStatisticsBugsPerProject.getXAxis()); - MessageHelper.printMessage(label + ": " + (int) e.getY() + " Bugs", StatisticsActivity.this); + MessageHelper.printMessage(label + ": " + (int) e.getY() + " Bugs", R.mipmap.ic_launcher_round, StatisticsActivity.this); } @Override @@ -148,9 +148,9 @@ public void onValueSelected(Entry e, Highlight h) { calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); value += "-" + simpleDateFormat.format(calendar.getTime()); } - MessageHelper.printMessage(value + ": Bugs: " + e.getY(), StatisticsActivity.this); + MessageHelper.printMessage(value + ": Bugs: " + e.getY(), R.mipmap.ic_launcher_round, StatisticsActivity.this); } catch (Exception ex) { - MessageHelper.printException(ex, StatisticsActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, StatisticsActivity.this); } } @@ -203,7 +203,7 @@ public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menExport) { this.lcStatisticsBugsInTime.saveToGallery("uniTrackerMobile_bugsInTime.jpg"); this.bcStatisticsBugsPerProject.saveToGallery("uniTrackerMobile_bugsPerProject.jpg"); - MessageHelper.printMessage(this.getString(R.string.statistics_export_succes), StatisticsActivity.this); + MessageHelper.printMessage(this.getString(R.string.statistics_export_succes), R.mipmap.ic_launcher_round, StatisticsActivity.this); } return super.onOptionsItemSelected(item); @@ -236,7 +236,7 @@ public void onPostExecute(Map>> result) data = result; load(); reloadCharts(); - MessageHelper.printMessage(getString(R.string.statistics_loaded), StatisticsActivity.this); + MessageHelper.printMessage(getString(R.string.statistics_loaded), R.mipmap.ic_launcher_round, StatisticsActivity.this); } }); statisticsTask.execute(); diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/UserActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/UserActivity.java index 7cd2ad43..c5e43949 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/UserActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/UserActivity.java @@ -23,13 +23,13 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.issues.User; import de.domjos.unitrackerlibrary.model.projects.Project; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.UserTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -86,7 +86,7 @@ public void onDelete(BaseDescriptionObject listObject) { new UserTask(UserActivity.this, bugService, currentProject.getId(), true, settings.showNotifications(), R.drawable.ic_person_black_24dp).execute(((User)listObject.getObject()).getId()).get(); manageControls(false, true, false); } catch (Exception ex) { - MessageHelper.printException(ex, UserActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, UserActivity.this); } } } @@ -108,7 +108,7 @@ protected void reload() { } } } catch (Exception ex) { - MessageHelper.printException(ex, UserActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, UserActivity.this); } } @@ -132,7 +132,7 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } catch (Exception ex) { - MessageHelper.printException(ex, UserActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, UserActivity.this); } break; case R.id.navCancel: @@ -146,10 +146,10 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, UserActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, UserActivity.this); } break; } diff --git a/app/src/main/java/de/domjos/unitrackermobile/activities/VersionActivity.java b/app/src/main/java/de/domjos/unitrackermobile/activities/VersionActivity.java index 920f0902..9a7c8ddb 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/activities/VersionActivity.java +++ b/app/src/main/java/de/domjos/unitrackermobile/activities/VersionActivity.java @@ -36,14 +36,14 @@ import java.util.Date; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; import de.domjos.unitrackerlibrary.model.projects.Version; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.ExportTask; import de.domjos.unitrackerlibrary.tasks.VersionTask; -import de.domjos.unitrackerlibrary.utils.Converter; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.model.AbstractActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -84,7 +84,7 @@ public void onDelete(BaseDescriptionObject listObject) { try { new VersionTask(VersionActivity.this, bugService, currentProject, true, settings.showNotifications(), "", R.drawable.ic_update_black_24dp).execute(((Version)listObject.getObject()).getId()).get(); } catch (Exception ex) { - MessageHelper.printException(ex, VersionActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, VersionActivity.this); } } }); @@ -139,7 +139,7 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } catch (Exception ex) { - MessageHelper.printException(ex, VersionActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, VersionActivity.this); } break; case R.id.navCancel: @@ -153,10 +153,10 @@ protected void initControls() { this.reload(); this.manageControls(false, true, false); } else { - MessageHelper.printMessage(this.getString(R.string.validator_no_success), this.getApplicationContext()); + MessageHelper.printMessage(this.getString(R.string.validator_no_success), R.mipmap.ic_launcher_round, this.getApplicationContext()); } } catch (Exception ex) { - MessageHelper.printException(ex, VersionActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, VersionActivity.this); } break; } @@ -217,7 +217,7 @@ protected void reload() { } } } catch (Exception ex) { - MessageHelper.printException(ex, this.getApplicationContext()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getApplicationContext()); } } @@ -266,7 +266,7 @@ private void controlsToObject() { this.currentVersion.setDeprecatedVersion(this.chkVersionDeprecated.isChecked()); } } catch (Exception ex) { - MessageHelper.printException(ex, VersionActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, VersionActivity.this); } } @@ -356,13 +356,13 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { VersionActivity.this, bugService, null, pid, files[0], false, R.drawable.ic_bug_report_black_24dp, bg, icon, "", vid); exportTask.execute(0).get(); - MessageHelper.printMessage(this.getString(R.string.versions_menu_changelog_created), VersionActivity.this); + MessageHelper.printMessage(this.getString(R.string.versions_menu_changelog_created), R.mipmap.ic_launcher_round, VersionActivity.this); } else { - MessageHelper.printMessage(this.getString(R.string.versions_menu_changelog_no_selected), VersionActivity.this); + MessageHelper.printMessage(this.getString(R.string.versions_menu_changelog_no_selected), R.mipmap.ic_launcher_round, VersionActivity.this); } } } catch (Exception ex) { - MessageHelper.printException(ex, VersionActivity.this); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, VersionActivity.this); } }); dialog.show(); diff --git a/app/src/main/java/de/domjos/unitrackermobile/adapter/PagerAdapter.java b/app/src/main/java/de/domjos/unitrackermobile/adapter/PagerAdapter.java index 7a31df9e..d03338d5 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/adapter/PagerAdapter.java +++ b/app/src/main/java/de/domjos/unitrackermobile/adapter/PagerAdapter.java @@ -35,7 +35,7 @@ import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.fragments.*; import de.domjos.unitrackermobile.helper.Helper; diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueAttachmentsFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueAttachmentsFragment.java index 460e467c..4d3dfec9 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueAttachmentsFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueAttachmentsFragment.java @@ -36,12 +36,12 @@ import java.io.InputStream; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Attachment; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; -import de.domjos.unitrackerlibrary.utils.Converter; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.R; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; import de.domjos.unitrackermobile.helper.Helper; @@ -95,7 +95,7 @@ public void onClick(BaseDescriptionObject listObject) { } } } catch (Exception ex) { - MessageHelper.printException(ex, getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getActivity()); } } }); @@ -142,12 +142,12 @@ public boolean onContextItemSelected(@NonNull MenuItem item) { bugService.deleteAttachment(id, null, null); getActivity().runOnUiThread(()->lvIssueAttachments.getAdapter().deleteItem(lvIssueAttachments.getAdapter().getItemPosition(listObject))); } catch (Exception ex) { - getActivity().runOnUiThread(()->MessageHelper.printException(ex, getActivity())); + getActivity().runOnUiThread(()->MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getActivity())); } }).start(); } } catch (Exception ex) { - MessageHelper.printException(ex, getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getActivity()); } return true; } @@ -231,7 +231,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } } } catch (Exception ex) { - MessageHelper.printException(ex, this.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity()); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueGeneralFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueGeneralFragment.java index 9b564df8..bbf24191 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueGeneralFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueGeneralFragment.java @@ -37,6 +37,7 @@ import java.util.LinkedList; import java.util.List; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.issues.Profile; @@ -48,7 +49,6 @@ import de.domjos.unitrackerlibrary.tasks.LoaderTask; import de.domjos.unitrackerlibrary.tasks.UserTask; import de.domjos.unitrackerlibrary.tasks.VersionTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.customwidgets.tokenizer.CommaTokenizer; @@ -221,7 +221,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, } } } catch (Exception ex) { - MessageHelper.printException(ex, this.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity()); } this.spIssueGeneralResolution = this.root.findViewById(R.id.spIssueGeneralResolution); this.txtIssueGeneralSubmitted = this.root.findViewById(R.id.txtIssueGeneralSubmitDate); @@ -289,7 +289,7 @@ public DescriptionObject getObject(DescriptionObject descriptionObject) { issue.setDueDate(DateConverter.convertStringToDate(this.txtIssueGeneralDueDate.getText().toString(), this.getContext())); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity()); } } return issue; @@ -593,7 +593,7 @@ private void initCategories() { } this.txtIssueGeneralCategory.setAdapter(arrayAdapter); } catch (Exception ex) { - MessageHelper.printException(ex, this.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity()); } } } @@ -610,7 +610,7 @@ private void initVersions() { } } } catch (Exception ex) { - this.getActivity().runOnUiThread(() -> MessageHelper.printException(ex, this.getActivity())); + this.getActivity().runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity())); } this.txtIssueGeneralVersion.setAdapter(arrayAdapter); this.txtIssueGeneralTargetVersion.setAdapter(arrayAdapter); diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueHistoryFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueHistoryFragment.java index f3417b7f..1c42cb48 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueHistoryFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueHistoryFragment.java @@ -31,11 +31,11 @@ import java.util.List; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.History; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.unitrackermobile.helper.DateConverter; @@ -123,7 +123,7 @@ protected void initData() { } } } catch (Exception ex) { - this.getActivity().runOnUiThread(() -> MessageHelper.printException(ex, this.getActivity())); + this.getActivity().runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity())); } }).start(); } diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueRelationsFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueRelationsFragment.java index 44799df3..40342baf 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueRelationsFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/IssueRelationsFragment.java @@ -26,13 +26,13 @@ import androidx.annotation.NonNull; import de.domjos.customwidgets.model.objects.BaseDescriptionObject; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.issues.Relationship; import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.tasks.IssueTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.customwidgets.widgets.swiperefreshdeletelist.SwipeRefreshDeleteList; @@ -267,12 +267,12 @@ private void delete() { Object obj = this.returnTemp(MainActivity.GLOBALS.getSettings(this.getContext()).getCurrentProjectId()); this.bugService.deleteBugRelation(this.currentEntry, this.issue.getId(), obj); } catch (Exception ex) { - Objects.requireNonNull(getActivity()).runOnUiThread(()->MessageHelper.printException(ex, this.getActivity())); + Objects.requireNonNull(getActivity()).runOnUiThread(()-> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity())); } }).start(); } } catch (Exception ex) { - MessageHelper.printException(ex, this.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getActivity()); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsLogFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsLogFragment.java index f1648cd6..ce01beea 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsLogFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsLogFragment.java @@ -27,8 +27,8 @@ import androidx.preference.PreferenceManager; import androidx.preference.SwitchPreference; -import de.domjos.unitrackerlibrary.utils.LogHelper; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.LogHelper; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackermobile.R; public class SettingsLogFragment extends PreferenceFragmentCompat { @@ -50,7 +50,7 @@ public void onCreate(Bundle savedInstanceState) { LogHelper logHelper = new LogHelper(super.getActivity()); logHelper.clearFile(); } catch (Exception ex) { - MessageHelper.printException(ex, super.getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, super.getActivity()); } finally { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(super.getActivity()).edit(); editor.putBoolean("swtLogClear", false); diff --git a/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsSecurityFragment.java b/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsSecurityFragment.java index 6549ef2a..a417a59e 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsSecurityFragment.java +++ b/app/src/main/java/de/domjos/unitrackermobile/fragments/SettingsSecurityFragment.java @@ -29,7 +29,7 @@ import androidx.preference.PreferenceManager; import androidx.preference.SwitchPreference; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.unitrackermobile.helper.Helper; @@ -61,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) { } } } catch (Exception ex) { - MessageHelper.printException(ex, getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getActivity()); } return true; }); @@ -84,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) { } } } catch (Exception ex) { - MessageHelper.printException(ex, getActivity()); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, getActivity()); } return true; })); diff --git a/app/src/main/java/de/domjos/unitrackermobile/helper/DateConverter.java b/app/src/main/java/de/domjos/unitrackermobile/helper/DateConverter.java index e69a1918..20818be2 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/helper/DateConverter.java +++ b/app/src/main/java/de/domjos/unitrackermobile/helper/DateConverter.java @@ -24,7 +24,7 @@ import java.util.Date; import java.util.Locale; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.unitrackermobile.settings.Settings; diff --git a/app/src/main/java/de/domjos/unitrackermobile/helper/Helper.java b/app/src/main/java/de/domjos/unitrackermobile/helper/Helper.java index e2c71f4a..ec218d91 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/helper/Helper.java +++ b/app/src/main/java/de/domjos/unitrackermobile/helper/Helper.java @@ -59,6 +59,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.model.issues.Attachment; import de.domjos.unitrackerlibrary.model.issues.Issue; @@ -79,7 +80,6 @@ import de.domjos.unitrackerlibrary.services.tracker.YouTrack; import de.domjos.unitrackerlibrary.tasks.IssueTask; import de.domjos.unitrackerlibrary.tasks.LoaderTask; -import de.domjos.unitrackerlibrary.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.MainActivity; import de.domjos.customwidgets.tokenizer.CommaTokenizer; @@ -171,7 +171,7 @@ public static IBugService getCurrentBugService(Authentication authentication, Co bugService = new SQLite(context, Helper.getVersionCode(context), new Authentication()); } } catch (Exception ex) { - MessageHelper.printException(ex, context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, context); } return bugService; } @@ -261,7 +261,7 @@ public void handleMessage(@NonNull Message mesg) { catch(RuntimeException ignored){} str_result = txtTags.getText().toString(); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } return str_result; } @@ -323,7 +323,7 @@ public static void showPasswordDialog(Activity activity, boolean firstLogin, boo pwdDialog.cancel(); } } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } })).start(); } else { @@ -346,11 +346,11 @@ public static void showPasswordDialog(Activity activity, boolean firstLogin, boo } } } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } }); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } @@ -387,13 +387,13 @@ public static void showResolveDialog(Activity activity, String array, int positi resolveDialog.dismiss(); runnable.run(); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } }); resolveDialog.setCancelable(true); resolveDialog.show(); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } @@ -421,7 +421,7 @@ public static void showAttachmentDialog(Activity activity, List atta }); attachmentDialog.show(); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } @@ -448,7 +448,7 @@ public static void showWhatsNewDialog(Activity activity) { settings.setWhatsNewVersion(); } } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } @@ -487,7 +487,7 @@ public static String getVersion(Context context) { PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionName; } catch (Exception ex) { - MessageHelper.printException(ex, context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, context); } return ""; } @@ -535,7 +535,7 @@ private static void addAttachmentToImageView(Activity activity, ImageView iv, At } } } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } }); filePickerDialog.show(); @@ -548,9 +548,9 @@ private static void saveAttachment(File file, byte[] content, Activity activity) bos.write(content); bos.flush(); bos.close(); - MessageHelper.printMessage(activity.getString(R.string.issues_context_attachment_saved), activity); + MessageHelper.printMessage(activity.getString(R.string.issues_context_attachment_saved), R.mipmap.ic_launcher_round, activity); } catch (Exception ex) { - MessageHelper.printException(ex, activity); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/helper/SQLiteGeneral.java b/app/src/main/java/de/domjos/unitrackermobile/helper/SQLiteGeneral.java index 7793132f..96b8f007 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/helper/SQLiteGeneral.java +++ b/app/src/main/java/de/domjos/unitrackermobile/helper/SQLiteGeneral.java @@ -32,9 +32,9 @@ import java.util.List; import java.util.Map; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.services.engine.Authentication; -import de.domjos.unitrackerlibrary.utils.Crypto; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.Crypto; import de.domjos.unitrackermobile.R; public class SQLiteGeneral extends SQLiteOpenHelper { @@ -142,7 +142,7 @@ List getAccounts(String where, boolean onlyCheck) { if(onlyCheck) { return null; } else { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } return authentications; @@ -190,7 +190,7 @@ public void insertOrUpdateAccount(Authentication authentication) { this.setHints(authentication); } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } @@ -204,7 +204,7 @@ private Map getHints(long id) { } cursor.close(); } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } return hints; } @@ -261,7 +261,7 @@ private void initDatabase(SQLiteDatabase db) { db.execSQL(query.trim()); } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } @@ -274,7 +274,7 @@ private void updateDatabase(SQLiteDatabase db) { } } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } @@ -304,7 +304,7 @@ private void addColumnIfNotExists(SQLiteDatabase db, String table, String column db.execSQL(String.format("ALTER TABLE %s ADD COLUMN %s %s", table, column, typeString)); } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } diff --git a/app/src/main/java/de/domjos/unitrackermobile/spotlight/OnBoardingHelper.java b/app/src/main/java/de/domjos/unitrackermobile/spotlight/OnBoardingHelper.java index 9999631c..14c07dac 100644 --- a/app/src/main/java/de/domjos/unitrackermobile/spotlight/OnBoardingHelper.java +++ b/app/src/main/java/de/domjos/unitrackermobile/spotlight/OnBoardingHelper.java @@ -33,7 +33,7 @@ import com.google.android.material.navigation.NavigationView; -import de.domjos.unitrackerlibrary.utils.MessageHelper; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackermobile.R; import de.domjos.unitrackermobile.activities.AccountActivity; import de.domjos.unitrackermobile.activities.MainActivity; @@ -102,7 +102,7 @@ protected Void doInBackground(Void... voids) { } } } catch (Exception ex) { - activity.runOnUiThread(() -> MessageHelper.printException(ex, activity)); + activity.runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity)); } return null; } @@ -146,7 +146,7 @@ protected Void doInBackground(Void... voids) { }); OnBoardingHelper.secondSteps = false; } catch (Exception ex) { - activity.runOnUiThread(() -> MessageHelper.printException(ex, activity)); + activity.runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, activity)); } return null; } diff --git a/unitrackerlibrary/build.gradle b/unitrackerlibrary/build.gradle index 51093878..9fd75f1c 100644 --- a/unitrackerlibrary/build.gradle +++ b/unitrackerlibrary/build.gradle @@ -65,4 +65,5 @@ dependencies { // library to create pdf-files implementation 'com.itextpdf:itextg:5.5.10' + implementation project(path: ':customwidgets') } diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/model/ListObject.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/model/ListObject.java deleted file mode 100644 index 37cf7bad..00000000 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/model/ListObject.java +++ /dev/null @@ -1,86 +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.unitrackerlibrary.model; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; - -import de.domjos.unitrackerlibrary.model.objects.DescriptionObject; -import de.domjos.unitrackerlibrary.utils.Converter; - -public class ListObject { - private byte[] icon; - private Drawable drawable; - private Context context; - private DescriptionObject descriptionObject; - private boolean selected; - - public ListObject(Context context, int resID, DescriptionObject descriptionObject) { - super(); - - this.context = context; - this.icon = null; - this.drawable = Converter.convertResourcesToDrawable(context, resID); - this.descriptionObject = descriptionObject; - } - - public ListObject(Context context, byte[] img, DescriptionObject descriptionObject) { - super(); - - this.context = context; - this.icon = img; - - if (this.icon != null) { - Bitmap bitmap = BitmapFactory.decodeByteArray(this.icon, 0, this.icon.length); - this.drawable = new BitmapDrawable(this.context.getResources(), bitmap); - } else { - this.drawable = null; - } - this.descriptionObject = descriptionObject; - } - - public void setIcon(byte[] icon) { - this.icon = icon; - if (this.icon != null) { - Bitmap bitmap = BitmapFactory.decodeByteArray(this.icon, 0, this.icon.length); - this.drawable = new BitmapDrawable(this.context.getResources(), bitmap); - } else { - this.drawable = null; - } - } - - public Drawable getIcon() { - return this.drawable; - } - - public DescriptionObject getDescriptionObject() { - return this.descriptionObject; - } - - public boolean isSelected() { - return this.selected; - } - - public void setSelected(boolean selected) { - this.selected = selected; - } -} diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/engine/JSONEngine.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/engine/JSONEngine.java index 71fd6194..39d4d3b8 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/engine/JSONEngine.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/engine/JSONEngine.java @@ -25,7 +25,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import de.domjos.unitrackerlibrary.services.authentication.AccessTokenProvider; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import okhttp3.Authenticator; import okhttp3.Call; import okhttp3.ConnectionPool; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/AzureDevOps.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/AzureDevOps.java index 5317e32e..2dd9af6a 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/AzureDevOps.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/AzureDevOps.java @@ -27,7 +27,7 @@ import de.domjos.unitrackerlibrary.permissions.AzureDevOpsPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import kotlin.text.Charsets; public final class AzureDevOps extends JSONEngine implements IBugService { diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Backlog.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Backlog.java index dfa9869d..588c1cbf 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Backlog.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Backlog.java @@ -38,7 +38,7 @@ import de.domjos.unitrackerlibrary.permissions.BacklogPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class Backlog extends JSONEngine implements IBugService { private Authentication authentication; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Bugzilla.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Bugzilla.java index eaf616f3..f9160df5 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Bugzilla.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Bugzilla.java @@ -42,7 +42,7 @@ import de.domjos.unitrackerlibrary.permissions.BugzillaPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class Bugzilla extends JSONEngine implements IBugService { private final String loginParams; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Github.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Github.java index e9e94839..601fc1d8 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Github.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Github.java @@ -37,7 +37,7 @@ import de.domjos.unitrackerlibrary.services.authentication.GithubTokenProvider; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class Github extends JSONEngine implements IBugService { private Authentication authentication; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Jira.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Jira.java index 95b6490c..1528d441 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Jira.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Jira.java @@ -41,7 +41,7 @@ import de.domjos.unitrackerlibrary.permissions.JiraPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class Jira extends JSONEngine implements IBugService { private final static String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS"; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/MantisBT.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/MantisBT.java index f21ffcf5..78e5d02c 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/MantisBT.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/MantisBT.java @@ -36,7 +36,7 @@ import de.domjos.unitrackerlibrary.permissions.MantisBTPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.SoapEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import static org.ksoap2.serialization.MarshalHashtable.NAMESPACE; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/OpenProject.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/OpenProject.java index 5127fa2c..f4d40fd8 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/OpenProject.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/OpenProject.java @@ -33,7 +33,7 @@ import de.domjos.unitrackerlibrary.permissions.OpenProjectPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; import okhttp3.Credentials; public final class OpenProject extends JSONEngine implements IBugService { diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/PivotalTracker.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/PivotalTracker.java index 578fe51f..12561be2 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/PivotalTracker.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/PivotalTracker.java @@ -31,7 +31,7 @@ import de.domjos.unitrackerlibrary.permissions.PivotalTrackerPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class PivotalTracker extends JSONEngine implements IBugService { private final static String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Redmine.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Redmine.java index e4728311..dfd84d82 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Redmine.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/Redmine.java @@ -41,7 +41,7 @@ import de.domjos.unitrackerlibrary.permissions.RedminePermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class Redmine extends JSONEngine implements IBugService { private Authentication authentication; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/SQLite.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/SQLite.java index 6e74a1fc..fa7b9a69 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/SQLite.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/SQLite.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; +import de.domjos.customwidgets.utils.MessageHelper; import de.domjos.unitrackerlibrary.R; import de.domjos.unitrackerlibrary.interfaces.IBugService; import de.domjos.unitrackerlibrary.interfaces.IFunctionImplemented; @@ -42,7 +43,6 @@ import de.domjos.unitrackerlibrary.model.projects.Version; import de.domjos.unitrackerlibrary.permissions.SQLitePermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; -import de.domjos.unitrackerlibrary.utils.MessageHelper; public final class SQLite extends SQLiteOpenHelper implements IBugService { private Context context; @@ -626,17 +626,17 @@ public void deleteAttachment(Long id, Long issue_id, Long project_id) { } @Override - public List> getBugRelations(Long issue_id, Long project_id) throws Exception { + public List> getBugRelations(Long issue_id, Long project_id) { return null; } @Override - public void insertOrUpdateBugRelations(Relationship relationship, Long issue_id, Long project_id) throws Exception { + public void insertOrUpdateBugRelations(Relationship relationship, Long issue_id, Long project_id) { } @Override - public void deleteBugRelation(Relationship relationship, Long issue_id, Long project_id) throws Exception { + public void deleteBugRelation(Relationship relationship, Long issue_id, Long project_id) { } @@ -923,7 +923,7 @@ private void initDatabase(SQLiteDatabase db) { db.execSQL(query.trim()); } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } @@ -934,7 +934,7 @@ private void updateDatabase(SQLiteDatabase db) { db.execSQL(query.trim()); } } catch (Exception ex) { - MessageHelper.printException(ex, this.context); + MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.context); } } diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/YouTrack.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/YouTrack.java index 8331f41c..aff1dd1a 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/YouTrack.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/services/tracker/YouTrack.java @@ -44,7 +44,7 @@ import de.domjos.unitrackerlibrary.permissions.YoutrackPermissions; import de.domjos.unitrackerlibrary.services.engine.Authentication; import de.domjos.unitrackerlibrary.services.engine.JSONEngine; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class YouTrack extends JSONEngine implements IBugService { private final static String PROJECT_FIELDS = "shortName,description,name,archived,id,leader,iconUrl"; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/AbstractTask.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/AbstractTask.java index c4184f28..7233aadf 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/AbstractTask.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/AbstractTask.java @@ -24,8 +24,9 @@ import java.lang.ref.WeakReference; +import de.domjos.customwidgets.utils.MessageHelper; +import de.domjos.unitrackerlibrary.R; import de.domjos.unitrackerlibrary.interfaces.IBugService; -import de.domjos.unitrackerlibrary.utils.MessageHelper; public abstract class AbstractTask extends AsyncTask { private WeakReference weakReference; @@ -71,13 +72,13 @@ protected void onPostExecute(Result result) { void printMessage() { if (this.bugService.getCurrentState() != 200 && this.bugService.getCurrentState() != 201) { if (!this.bugService.getCurrentMessage().isEmpty()) { - ((Activity) this.getContext()).runOnUiThread(() -> MessageHelper.printMessage(this.bugService.getCurrentMessage(), this.getContext())); + ((Activity) this.getContext()).runOnUiThread(() -> MessageHelper.printMessage(this.bugService.getCurrentMessage(), R.mipmap.ic_launcher_round, this.getContext())); } } } void printException(Exception ex) { - ((Activity) this.getContext()).runOnUiThread(() -> MessageHelper.printException(ex, this.getContext())); + ((Activity) this.getContext()).runOnUiThread(() -> MessageHelper.printException(ex, R.mipmap.ic_launcher_round, this.getContext())); } protected abstract void before(); diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/LocalSyncTask.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/LocalSyncTask.java index ed22e30b..45bfc83b 100644 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/LocalSyncTask.java +++ b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/tasks/LocalSyncTask.java @@ -32,7 +32,7 @@ import de.domjos.unitrackerlibrary.model.issues.Attachment; import de.domjos.unitrackerlibrary.model.issues.Issue; import de.domjos.unitrackerlibrary.model.projects.Project; -import de.domjos.unitrackerlibrary.utils.Converter; +import de.domjos.customwidgets.utils.Converter; public final class LocalSyncTask extends AbstractTask { private String path; diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Converter.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Converter.java deleted file mode 100644 index f6860661..00000000 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Converter.java +++ /dev/null @@ -1,130 +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.unitrackerlibrary.utils; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.Build; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.nio.ByteBuffer; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; - -public class Converter { - - public static byte[] downloadFile(URL url) throws Exception { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - URLConnection conn = url.openConnection(); - conn.setRequestProperty("User-Agent", "Firefox"); - - try (InputStream inputStream = conn.getInputStream()) { - int n; - byte[] buffer = new byte[1024]; - while (-1 != (n = inputStream.read(buffer))) { - output.write(buffer, 0, n); - } - } - byte[] img = output.toByteArray(); - ByteBuffer imageBytes = ByteBuffer.wrap(img); - return imageBytes.array(); - } - - public static String convertStreamToString(InputStream stream) throws Exception { - BufferedReader br = new BufferedReader(new InputStreamReader(stream)); - StringBuilder sb = new StringBuilder(); - String line; - while ((line = br.readLine()) != null) { - sb.append(line).append("\n"); - } - br.close(); - return sb.toString(); - } - - public static Date convertStringToDate(String dt, String format) throws Exception { - if(dt!=null) { - if(!dt.isEmpty()) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.GERMAN); - return simpleDateFormat.parse(dt); - } - } - return null; - } - - public static Drawable convertStringToImage(String url) { - try { - InputStream is = (InputStream) new URL(url).getContent(); - return Drawable.createFromStream(is, "src name"); - } catch (Exception e) { - return null; - } - } - - public static byte[] convertStringToByteArray(String url) { - try { - InputStream is = (InputStream) new URL(url).getContent(); - return Converter.convertStreamToByteArray(is); - } catch (Exception e) { - return null; - } - } - - public static byte[] convertDrawableToByteArray(Drawable drawable) { - Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); - return stream.toByteArray(); - } - - public static byte[] convertStreamToByteArray(InputStream stream) throws Exception { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int nRead; - byte[] data = new byte[16384]; - while ((nRead = stream.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - stream.close(); - return buffer.toByteArray(); - } - - public static void convertByteArrayToFile(byte[] content, File file) throws Exception { - FileOutputStream fos = new FileOutputStream(file); - fos.write(content); - fos.close(); - } - - @SuppressWarnings("deprecation") - public static Drawable convertResourcesToDrawable(Context context, int resource_id) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return context.getDrawable(resource_id); - } else { - return context.getResources().getDrawable(resource_id); - } - } -} diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Crypto.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Crypto.java deleted file mode 100644 index c418df04..00000000 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/Crypto.java +++ /dev/null @@ -1,100 +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.unitrackerlibrary.utils; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Build; -import android.util.Base64; - -import java.nio.charset.StandardCharsets; -import java.security.Key; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -import javax.crypto.Cipher; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.SecretKeySpec; - -public class Crypto { - private byte[] salt; - private AlgorithmParameterSpec parameterSpec; - private Key keySpec; - - public Crypto(Context context, String password) throws Exception { - SharedPreferences preferences = context.getSharedPreferences("dBall", Context.MODE_PRIVATE); - String content = preferences.getString("salt", ""); - if (content.isEmpty()) { - this.salt = this.generateNewSalt(); - preferences.edit().putString("salt", Base64.encodeToString(this.salt, Base64.NO_WRAP)).apply(); - } else { - this.salt = Base64.decode(content, Base64.NO_WRAP); - } - this.keySpec = this.generateKey(password); - - String ivString = preferences.getString("iv", ""); - byte[] iv; - if (ivString.isEmpty()) { - iv = this.generateNewIv(); - preferences.edit().putString("iv", Base64.encodeToString(iv, Base64.NO_WRAP)).apply(); - } else { - iv = Base64.decode(ivString, Base64.NO_WRAP); - } - this.parameterSpec = new IvParameterSpec(iv); - } - - public String encryptString(String message) throws Exception { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); - cipher.init(Cipher.ENCRYPT_MODE, this.keySpec, this.parameterSpec); - return Base64.encodeToString(cipher.doFinal(message.getBytes()), Base64.NO_WRAP); - } - - public String decryptString(String message) throws Exception { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); - cipher.init(Cipher.DECRYPT_MODE, keySpec, this.parameterSpec); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - return new String(cipher.doFinal(Base64.decode(message, Base64.NO_WRAP)), StandardCharsets.UTF_8); - } else { - return new String(cipher.doFinal(Base64.decode(message, Base64.NO_WRAP))); - } - } - - private Key generateKey(String password) throws Exception { - PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(), this.salt, 1324, 256); - SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); - byte[] keyBytes = secretKeyFactory.generateSecret(pbeKeySpec).getEncoded(); - return new SecretKeySpec(keyBytes, "AES"); - } - - private byte[] generateNewIv() { - SecureRandom random = new SecureRandom(); - byte[] iv = new byte[16]; - random.nextBytes(iv); - return iv; - } - - private byte[] generateNewSalt() { - byte[] salt = new byte[256]; - SecureRandom random = new SecureRandom(); - random.nextBytes(salt); - return salt; - } -} diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/LogHelper.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/LogHelper.java deleted file mode 100644 index f4fdfe28..00000000 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/LogHelper.java +++ /dev/null @@ -1,109 +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.unitrackerlibrary.utils; - -import android.app.Activity; -import android.util.Log; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Objects; - -public class LogHelper { - private File logFile; - - - public LogHelper(Activity activity) { - try { - this.logFile = new File(activity.getFilesDir().getAbsolutePath() + File.separatorChar + "error.log"); - if (!this.logFile.exists()) { - if (this.logFile.createNewFile()) { - Log.v("Log-File", "NewFile"); - } - } - } catch (Exception ex) { - Log.e("Error", ex.getMessage(), ex); - } - } - - void logError(Exception ex) { - try { - StringBuilder builder = new StringBuilder(Objects.requireNonNull(ex.getMessage())); - builder.append("\n"); - builder.append(ex.toString()); - for (StackTraceElement element : ex.getStackTrace()) { - builder.append(String.format("%s:%s#%s(%s)%n", element.getFileName(), element.getClassName(), element.getMethodName(), element.getLineNumber())); - } - - BufferedWriter buf = new BufferedWriter(new FileWriter(this.logFile, true)); - buf.append(builder.toString()); - buf.newLine(); - buf.close(); - } catch (IOException e) { - Log.e("Error", e.getMessage(), e); - } - } - - void logMessage(String message) { - try { - BufferedWriter buf = new BufferedWriter(new FileWriter(this.logFile, true)); - buf.append(message); - buf.newLine(); - buf.close(); - } catch (IOException e) { - Log.e("Error", e.getMessage(), e); - } - } - - public void clearFile() { - try { - if (this.logFile.delete()) { - if (this.logFile.createNewFile()) { - this.logMessage("Successfully create a new Log-File!"); - } - } - } catch (IOException e) { - Log.e("Error", e.getMessage(), e); - } - } - - public void export(String folder) throws Exception { - File exportFile = new File(folder + File.separatorChar + this.logFile.getName()); - this.copy(this.logFile, exportFile); - } - - private void copy(File src, File dst) throws IOException { - try (InputStream in = new FileInputStream(src)) { - try (OutputStream out = new FileOutputStream(dst)) { - // Transfer bytes from in to out - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - } - } - } -} diff --git a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/MessageHelper.java b/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/MessageHelper.java deleted file mode 100644 index 8973441f..00000000 --- a/unitrackerlibrary/src/main/java/de/domjos/unitrackerlibrary/utils/MessageHelper.java +++ /dev/null @@ -1,155 +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.unitrackerlibrary.utils; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Build; -import android.util.Log; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.core.app.NotificationCompat; -import androidx.preference.PreferenceManager; - -import java.util.Random; -import de.domjos.unitrackerlibrary.R; - -public class MessageHelper { - private final static String id = "UniBuggerChannel"; - - public static void printException(Exception ex, Context context) { - try { - if(ex!=null) { - if(ex.getMessage()!=null) { - StringBuilder builder = new StringBuilder(ex.getMessage()).append("\n"); - for (StackTraceElement element : ex.getStackTrace()) { - builder.append(String.format("%s.%s#%s(%s)%n", element.getFileName(), element.getClassName(), element.getMethodName(), element.getLineNumber())); - } - MessageHelper.printMessage(ex.toString(), context, false); - MessageHelper.log(ex, context); - } - } - } catch (Exception ignored) { - } - Log.e("Exception", "Error", ex); - } - - public static void printMessage(String message, Context context) { - MessageHelper.printMessage(message, context, true); - } - - private static void printMessage(String message, Context context, boolean log) { - if (context instanceof Activity) { - MessageHelper.printMessage(message, (Activity) context); - } else { - Toast.makeText(context, message, Toast.LENGTH_LONG).show(); - } - if (log) { - if (MessageHelper.getSetting("swtLogCreateLog", true, context) && - MessageHelper.getSetting("swtLogNormalMessages", false, context)) { - - MessageHelper.log(message, context); - } - } - } - - private static boolean getSetting(String key, boolean defaultValue, Context context) { - SharedPreferences sharedPreferences; - if (context instanceof Activity) { - sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); - } else { - sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - } - return sharedPreferences.getBoolean(key, defaultValue); - } - - private static void log(Exception ex, Context context) { - if (context instanceof Activity) { - if (MessageHelper.getSetting("swtLogCreateLog", true, context)) { - LogHelper logHelper = new LogHelper((Activity) context); - logHelper.logError(ex); - } - } - } - - private static void log(String messages, Context context) { - if (context instanceof Activity) { - if (MessageHelper.getSetting("swtLogCreateLog", true, context)) { - LogHelper logHelper = new LogHelper((Activity) context); - logHelper.logMessage(messages); - } - } - } - - private static void printMessage(String message, Activity activity) { - LayoutInflater inflater = activity.getLayoutInflater(); - View layout = inflater.inflate(R.layout.custom_toast, activity.findViewById(R.id.custom_toast_container)); - TextView text = layout.findViewById(R.id.text); - text.setText(message); - Toast toast = new Toast(activity); - toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); - toast.setDuration(Toast.LENGTH_LONG); - toast.setView(layout); - toast.show(); - } - - @TargetApi(Build.VERSION_CODES.JELLY_BEAN) - public static int startProgressNotification(Activity activity, String title, String content, int icon) { - MessageHelper.createChannel(activity.getApplicationContext()); - NotificationManager manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE); - NotificationCompat.Builder builder = new NotificationCompat.Builder(activity, id); - Notification notification = builder.setContentTitle(title).setContentText(content).setSmallIcon(icon).setProgress(0, 0, true).build(); - Random random = new Random(); - int id = random.nextInt(); - if(manager!=null) { - manager.notify(id, notification); - } - return id; - } - - public static void stopProgressNotification(Activity activity, int id) { - NotificationManager manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE); - if(manager!=null) { - manager.cancel(id); - } - } - - private static void createChannel(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - CharSequence name = context.getString(R.string.app_name); - String description = context.getString(R.string.app_name); - int importance = NotificationManager.IMPORTANCE_DEFAULT; - NotificationChannel channel = new NotificationChannel(id, name, importance); - channel.setDescription(description); - NotificationManager notificationManager = context.getSystemService(NotificationManager.class); - if(notificationManager!=null) { - notificationManager.createNotificationChannel(channel); - } - } - } -}