Skip to content

Commit

Permalink
notification can now take to reviewer Activity if review was in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmJaishree committed Mar 22, 2021
1 parent 7921fc2 commit 22e5407
Show file tree
Hide file tree
Showing 3 changed files with 287 additions and 1 deletion.
17 changes: 17 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import com.ichi2.anki.dialogs.RescheduleDialog;
import com.ichi2.anki.reviewer.PeripheralKeymap;
import com.ichi2.anki.reviewer.ReviewerUi;
import com.ichi2.anki.services.NotificationService;
import com.ichi2.anki.workarounds.FirefoxSnackbarWorkaround;
import com.ichi2.anki.reviewer.ActionButtons;
import com.ichi2.async.CollectionTask;
Expand Down Expand Up @@ -162,6 +163,7 @@ public void onPostExecute(PairWithBoolean<Card[]> result) {

@Override
protected void onCreate(Bundle savedInstanceState) {

if (showedActivityFailedScreen(savedInstanceState)) {
return;
}
Expand Down Expand Up @@ -273,6 +275,21 @@ protected int getContentViewAttr(int fullscreenMode) {
@Override
protected void onCollectionLoaded(Collection col) {
super.onCollectionLoaded(col);

//This checks if the control came here through Notification tap.
if (getIntent().getExtras() != null) {
if (getIntent().getExtras().containsKey(NotificationService.THROUGH_NOTIFICATION)) {
/* It verifies if there are pending cards to review
if there are pending cards, then this Activity will resume the pending Review
else the control will go to the DeckPicker Activity to show the Deck List
*/
if (col.getSched().count() == 0) {
startActivityWithoutAnimation(new Intent(this, DeckPicker.class));
finishWithoutAnimation();
}
}
}

// Load the first card and start reviewing. Uses the answer card
// task to load a card, but since we send null
// as the card to answer, no card will be answered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import androidx.core.content.ContextCompat;

import com.ichi2.anki.AnkiDroidApp;
import com.ichi2.anki.CollectionHelper;
import com.ichi2.anki.DeckPicker;
import com.ichi2.anki.NotificationChannels;
import com.ichi2.anki.Preferences;
import com.ichi2.anki.R;
import com.ichi2.anki.Reviewer;
import com.ichi2.widget.WidgetStatus;

import timber.log.Timber;
Expand All @@ -40,6 +42,11 @@ public class NotificationService extends BroadcastReceiver {

public static final String INTENT_ACTION = "com.ichi2.anki.intent.action.SHOW_NOTIFICATION";

/**
* Used by Activities to check if the control came from Notification tap.
*/
public static final String THROUGH_NOTIFICATION = "throughNotification";

@Override
public void onReceive(Context context, Intent intent) {
Timber.i("NotificationService: OnStartCommand");
Expand Down Expand Up @@ -71,7 +78,14 @@ public void onReceive(Context context, Intent intent) {
builder.setLights(Color.BLUE, 1000, 1000);
}
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context, DeckPicker.class);
// If there are pending reviews then tapping the notification will open Review Activity instead of DeckPicer Activity
Intent resultIntent;
if (currentlySelectedDeckHasDueCards(context)) {
resultIntent = new Intent(context, Reviewer.class);
resultIntent.putExtra(THROUGH_NOTIFICATION, true);
} else {
resultIntent = new Intent(context, DeckPicker.class);
}
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
Expand All @@ -83,4 +97,19 @@ public void onReceive(Context context, Intent intent) {
manager.cancel(WIDGET_NOTIFY_ID);
}
}


/**
* Checks if currently selected deck has due cards
*
* @param context.
* @return true if currently selected deck has due cards otherwise false.
*/
private boolean currentlySelectedDeckHasDueCards(Context context) {
try {
return CollectionHelper.getInstance().getCol(context).getSched().count() > 0;
} catch (Exception e) {
return false;
}
}
}
240 changes: 240 additions & 0 deletions in progress
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
commit bfcc320a0db86724a5252c941c60d167e6f2e6db (HEAD -> issue#3593, upstream/issue#3593)
Author: IAmJaishree <jaisghunawat99@gmail.com>
Date: Tue Mar 16 08:45:25 2021 +0530

notification can now take to reviewer Activity if review was in progress

commit 7921fc264abca3332328d3e0bc75cde718b4bf28 (upstream/master, master)
Author: Hariharan S <56928954+haran2248@users.noreply.github.com>
Date: Tue Mar 16 01:23:57 2021 +0530

Change icon colors in the help dialogs to blue (#8168)

commit d04d8fd14a3e39adc70d2c93bdbe63463b11d321
Author: Mrudul Tora <mrudultora@gmail.com>
Date: Tue Mar 16 00:48:44 2021 +0530

Include show changelog in prefs for all builds (#8231)

* Added change logs for release builds
* Extracted string to resource file

commit b34276374a6259e64b790966a10e23a881865d86
Author: aflah02 <72096386+aflah02@users.noreply.github.com>
Date: Mon Mar 15 18:23:28 2021 +0530

Created CONTRIBUTING.md (#8222)

Created CONTRIBUTING.md and linked the wiki for developers and non developers

commit 1806ccc66a55828f9fa1084ed1cea5d250760528
Author: Mike Hardy <github@mikehardy.net>
Date: Mon Mar 15 04:29:29 2021 +0000

Bumped version to 2.15alpha30
@branch-specific

commit 5fc8c3afa084a40cc79df9d91cdac2299e0f1408
Author: Mike Hardy <github@mikehardy.net>
Date: Sun Mar 14 23:20:58 2021 -0500

Manually bump version number of attempt to publish failed on lintRelease

that stopped the version from publishing correctly but not before it sent
the APKs up to Google Play with the version code in it already, which is
an irrevocable act

commit 13a17a80b35cbc36ad1c47250266e77c1e11f6ad
Author: David Allison <62114487+david-allison-1@users.noreply.github.com>
Date: Mon Mar 15 00:56:52 2021 +0000

Updated strings from Crowdin (#8217)

Co-authored-by: AnkiDroid Translations <ankidroid@ankidroid.org>

commit ea7b48fa47a36e87a8e9babdfc6f84062b158124
Author: AnkiDroid Translations <ankidroid@ankidroid.org>
Date: Sun Mar 14 22:52:01 2021 +0000

Updated strings from Crowdin

commit d1f7d09792e06c4b0548f600b14cc24dc7a953ba
Author: David Allison <62114487+david-allison-1@users.noreply.github.com>
Date: Sun Mar 14 22:28:48 2021 +0000

Readme: Fix Contributors Link

Previously pointed to jest

commit b79b0c3aea9f610d5691f4e0e7c5fb81cee29334
Author: TarekkMA <tarekkma@gmail.com>
Date: Sat Mar 13 15:47:56 2021 +0200

Add MaxExecFunctionTest

commit 5bab33292046d8f455bf09d300e28722092ab18d
Author: TarekkMA <tarekkma@gmail.com>
Date: Thu Mar 11 12:05:00 2021 +0200

feat: warn when loading external http content

fix: ``isLoadedFromHttpUrl(String url)``

it was comparing the whole url to "http", rather than checking if the url starts with "http" or not

formatting AbstractFlashcardViewer.java

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

formatting AbstractFlashcardViewer.java

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

formatting AbstractFlashcardViewer.java

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

Update AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java

formatting AbstractFlashcardViewer.java

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

temp

commit f56ebfa34bb0e837cda2e1baf94be081e83070db
Author: huixing <wanghuixing24@gmail.com>
Date: Mon Mar 15 06:16:12 2021 +0800

Allow navigation drawer open from whole screen (#8071)

Co-authored-by: HuixingWang <whx24@live.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>

commit 947976d93aa02b05d523796c30daa0feff60915b
Author: aflah02 <72096386+aflah02@users.noreply.github.com>
Date: Mon Mar 15 03:43:50 2021 +0530

Add credits section for github and opencollective supporters to README (#8206)

commit 5f71d96f1af9fad497f6534db408d7ad6b32ed60
Author: Mani <12841290+infinyte7@users.noreply.github.com>
Date: Mon Mar 15 06:09:40 2021 +0800

Add JS API to know if answer is displaying or question (#8199)

* isDisplayingAnswer

commit 26295a2efc870979ce3bd224b3e8f0c4bd37a566
Author: Mrudul Tora <mrudultora@gmail.com>
Date: Mon Mar 15 03:39:05 2021 +0530

Add icons to Multimedia menu in Note Editor (#8204)

* Added icons to multimedia menu

* Removed showAsAction=true

commit 14af04df24633a25ad32a52ccd526944f893909c
Author: mrudultora <mrudultora@gmail.com>
Date: Sat Mar 13 17:08:41 2021 +0530

Change log theme with respect to app theme

commit 8fa3e45e2d3cf4d9898caf990825429f472faad9
Author: Mrudul Tora <mrudultora@gmail.com>
Date: Mon Mar 15 02:39:19 2021 +0530

Change custom tabs use to respect to app theme (#8175)

* Changed custom tabs theme with respect to app theme

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

commit a97a81af42e5f3122467ed5c5a64de08927c31f3
Author: Tushar Bhatt <tbhatt321@gmail.com>
Date: Mon Mar 15 00:19:32 2021 +0530

Add +/- preference dialog, use for "New cards/day" (#8191)

* Extended NumberRangePreference to add increment/decrement buttons
* Replaced NumberRangePreference with IncrementerNumberRangePreference for "New cards/day"
* Added strings for + and - symbols

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>

commit 006322ae6fef5a72c8fa02cc2fac526935ca3a9c
Author: Aryan Dokania <61244704+imaryandokania@users.noreply.github.com>
Date: Sun Mar 14 13:41:07 2021 +0545

fix: Remove space in Login ProgressDialog

* Fixes Bug ankidroid#8192.

* Update AnkiDroid/src/main/java/com/ichi2/anki/MyAccount.java

commit 330353ce63ce6dd3457a73419cd1162169b7da01
Author: Arthur Milchior <arthur@milchior.fr>
Date: Sun Mar 14 05:52:42 2021 +0100

Add accessibility mention to PR template (#8189)

* Add accessibility mention to PR template

commit 4481bad0903a6eea8cad503a12767c893a179aef (origin/master, origin/HEAD)
Author: Mike Hardy <github@mikehardy.net>
Date: Sun Mar 7 17:47:22 2021 -0500

Forward port stats from ViewPager to ViewPager2

commit 24532b1e988d017d37df0706515ff7cc4439d67c
Author: Henrik Giesel <hengiesel@gmail.com>
Date: Sun Mar 7 12:29:51 2021 +0100

Revert "NF: delete mathjax fonts"

This reverts commit b384a650ef3c0042dfba6396ee70e5d86bd05829.

commit 1337f3ea21cef25f549a89a81dcbaf151dde184d
Author: Henrik Giesel <hengiesel@gmail.com>
Date: Sun Mar 7 12:29:25 2021 +0100

Revert "Mathjax output SVG instead of css"

This reverts commit 42afcfc27019d1281f8f539441a466a939b49268.

commit 71635c6ace45b6522337f02ec663e71a260dd621 (tag: v2.15alpha28)
Author: Mike Hardy <github@mikehardy.net>
Date: Sat Mar 6 23:41:08 2021 +0000

Bumped version to 2.15alpha28
@branch-specific

commit f7929f380132e0b7533d2e66e9e3c966b3a8a73a
Author: AnkiDroid Translations <ankidroid@ankidroid.org>
Date: Sat Mar 6 22:10:19 2021 +0000

Updated strings from Crowdin

commit e55205dc38ba6056cd4fcd1b3c33902aa13d2943
Author: Mike Hardy <github@mikehardy.net>
Date: Sat Mar 6 13:17:26 2021 -0500

Set previous image path/URI in all cases

we only want to delete if it was not pre-existing, but we always want
the path for revert

This affects 2.14 and should be cherry-picked

commit 4030ac3d4b29569ff35a35adcc251f9026c59e92
Author: Mike Hardy <github@mikehardy.net>
Date: Sat Mar 6 13:05:53 2021 -0500

Implement uCrop for Android 11

This code path will not be accessed at all on Android < 11, so it is safe to cherry-pick

Fixes #7232

Follow-up should

0 comments on commit 22e5407

Please sign in to comment.