diff --git a/app/build.gradle b/app/build.gradle index 1b1b749..959a6a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,11 +30,11 @@ android { dependencies { - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - implementation 'com.android.support:design:28.0.0' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'com.google.android.material:material:1.3.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8acc3b5..53859b8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,10 @@ + + + + { - shareMeeting(createCurrMeetingFromUI()); - }); + ShareIcon.setOnClickListener(v -> shareMeeting(createCurrMeetingFromUI())); } private void shareMeeting(Meeting meeting) { @@ -100,23 +93,17 @@ public class MainActivity extends AppCompatActivity { private void watchNewIcon() { ImageView AddIcon = findViewById(R.id.imageAdd); - AddIcon.setOnClickListener(v -> { - fillBlank(); - }); + AddIcon.setOnClickListener(v -> fillBlank()); } private void watchAttIcon() { ImageView AttIcon = findViewById(R.id.imageAttend); - AttIcon.setOnClickListener(v -> { - btnJoin_onClick(null); - }); + AttIcon.setOnClickListener(v -> btnJoin_onClick(null)); } private void watchDeleteIcon() { ImageView trashIcon = findViewById(R.id.imageTrash); - trashIcon.setOnClickListener(v -> { - removeMeeting(getLastMeeting()); - }); + trashIcon.setOnClickListener(v -> removeMeeting(getLastMeeting())); } private void removeMeeting(int meeting) { @@ -160,9 +147,7 @@ public class MainActivity extends AppCompatActivity { private void watchSaveIcon() { ImageView saveIcon = findViewById(R.id.imageSave); - saveIcon.setOnClickListener(v -> { - saveAllMeetings(); - }); + saveIcon.setOnClickListener(v -> saveAllMeetings()); } public void watchMeetingNameBox() { @@ -194,7 +179,7 @@ public class MainActivity extends AppCompatActivity { AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName); ImageView dropdown = findViewById(R.id.image); - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, meetingNames); + ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, meetingNames); textMeetingName.setAdapter(adapter); textMeetingName.setOnTouchListener((View.OnTouchListener) (paramView, paramMotionEvent) -> { @@ -203,9 +188,7 @@ public class MainActivity extends AppCompatActivity { return false; }); - textMeetingName.setOnItemClickListener((arg0, view, arg2, arg3) -> { - fillWithSelectedMeeting(); - }); + textMeetingName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedMeeting()); dropdown.setOnClickListener(v -> { textMeetingName.showDropDown(); @@ -217,19 +200,17 @@ public class MainActivity extends AppCompatActivity { Meeting meeting = getMeetings().get(meetingIndex); ArrayList attendees = meeting.attendees; - String attNames[] = new String[attendees.size()]; + String[] attNames = new String[attendees.size()]; for (int i = 0; i < attendees.size(); i++) { attNames[i] = attendees.get(i).name; } AutoCompleteTextView textName = findViewById(R.id.textBoxName); ImageView dropdown = findViewById(R.id.image2); - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, attNames); + ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, attNames); textName.setAdapter(adapter); - textName.setOnItemClickListener((arg0, view, arg2, arg3) -> { - fillWithSelectedAtt(); - }); + textName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedAtt()); dropdown.setOnClickListener(v -> { textName.showDropDown(); @@ -291,6 +272,7 @@ public class MainActivity extends AppCompatActivity { for (Object obj : listMeetings) { try { + if (objOutputStream == null) throw new AssertionError(); objOutputStream.writeObject(obj); } catch (IOException e) { e.printStackTrace(); @@ -302,6 +284,7 @@ public class MainActivity extends AppCompatActivity { } } try { + if (objOutputStream == null) throw new AssertionError(); objOutputStream.close(); } catch (IOException e) { e.printStackTrace(); @@ -313,7 +296,7 @@ public class MainActivity extends AppCompatActivity { public ArrayList stringToMeetings(String string) { byte[] bytes = Base64.decode(string, 0); - ArrayList listMeetings = new ArrayList(); + ArrayList listMeetings = new ArrayList<>(); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream obj = null; try { @@ -324,19 +307,19 @@ public class MainActivity extends AppCompatActivity { try { while (bis.available() != -1) { //Read object from file + if (obj == null) throw new AssertionError(); Meeting meeting = (Meeting) obj.readObject(); listMeetings.add(meeting); } } catch (EOFException ex) { //ex.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { + } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } return listMeetings; } + @SuppressLint("ApplySharedPref") public void saveMeetingList(ArrayList meetingList) { SharedPreferences mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor prefsEditor = mPrefs.edit(); @@ -344,6 +327,7 @@ public class MainActivity extends AppCompatActivity { prefsEditor.commit(); } + @SuppressLint("ApplySharedPref") public void setLastMeeting(int id) { SharedPreferences mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor prefsEditor = mPrefs.edit(); @@ -399,8 +383,7 @@ public class MainActivity extends AppCompatActivity { EditText editName = findViewById(R.id.textBoxName); EditText editAtt = findViewById(R.id.editAtt); - Meeting currMeeting = new Meeting(editMeetingName.getText().toString(), editID.getText().toString(), editPW.getText().toString(), editName.getText().toString(), editAtt.getText().toString()); - return currMeeting; + return new Meeting(editMeetingName.getText().toString(), editID.getText().toString(), editPW.getText().toString(), editName.getText().toString(), editAtt.getText().toString()); } public void saveAllMeetings() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d89fa52..4c94e2c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,5 +12,7 @@ Meeting-ID: Kenncode: Meeting Name: + Daten wurden zurückgesetzt, da die Config-Struktur nochmal verändert wurde. + Hinweis \ No newline at end of file