Skip to content

Notify when network is not present#68

Open
BruceGitHub wants to merge 2 commits intonoiapp:developfrom
BruceGitHub:issue-21-adds-notify-on-network-los
Open

Notify when network is not present#68
BruceGitHub wants to merge 2 commits intonoiapp:developfrom
BruceGitHub:issue-21-adds-notify-on-network-los

Conversation

@BruceGitHub
Copy link
Copy Markdown

@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
android:name="org.dpppt.android.app.onboarding.OnboardingActivity"
android:launchMode="singleTop" />

<service android:name=".network.CheckConnectionStatus"
Copy link
Copy Markdown
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
Copy Markdown
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

public class MainActivity extends FragmentActivity {

private static final String PREFS_COVID = "PREFS_COVID";
public static final String PREFS_COVID = "PREFS_COVID";
Copy link
Copy Markdown
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

tracingViewModel.getAppStateLiveData()
.observe(getViewLifecycleOwner(), appState -> headerView.setState(appState));

tracingViewModel.getNetworkEnableLiveData()
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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