Skip to content

Commit

Permalink
solve bug 0000399
Browse files Browse the repository at this point in the history
  • Loading branch information
domjos1994 committed Oct 30, 2019
1 parent ccbf380 commit aab093a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}

if(resultCode == RESULT_OK && requestCode == MainActivity.RELOAD_SETTINGS) {
this.bugService = Helper.getCurrentBugService(MainActivity.this);
this.reload();
this.changePagination();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
Expand All @@ -45,7 +44,6 @@
import android.widget.*;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

Expand Down Expand Up @@ -119,7 +117,12 @@ public static IBugService getCurrentBugService(Authentication authentication, Co
if (authentication != null) {
switch (authentication.getTracker()) {
case MantisBT:
bugService = new MantisBT(authentication, MainActivity.GLOBALS.getSettings(context).isShowBugsOfSubProjects());
Settings settings = MainActivity.GLOBALS.getSettings(context);
bugService = new MantisBT(
authentication,
settings.isShowMantisBugsOfSubProjects(),
settings.isShowMantisFilter()
);
break;
case Bugzilla:
bugService = new Bugzilla(authentication);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ public boolean isLocalSyncAutomatically() {
return this.userPreferences.getBoolean("swtSyncAutomatically", false);
}

public boolean isShowBugsOfSubProjects() {
return this.userPreferences.getBoolean("swtBugTrackerSub", false);
public boolean isShowMantisBugsOfSubProjects() {
return this.userPreferences.getBoolean("swtBugTrackerMantisSub", false);
}

public boolean isShowMantisFilter() {
return this.userPreferences.getBoolean("swtBugTrackerMantisFilter", false);
}

public boolean isShowTutorial() {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
<string name="settings_bug_tracker_mantis">MantisBT</string>
<string name="settings_bug_tracker_mantis_sub">Bugs von Unter-Projekten!</string>
<string name="settings_bug_tracker_mantis_sub_summary">Bugs von Unter-Projekten anzeigen!</string>
<string name="settings_bug_tracker_mantis_filter">Use Filter?</string>
<string name="settings_bug_tracker_mantis_filter_summary">Use Filter of Mantis or show all bugs?</string>
<string name="settings_internet">Internet</string>
<string name="settings_internet_summary">Ändern Sie hier die Einstellungen, welche die Synchronisation mit entfernten Daten betrifft!</string>
<string name="settings_internet_wlan_reload">Fehler im Wlan automatisch neu laden</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
<string name="settings_bug_tracker_mantis">MantisBT</string>
<string name="settings_bug_tracker_mantis_sub">Bugs from sub-projects!</string>
<string name="settings_bug_tracker_mantis_sub_summary">Show bugs from sub-projects!</string>
<string name="settings_bug_tracker_mantis_filter">Filter benutzen?</string>
<string name="settings_bug_tracker_mantis_filter_summary">Filter benutzen oder alle Bugs anzeigen?</string>
<string name="settings_internet">Internet</string>
<string name="settings_internet_summary">Change here the settings, which concerns the synchronization with removed data!</string>
<string name="settings_internet_wlan_reload">"Automatically reload errors in the WLAN "</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/xml/pref_bug_tracker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_bug_tracker_mantis">
<SwitchPreference
android:key="swtBugTrackerSub"
android:key="swtBugTrackerMantisSub"
android:title="@string/settings_bug_tracker_mantis_sub"
android:summary="@string/settings_bug_tracker_mantis_sub_summary" />
<SwitchPreference
android:key="swtBugTrackerMantisFilter"
android:title="@string/settings_bug_tracker_mantis_filter"
android:summary="@string/settings_bug_tracker_mantis_filter_summary" />
</PreferenceCategory>
</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,24 @@
public final class MantisBT extends SoapEngine implements IBugService<Long> {
private final static String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
private String currentMessage;
private final String LIST_ISSUE_ACTION;
private Authentication authentication;
private int state;
private boolean showSub;
private boolean showSub, showFilter;

public MantisBT(Authentication authentication, boolean showSub) {
public MantisBT(Authentication authentication, boolean showSub, boolean showFilter) {
super(authentication, "/api/soap/mantisconnect.php");
this.authentication = authentication;
this.currentMessage = "";
this.state = 0;
this.showSub = showSub;
this.showFilter = showFilter;

if(this.showFilter) {
this.LIST_ISSUE_ACTION = "mc_project_get_issue_headers";
} else {
this.LIST_ISSUE_ACTION = "mc_filter_search_issue_headers";
}
}

@Override
Expand Down Expand Up @@ -222,15 +230,19 @@ public void deleteVersion(Long id, Long project_id) throws Exception {

@Override
public long getMaximumNumberOfIssues(Long project_id, IssueFilter filter) throws Exception {
SoapObject request = new SoapObject(super.soapPath, "mc_filter_search_issue_headers");
SoapObject request = new SoapObject(super.soapPath, this.LIST_ISSUE_ACTION);
if(this.showFilter) {
request.addProperty("project_id", project_id);
} else {
SoapObject filterObject = new SoapObject(NAMESPACE, "FilterSearchData");
Vector<Integer> projects = new Vector<>();
projects.add(Integer.parseInt(String.valueOf(project_id)));
filterObject.addProperty("project_id", projects);
request.addProperty("filter", filterObject);
}
request.addProperty("page_number", 1);
request.addProperty("per_page", -1);
SoapObject filterObject = new SoapObject(NAMESPACE, "FilterSearchData");
Vector<Integer> projects = new Vector<>();
projects.add(Integer.parseInt(String.valueOf(project_id)));
filterObject.addProperty("project_id", projects);
request.addProperty("filter", filterObject);
Object object = this.executeAction(request, "mc_filter_search_issue_headers", true);
Object object = this.executeAction(request, this.LIST_ISSUE_ACTION, true);
object = this.getResult(object);
if (object instanceof Vector) {
Vector vector = (Vector) object;
Expand Down Expand Up @@ -258,19 +270,22 @@ public List<Issue<Long>> getIssues(Long pid, int page, int numberOfItems) throws
@Override
public List<Issue<Long>> getIssues(Long pid, int page, int numberOfItems, IssueFilter filter) throws Exception {
List<Issue<Long>> issues = new LinkedList<>();

SoapObject request = new SoapObject(super.soapPath, "mc_filter_search_issue_headers");
SoapObject request = new SoapObject(super.soapPath, this.LIST_ISSUE_ACTION);
if(this.showFilter) {
request.addProperty("project_id", pid);
} else {
SoapObject filterObject = new SoapObject(NAMESPACE, "FilterSearchData");
Vector<Integer> projects = new Vector<>();
projects.add(Integer.parseInt(String.valueOf(pid)));
filterObject.addProperty("project_id", projects);
request.addProperty("filter", filterObject);
}
request.addProperty("page_number", page);
request.addProperty("per_page", numberOfItems);
SoapObject filterObject = new SoapObject(NAMESPACE, "FilterSearchData");
Vector<Integer> projects = new Vector<>();
projects.add(Integer.parseInt(String.valueOf(pid)));
filterObject.addProperty("project_id", projects);
request.addProperty("filter", filterObject);

List<String> enumView = this.getEnums("view_states");
List<String> enumStatus = this.getEnums("status");
Object object = this.executeAction(request, "mc_filter_search_issue_headers", true);
Object object = this.executeAction(request, this.LIST_ISSUE_ACTION, true);
object = this.getResult(object);
if (object instanceof Vector) {
Vector vector = (Vector) object;
Expand Down Expand Up @@ -882,14 +897,17 @@ public List<Tag<Long>> getTags(Long project_id) throws Exception {
Object object = this.executeAction(request, "mc_tag_get_all", true);
object = this.getResult(object);
SoapObject soapObject = (SoapObject) object;
Vector vector = (Vector) soapObject.getProperty("results");
for (int i = 0; i <= vector.size() - 1; i++) {
SoapObject tagObject = (SoapObject) vector.get(i);
Tag<Long> tag = new Tag<>();
tag.setId(Long.parseLong(tagObject.getPropertyAsString("id")));
tag.setTitle(tagObject.getPropertyAsString("name"));
tag.setDescription(tagObject.getPropertyAsString("description"));
tags.add(tag);
if(soapObject!=null) {
Vector vector = (Vector) soapObject.getProperty("results");
for (int i = 0; i <= vector.size() - 1; i++) {
SoapObject tagObject = (SoapObject) vector.get(i);
Tag<Long> tag = new Tag<>();
tag.setId(Long.parseLong(tagObject.getPropertyAsString("id")));
tag.setTitle(tagObject.getPropertyAsString("name"));
tag.setDescription(tagObject.getPropertyAsString("description"));
tags.add(tag);
}

}

return tags;
Expand Down Expand Up @@ -1098,20 +1116,22 @@ private List<Version<Long>> getVersionsByFilter(String action, Long project_id)
Object result = this.getResult(object);
if (object instanceof Vector) {
Vector vector = (Vector) result;
for (int i = 0; i <= vector.size() - 1; i++) {
SoapObject soapObject = (SoapObject) vector.get(i);
Version<Long> version = new Version<>();
version.setId(Long.parseLong(soapObject.getPropertyAsString("id")));
if (soapObject.hasProperty("name")) {
version.setTitle(soapObject.getPropertyAsString("name"));
}
if (soapObject.hasProperty("description")) {
version.setDescription(soapObject.getPropertyAsString("description"));
if(vector != null) {
for (int i = 0; i <= vector.size() - 1; i++) {
SoapObject soapObject = (SoapObject) vector.get(i);
Version<Long> version = new Version<>();
version.setId(Long.parseLong(soapObject.getPropertyAsString("id")));
if (soapObject.hasProperty("name")) {
version.setTitle(soapObject.getPropertyAsString("name"));
}
if (soapObject.hasProperty("description")) {
version.setDescription(soapObject.getPropertyAsString("description"));
}
version.setDeprecatedVersion(Boolean.parseBoolean(soapObject.getPropertyAsString("obsolete")));
version.setReleasedVersion(Boolean.parseBoolean(soapObject.getPropertyAsString("released")));
version.setReleasedVersionAt(Converter.convertStringToDate(soapObject.getPropertyAsString("date_order"), MantisBT.DATE_TIME_FORMAT).getTime());
versions.add(version);
}
version.setDeprecatedVersion(Boolean.parseBoolean(soapObject.getPropertyAsString("obsolete")));
version.setReleasedVersion(Boolean.parseBoolean(soapObject.getPropertyAsString("released")));
version.setReleasedVersionAt(Converter.convertStringToDate(soapObject.getPropertyAsString("date_order"), MantisBT.DATE_TIME_FORMAT).getTime());
versions.add(version);
}
}
return versions;
Expand Down

0 comments on commit aab093a

Please sign in to comment.