-
Notifications
You must be signed in to change notification settings - Fork 15
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
Notify when network is not present #68
base: develop
Are you sure you want to change the base?
Notify when network is not present #68
Conversation
@@ -36,6 +37,16 @@ | |||
android:name="org.dpppt.android.app.onboarding.OnboardingActivity" | |||
android:launchMode="singleTop" /> | |||
|
|||
<service android:name=".network.CheckConnectionStatus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move in new class notification\NotificationService
@@ -19,7 +19,7 @@ | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change visibility to use in other parts
@@ -67,6 +71,18 @@ private void setupHeader(View view) { | |||
headerView = view.findViewById(R.id.main_header_container); | |||
tracingViewModel.getAppStateLiveData() | |||
.observe(getViewLifecycleOwner(), appState -> headerView.setState(appState)); | |||
|
|||
tracingViewModel.getNetworkEnableLiveData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class for scheduling or rescheduling the job
import org.dpppt.android.app.util.DebugUtils; | ||
|
||
|
||
public class NotificationService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
RequiresApi
annotation > Wip