Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ plugins {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
compileSdk 33

defaultConfig {
applicationId "com.example.wordsapp"
minSdkVersion 19
targetSdkVersion 30
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -50,7 +49,7 @@ android {
}

buildFeatures {
viewBinding = true
viewBinding true
}
}

Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.wordsapp">

<application
Expand All @@ -23,8 +24,11 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Words">
<activity android:name=".MainActivity">
android:theme="@style/Theme.Words"
tools:ignore="AllowBackup">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/example/wordsapp/LetterAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/
package com.example.wordsapp

import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.Button
import androidx.annotation.RequiresApi
import androidx.navigation.findNavController
import androidx.recyclerview.widget.RecyclerView

Expand All @@ -38,7 +36,7 @@ class LetterAdapter :
* Provides a reference for the views needed to display items in your list.
*/
class LetterViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
val button = view.findViewById<Button>(R.id.button_item)
val button: Button = view.findViewById(R.id.button_item)
}

override fun getItemCount(): Int {
Expand All @@ -62,7 +60,7 @@ class LetterAdapter :
* Replaces the content of an existing view with new data
*/
override fun onBindViewHolder(holder: LetterViewHolder, position: Int) {
val item = list.get(position)
val item = list[position]
holder.button.text = item.toString()

// Assigns a [OnClickListener] to the button contained in the [ViewHolder]
Expand All @@ -78,23 +76,19 @@ class LetterAdapter :
// Setup custom accessibility delegate to set the text read with
// an accessibility service
companion object Accessibility : View.AccessibilityDelegate() {
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfo?
) {
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(host, info)
// With `null` as the second argument to [AccessibilityAction], the
// accessibility service announces "double tap to activate".
// If a custom string is provided,
// it announces "double tap to <custom string>".
val customString = host?.context?.getString(R.string.look_up_words)
val customString = host.context?.getString(R.string.look_up_words)
val customClick =
AccessibilityNodeInfo.AccessibilityAction(
AccessibilityNodeInfo.ACTION_CLICK,
customString
)
info?.addAction(customClick)
info.addAction(customClick)
}
}
}
12 changes: 3 additions & 9 deletions app/src/main/java/com/example/wordsapp/LetterListFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
package com.example.wordsapp

import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.*
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -52,11 +47,10 @@ class LetterListFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
// Retrieve and inflate the layout for this fragment
_binding = FragmentLetterListBinding.inflate(inflater, container, false)
val view = binding.root
return view
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/example/wordsapp/WordAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ package com.example.wordsapp
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.Button
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.RecyclerView

/**
* Adapter for the [RecyclerView] in [DetailActivity].
* Adapter for the [RecyclerView] in [WordListFragment].
*/
class WordAdapter(private val letterId: String, context: Context) :
RecyclerView.Adapter<WordAdapter.WordViewHolder>() {
Expand All @@ -53,7 +51,7 @@ class WordAdapter(private val letterId: String, context: Context) :
}

class WordViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
val button = view.findViewById<Button>(R.id.button_item)
val button: Button = view.findViewById(R.id.button_item)
}

override fun getItemCount(): Int = filteredWords.size
Expand Down Expand Up @@ -95,23 +93,19 @@ class WordAdapter(private val letterId: String, context: Context) :
// Setup custom accessibility delegate to set the text read with
// an accessibility service
companion object Accessibility : View.AccessibilityDelegate() {
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfo?
) {
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(host, info)
// With `null` as the second argument to [AccessibilityAction], the
// accessibility service announces "double tap to activate".
// If a custom string is provided,
// it announces "double tap to <custom string>".
val customString = host?.context?.getString(R.string.look_up_word)
val customString = host.context?.getString(R.string.look_up_word)
val customClick =
AccessibilityNodeInfo.AccessibilityAction(
AccessibilityNodeInfo.ACTION_CLICK,
customString
)
info?.addAction(customClick)
info.addAction(customClick)
}
}
}
10 changes: 6 additions & 4 deletions app/src/main/java/com/example/wordsapp/WordListFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.wordsapp.databinding.FragmentWordListBinding

/**
Expand All @@ -35,8 +36,8 @@ class WordListFragment : Fragment() {
* a DetailListFragment instance.
*/
companion object {
val LETTER = "letter"
val SEARCH_PREFIX = "https://www.google.com/search?q="
const val LETTER = "letter"
const val SEARCH_PREFIX = "https://www.google.com/search?q="
}

private var _binding: FragmentWordListBinding? = null
Expand All @@ -45,6 +46,7 @@ class WordListFragment : Fragment() {
// onDestroyView.
private val binding get() = _binding!!

private lateinit var recyclerView: RecyclerView
private lateinit var letterId: String

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -60,14 +62,14 @@ class WordListFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
// Retrieve and inflate the layout for this fragment
_binding = FragmentWordListBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val recyclerView = binding.recyclerView
recyclerView = binding.recyclerView
recyclerView.layoutManager = LinearLayoutManager(requireContext())
recyclerView.adapter = WordAdapter(letterId, requireContext())

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_letter_list.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2020 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/letterListFragment">

<fragment
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<item name="colorSecondary">@color/blue_200</item>
<item name="colorSecondaryVariant">@color/blue_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

<color name="blue_200">#62A3FF</color>
<color name="blue_700">#1675D1</color>
<color name="blue_900">#004A9F</color>

<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
-->
<resources>
<string name="app_name">Words</string>
<string name="detail_prefix">Words That Start With</string>
<string name="action_switch_layout">Switch Layout</string>
<string name="look_up_word">Look up word in a Browser Search</string>
<string name="look_up_words">Show Stored Words</string>
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/res/values/styles.xml

This file was deleted.

18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
appcompat_version = "1.2.0"
constraintlayout_version = "2.0.2"
core_ktx_version = "1.3.2"
kotlin_version = "1.5.30"
material_version = "1.2.1"
nav_version = "2.3.1"
appcompat_version = "1.4.2"
constraintlayout_version = "2.1.4"
core_ktx_version = "1.8.0"
kotlin_version = "1.7.10"
material_version = "1.6.1"
nav_version = '2.5.1'
lifecycle_version = "2.3.1"
datastore_version = "1.0.0"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"

Expand All @@ -42,7 +42,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip