Package com.syzygy.events
Class SyzygyApplication
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.app.Application
com.syzygy.events.SyzygyApplication
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.content.ComponentCallbacks2
,Consumer<RuntimeException>
public class SyzygyApplication
extends android.app.Application
implements Consumer<RuntimeException>
The main application class
This class handles the navigation between the different activities
This class manages the database and keeps track of which user is logged in
Also contains helper functions for activities
-
Nested Class Summary
Nested classes/interfaces inherited from class android.app.Application
android.app.Application.ActivityLifecycleCallbacks, android.app.Application.OnProvideAssistDataListener
Nested classes/interfaces inherited from class android.content.Context
android.content.Context.BindServiceFlags
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final CharSequence
private SyzygyActivity
The current activity displayed to the userprivate Database
The database instance for this apppprivate String
The id of the deviceSet of listeners that are waiting on receiving a user selected imageprivate com.google.android.gms.location.FusedLocationProviderClient
The client to get the locationstatic final int
The request code to use when requesting permissions for locationSet of listeners that are waiting on receiving the device's location(package private) android.graphics.drawable.Drawable
The icon to use for the create facility menu option(package private) android.graphics.drawable.Drawable
The icon to use for admin menu optionstatic boolean
private User.NotificationListener
The listener for notificationsstatic final String
The id of the User account associated with the Syzygy systemprivate User
The user logged into the deviceFields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APP_SEARCH_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_ACTIVITY_STARTS, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_EXTERNAL_SERVICE_LONG, BIND_IMPORTANT, BIND_INCLUDE_CAPABILITIES, BIND_NOT_FOREGROUND, BIND_NOT_PERCEPTIBLE, BIND_SHARED_ISOLATED_PROCESS, BIND_WAIVE_PRIORITY, BIOMETRIC_SERVICE, BLOB_STORE_SERVICE, BLUETOOTH_SERVICE, BUGREPORT_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_DIAGNOSTICS_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, CREDENTIAL_SERVICE, CROSS_PROFILE_APPS_SERVICE, DEVICE_ID_DEFAULT, DEVICE_ID_INVALID, DEVICE_LOCK_SERVICE, DEVICE_POLICY_SERVICE, DISPLAY_HASH_SERVICE, DISPLAY_SERVICE, DOMAIN_VERIFICATION_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, EUICC_SERVICE, FILE_INTEGRITY_SERVICE, FINGERPRINT_SERVICE, GAME_SERVICE, GRAMMATICAL_INFLECTION_SERVICE, HARDWARE_PROPERTIES_SERVICE, HEALTHCONNECT_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, IPSEC_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCALE_SERVICE, LOCATION_SERVICE, MEDIA_COMMUNICATION_SERVICE, MEDIA_METRICS_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, OVERLAY_SERVICE, PEOPLE_SERVICE, PERFORMANCE_HINT_SERVICE, POWER_SERVICE, PRINT_SERVICE, RECEIVER_EXPORTED, RECEIVER_NOT_EXPORTED, RECEIVER_VISIBLE_TO_INSTANT_APPS, RESTRICTIONS_SERVICE, ROLE_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_IMS_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, TV_INTERACTIVE_APP_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_MANAGER_SERVICE, VIBRATOR_SERVICE, VIRTUAL_DEVICE_SERVICE, VPN_MANAGEMENT_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_RANGING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called on errors in the databaseprivate boolean
void
Sets the user to nullvoid
displayImage
(DatabaseInstance<?> instance) Displays the associated image of the instance to the user as a popupformatTimestamp
(com.google.firebase.Timestamp t) Formats a timestampGets the databasevoid
Gets an image from the uservoid
getLocation
(Consumer<android.location.Location> locationListener) Gets the locationgetUser()
void
loadMenuIcon
(android.view.Menu menu) Loads the icon for the account menuvoid
loadMenuItemIcons
(android.view.Menu menu) Loads the icons for the account menu optionsvoid
onCreate()
void
(package private) void
pingLocation
(boolean granted) Called when users grants/declines location permission.(package private) void
registerActivity
(SyzygyActivity activity) Called on create of activities to register that this activity is the current activity.private void
Gets the current location and actions all location listeners.(package private) void
sendImage
(android.net.Uri image) Called when the user selects an image.void
Sends a notification to the userprivate void
Sets the user using this device and registers a notification listenersignupUser
(String name, String email, String phone, String bio, Boolean admin, Boolean org, android.net.Uri image, Consumer<Boolean> onComplete) To be called by the Signup activity upon submissionvoid
switchToActivity
(Class<? extends android.app.Activity> to) Opens the new activity and closes the old activityMethods inherited from class android.app.Application
getProcessName, onConfigurationChanged, onLowMemory, onTrimMemory, registerActivityLifecycleCallbacks, registerComponentCallbacks, registerOnProvideAssistDataListener, unregisterActivityLifecycleCallbacks, unregisterComponentCallbacks, unregisterOnProvideAssistDataListener
Methods inherited from class android.content.ContextWrapper
attachBaseContext, bindIsolatedService, bindService, bindService, bindService, bindService, bindServiceAsUser, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingOrSelfUriPermissions, checkCallingPermission, checkCallingUriPermission, checkCallingUriPermissions, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermissions, clearWallpaper, createAttributionContext, createConfigurationContext, createContext, createContextForSplit, createDeviceContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createWindowContext, createWindowContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getAttributionSource, getAttributionTag, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDeviceId, getDir, getDisplay, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainExecutor, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getParams, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, isUiContext, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerDeviceIdChangeListener, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeSelfPermissionsOnKill, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startForegroundService, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterDeviceIdChangeListener, unregisterReceiver, updateServiceGroup
Methods inherited from class android.content.Context
bindIsolatedService, getColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, revokeSelfPermissionOnKill, sendBroadcastWithMultiplePermissions
-
Field Details
-
NO_DATABASE
public static boolean NO_DATABASE -
SYSTEM_ACCOUNT_ID
The id of the User account associated with the Syzygy system- See Also:
-
LOCATION_REQUEST_CODE
public static final int LOCATION_REQUEST_CODEThe request code to use when requesting permissions for location- See Also:
-
db
The database instance for this appp -
user
The user logged into the device -
notificationListener
The listener for notifications -
deviceID
The id of the device -
currentActivity
The current activity displayed to the user -
location
private com.google.android.gms.location.FusedLocationProviderClient locationThe client to get the location -
locationListeners
Set of listeners that are waiting on receiving the device's location -
imageListeners
Set of listeners that are waiting on receiving a user selected image -
CHANNEL_ID
- See Also:
-
CHANNEL_NAME
-
-
Constructor Details
-
SyzygyApplication
public SyzygyApplication()
-
-
Method Details
-
onCreate
public void onCreate()- Overrides:
onCreate
in classandroid.app.Application
-
setUser
Sets the user using this device and registers a notification listener -
loadMenuIcon
public void loadMenuIcon(android.view.Menu menu) Loads the icon for the account menu- Parameters:
menu
- The menu
-
loadMenuItemIcons
public void loadMenuItemIcons(android.view.Menu menu) Loads the icons for the account menu options- Parameters:
menu
- The menu
-
onTerminate
public void onTerminate()- Overrides:
onTerminate
in classandroid.app.Application
-
registerActivity
Called on create of activities to register that this activity is the current activity. Switches the update listener over to the new activity- Parameters:
activity
- The now current activity
-
getUser
- Returns:
- The user currently using this app
-
clearUser
public void clearUser()Sets the user to null -
getDatabase
Gets the database- Returns:
- the database
-
canGetLocation
private boolean canGetLocation()- Returns:
- If permission has been granted to get location
-
retrieveLocation
private void retrieveLocation()Gets the current location and actions all location listeners. Location listeners are passednull
if permissions are not granted or the location fails. Clears the listeners list after actioning. -
pingLocation
void pingLocation(boolean granted) Called when users grants/declines location permission. Actions all waiting location listeners. Passesnull
if permissions are not granted or the location fails. Clears the listeners list after retrieval.- Parameters:
granted
- If permission was granted
-
sendImage
void sendImage(android.net.Uri image) Called when the user selects an image. Sends the image to all current listeners- Parameters:
image
- The image
-
getLocation
Gets the locationChecks if location permissions are granted. If not, asks for permission. Then actions the listener with
null
if permissions are still not granted or an error occurs. Otherwise passes the location- Parameters:
locationListener
- The listener. Called when the location has been retrieved
-
getImage
Gets an image from the userChecks if file search permissions are granted. If not, asks for permission. Then actions the listener with
null
if permissions are still not granted or an error occurs. Otherwise passes the image- Parameters:
imageListener
- The listener. Called when the image has been retrieved
-
displayImage
Displays the associated image of the instance to the user as a popup- Parameters:
instance
- The instance whose image should be displayed
-
signupUser
public Set<Integer> signupUser(String name, String email, String phone, String bio, Boolean admin, Boolean org, android.net.Uri image, Consumer<Boolean> onComplete) To be called by the Signup activity upon submission- Returns:
- all invalid properties
-
switchToActivity
Opens the new activity and closes the old activity- Parameters:
to
- The new activity
-
formatTimestamp
Formats a timestamp- Parameters:
t
- the time- Returns:
- The timestamp as "dd/MM/yyyy"
-
accept
Called on errors in the database- Specified by:
accept
in interfaceConsumer<RuntimeException>
-
sendNotification
Sends a notification to the user- Parameters:
n
- The notification
-