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

Notify when network is not present #68

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

BruceGitHub
Copy link

@BruceGitHub BruceGitHub commented May 17, 2020

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

  • NotificationService
  • InfoStatusNetwork
  • ScheduleMonitoringStatusNetwork

TODO:
[ ] Remove RequiresApi annotation > Wip

Adds notify in status bar and in main activity
when the network go down
@Magicianred Magicianred added the review developer an approve by a developer label May 17, 2020
@@ -36,6 +37,16 @@
android:name="org.dpppt.android.app.onboarding.OnboardingActivity"
android:launchMode="singleTop" />

<service android:name=".network.CheckConnectionStatus"
Copy link
Author

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() {
Copy link
Author

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";
Copy link
Author

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()
Copy link
Author

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 {
Copy link
Author

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 {
Copy link
Author

@BruceGitHub BruceGitHub May 17, 2020

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) {
Copy link
Author

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 {
Copy link
Author

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 {
Copy link
Author

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

@Magicianred Magicianred changed the title Fix #21 Notify when network is not present May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review developer an approve by a developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants