-
Notifications
You must be signed in to change notification settings - Fork 1
Android Codebase Setup #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xleonx0x
wants to merge
22
commits into
main
Choose a base branch
from
android_setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4ad1eb0
feat: update ci pipeline to trigger based on file changes in android/ios
xleonx0x 7566550
feat(android): setup basic android codebase
xleonx0x e310ffd
chore: added separate jobs for lint, build, tests
xleonx0x dd01548
Chore: added basic colors
ff73fee
refactor: refactored the project structure
PPigeon98 4d0e173
refactor: added a tests folder
PPigeon98 2e08344
feat(android): added graphql queries and schema
xleonx0x 315736a
feat(android): added graphql client
xleonx0x 80e0d1b
feat(android): added buildings model and repository
xleonx0x 819472f
feat(android): added simple building screen and view model
xleonx0x 8ad7b34
feat(android): added main UI entry
xleonx0x a61d9c2
chore(android): added gradle dependencies
xleonx0x bd16479
chore(android): removed Koin library, to now use manual dependency in…
xleonx0x 7d50b60
Merge branch 'main' of github.com:devsoc-unsw/freerooms-mobile into a…
xleonx0x 708d2a7
chore(android): ran formatter and fixed linting
xleonx0x 403c990
chore(android): fix ci
xleonx0x 9adb4e3
chore(android): fix test by mocking apollo exception
xleonx0x f66a4ce
feat: created proper icons for the app
PPigeon98 82a8dbf
chore: remove random .idea folder
xleonx0x eb919f1
refactor(android): split into multi-module app
xleonx0x 54b7e79
chore(android): run formatter
xleonx0x 9bc3c8f
feat(android): add git hooks for android codebase
xleonx0x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Android CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'android/**' | ||
| - '.github/workflows/android.yml' | ||
|
|
||
| jobs: | ||
| Lint: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: android | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
| cache: gradle | ||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
| - name: Run Linter and Formatter | ||
| run: ./gradlew detekt && ./gradlew ktfmtCheck | ||
| Build: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: android | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
| cache: gradle | ||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
| - name: Build Apk | ||
| run: ./gradlew assembleDebug | ||
| Tests: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: android | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
| cache: gradle | ||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
| - name: Run Tests | ||
| run: ./gradlew test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| *.iml | ||
| .gradle | ||
| /local.properties | ||
| /.idea/caches | ||
| /.idea/libraries | ||
| /.idea/modules.xml | ||
| /.idea/workspace.xml | ||
| /.idea/navEditor.xml | ||
| /.idea/assetWizardSettings.xml | ||
| .DS_Store | ||
| /build | ||
| /captures | ||
| .externalNativeBuild | ||
| .cxx | ||
| local.properties | ||
| # Gradle files | ||
| .gradle/ | ||
| build/ | ||
|
|
||
| # Local configuration file (sdk path, etc) | ||
| local.properties | ||
|
|
||
| # Log/OS Files | ||
| *.log | ||
|
|
||
| # Android Studio generated files and folders | ||
| captures/ | ||
| .externalNativeBuild/ | ||
| .cxx/ | ||
| *.aab | ||
| *.apk | ||
| output-metadata.json | ||
|
|
||
| # IntelliJ | ||
| *.iml | ||
| .idea/ | ||
| misc.xml | ||
| deploymentTargetDropDown.xml | ||
| render.experimental.xml | ||
|
|
||
| # Keystore files | ||
| *.jks | ||
| *.keystore | ||
|
|
||
| # Google Services (e.g. APIs or Firebase) | ||
| google-services.json | ||
|
|
||
| # Android Profiling | ||
| *.hprof |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| plugins { | ||
| alias(libs.plugins.android.application) | ||
| alias(libs.plugins.kotlin.compose) | ||
| id("dev.detekt") version ("2.0.0-alpha.2") | ||
| } | ||
|
|
||
| detekt { | ||
| buildUponDefaultConfig = true | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.devsoc.freerooms" | ||
| compileSdk = 36 | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.devsoc.freerooms" | ||
| minSdk = 29 | ||
| targetSdk = 36 | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_11 | ||
| targetCompatibility = JavaVersion.VERSION_11 | ||
| } | ||
|
|
||
| buildFeatures { | ||
| compose = true | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(project(":core:ui")) | ||
| implementation(project(":core:network")) | ||
| implementation(project(":feature:buildings")) | ||
| implementation(project(":feature:rooms")) | ||
|
|
||
| implementation(libs.androidx.core.ktx) | ||
| implementation(libs.androidx.lifecycle.runtime.ktx) | ||
| implementation(libs.androidx.activity.compose) | ||
| implementation(platform(libs.androidx.compose.bom)) | ||
| implementation(libs.androidx.compose.ui) | ||
| implementation(libs.androidx.compose.ui.graphics) | ||
| implementation(libs.androidx.compose.ui.tooling.preview) | ||
| implementation(libs.androidx.compose.material3) | ||
| implementation(libs.androidx.lifecycle.viewmodel.compose) | ||
|
|
||
| implementation(platform(libs.okhttp.bom)) | ||
| implementation(libs.okhttp) | ||
| implementation(libs.okhttp.logging) | ||
|
|
||
| detektPlugins(libs.detekt.compose.rules) | ||
|
|
||
| debugImplementation(libs.androidx.compose.ui.tooling) | ||
| debugImplementation(libs.androidx.compose.ui.test.manifest) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Add project specific ProGuard rules here. | ||
| # You can control the set of applied configuration files using the | ||
| # proguardFiles setting in build.gradle. | ||
| # | ||
| # For more details, see | ||
| # http://developer.android.com/guide/developing/tools/proguard.html | ||
|
|
||
| # If your project uses WebView with JS, uncomment the following | ||
| # and specify the fully qualified class name to the JavaScript interface | ||
| # class: | ||
| #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| # public *; | ||
| #} | ||
|
|
||
| # Uncomment this to preserve the line number information for | ||
| # debugging stack traces. | ||
| #-keepattributes SourceFile,LineNumberTable | ||
|
|
||
| # If you keep the line number information, uncomment this to | ||
| # hide the original source file name. | ||
| #-renamesourcefileattribute SourceFile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools"> | ||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
|
||
| <application | ||
| android:name=".MainApplication" | ||
| android:allowBackup="true" | ||
| android:dataExtractionRules="@xml/data_extraction_rules" | ||
| android:fullBackupContent="@xml/backup_rules" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="@string/app_name" | ||
| android:roundIcon="@mipmap/ic_launcher_round" | ||
| android:supportsRtl="true" | ||
| android:theme="@style/Theme.Freerooms"> | ||
| <activity | ||
| android:name=".MainActivity" | ||
| android:exported="true" | ||
| android:theme="@style/Theme.Freerooms"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
|
|
||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
|
|
||
| </manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/com/devsoc/freerooms/AppContainer.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.devsoc.freerooms | ||
|
|
||
| import android.util.Log | ||
| import com.apollographql.apollo.ApolloClient | ||
| import com.apollographql.apollo.network.okHttpClient | ||
| import com.devsoc.freerooms.core.network.LiveGraphQLClient | ||
| import com.devsoc.freerooms.core.network.NetworkConstants | ||
| import com.devsoc.freerooms.feature.buildings.data.LiveBuildingRepository | ||
| import okhttp3.OkHttpClient | ||
| import okhttp3.logging.HttpLoggingInterceptor | ||
|
|
||
| class AppContainer { | ||
|
|
||
| private val okHttpClient = OkHttpClient.Builder() | ||
| .addInterceptor(HttpLoggingInterceptor { message -> | ||
| Log.d("OkHttp", message) | ||
| }.apply { | ||
| level = HttpLoggingInterceptor.Level.BODY | ||
| }) | ||
| .build() | ||
|
|
||
| private val apolloClient = ApolloClient.Builder() | ||
| .serverUrl(NetworkConstants.SERVER_URL) | ||
| .okHttpClient(okHttpClient) | ||
| .build() | ||
|
|
||
| private val graphQLClient = LiveGraphQLClient(apolloClient) | ||
|
|
||
| val buildingRepository = LiveBuildingRepository(graphQLClient) | ||
| } |
26 changes: 26 additions & 0 deletions
26
android/app/src/main/java/com/devsoc/freerooms/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.devsoc.freerooms | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.activity.ComponentActivity | ||
| import androidx.activity.compose.setContent | ||
| import androidx.activity.enableEdgeToEdge | ||
| import androidx.activity.viewModels | ||
| import com.devsoc.freerooms.core.ui.FreeroomsTheme | ||
| import com.devsoc.freerooms.feature.buildings.ui.BuildingScreen | ||
|
|
||
| class MainActivity : ComponentActivity() { | ||
|
|
||
| private val buildingViewModel by viewModels<com.devsoc.freerooms.feature.buildings.data.BuildingViewModel> { | ||
| MainApplication.BuildingViewModelFactory | ||
| } | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| enableEdgeToEdge() | ||
| setContent { | ||
| FreeroomsTheme { | ||
| BuildingScreen(viewModel = buildingViewModel) | ||
| } | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
android/app/src/main/java/com/devsoc/freerooms/MainApplication.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.devsoc.freerooms | ||
|
|
||
| import android.app.Application | ||
| import androidx.lifecycle.ViewModelProvider | ||
| import androidx.lifecycle.viewmodel.initializer | ||
| import androidx.lifecycle.viewmodel.viewModelFactory | ||
| import com.devsoc.freerooms.feature.buildings.data.BuildingViewModel | ||
|
|
||
| class MainApplication : Application() { | ||
| val appContainer = AppContainer() | ||
|
|
||
| companion object { | ||
| val BuildingViewModelFactory = viewModelFactory { | ||
| initializer { | ||
| val application = (this[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY] as MainApplication) | ||
| val repository = application.appContainer.buildingRepository | ||
| BuildingViewModel(repository = repository) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="147dp" | ||
| android:height="236dp" | ||
| android:viewportWidth="147" | ||
| android:viewportHeight="236"> | ||
| <path | ||
| android:pathData="M91,0L0,52L14,60L105,8L91,0Z" | ||
| android:fillColor="#F1915B"/> | ||
| <path | ||
| android:pathData="M91,32L84,36L140,68L147,64L105,40L91,32Z" | ||
| android:fillColor="#F1915B"/> | ||
| <path | ||
| android:pathData="M105,8L14,60V236L28,228V220V68L77,40L84,36L91,32L105,40V8Z" | ||
| android:fillColor="#B5512F"/> | ||
| <path | ||
| android:pathData="M14,60L0,52V228L14,236V60Z" | ||
| android:fillColor="#94442A"/> | ||
| <path | ||
| android:pathData="M147,224V64L140,68V228L147,224Z" | ||
| android:fillColor="#B5512F"/> | ||
| <path | ||
| android:pathData="M77,192L140,228V68L84,36L77,40V192ZM91,112V64L98,68L105,72L119,80V120V128L105,120L91,112ZM120.37,156.83C117.79,158.47 114.04,157.21 112,154C109.96,150.79 110.4,146.86 112.99,145.22C113.11,145.14 113.24,145.07 113.36,145.01L116.37,143.29C118.96,141.65 122.7,142.91 124.74,146.12C126.78,149.32 126.34,153.26 123.75,154.9L120.37,156.83Z" | ||
| android:fillColor="#D4613C" | ||
| android:fillType="evenOdd"/> | ||
| <path | ||
| android:pathData="M112,154C114.04,157.21 117.79,158.47 120.37,156.83C122.96,155.19 123.4,151.26 121.36,148.05C119.42,144.99 115.92,143.7 113.36,145.01L112.99,145.22C110.4,146.86 109.96,150.79 112,154Z" | ||
| android:fillColor="#E39345"/> | ||
| <path | ||
| android:pathData="M121.36,148.05C123.4,151.26 122.96,155.19 120.37,156.83L123.75,154.9C126.34,153.26 126.78,149.32 124.74,146.12C122.7,142.91 118.96,141.65 116.37,143.29L113.36,145.01C115.92,143.7 119.42,144.99 121.36,148.05Z" | ||
| android:fillColor="#F9AA53"/> | ||
| <path | ||
| android:pathData="M91,64V112L98,108V68L91,64Z" | ||
| android:fillColor="#9EAEB6"/> | ||
| <path | ||
| android:pathData="M98,108L91,112L105,120V112L98,108Z" | ||
| android:fillColor="#AFC0C8"/> | ||
| <path | ||
| android:pathData="M98,68V108L105,112V72L98,68Z" | ||
| android:fillColor="#BBD6E3"/> | ||
| <path | ||
| android:pathData="M98,68V108L105,112V72L98,68Z" | ||
| android:fillColor="#B5512F" | ||
| android:fillAlpha="0.2"/> | ||
| <path | ||
| android:pathData="M119,120V80L105,72V112L119,120Z" | ||
| android:fillColor="#BBD6E3"/> | ||
| <path | ||
| android:pathData="M119,128V120L105,112V120L119,128Z" | ||
| android:fillColor="#AFC0C8"/> | ||
| </vector> |
10 changes: 10 additions & 0 deletions
10
android/app/src/main/res/drawable/ic_launcher_background.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="108dp" | ||
| android:height="108dp" | ||
| android:viewportWidth="108" | ||
| android:viewportHeight="108"> | ||
| <path | ||
| android:fillColor="#FFFFFF" | ||
| android:pathData="M0,0h108v108h-108z" /> | ||
| </vector> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.