Skip to content

Commit

Permalink
Move AppDaysUsedRepository to browser-api so it can be accessed from …
Browse files Browse the repository at this point in the history
…autofill (#4474)

Task/Issue URL: https://app.asana.com/0/0/1207179707350731/f 

### Description
Moves a class from app module to `browser-api` so it can be used in autofill survey.

### Steps to test this PR
- [ ] QA-optional
  • Loading branch information
CDRussell committed May 9, 2024
1 parent e0ee0ae commit d36daab
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ import kotlinx.coroutines.withContext

private val formatter = SimpleDateFormat("yyyy-MM-dd", Locale.US)

interface AppDaysUsedRepository {
suspend fun getNumberOfDaysAppUsed(): Long
suspend fun recordAppUsedToday()
suspend fun getNumberOfDaysAppUsedSinceDate(date: Date): Long
suspend fun getLastActiveDay(): String
suspend fun getPreviousActiveDay(): String?
}

class AppDaysUsedDatabaseRepository(private val appDaysUsedDao: AppDaysUsedDao) : AppDaysUsedRepository {

private val singleThreadedDispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.app.usage.app

import java.util.*

/**
* Repository for storing and retrieving the number of days the app has been used
*/
interface AppDaysUsedRepository {

/**
* Get the number of days the app has been used
*/
suspend fun getNumberOfDaysAppUsed(): Long

/**
* Record that the app has been used today
*/
suspend fun recordAppUsedToday()

/**
* Get the number of days the app has been used since a given date
*/
suspend fun getNumberOfDaysAppUsedSinceDate(date: Date): Long

/**
* Get the last day the app was used
*/
suspend fun getLastActiveDay(): String

/**
* Get the previous active day
*/
suspend fun getPreviousActiveDay(): String?
}

0 comments on commit d36daab

Please sign in to comment.