Skip to content

Commit

Permalink
Merge pull request #54 from mutualmobile/feat/mobile-sample-app
Browse files Browse the repository at this point in the history
Implement Mobile Sample App
  • Loading branch information
shubhamsinghmutualmobile authored May 2, 2023
2 parents dd9961a + 1624c34 commit d6feaa1
Show file tree
Hide file tree
Showing 52 changed files with 1,113 additions and 235 deletions.
2 changes: 2 additions & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {
val jUnitVersion = "4.13.2"
val androidJUnitVersion = "1.1.5"
val espressoVersion = "3.5.1"
val splashScreenVersion = "1.0.1"

implementation(project(mapOf("path" to ":composesensors")))
implementation("androidx.core:core-ktx:$coreKtxVersion")
Expand All @@ -75,4 +76,5 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
implementation("androidx.core:core-splashscreen:$splashScreenVersion")
}
6 changes: 4 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ComposeSensors"
android:theme="@style/Theme.App.Starting"
tools:targetApi="31">
<activity
android:name="com.mutualmobile.sample.MainActivity"
android:exported="true"
android:theme="@style/Theme.ComposeSensors">
android:screenOrientation="portrait"
android:theme="@style/Theme.App.Starting"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file added sample/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 8 additions & 28 deletions sample/src/main/java/com/mutualmobile/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,29 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.mutualmobile.composesensors.rememberAccelerometerSensorState
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.mutualmobile.sample.ui.screens.sensorlist.SensorsListScreen
import com.mutualmobile.sample.ui.theme.ComposeSensorsTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

WindowCompat.setDecorFitsSystemWindows(window, false)

setContent {
ComposeSensorsTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val accelerometerState = rememberAccelerometerSensorState()
Text(
text = "Force X: ${accelerometerState.xForce}" +
"\nForce Y: ${accelerometerState.yForce}" +
"\nForce Z: ${accelerometerState.zForce}" +
"\nIs Available?: ${accelerometerState.isAvailable}," +
"\nAccuracy?: ${accelerometerState.accuracy}"
)
SensorsListScreen()
}
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
ComposeSensorsTheme {
Greeting("Android")
}
}
Loading

0 comments on commit d6feaa1

Please sign in to comment.