Browse Source

do not collapse table sections in record overview if reloaded
decide delete all attack data and filtered attack data.

julien.clauter 10 năm trước cách đây
mục cha
commit
046ed01f0f

+ 2 - 1
res/values-de/strings.xml

@@ -58,7 +58,8 @@
     <string name="delete_dialog_title">Delete data sets by:</string>
     <string name="dialog_clear_database_date">Delete all data before:</string>
 
-    <string name="deleteAttacksTitle">Sollen diese Angriffsdaten gel&#246;scht werden?</string>
+    <string name="deleteFILTEREDAttacksTitle">Durch die Filtereinstellung werden nur die gefilterten Angriffsdaten gel&#246;scht.\n\nM&#246;chten Sie fortfahren?</string>
+    <string name="deleteALLAttacksTitle">Sollen s&#228;mtliche Angriffsdaten gel&#246;scht werden?\n\nDurch die Filtereinstellungen k&#246;nnen Sie auch gezielt Angriffsdaten gel&#246;schen!</string>
 
     <string name="threatmap_show_records"><u>Zeige Aufzeichnungen</u></string>
 

+ 2 - 1
res/values/strings.xml

@@ -76,7 +76,8 @@
 	<string name="delete_dialog_title">Delete data sets by:</string>	
 	<string name="dialog_clear_database_date">Delete all data before:</string>
 
-    <string name="deleteAttacksTitle">Delete these attack entries?</string>
+    <string name="deleteFILTEREDAttacksTitle">Delete the filtered attack data?</string>
+    <string name="deleteALLAttacksTitle">Delete all attack data?\n\nYou can delete specific attack data by filtering!</string>
 
 	<string name="threatmap_show_records"><u>Show records</u></string>
 

+ 36 - 8
src/de/tudarmstadt/informatik/hostage/ui/fragment/RecordOverviewFragment.java

@@ -239,6 +239,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
     /**Initialises the expandable list view in a backgorund thread*/
     private void initialiseListView(){
         if (loader != null) loader.interrupt();
+        if (this.openSections == null) this.openSections = new ArrayList<Integer>();
 
         this.spinner.setVisibility(View.VISIBLE);
 
@@ -264,6 +265,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
                                 if (adapter.getGroupCount() >= 1){
                                     RecordOverviewFragment.this.expListView.expandGroup(DEFAULT_GROUPING_KEY_INDEX);
+                                    if (!RecordOverviewFragment.this.openSections.contains(DEFAULT_GROUPING_KEY_INDEX)){
+                                        RecordOverviewFragment.this.openSections.add(DEFAULT_GROUPING_KEY_INDEX);
+                                    }
                                 } else {
                                     RecordOverviewFragment.this.setSectionToOpen(RecordOverviewFragment.this.sectionToOpen);
                                 }
@@ -379,7 +383,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
     }
 
-	@Override
+    @Override
+    public void onDestroy(){
+        if (mReceiver != null){
+        }
+        super.onDestroy();
+    }
+
+
+    @Override
 	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
 		// Inflate the menu items for use in the action bar
 		inflater.inflate(R.menu.records_overview_actions, menu);
@@ -450,11 +462,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         // Use the Builder class for convenient dialog construction
         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
 
-        String deleteAttacksTitle = MainActivity.getInstance().getString(R.string.deleteAttacksTitle);
+        String deleteFILTEREDAttacksTitle = MainActivity.getInstance().getString(R.string.deleteFILTEREDAttacksTitle);
+        String deleteALLAttacksTitle = MainActivity.getInstance().getString(R.string.deleteALLAttacksTitle);
+
         String cancelTitle = MainActivity.getInstance().getString(R.string.cancel);
         String deleteTitle = MainActivity.getInstance().getString(R.string.delete);
 
-        builder.setMessage(deleteAttacksTitle)
+        String text = this.filter.isSet()? deleteFILTEREDAttacksTitle : deleteALLAttacksTitle;
+
+        builder.setMessage(text)
                 .setPositiveButton(deleteTitle, new DialogInterface.OnClickListener() {
                     private RecordOverviewFragment recordOverviewFragment = null;
                     public void onClick(DialogInterface dialog, int id) {
@@ -662,12 +678,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                             this.actualiseUI();
                         }
                         private void actualiseUI(){
+                            RecordOverviewFragment self = RecordOverviewFragment.this;
                             if (adapter != null){
-                                RecordOverviewFragment.this.expListView.setAdapter(adapter);
+                                self.expListView.setAdapter(adapter);
                                 adapter.notifyDataSetChanged();
-                                RecordOverviewFragment.this.spinner.setVisibility(View.GONE);
+                                self.spinner.setVisibility(View.GONE);
+                            }
+                            self.showEmptyDataNotification();
+                            if (self.openSections != null && self.expListView != null){
+                                for (int i = 0; i < self.openSections.size(); i++){
+                                    int index = self.openSections.get(i);
+                                    self.expListView.expandGroup(index);
+                                }
                             }
-                            RecordOverviewFragment.this.showEmptyDataNotification();
                         }
                     });
                 }
@@ -707,6 +730,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                 int section = this.getGroupTitles().indexOf(this.sectionToOpen);
                 this.expListView.expandGroup(section);
                 this.sectionToOpen = "";
+                if (!this.openSections.contains(section)){
+                    RecordOverviewFragment.this.openSections.add(section);
+                }
             }
         }
     }
@@ -749,13 +775,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         mylist.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
             @Override
             public void onGroupExpand(int i) {
-                RecordOverviewFragment.this.openSections.add(new Integer(i));
+                if (!RecordOverviewFragment.this.openSections.contains(i)){
+                    RecordOverviewFragment.this.openSections.add(i);
+                }
             }
         });
         mylist.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
             @Override
             public void onGroupCollapse(int i) {
-                RecordOverviewFragment.this.openSections.remove(new Integer(i));
+                RecordOverviewFragment.this.openSections.remove(i);
             }
         });
 	}