Skip to content

Commit

Permalink
Force clean deleted logs from disk
Browse files Browse the repository at this point in the history
- clean up job may not run on devices due to factors mentioned in
  https://github.com/evernote/android-job/wiki/FAQ#what-happens-with-jobs-after-the-app-was-forced-killed
  This option hence powrs the user to run the job at the exact moment

Signed-off-by: Arka Prava Basu <[email protected]>
  • Loading branch information
archie94 committed Feb 20, 2019
1 parent 693db02 commit 860338f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/org/havenapp/main/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ public boolean onOptionsItemSelected (MenuItem item) {
case R.id.action_test_notification:
testNotifications();
break;
case R.id.action_run_cleanup_job:
runCleanUpJob();
break;
}
return true;
}
Expand All @@ -337,6 +340,10 @@ private void removeAllEvents()
new EventDeleteAllAsync(() -> onAllEventsRemoved(removedEvents)).execute(removedEvents);
}

private void runCleanUpJob() {
RemoveDeletedFilesJob.Companion.runNow();
}

private void onAllEventsRemoved(List<Event> removedEvents) {
Snackbar.make(recyclerView, resourceManager.getString(R.string.events_deleted), Snackbar.LENGTH_SHORT)
.setAction(resourceManager.getString(R.string.undo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class RemoveDeletedFilesJob: Job() {
.build()
.schedule()
}

fun runNow(): Int {
return JobRequest.Builder(SERVICE_TAG)
.startNow()
.build()
.schedule()
}
}

override fun onRunJob(params: Params): Result {
Expand Down
7 changes: 7 additions & 0 deletions src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
android:orderInCategory="100"
android:title="@string/menu_licenses"
app:showAsAction="never" />

<item
android:id="@+id/action_run_cleanup_job"
android:title="@string/run_disk_cleanup"
android:orderInCategory="2"
app:showAsAction="never"/>

<item
android:id="@+id/action_remove_all_events"
android:title="@string/remove_all_logs"
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,6 @@

<string name="status_recording_video">Recording...</string>
<string name="status_light">LIGHT DETECTED</string>
<string name="run_disk_cleanup">Clean deleted logs from disk</string>

</resources>

0 comments on commit 860338f

Please sign in to comment.