Merge pull request #770 from android/refactor/remove_unused_statements

Remove unused statements
pull/773/head
Milosz Moczkowski 1 year ago committed by GitHub
commit 1345764649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice
import com.google.samples.apps.nowinandroid.NiaBuildType import com.google.samples.apps.nowinandroid.NiaBuildType
import com.google.samples.apps.nowinandroid.configureFlavors import com.google.samples.apps.nowinandroid.configureFlavors

@ -52,8 +52,6 @@ class BaselineProfileGenerator {
// Navigate to saved screen // Navigate to saved screen
goToBookmarksScreen() goToBookmarksScreen()
// TODO: we need to implement adding stuff to bookmarks before able to scroll it
// bookmarksScrollFeedDownUp()
// Navigate to interests screen // Navigate to interests screen
goToInterestsScreen() goToInterestsScreen()

@ -19,7 +19,6 @@ package com.google.samples.apps.nowinandroid.bookmarks
import androidx.benchmark.macro.MacrobenchmarkScope import androidx.benchmark.macro.MacrobenchmarkScope
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import com.google.samples.apps.nowinandroid.flingElementDownUp
fun MacrobenchmarkScope.goToBookmarksScreen() { fun MacrobenchmarkScope.goToBookmarksScreen() {
device.findObject(By.text("Saved")).click() device.findObject(By.text("Saved")).click()
@ -29,8 +28,3 @@ fun MacrobenchmarkScope.goToBookmarksScreen() {
val topAppBar = device.findObject(By.res("niaTopAppBar")) val topAppBar = device.findObject(By.res("niaTopAppBar"))
topAppBar.wait(Until.hasObject(By.text("Saved")), 2_000) topAppBar.wait(Until.hasObject(By.text("Saved")), 2_000)
} }
fun MacrobenchmarkScope.bookmarksScrollFeedDownUp() {
val feedList = device.findObject(By.res("bookmarks:feed"))
device.flingElementDownUp(feedList)
}

@ -16,20 +16,16 @@
package com.google.samples.apps.nowinandroid package com.google.samples.apps.nowinandroid
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion import org.gradle.api.JavaVersion
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/** /**

@ -4,7 +4,6 @@ import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.ApplicationProductFlavor import com.android.build.api.dsl.ApplicationProductFlavor
import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.ProductFlavor import com.android.build.api.dsl.ProductFlavor
import org.gradle.api.Project
@Suppress("EnumEntryName") @Suppress("EnumEntryName")
enum class FlavorDimension { enum class FlavorDimension {
@ -17,10 +16,10 @@ enum class FlavorDimension {
@Suppress("EnumEntryName") @Suppress("EnumEntryName")
enum class NiaFlavor(val dimension: FlavorDimension, val applicationIdSuffix: String? = null) { enum class NiaFlavor(val dimension: FlavorDimension, val applicationIdSuffix: String? = null) {
demo(FlavorDimension.contentType, applicationIdSuffix = ".demo"), demo(FlavorDimension.contentType, applicationIdSuffix = ".demo"),
prod(FlavorDimension.contentType, ) prod(FlavorDimension.contentType)
} }
fun Project.configureFlavors( fun configureFlavors(
commonExtension: CommonExtension<*, *, *, *>, commonExtension: CommonExtension<*, *, *, *>,
flavorConfigurationBlock: ProductFlavor.(flavor: NiaFlavor) -> Unit = {} flavorConfigurationBlock: ProductFlavor.(flavor: NiaFlavor) -> Unit = {}
) { ) {
@ -33,7 +32,7 @@ fun Project.configureFlavors(
flavorConfigurationBlock(this, it) flavorConfigurationBlock(this, it)
if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) { if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) {
if (it.applicationIdSuffix != null) { if (it.applicationIdSuffix != null) {
this.applicationIdSuffix = it.applicationIdSuffix applicationIdSuffix = it.applicationIdSuffix
} }
} }
} }

@ -34,7 +34,6 @@ data class AnalyticsEvent(
class Types { class Types {
companion object { companion object {
const val SCREEN_VIEW = "screen_view" // (extras: SCREEN_NAME) const val SCREEN_VIEW = "screen_view" // (extras: SCREEN_NAME)
const val VIEW_SEARCH_RESULTS = "view_search_results" // (extras: SEARCH_TERM)
} }
} }
@ -54,7 +53,6 @@ data class AnalyticsEvent(
class ParamKeys { class ParamKeys {
companion object { companion object {
const val SCREEN_NAME = "screen_name" const val SCREEN_NAME = "screen_name"
const val SEARCH_TERM = "search_term"
} }
} }
} }

@ -36,9 +36,3 @@ data class NewsResourceFtsEntity(
@ColumnInfo(name = "content") @ColumnInfo(name = "content")
val content: String, val content: String,
) )
fun NewsResourceEntity.asFtsEntity() = NewsResourceFtsEntity(
newsResourceId = id,
title = title,
content = content,
)

@ -143,13 +143,13 @@ class NiaPreferencesDataSource @Inject constructor(
} }
suspend fun setNewsResourcesViewed(newsResourceIds: List<String>, viewed: Boolean) { suspend fun setNewsResourcesViewed(newsResourceIds: List<String>, viewed: Boolean) {
userPreferences.updateData { userPreferences.updateData { prefs ->
it.copy { prefs.copy {
newsResourceIds.forEach { newsResourceIds.forEach { id ->
if (viewed) { if (viewed) {
viewedNewsResourceIds.put(it, true) viewedNewsResourceIds.put(id, true)
} else { } else {
viewedNewsResourceIds.remove(it) viewedNewsResourceIds.remove(id)
} }
} }
} }

@ -18,19 +18,13 @@ package com.google.samples.apps.nowinandroid.core.designsystem.icon
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.filled.ArrowDropUp
import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material.icons.rounded.Add import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.ArrowBack import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Check import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Close import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.ExpandLess
import androidx.compose.material.icons.rounded.Fullscreen
import androidx.compose.material.icons.rounded.Grid3x3 import androidx.compose.material.icons.rounded.Grid3x3
import androidx.compose.material.icons.rounded.Person import androidx.compose.material.icons.rounded.Person
import androidx.compose.material.icons.rounded.PlayArrow
import androidx.compose.material.icons.rounded.Search import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.Settings import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material.icons.rounded.ShortText import androidx.compose.material.icons.rounded.ShortText
@ -45,25 +39,19 @@ import com.google.samples.apps.nowinandroid.core.designsystem.R
* Now in Android icons. Material icons are [ImageVector]s, custom icons are drawable resource IDs. * Now in Android icons. Material icons are [ImageVector]s, custom icons are drawable resource IDs.
*/ */
object NiaIcons { object NiaIcons {
val AccountCircle = Icons.Outlined.AccountCircle
val Add = Icons.Rounded.Add val Add = Icons.Rounded.Add
val ArrowBack = Icons.Rounded.ArrowBack val ArrowBack = Icons.Rounded.ArrowBack
val ArrowDropDown = Icons.Default.ArrowDropDown
val ArrowDropUp = Icons.Default.ArrowDropUp
val Bookmark = R.drawable.ic_bookmark val Bookmark = R.drawable.ic_bookmark
val BookmarkBorder = R.drawable.ic_bookmark_border val BookmarkBorder = R.drawable.ic_bookmark_border
val Bookmarks = R.drawable.ic_bookmarks val Bookmarks = R.drawable.ic_bookmarks
val BookmarksBorder = R.drawable.ic_bookmarks_border val BookmarksBorder = R.drawable.ic_bookmarks_border
val Check = Icons.Rounded.Check val Check = Icons.Rounded.Check
val Close = Icons.Rounded.Close val Close = Icons.Rounded.Close
val ExpandLess = Icons.Rounded.ExpandLess
val Fullscreen = Icons.Rounded.Fullscreen
val Grid3x3 = Icons.Rounded.Grid3x3 val Grid3x3 = Icons.Rounded.Grid3x3
val MenuBook = R.drawable.ic_menu_book val MenuBook = R.drawable.ic_menu_book
val MenuBookBorder = R.drawable.ic_menu_book_border val MenuBookBorder = R.drawable.ic_menu_book_border
val MoreVert = Icons.Default.MoreVert val MoreVert = Icons.Default.MoreVert
val Person = Icons.Rounded.Person val Person = Icons.Rounded.Person
val PlayArrow = Icons.Rounded.PlayArrow
val Search = Icons.Rounded.Search val Search = Icons.Rounded.Search
val Settings = Icons.Rounded.Settings val Settings = Icons.Rounded.Settings
val ShortText = Icons.Rounded.ShortText val ShortText = Icons.Rounded.ShortText

@ -27,7 +27,6 @@ internal val Blue30 = Color(0xFF004D61)
internal val Blue40 = Color(0xFF006780) internal val Blue40 = Color(0xFF006780)
internal val Blue80 = Color(0xFF5DD5FC) internal val Blue80 = Color(0xFF5DD5FC)
internal val Blue90 = Color(0xFFB8EAFF) internal val Blue90 = Color(0xFFB8EAFF)
internal val Blue95 = Color(0xFFDDF4FF)
internal val DarkGreen10 = Color(0xFF0D1F12) internal val DarkGreen10 = Color(0xFF0D1F12)
internal val DarkGreen20 = Color(0xFF223526) internal val DarkGreen20 = Color(0xFF223526)
internal val DarkGreen30 = Color(0xFF394B3C) internal val DarkGreen30 = Color(0xFF394B3C)
@ -61,14 +60,12 @@ internal val Orange30 = Color(0xFF812800)
internal val Orange40 = Color(0xFFA23F16) internal val Orange40 = Color(0xFFA23F16)
internal val Orange80 = Color(0xFFFFB59B) internal val Orange80 = Color(0xFFFFB59B)
internal val Orange90 = Color(0xFFFFDBCF) internal val Orange90 = Color(0xFFFFDBCF)
internal val Orange95 = Color(0xFFFFEDE8)
internal val Purple10 = Color(0xFF36003C) internal val Purple10 = Color(0xFF36003C)
internal val Purple20 = Color(0xFF560A5D) internal val Purple20 = Color(0xFF560A5D)
internal val Purple30 = Color(0xFF702776) internal val Purple30 = Color(0xFF702776)
internal val Purple40 = Color(0xFF8B418F) internal val Purple40 = Color(0xFF8B418F)
internal val Purple80 = Color(0xFFFFA9FE) internal val Purple80 = Color(0xFFFFA9FE)
internal val Purple90 = Color(0xFFFFD6FA) internal val Purple90 = Color(0xFFFFD6FA)
internal val Purple95 = Color(0xFFFFEBFA)
internal val PurpleGray30 = Color(0xFF4D444C) internal val PurpleGray30 = Color(0xFF4D444C)
internal val PurpleGray50 = Color(0xFF7F747C) internal val PurpleGray50 = Color(0xFF7F747C)
internal val PurpleGray60 = Color(0xFF998D96) internal val PurpleGray60 = Color(0xFF998D96)

@ -112,22 +112,6 @@ class TestUserDataRepository : UserDataRepository {
} }
} }
/**
* A test-only API to allow setting/unsetting of bookmarks.
*
*/
fun setNewsResourceBookmarks(newsResourceIds: Set<String>) {
currentUserData.let { current ->
_userData.tryEmit(current.copy(bookmarkedNewsResources = newsResourceIds))
}
}
/**
* A test-only API to allow querying the current followed topics.
*/
fun getCurrentFollowedTopics(): Set<String>? =
_userData.replayCache.firstOrNull()?.followedTopics
/** /**
* A test-only API to allow setting of user data directly. * A test-only API to allow setting of user data directly.
*/ */

@ -250,14 +250,6 @@ fun NewsResourceMetaData(
) )
} }
@Composable
fun NewsResourceLink(
@Suppress("UNUSED_PARAMETER")
newsResource: NewsResource,
) {
TODO()
}
@Composable @Composable
fun NewsResourceShortDescription( fun NewsResourceShortDescription(
newsResourceShortDescription: String, newsResourceShortDescription: String,

@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice
plugins { plugins {
id("nowinandroid.android.feature") id("nowinandroid.android.feature")
id("nowinandroid.android.library.compose") id("nowinandroid.android.library.compose")

@ -112,7 +112,7 @@ class ForYouScreenTest {
@Test @Test
fun topicSelector_whenNoTopicsSelected_showsTopicChipsAndDisabledDoneButton() { fun topicSelector_whenNoTopicsSelected_showsTopicChipsAndDisabledDoneButton() {
val testData = followableTopicTestData.map { it -> it.copy(isFollowed = false) } val testData = followableTopicTestData.map { it.copy(isFollowed = false) }
composeTestRule.setContent { composeTestRule.setContent {
BoxWithConstraints { BoxWithConstraints {

@ -30,7 +30,6 @@ import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRe
import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository
import com.google.samples.apps.nowinandroid.core.testing.repository.emptyUserData import com.google.samples.apps.nowinandroid.core.testing.repository.emptyUserData
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.core.testing.util.TestNetworkMonitor
import com.google.samples.apps.nowinandroid.core.testing.util.TestSyncManager import com.google.samples.apps.nowinandroid.core.testing.util.TestSyncManager
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.feature.foryou.navigation.LINKED_NEWS_RESOURCE_ID import com.google.samples.apps.nowinandroid.feature.foryou.navigation.LINKED_NEWS_RESOURCE_ID
@ -54,7 +53,6 @@ class ForYouViewModelTest {
@get:Rule @get:Rule
val mainDispatcherRule = MainDispatcherRule() val mainDispatcherRule = MainDispatcherRule()
private val networkMonitor = TestNetworkMonitor()
private val syncManager = TestSyncManager() private val syncManager = TestSyncManager()
private val userDataRepository = TestUserDataRepository() private val userDataRepository = TestUserDataRepository()
private val topicsRepository = TestTopicsRepository() private val topicsRepository = TestTopicsRepository()

@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice
plugins { plugins {
id("nowinandroid.android.feature") id("nowinandroid.android.feature")
id("nowinandroid.android.library.compose") id("nowinandroid.android.library.compose")

@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice
plugins { plugins {
id("nowinandroid.android.feature") id("nowinandroid.android.feature")
id("nowinandroid.android.library.compose") id("nowinandroid.android.library.compose")

@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import com.android.build.api.dsl.ManagedVirtualDevice
plugins { plugins {
id("nowinandroid.android.feature") id("nowinandroid.android.feature")
id("nowinandroid.android.library.compose") id("nowinandroid.android.library.compose")

@ -59,7 +59,6 @@ import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank
import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider import com.google.samples.apps.nowinandroid.core.ui.UserNewsResourcePreviewParameterProvider
import com.google.samples.apps.nowinandroid.core.ui.userNewsResourceCardItems import com.google.samples.apps.nowinandroid.core.ui.userNewsResourceCardItems
import com.google.samples.apps.nowinandroid.feature.topic.R.string import com.google.samples.apps.nowinandroid.feature.topic.R.string
import com.google.samples.apps.nowinandroid.feature.topic.TopicUiState.Loading
@Composable @Composable
internal fun TopicRoute( internal fun TopicRoute(
@ -107,7 +106,7 @@ internal fun TopicScreen(
Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing)) Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))
} }
when (topicUiState) { when (topicUiState) {
Loading -> item { TopicUiState.Loading -> item {
NiaLoadingWheel( NiaLoadingWheel(
modifier = modifier, modifier = modifier,
contentDesc = stringResource(id = string.topic_loading), contentDesc = stringResource(id = string.topic_loading),

Loading…
Cancel
Save