Skip to content

[GSOC] Implemented Service to store Deck Meta Data#11487

Closed
prateek-singh-3212 wants to merge 7 commits into
ankidroid:mainfrom
prateek-singh-3212:Sync_Deck_Meta_Data
Closed

[GSOC] Implemented Service to store Deck Meta Data#11487
prateek-singh-3212 wants to merge 7 commits into
ankidroid:mainfrom
prateek-singh-3212:Sync_Deck_Meta_Data

Conversation

@prateek-singh-3212

@prateek-singh-3212 prateek-singh-3212 commented May 31, 2022

Copy link
Copy Markdown
Member

Pull Request template

Purpose / Description

I am working on decoupling the notification ( currently It causes random notification triggring in our app). This PR also aims to solve the problem of tight coupling between notification and small widget.

Fixes

Fixes #8114
Fixes #6476

Approach

What is the issue?
The complete issue is documented in #6476. The main issue is that Current notification system is coupled with widget and notification is only triggered when user use widget.
Secondly, Notification is triggered when user is using the app. How? Whenever deck review completes the deck the widget data is updated Hence Notification is shown (Because it is tightly coupled).

Architectural: one "unit of work" per time, rather than per deck.

ALGO FOR DECK NOTIFICATION
Input: TreeMap<time, List>

We store the the time and list of decks whose notification needs to be send on that time.
The map is TreeMap which stores the data in sorted key form.

Working of algo:

  1. Takes the input time (EPOCH Long)
            if (currentTimeMS < scheduleTimeMS) {
                    // Scheduled time is gone for today.
                    // Only add time in time deck map. No need to reschedule work manager.
                    // Update schedule time for next day `scheduleTimeMS += 3600000`
                    // Update data in map
            } else if (scheduleTimeMS < (first key of map {Map is sorted so it will contain the most upcomming deck reminder at **TOP**})) {
                    // Scheduled time will come today only. And it will come before the current schedule deck.
                    // Updating data in map
                    // Replacing old work manager with new one.
            } else {
                    // Scheduled time will come today. And it will come after the current schedule deck.
                    // Updating data in map
            }

ALGO FOR ALL DECK NOTIFICATION
All deck notification will work in the syncronization with above algo and addintion to this If Thier is no scheduled notification in next 1 hour then also work manager will run after 1 hour and check the all deck status.

How Has This Been Tested?

Tested on samsung galaxy M51(API 31)

Checklist

Please, go through these checks before submitting the PR.

  • You have not changed whitespace unnecessarily (it makes diffs hard to read)
  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • Your code follows the style of the project (e.g. never omit braces in if statements)
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author Review High Priority Request for high priority review Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget: Notification & Sound each time I change AnkiDroid Activities [Bug] Notifications. (android issue???)

7 participants