BinoculaRSS (pronounced /bəˈnäkyələrz/) is a feature-rich RSS reader application, still currently under development. It is built using Kotlin and Jetpack Compose.
Install Android Studio, clone the project, and open the project. Follow any prompts that Android Studio gives you about installing a JDK or Android SDK.
You can choose to run the code on a physical Android device or an Android emulator.
Ensure that ADB is installed. This is so that Android Studio can communicate with your phone. You will need to activate developer mode. For instructions on how to install ADB, see the following article.
- Enable developer mode:
- Go into
About this Phone
. - Find the
Build Number
heading, and click on it until a toast message pops up saying something along the lines ofYou are a developer
.
- Go into
- Go into developer settings (location varies by device), and enable
USB Debugging
. - In Android Studio select the
APP
build configuration, select your device from the device drop down, and press the run button.
Ensure that ADB is installed. This is so that Android Studio can communicate with the emulator. For instructions on how to install ADB, see the following article.
- Open the
AVD Manager
(Android Virtual Device Manager) - Click
Create Virtual Device
- Select any phone model and click
Next
- Click
Download
next to an Android System image from theRecommended
tab. We recommend Android R. PressFinish
. Wait for the download to complete and clickNext
. - Press
Finish
. - In Android Studio select the
APP
build configuration on the top right, select your device from the device drop down, and press the run button.
- Variables should be named in
camelCase
. - Functions should be named with
camelCase
. - Composable functions should be
PascalCase
. - Classes should be named with
PascalCase
.
For theming, refer to the MaterialTheme
package. For example, to get the primary colour, reference MaterialTheme.colorScheme.primary
. The following is a list of colours that are available:
- background
- error
- errorContainer
- inverseOnSurface
- inversePrimary
- inverseSurface
- onBackground
- onError
- onErrorContainer
- onPrimary
- onPrimaryContainer
- onSecondary
- onSecondaryContainer
- onSurface
- onSurfaceVariant
- onTertiary
- onTertiaryContainer
- outline
- primary
- primaryContainer
- secondary
- secondaryContainer
- surface
- surfaceVariant
- tertiary
- tertiaryContainer
View activities/ui.theme/*
for more MaterialTheme listing convensions.
In your Activity
classes, try and break up your composables as much as possible. Make things very modular so the average function line count remains low. Compile all of your composables into a composable function called UI
at the bottom. The outermost composable in this UI
composable should be a Surface
with color set to MaterialTheme.colorScheme.background
.
To ensure that your activity is themed in accordance to the theming standards we have put in place, adhere to the following steps:
- At the top of your activity, include the following lines to make the theming work:
private lateinit var sharedPref: SharedPreferences
private lateinit var sharedPrefEditor: SharedPreferences.Editor
private lateinit var theme: String
private lateinit var themeState: MutableState<String>
private var materialYou by Delegates.notNull<Boolean>()
private lateinit var materialYouState: MutableState<Boolean>
- Include the following code in the
onCreate
function:
setContent {
themeState = remember { mutableStateOf(theme) }
materialYouState = remember { mutableStateOf(materialYou) }
BinoculaRSSTheme(theme = themeState.value, materialYou = materialYouState.value) {
UI()
}
}
// Initialize shared preferences theme variables
sharedPref = this.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
sharedPrefEditor = sharedPref.edit()
theme = sharedPref.getString(THEME, "System Default").toString()
materialYou = sharedPref.getBoolean(MATERIAL_YOU, false)
- Include the following code in your
onResume
function:
theme = sharedPref
.getString(SettingsActivity.PreferenceKeys.THEME, "System Default")
.toString()
materialYou = sharedPref.getBoolean(SettingsActivity.PreferenceKeys.MATERIAL_YOU, false)
- At the top of your
UI
composable function, you should include the following code to make the status bar and navigation bar theming work:
// Set status bar and nav bar colours.
val systemUiController = rememberSystemUiController()
val useDarkIcons = when (theme) {
"Dark Theme" -> false
"Light Theme" -> true
else -> !isSystemInDarkTheme()
}
val color = MaterialTheme.colorScheme.background
SideEffect {
systemUiController.setSystemBarsColor(
color = color,
darkIcons = useDarkIcons
)
}