Skip to content

Commit 66611cf

Browse files
authored
Add initial project structure for credman snippets (#469)
* Add initial project structure for credman snippets * Run spotless and update gradle file
1 parent bc9dfb8 commit 66611cf

File tree

30 files changed

+537
-11
lines changed

30 files changed

+537
-11
lines changed

bluetoothle/src/main/java/com/sample/android/bluetoothle/kotlin/DeviceScanActivity.kt

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sample.android.bluetoothle.kotlin
218

319
import android.app.ListActivity
@@ -45,4 +61,4 @@ class DeviceScanActivity : ListActivity() {
4561
}
4662
}
4763
// [END start_and_stop_scan]
48-
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sample.android.bluetoothle.kotlin
218

319
import android.bluetooth.BluetoothClass
420
import android.bluetooth.BluetoothDevice
521
import android.content.Context
622
import android.widget.ArrayAdapter
723

8-
class LeDeviceListAdapter(context: Context?, layout: Int)
9-
: ArrayAdapter<BluetoothClass.Device?>(context!!, layout) {
24+
class LeDeviceListAdapter(context: Context?, layout: Int) :
25+
ArrayAdapter<BluetoothClass.Device?>(context!!, layout) {
1026

1127
fun addDevice(device: BluetoothDevice?) {
1228
// This is where you can add devices to the adapter to
1329
// show a list of discovered devices in the UI.
1430
}
15-
}
31+
}

bluetoothle/src/main/java/com/sample/android/bluetoothle/kotlin/MainActivity.kt

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.sample.android.bluetoothle.kotlin
218

319
import android.bluetooth.BluetoothAdapter

identity/credentialmanager/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.compose.compiler)
5+
}
6+
7+
android {
8+
namespace = "com.example.identity.credentialmanager"
9+
compileSdk = libs.versions.compileSdk.get().toInt()
10+
11+
defaultConfig {
12+
applicationId = "com.example.identity.credentialmanager"
13+
minSdk = libs.versions.minSdk.get().toInt()
14+
targetSdk = libs.versions.targetSdk.get().toInt()
15+
versionCode = 1
16+
versionName = "1.0"
17+
18+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19+
}
20+
21+
buildTypes {
22+
release {
23+
isMinifyEnabled = false
24+
proguardFiles(
25+
getDefaultProguardFile("proguard-android-optimize.txt"),
26+
"proguard-rules.pro"
27+
)
28+
}
29+
}
30+
compileOptions {
31+
sourceCompatibility = JavaVersion.VERSION_11
32+
targetCompatibility = JavaVersion.VERSION_11
33+
}
34+
kotlinOptions {
35+
jvmTarget = "11"
36+
}
37+
buildFeatures {
38+
compose = true
39+
}
40+
}
41+
42+
dependencies {
43+
44+
implementation(libs.androidx.core.ktx)
45+
implementation(libs.androidx.lifecycle.runtime)
46+
implementation(libs.androidx.activity.compose)
47+
implementation(platform(libs.androidx.compose.bom))
48+
implementation(libs.androidx.compose.ui)
49+
implementation(libs.androidx.compose.ui.graphics)
50+
implementation(libs.androidx.compose.ui.tooling.preview)
51+
implementation(libs.androidx.compose.material3)
52+
debugImplementation(libs.androidx.compose.ui.tooling)
53+
debugImplementation(libs.androidx.compose.ui.test.manifest)
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:supportsRtl="true"
10+
android:theme="@style/Theme.Snippets">
11+
<activity
12+
android:name=".MainActivity"
13+
android:exported="true"
14+
android:label="@string/app_name"
15+
android:theme="@style/Theme.Snippets">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
22+
class MainActivity : ComponentActivity() {
23+
override fun onCreate(savedInstanceState: Bundle?) {
24+
super.onCreate(savedInstanceState)
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager.ui.theme
18+
19+
import androidx.compose.ui.graphics.Color
20+
21+
val Purple80 = Color(0xFFD0BCFF)
22+
val PurpleGrey80 = Color(0xFFCCC2DC)
23+
val Pink80 = Color(0xFFEFB8C8)
24+
25+
val Purple40 = Color(0xFF6650a4)
26+
val PurpleGrey40 = Color(0xFF625b71)
27+
val Pink40 = Color(0xFF7D5260)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager.ui.theme
18+
19+
import android.os.Build
20+
import androidx.compose.foundation.isSystemInDarkTheme
21+
import androidx.compose.material3.MaterialTheme
22+
import androidx.compose.material3.darkColorScheme
23+
import androidx.compose.material3.dynamicDarkColorScheme
24+
import androidx.compose.material3.dynamicLightColorScheme
25+
import androidx.compose.material3.lightColorScheme
26+
import androidx.compose.runtime.Composable
27+
import androidx.compose.ui.platform.LocalContext
28+
29+
private val DarkColorScheme = darkColorScheme(
30+
primary = Purple80,
31+
secondary = PurpleGrey80,
32+
tertiary = Pink80
33+
)
34+
35+
private val LightColorScheme = lightColorScheme(
36+
primary = Purple40,
37+
secondary = PurpleGrey40,
38+
tertiary = Pink40
39+
)
40+
41+
@Composable
42+
fun SnippetsTheme(
43+
darkTheme: Boolean = isSystemInDarkTheme(),
44+
// Dynamic color is available on Android 12+
45+
dynamicColor: Boolean = true,
46+
content: @Composable () -> Unit
47+
) {
48+
val colorScheme = when {
49+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
50+
val context = LocalContext.current
51+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
52+
}
53+
54+
darkTheme -> DarkColorScheme
55+
else -> LightColorScheme
56+
}
57+
58+
MaterialTheme(
59+
colorScheme = colorScheme,
60+
typography = Typography,
61+
content = content
62+
)
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.identity.credentialmanager.ui.theme
18+
19+
import androidx.compose.material3.Typography
20+
import androidx.compose.ui.text.TextStyle
21+
import androidx.compose.ui.text.font.FontFamily
22+
import androidx.compose.ui.text.font.FontWeight
23+
import androidx.compose.ui.unit.sp
24+
25+
// Set of Material typography styles to start with
26+
val Typography = Typography(
27+
bodyLarge = TextStyle(
28+
fontFamily = FontFamily.Default,
29+
fontWeight = FontWeight.Normal,
30+
fontSize = 16.sp,
31+
lineHeight = 24.sp,
32+
letterSpacing = 0.5.sp
33+
)
34+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:endX="85.84757"
11+
android:endY="92.4963"
12+
android:startX="42.9492"
13+
android:startY="49.59793"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:fillColor="#FFFFFF"
26+
android:fillType="nonZero"
27+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>

0 commit comments

Comments
 (0)