Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2024: Add Survey Feature #1222

Merged
merged 52 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8efe4aa
Added a showcase MVP for Survey UI
amrhossamdev Jul 14, 2024
5314359
Refactor
amrhossamdev Jul 15, 2024
fb714d4
Added survey base
aaronbrethorst Sep 1, 2024
1c01d83
Refactor survey codebase
amrhossamdev Aug 8, 2024
aa6a591
Added External Survey Support
amrhossamdev Aug 10, 2024
0649730
Add External Survey Activity
aaronbrethorst Sep 1, 2024
0161e39
Removed unused file
amrhossamdev Aug 10, 2024
b844f4e
Removed unused file
amrhossamdev Aug 10, 2024
e9d1585
Added TODO
amrhossamdev Aug 10, 2024
d0a1971
Refactor
amrhossamdev Aug 10, 2024
945f044
Refactor
amrhossamdev Aug 12, 2024
a70b0b3
Refactor
amrhossamdev Aug 12, 2024
0c977eb
Refactor
amrhossamdev Aug 12, 2024
2a7a472
Change log warning to log error
amrhossamdev Aug 12, 2024
d6435da
Refactor
amrhossamdev Aug 12, 2024
4182716
Refactor
amrhossamdev Aug 12, 2024
c04a14a
Refactor
amrhossamdev Aug 12, 2024
38be0f3
Revert changes due to JCenter outage affecting CI
amrhossamdev Aug 12, 2024
69f34a3
Control survey visibility based on routes or stops
amrhossamdev Aug 14, 2024
954cc44
Populate shared info for privacy in external surveys
amrhossamdev Aug 15, 2024
33b593c
Refactor
amrhossamdev Aug 15, 2024
88499a5
Handle submitting answers for external survey
amrhossamdev Aug 18, 2024
df7053e
Implement saving of completed surveys to RoomD
amrhossamdev Aug 19, 2024
a787cea
Update kotlin version and remove kotlin extension
amrhossamdev Aug 19, 2024
7e8d2b7
JVM compatible with kotlin version
amrhossamdev Aug 19, 2024
58664e6
Added jvmTarget for kotlin
amrhossamdev Aug 19, 2024
914a9d4
Edit jvmTarget version
amrhossamdev Aug 19, 2024
ca9386d
Handle dismiss survey actions
amrhossamdev Aug 20, 2024
73400af
Refactor code and add comments for better clarity
amrhossamdev Aug 20, 2024
6f9e206
Enable region-based survey handling
amrhossamdev Aug 20, 2024
2be3dc6
Refactor and Survey Handling
amrhossamdev Aug 22, 2024
5be95c1
Added progress overlay
amrhossamdev Aug 23, 2024
ba630a2
Refactor
amrhossamdev Aug 23, 2024
a015363
Refactor
amrhossamdev Aug 23, 2024
8f8218a
Add option to enable/disable studies, append user ID to studies API, …
amrhossamdev Aug 23, 2024
70a8e02
Add control for survey visibility frequency count
amrhossamdev Aug 24, 2024
f0c4c18
feat: Implement survey reminder functionality and refactor codebase
amrhossamdev Aug 24, 2024
17868a1
fix: Prevent RecyclerView from adding extra views on bind
amrhossamdev Aug 24, 2024
1ad639f
refactor: survey manager
amrhossamdev Aug 24, 2024
2203bc8
Restore survey visibility control
amrhossamdev Aug 24, 2024
fad4ba4
fix: Questions adapter
amrhossamdev Aug 25, 2024
f30dfa4
refactor: survey manager
amrhossamdev Aug 25, 2024
03efce2
Translate survey strings and redesign questions view
amrhossamdev Aug 25, 2024
9cd3c53
Polish Survey UI and Fix Bugs Affecting External Surveys
amrhossamdev Aug 25, 2024
ec942b4
Refactor
amrhossamdev Aug 26, 2024
1c6f1fd
fix: ensure survey view is only visible on the map
amrhossamdev Aug 26, 2024
7c593bb
refactor survey setup
amrhossamdev Aug 26, 2024
d74bec8
adjust margin
amrhossamdev Aug 26, 2024
698260e
Remove id from shared info text
amrhossamdev Aug 27, 2024
42841a1
chore: add comments to multiple files for clarity
amrhossamdev Aug 31, 2024
64e65f9
chore: add comments
amrhossamdev Aug 31, 2024
907419d
feat: support sending all route IDs for external survey embedded data
amrhossamdev Aug 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.9.21'
repositories {
google()
mavenCentral()
Expand Down
14 changes: 10 additions & 4 deletions onebusaway-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.apache.tools.ant.filters.ConcatFilter

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

repositories {
maven {
Expand Down Expand Up @@ -275,10 +275,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

testOptions {
unitTests.includeAndroidResources true
}
Expand Down Expand Up @@ -368,6 +370,10 @@ dependencies {
implementation "androidx.concurrent:concurrent-listenablefuture-callback:1.0.0-beta01"
implementation "androidx.core:core-ktx:1.7.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// RoomDB
implementation "androidx.room:room-runtime:2.6.1"
kapt "androidx.room:room-compiler:2.6.1"
implementation "androidx.room:room-ktx:2.6.1"

}

Expand Down
83 changes: 44 additions & 39 deletions onebusaway-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011-2022 Paul Watts ([email protected]),
University of South Florida ([email protected]),
University of South Florida ([email protected]),
Microsoft Corporation.

Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,10 +19,10 @@
xmlns:android="http://schemas.android.com/apk/res/android">

<permission
android:name="${applicationId}.permission.TRIP_SERVICE"
android:label="@string/trip_service_perm_label"
android:description="@string/trip_service_perm_description"
android:protectionLevel="normal"/>
android:name="${applicationId}.permission.TRIP_SERVICE"
android:label="@string/trip_service_perm_label"
android:description="@string/trip_service_perm_description"
android:protectionLevel="normal"/>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down Expand Up @@ -64,13 +64,18 @@
android:value="org.onebusaway.android.ui.SearchActivity" />

<activity
android:name=".ui.DonationLearnMoreActivity"
android:exported="false"
android:label="@string/title_activity_donation_learn_more"
android:parentActivityName=".ui.HomeActivity">
android:theme="@style/Theme.OneBusAway.NoActionBar"
android:name=".ui.survey.activities.SurveyWebViewActivity"
android:exported="false" />

<activity
android:name=".ui.DonationLearnMoreActivity"
android:exported="false"
android:label="@string/title_activity_donation_learn_more"
android:parentActivityName=".ui.HomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.PreferencesActivity" />
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.PreferencesActivity" />
</activity>

<activity
Expand All @@ -82,8 +87,8 @@
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>

<activity
Expand Down Expand Up @@ -230,8 +235,8 @@
android:scheme="onebusaway" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
</activity>
<activity android:name="org.onebusaway.android.ui.RegionsActivity"/>
<activity android:name="org.onebusaway.android.ui.AgenciesActivity"/>
Expand All @@ -251,8 +256,8 @@
</intent-filter>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
</activity>
<activity
android:name="org.onebusaway.android.ui.NightLightActivity"
Expand All @@ -267,16 +272,16 @@
</intent-filter>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
</activity>
<activity
android:name="org.onebusaway.android.ui.TripPlanActivity"
android:label="@string/title_activity_trip_plan"
android:parentActivityName="org.onebusaway.android.ui.HomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
</activity>
<activity
android:name="org.onebusaway.android.ui.FeedbackActivity"
Expand All @@ -291,8 +296,8 @@

<!-- Provider is defined in build.gradle flavors -->
<provider
android:name="org.onebusaway.android.provider.ObaProvider"
android:authorities="${databaseAuthority}"/>
android:name="org.onebusaway.android.provider.ObaProvider"
android:authorities="${databaseAuthority}"/>

<service
android:name=".tripservice.TripService"
Expand Down Expand Up @@ -362,38 +367,38 @@
</receiver>

<receiver
android:enabled="true" android:name=".travelbehavior.receiver.TransitionBroadcastReceiver">
android:enabled="true" android:name=".travelbehavior.receiver.TransitionBroadcastReceiver">
</receiver>
<receiver
android:enabled="true" android:name=".travelbehavior.receiver.RecognitionBroadcastReceiver">
android:enabled="true" android:name=".travelbehavior.receiver.RecognitionBroadcastReceiver">
</receiver>
<receiver
android:enabled="true" android:name=".travelbehavior.receiver.LocationBroadcastReceiver">
android:enabled="true" android:name=".travelbehavior.receiver.LocationBroadcastReceiver">
</receiver>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/apiv2_key"/>
android:name="com.google.android.geo.API_KEY"
android:value="@string/apiv2_key"/>

<activity
android:name="org.onebusaway.android.ui.AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName="org.onebusaway.android.ui.PreferencesActivity"
android:theme="@style/Theme.OneBusAway.NoActionBar">
android:name="org.onebusaway.android.ui.AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName="org.onebusaway.android.ui.PreferencesActivity"
android:theme="@style/Theme.OneBusAway.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.PreferencesActivity"/>
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.PreferencesActivity"/>
</activity>

<!-- Opt-out of June 2018 Android Maps styling with pin POI icons - see #891 -->
<meta-data android:name="com.google.android.gms.maps.API_OPTIONS" android:value="B3H9HE845CFHYG"/>
</application>

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
</manifest>
android:glEsVersion="0x00020000"
android:required="true"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.onebusaway.android.database

import androidx.room.Database
import androidx.room.RoomDatabase
import org.onebusaway.android.ui.survey.dao.StudiesDao
import org.onebusaway.android.ui.survey.dao.SurveysDao
import org.onebusaway.android.ui.survey.entity.Study
import org.onebusaway.android.ui.survey.entity.Survey

/**
* Main database class for the app, containing `Study` and `Survey` entities.
* Provides abstract methods for accessing `StudiesDao` and `SurveysDao`.
* The `@Database` annotation sets up Room with version 1 of the schema.
*/
@Database(entities = [Study::class, Survey::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
abstract fun studiesDao(): StudiesDao
abstract fun surveysDao(): SurveysDao
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.onebusaway.android.io.request.survey;

import android.content.Context;
import android.net.Uri;

import androidx.annotation.NonNull;

import org.onebusaway.android.R;
import org.onebusaway.android.app.Application;
import org.onebusaway.android.io.request.RequestBase;
import org.onebusaway.android.io.request.survey.model.StudyResponse;
import org.onebusaway.android.ui.survey.SurveyPreferences;

import java.util.concurrent.Callable;

/**
* Represents a request to fetch study data.
*/

public final class ObaStudyRequest extends RequestBase implements Callable<StudyResponse> {

private ObaStudyRequest(Uri uri) {
super(uri);
}

public static class Builder {

private static Uri URI = null;

public Builder(Context context) {
String studyAPIURL = Application.get().getResources().getString(R.string.studies_api_url);
studyAPIURL = studyAPIURL.replace("regionID", String.valueOf(Application.get().getCurrentRegion().getId()));
URI = Uri.parse(studyAPIURL).buildUpon().appendQueryParameter("user_id", SurveyPreferences.getUserUUID(context)).build();
}

public ObaStudyRequest build() {
return new ObaStudyRequest(URI);
}
}

public static ObaStudyRequest newRequest(Context context) {
return new Builder(context).build();
}

@Override
public StudyResponse call() {
return call(StudyResponse.class);
}

@NonNull
@Override
public String toString() {
return "ObaSurveyRequest [mUri=" + mUri + "]";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.onebusaway.android.io.request.survey;

import org.onebusaway.android.io.request.survey.model.StudyResponse;

/**
* Interface to handle the callbacks for survey-related requests.
* Implementations of this interface should define how to handle
* successful and failed survey responses.
*/

public interface StudyRequestListener {
void onSurveyResponseReceived(StudyResponse response);
void onSurveyResponseFail();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.onebusaway.android.io.request.survey;

import android.os.AsyncTask;
import android.util.Log;

import org.onebusaway.android.io.request.survey.model.StudyResponse;

/**
* AsyncTask for performing background operations related to study requests.
*/
public class StudyRequestTask extends AsyncTask<ObaStudyRequest, Void, StudyResponse> {
private static final String TAG = "Survey Request";
private StudyRequestListener mListener;

public StudyRequestTask(StudyRequestListener listener) {
mListener = listener;
}

@Override
protected StudyResponse doInBackground(ObaStudyRequest... requests) {
try {
return requests[0].call();
} catch (Exception e) {
Log.e(TAG, "Error executing survey request", e);
return null;
}
}

@Override
protected void onPostExecute(StudyResponse response) {
if (response != null) {
mListener.onSurveyResponseReceived(response);
} else {
mListener.onSurveyResponseFail();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.onebusaway.android.io.request.survey;

import org.onebusaway.android.io.request.survey.submit.SubmitSurveyRequestListener;
import org.onebusaway.android.ui.survey.SurveyActionsListener;

/**
* Interface that combines various survey-related listeners.
*/
public interface SurveyListener extends StudyRequestListener, SubmitSurveyRequestListener, SurveyActionsListener {
}
Loading
Loading