Notify when network is not present#68
Conversation
| android:name="org.dpppt.android.app.onboarding.OnboardingActivity" | ||
| android:launchMode="singleTop" /> | ||
|
|
||
| <service android:name=".network.CheckConnectionStatus" |
There was a problem hiding this comment.
JobService to register a callback or a receiver for first time
| }; | ||
|
|
||
| @RequiresApi(api = Build.VERSION_CODES.O) | ||
| private void createNotificationChannel() { |
There was a problem hiding this comment.
Move in new class notification\NotificationService
| public class MainActivity extends FragmentActivity { | ||
|
|
||
| private static final String PREFS_COVID = "PREFS_COVID"; | ||
| public static final String PREFS_COVID = "PREFS_COVID"; |
There was a problem hiding this comment.
Change visibility to use in other parts
| tracingViewModel.getAppStateLiveData() | ||
| .observe(getViewLifecycleOwner(), appState -> headerView.setState(appState)); | ||
|
|
||
| tracingViewModel.getNetworkEnableLiveData() |
There was a problem hiding this comment.
Adds new liveData to intercept changes of the network connection by change the UI according to this input
| import org.dpppt.android.app.notifications.NotificationService; | ||
|
|
||
|
|
||
| public class CheckConnectionStatus extends JobService { |
There was a problem hiding this comment.
This class set the listener for network status, try until the connection return alive atleast one time
|
|
||
| import org.dpppt.android.app.util.DebugUtils; | ||
|
|
||
| public class InfoStatusNetwork { |
There was a problem hiding this comment.
This class read the status of the network (this is a util class)
| return new IntentFilter(UPDATE_NETWORK_STATUS); | ||
| } | ||
|
|
||
| public static void sendUpdateBroadcast(Context context) { |
There was a problem hiding this comment.
Helper method to notify the change of the network, maybe be put in other class but for now, I think that this is a good choice
|
|
||
| import org.dpppt.android.app.util.DebugUtils; | ||
|
|
||
| public class ScheduleMonitoringStatusNetwork { |
There was a problem hiding this comment.
Class for scheduling or rescheduling the job
| import org.dpppt.android.app.util.DebugUtils; | ||
|
|
||
|
|
||
| public class NotificationService { |
There was a problem hiding this comment.
class to manage the notification behaviour in general way
Adds notify in status bar and in main activity
when the network go down.
The main idea behind this PR is check the connection while the app is active or in background, because without the connection it is an impossible receiver the report of contacts with other sick people.
New class
TODO:
[ ] Remove
RequiresApiannotation > Wip