Skip to content

Commit

Permalink
Merge pull request #855 from ZeusWPI/cleanup2
Browse files Browse the repository at this point in the history
Clean up stuff
  • Loading branch information
niknetniko authored Nov 30, 2023
2 parents 44ecba1 + d3aeb9b commit aacec65
Show file tree
Hide file tree
Showing 337 changed files with 2,183 additions and 5,984 deletions.
12 changes: 8 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ android {

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

buildTypes {
Expand All @@ -120,7 +120,7 @@ android {
debug {
// Disable crashlytics in debug builds if necessary.
ext.enableCrashlytics = Boolean.parseBoolean(props.getProperty("hydra.debug.reporting"))
testCoverageEnabled true
// testCoverageEnabled true
}
}

Expand Down Expand Up @@ -199,6 +199,9 @@ dependencies {
implementation 'dev.chrisbanes.insetter:insetter:0.6.1'
implementation 'com.github.niqdev:ipcam-view:2.4.0'

annotationProcessor 'io.soabase.record-builder:record-builder-processor:37'
compileOnly 'io.soabase.record-builder:record-builder-core:37'

// Dependencies for the Play Store version.
storeImplementation 'com.google.android.gms:play-services-maps:18.2.0'
storeImplementation 'com.google.firebase:firebase-analytics:21.4.0'
Expand Down Expand Up @@ -230,9 +233,10 @@ dependencies {
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.15.2'
testImplementation 'com.shazam:shazamcrest:0.11'
testImplementation 'org.skyscreamer:jsonassert:1.5.1'
testImplementation 'org.jeasy:easy-random-core:5.0.0'
testImplementation 'org.jeasy:easy-random-core:6.0.0-SNAPSHOT'
testImplementation 'org.apache.commons:commons-lang3:3.13.0'
testImplementation 'commons-validator:commons-validator:1.7'
testImplementation 'com.google.guava:guava:32.1.3-jre'
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

<!-- Details about association events. -->
<activity
android:name=".association.event.EventDetailsActivity"
android:name=".association.EventDetailsActivity"
android:label="@string/event_detail_activity_title"
android:launchMode="singleTop"
android:parentActivityName=".MainActivity" />
Expand Down
28 changes: 9 additions & 19 deletions app/src/main/java/be/ugent/zeus/hydra/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
* <p>
* The logic for handling the navigation drawer is not immediately obvious to those who do not work with it regularly.
* Proceed with caution.
*
* <p>
* <h1>Navigation</h1>
* <p>
* One of the main responsibilities of this activity is managing navigation between the drawer, the fragments and the
* fragments between each other. The navigation is built in two main components: navigation forward and navigating
* backwards. Each component itself is not that difficult. Together the provide an intuitive navigation.
*
* <p>
* <h2>Forward navigation</h2>
* <p>
* When the user navigates to a new fragment in this activity, the back stack (of the {@link #getSupportFragmentManager()}
Expand Down Expand Up @@ -112,7 +112,7 @@
* <p>
* The third and last scenario is the easiest: nothing should be done when the activity is first started or recreated.
* The fragments should not be added to the back stack.
*
* <p>
* <h2>Backwards navigation</h2>
* <p>
* The logic above makes the backwards navigation quite simple, and can be summarized as:
Expand Down Expand Up @@ -149,7 +149,7 @@
* After this method call, the fragment can behave as if the arguments were directly set on the fragment itself.
* <p>
* This function will only be called when creating a fragment, not when popping from the back stack.
*
* <p>
* <h1>Common views and removal</h1>
* <p>
* The activity provides some common views:
Expand All @@ -172,7 +172,7 @@
* <p>
* The reason fragments cannot fully rely on the default lifecycle methods, such as {@link Fragment#onStop()}, is that
* the fragment is not always removed immediately by the activity when it is hidden (this as to do with performance).
*
* <p>
* <h1>Arguments</h1>
* <p>
* The activity has one public argument: which child fragment to load. The preferred way of using it is
Expand Down Expand Up @@ -683,24 +683,14 @@ public interface OnBackPressed {
private static final class TutorialEndEvent implements Event {
@Nullable
@Override
public String getEventName() {
public String eventName() {
return Reporting.getEvents().tutorialComplete();
}
}

/**
* Groups an update for the navigation drawer.
*/
private static class DrawerUpdate {
@NavigationSource
final int navigationSource;
final Fragment fragment;
final MenuItem menuItem;

private DrawerUpdate(int navigationSource, Fragment fragment, MenuItem menuItem) {
this.navigationSource = navigationSource;
this.fragment = fragment;
this.menuItem = menuItem;
* Groups an update for the navigation drawer.
*/
private record DrawerUpdate(@NavigationSource int navigationSource, Fragment fragment, MenuItem menuItem) {
}
}
}
101 changes: 30 additions & 71 deletions app/src/main/java/be/ugent/zeus/hydra/association/Association.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,47 @@
import android.os.Parcelable;
import androidx.annotation.Nullable;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* Represents an association registered with the DSA.
*
* @author feliciaan
* @author Niko Strijbol
*/
public final class Association implements Parcelable {

private String abbreviation;
private String name;
private List<String> path;
@Nullable
private String description;
private String email;
@Nullable
private String logo;
@Nullable
private String website;

public Association() {
// Moshi uses this!
}

/** @noinspection ProtectedMemberInFinalClass*/
protected Association(Parcel in) {
abbreviation = in.readString();
name = in.readString();
path = in.createStringArrayList();
description = in.readString();
email = in.readString();
logo = in.readString();
website = in.readString();
public record Association(
String abbreviation,
String name,
List<String> path,
@Nullable String description,
@Nullable String email,
@Nullable String logo,
@Nullable String website
) implements Parcelable {

private Association(Parcel in) {
this(
in.readString(),
in.readString(),
in.createStringArrayList(),
in.readString(),
in.readString(),
in.readString(),
in.readString()
);
}

public static Association unknown(String name) {
Association association = new Association();
association.abbreviation = "unknown";
association.name = name;
association.description = "Onbekende vereniging";
return association;
return new Association(
"unknown",
name,
Collections.emptyList(),
"Onbekende vereniging",
null,
null,
null
);
}

@Override
Expand Down Expand Up @@ -98,43 +96,4 @@ public Association[] newArray(int size) {
return new Association[size];
}
};

@Nullable
public String getDescription() {
return description;
}

@Nullable
public String getWebsite() {
return website;
}

/**
* @return A name for this association. If a full name is available, that is returned. If not, the display name is.
*/
public String getName() {
return name;
}

public String getAbbreviation() {
return abbreviation;
}

@Nullable
public String getImageLink() {
return logo;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Association that = (Association) o;
return Objects.equals(abbreviation, that.abbreviation);
}

@Override
public int hashCode() {
return Objects.hash(abbreviation);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 The Hydra authors
* Copyright (c) 2023 Niko Strijbol
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,33 +20,28 @@
* SOFTWARE.
*/

package be.ugent.zeus.hydra.association.event;
package be.ugent.zeus.hydra.association;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* @author Niko Strijbol
* Top-level response object for the DSA API.
* <p>
* This is basically an object with an association list inside it.
* While the list won't be null most of the time, we do not control this API,
* so we assume is can be null to have a more robust app.
*/
public final class EventPage {

/** @noinspection unused*/
private List<Event> entries;

public List<Event> getEntries() {
return entries;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EventPage eventPage = (EventPage) o;
return Objects.equals(entries, eventPage.entries);
}

public record AssociationList(
@Nullable List<Association> associations
) {
@NonNull
@Override
public int hashCode() {
return Objects.hash(entries);
public List<Association> associations() {
return Objects.requireNonNullElse(associations, Collections.emptyList());
}
}
Loading

0 comments on commit aacec65

Please sign in to comment.