Skip to content

Commit 3fa2da5

Browse files
Merge pull request #22 from flyingfish162/main
Update tutorials against BTP Android SDK 24.12.0
2 parents f88ada5 + 0e32196 commit 3fa2da5

File tree

70 files changed

+1263
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1263
-227
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
-10.6 KB
Loading
6.85 KB
Loading
Binary file not shown.

tutorials/sdk-android-wizard-app-customize/sdk-android-wizard-app-customize.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,31 @@ In this section, you will configure the object cell to display a product's name,
6868

6969
1. In Android Studio, on Windows, press **`Ctrl+shift+N`**, or on a Mac, press **`command+shift+O`**. Type **`ProductEntitiesScreen`** to open `ProductEntitiesScreen.kt`.
7070

71-
2. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`viewModel.getEntityTitle(entity)`** to navigate to the line `headline = viewModel.getEntityTitle(entity),`. Change this line to `headline = entity.getOptionalValue(Product.name).toString(),`. This will display the product name as the headline value of the object cell.
71+
2. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`viewModel.getEntityTitle(entity)`** to navigate to the line `setHeadline(viewModel.getEntityTitle(entity))`. Change this line to `setHeadline(entity.getOptionalValue(Product.name).toString())`. This will display the product name as the headline value of the object cell.
7272

7373
If the class `Product` appears in red, it indicates that Android Studio could not locate the class. Select the class, and on Windows press **`Alt+Enter`**, or on a Mac, press **`option+return`** to use Android Studio's quick fix to add the missing imports.
7474

75-
Alternatively, you can enable the following setting: Windows: **Settings**; Mac: **Android Studio > Settings...**
75+
Alternatively, you can open the settings screen: Windows: **Settings**; Mac: **Android Studio > Settings...**. Then go to **Editor > General > Auto Import**, enable **Add unambiguous imports on the fly** in the `Kotlin` section.
7676

77-
![Add unambiguous imports on the fly](auto-import-kotlin.png)
78-
79-
3. In the same code block, replace `subheadline` and `footnote`, and add `status` with the following code, which will display the category, description, and price.
77+
3. In the same code block, replace `setSubheadline` and `setFootnote`, and add `setStatusInfoLabel` with the following code, which will display the category, description, and price.
8078

8179
```Kotlin
82-
subheadline = entity.getDataValue(Product.category).toString(),
83-
footnote = entity.getDataValue(Product.shortDescription).toString(),
84-
status = FioriObjectCellStatusData(
85-
label = "$ ${entity.getDataValue(Product.price).toString()}"
86-
),
80+
setSubheadline(entity.getDataValue(Product.category).toString())
81+
setFootnote(entity.getDataValue(Product.shortDescription).toString())
82+
setStatusInfoLabel(
83+
FioriStatusInfoLabelDataInOC(
84+
items = listOf(
85+
FioriLabelItemData(
86+
label = "$ ${entity.getDataValue(Product.price).toString()}"
87+
)
88+
)
89+
)
90+
)
8791
```
8892

8993
4. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`FioriObjectCell`** to navigate to the `FioriObjectCell` invocation.
9094

91-
5. Add the following code right after `FioriObjectCell`, and add it right before `if (entities.loadState.refresh == LoadState.Loading)`, to add a divider between the product items.
95+
5. Add the following code right after `FioriObjectCell` invocation, and add it right before `if (entities.loadState.refresh == LoadState.Loading)` at the same time, to add a divider between the product items.
9296

9397
```Kotlin
9498
FioriDivider()
@@ -165,9 +169,7 @@ In this section, you will configure the object cell to display a product's name,
165169

166170
If the classes `LinearLayoutManager` and `DividerItemDecoration` appear in red, it indicates that Android Studio could not locate them. Select each class, and on Windows, press **`Alt+Enter`**, or on a Mac, press **`option+return`** to use Android Studio's quick fix to add the missing imports.
167171

168-
Alternatively, you can enable the following setting: Windows: **Settings**; Mac: **Android Studio > Settings...**
169-
170-
![Add unambiguous imports on the fly](auto-import-kotlin.png)
172+
Alternatively, you can enable the following setting: Windows: **Settings**; Mac: **Android Studio > Settings...**. Then go to **Editor > General > Auto Import**, enable **Add unambiguous imports on the fly** in the `Kotlin` section.
171173

172174
6. On Windows, press **`Ctrl+N`**, or on a Mac, press **`command+O`**, and type **`Repository`** to open `Repository.kt`.
173175

@@ -223,7 +225,7 @@ In this section, you will update the screen's title, configure the object cell t
223225

224226
7. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`FioriObjectCell`** to navigate to the `FioriObjectCell` invocation.
225227

226-
8. Add the following code right after `FioriObjectCell` and add it right before `if (entities.loadState.refresh == LoadState.Loading)`, which adds a divider between categories:
228+
8. Add the following code right after `FioriObjectCell` invocation and add it right before `if (entities.loadState.refresh == LoadState.Loading)` at the same time, which adds a divider between categories:
227229

228230
```Kotlin
229231
FioriDivider()
@@ -234,14 +236,20 @@ In this section, you will update the screen's title, configure the object cell t
234236
10. Replace the value of `objectCellData` with the following to display the main category instead, hide the footnote, and show the number of products per category.
235237

236238
```Kotlin
237-
val objectCellData = FioriObjectCellData(
238-
headline = viewModel.getEntityTitle(entity),
239-
subheadline = entity.getDataValue(ProductCategory.mainCategoryName).toString(),
240-
avatar = avatar,
241-
status = FioriObjectCellStatusData(
242-
label = "${entity.getDataValue(ProductCategory.numberOfProducts).toString()} Products"
239+
val objectCellData = FioriObjectCellData.Builder().apply {
240+
setHeadline(viewModel.getEntityTitle(entity))
241+
setSubheadline(entity.getDataValue(ProductCategory.mainCategoryName).toString())
242+
setAvatar(avatar)
243+
setStatusInfoLabel(
244+
FioriStatusInfoLabelDataInOC(
245+
items = listOf(
246+
FioriLabelItemData(
247+
label = "${entity.getDataValue(ProductCategory.numberOfProducts).toString()} Products"
248+
)
249+
)
250+
)
243251
)
244-
).apply { setDisplayReadIndicator(false) }
252+
}.build()
245253
```
246254

247255
11. Run the app again. You'll see that the **title**, **subheadline**, and **status** are now displayed, while the **icon** and **footnote** are no longer visible.
@@ -366,7 +374,9 @@ In this section, you will modify the app to initially show the **Product Categor
366374

367375
3. On Windows, press **`Ctrl+N`**, or on a Mac, press **`command+O`**, and type **`ODataViewModel`**, to open `ODataViewModel.kt`.
368376

369-
4. Replace the `onFloatingAdd` function with the following code:
377+
4. On Windows, press **`Ctrl+F12`**, or on a Mac, press **`command+F12`**, and type **`onFloatingAdd`**, to navigate to `onFloatingAdd` method.
378+
379+
5. Replace the `onFloatingAdd` function with the following code:
370380

371381
```Kotlin
372382
//return create action when nav property value is list type or null, or entitySet is singleton and entity screen is not empty
@@ -389,15 +399,15 @@ In this section, you will modify the app to initially show the **Product Categor
389399
}
390400
```
391401

392-
5. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ProductEntitiesScreen`**, to open `ProductEntitiesScreen.kt`.
402+
6. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ProductEntitiesScreen`**, to open `ProductEntitiesScreen.kt`.
393403

394-
6. Add a variable to retrive the selected category name from `ODataViewModel`:
404+
7. Add a variable in the method body to retrive the selected category name from `ODataViewModel`:
395405

396406
```Kotlin
397407
val category = (viewModel.parent as? ProductCategory)?.categoryName
398408
```
399409

400-
7. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`return@items`** to locate the line `val entity = entities[index] ?: return@items`. Immediately after this line, add the following code to filter the products list to display only the products for the selected category:
410+
8. On Windows, press **`Ctrl+F`**, or on a Mac, press **`command+F`**, and type **`return@items`** to locate the line `val entity = entities[index] ?: return@items`. Immediately after this line, add the following code to filter the products list to display only the products for the selected category:
401411

402412
```Kotlin
403413
category?.also {
@@ -407,9 +417,9 @@ In this section, you will modify the app to initially show the **Product Categor
407417
}
408418
```
409419

410-
8. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ODataNavHost`**, to open `ODataNavHost.kt`.
420+
9. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ODataNavHost`**, to open `ODataNavHost.kt`.
411421

412-
9. Replace the `if (!uiState.isEntityFocused)` block with the following:
422+
10. Replace the `if (!uiState.isEntityFocused)` block with the following:
413423

414424
```Kotlin
415425
if (!uiState.isEntityFocused) {
@@ -434,7 +444,7 @@ In this section, you will modify the app to initially show the **Product Categor
434444

435445
You can navigate to the **EntityList** screen by pressing the **Back** button on the **Product Categories** screen. The **EntityList** screen retains the **Settings** menu for convenience.
436446

437-
10. Replace the `EntityOperationType.DETAIL` code block with the following, which will enable the navigation from the Category list screen to the Product list screen.
447+
11. Replace the `EntityOperationType.DETAIL` code block with the following, which will enable the navigation from the Category list screen to the Product list screen.
438448

439449
```Kotlin
440450
EntityOperationType.DETAIL -> if (viewModel.entityType == ESPMContainerMetadata.EntityTypes.productCategory) {
@@ -454,7 +464,7 @@ In this section, you will modify the app to initially show the **Product Categor
454464
}
455465
```
456466

457-
11. Replace the `viewModel` of `composable(route = EntityNavigationCommands(entityType).entityListNav.route)` with the following `viewModel` so that the product screen can retrieve the selected category name:
467+
12. Replace the `viewModel` of `composable(route = EntityNavigationCommands(entityType).entityListNav.route)` with the following `viewModel` so that the product screen can retrieve the selected category name:
458468

459469
```Kotlin
460470
val viewModel: ODataViewModel = viewModel(
@@ -472,19 +482,19 @@ In this section, you will modify the app to initially show the **Product Categor
472482
)
473483
```
474484

475-
12. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ProductCategoryEntitiesScreen`**, to open `ProductCategoryEntitiesScreen.kt`.
485+
13. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`ProductCategoryEntitiesScreen`**, to open `ProductCategoryEntitiesScreen.kt`.
476486

477-
13. Set `floatingActionClick` in `OperationScreenSettings` of `OperationScreen` to **`null`** instead of `viewModel.onFloatingAdd()`.
487+
14. Set `floatingActionClick` in `OperationScreenSettings` of `OperationScreen` to **`null`** instead of `viewModel.onFloatingAdd()`.
478488

479-
14. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`EntityScreenCommonUI`**, to open `EntityScreenCommonUI.kt`.
489+
15. On Windows, press **`Ctrl+Shift+N`**, or on a Mac, press **`command+Shift+O`**, and type **`EntityScreenCommonUI`**, to open `EntityScreenCommonUI.kt`.
480490

481-
15. Find the `ActionItem` of `R.string.menu_home` and change its overflowMode to the following:
491+
16. Find the `ActionItem` of `R.string.menu_home` and change its overflowMode to the following:
482492

483493
```Kotlin
484494
overflowMode = if(viewModel.entityType == ESPMContainerMetadata.EntityTypes.productCategory) OverflowMode.NOT_SHOWN else OverflowMode.IF_NECESSARY,
485495
```
486496

487-
16. Run the app again. You'll see that the **Product Categories** screen is now the first screen displayed, the **Home** menu is no longer visible, and selecting a category shows the products list screen, which now displays only the products for that selected category.
497+
17. Run the app again. You'll see that the **Product Categories** screen is now the first screen displayed, the **Home** menu is no longer visible, and selecting a category shows the products list screen, which now displays only the products for that selected category.
488498

489499
![Product category list screen](reformatted-product-category-list2-jc.png)
490500

@@ -585,8 +595,6 @@ In this section you will add a search field to **Product Categories** screen, al
585595

586596
1. First, right-click the `res/drawable` folder to create a new **Drawable Resource File** **`ic_search_icon.xml`**, and use the following XML content.
587597

588-
![Create a new Drawable Resource File](create-new-drawable-resource-file.png)
589-
590598
```XML
591599
<?xml version="1.0" encoding="utf-8"?>
592600
<vector xmlns:android="http://schemas.android.com/apk/res/android"
@@ -765,8 +773,6 @@ In this section you will add a search field to **Product Categories** screen, al
765773

766774
1. First, right-click the `res/drawable` folder to create a new **Drawable Resource File** **`ic_search_icon.xml`**, and use the following XML content.
767775

768-
![Create a new Drawable Resource File](create-new-drawable-resource-file.png)
769-
770776
```XML
771777
<?xml version="1.0" encoding="utf-8"?>
772778
<vector xmlns:android="http://schemas.android.com/apk/res/android"
@@ -784,8 +790,6 @@ In this section you will add a search field to **Product Categories** screen, al
784790

785791
2. Right-click the `res/menu` folder to add a new **Menu Resource File** named **`product_categories_menu.xml`**, and use the following XML for its contents.
786792

787-
![Add a new Menu Resource File](add-new-menu-resource-file.png)
788-
789793
```XML
790794
<?xml version="1.0" encoding="utf-8"?>
791795
<menu xmlns:android="http://schemas.android.com/apk/res/android"
@@ -892,9 +896,7 @@ In this section, you will add a Top Products section to the **Products** screen,
892896

893897
First, we'll generate additional sales data in the sample OData service.
894898

895-
1. In **SAP Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **com.sap.wizapp** and go to **Mobile Sample OData ESPM**.
896-
897-
![Sample OData feature on Mobile Services](sample-odata-feature.png)
899+
1. In **SAP Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **btp.sdk.wizapp** and go to **Sample OData ESPM**.
898900

899901
2. Change the **Entity Sets** dropdown to **`SalesOrderItems`** and then click the **generate sample sales orders** icon five times. This will create additional sales order items, which we can use to base our top products on, based on the quantity sold.
900902

@@ -1050,9 +1052,7 @@ In this section, you will add a Top Products section to the **Products** screen,
10501052

10511053
First, we'll generate additional sales data in the sample OData service.
10521054

1053-
1. In **SAP Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/Hybrid** > **com.sap.wizapp** and go to **Mobile Sample OData ESPM**.
1054-
1055-
![Sample OData feature on Mobile Services](sample-odata-feature.png)
1055+
1. In **SAP Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/Hybrid** > **btp.sdk.wizapp** and go to **Sample OData ESPM**.
10561056

10571057
2. Change the **Entity Sets** dropdown to **`SalesOrderItems`** and then click the **generate sample sales orders** icon five times. This will create additional sales order items, which we can use to base our top products on, based on the quantity sold.
10581058

-17.3 KB
Loading

tutorials/sdk-android-wizard-app-logging/sdk-android-wizard-app-logging.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ time: 15
104104
105105
5. Navigate back to the entity list screen, then back into the **Settings** screen to see the effect of changing the log level.
106106
107-
![Settings menu opened](settings_menu_jc.png)
108-
109107
6. Examine the **Logcat** (located at the bottom of the Android Studio screen, click it and you can see the logs). In the filter, add the name of the class that we are interested in seeing the log from: **`com.sap.wizapp.ui.odata.viewmodel.SettingsViewModel`**.
110108
111109
Notice that the messages were logged since the log level of the app was set to **Debug** or **Path**.
@@ -138,8 +136,6 @@ The SDK libraries also log output based on the app's log level.
138136
139137
5. Navigate back to the entity list screen, then back into the **Settings** screen to see the effect of changing the log level.
140138
141-
![Settings menu opened](settings_menu.png)
142-
143139
6. Examine the **Logcat** (located at the bottom of the Android Studio screen, click it and you can see the logs). In the filter, add the name of the class that we are interested in seeing the log from: **`com.sap.wizapp.mdui.EntitySetListActivity`**.
144140
145141
Notice that the messages were logged since the log level of the app was set to **Debug** or **Path**.
@@ -169,9 +165,9 @@ The SDK libraries also log output based on the app's log level.
169165

170166
![Log upload succeeded](log_uploaded_jc.png)
171167

172-
2. In the **Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **com.sap.wizapp** > **Mobile Client Log Upload**.
168+
2. In the **Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **btp.sdk.wizapp** > **Client Log Upload**.
173169

174-
![Mobile Applications > Native/MDK > com.sap.wizapp > Mobile Client Log Upload](select_and_download_log.png)
170+
![Mobile Applications > Native/MDK > btp.sdk.wizapp > Client Log Upload](select_and_download_log.png)
175171

176172
3. Select the **Error Logs** tab and you will see the log you just uploaded in the **Error** level list. If the log doesn't appear immediately, wait for a few moments, then click **Go** to refresh the view.
177173
@@ -199,9 +195,9 @@ The SDK libraries also log output based on the app's log level.
199195
200196
![Log upload succeeded](log_uploaded.png)
201197
202-
2. In the **Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **com.sap.wizapp** > **Mobile Client Log Upload**.
198+
2. In the **Mobile Services cockpit**, navigate to **Mobile Applications** > **Native/MDK** > **btp.sdk.wizapp** > **Client Log Upload**.
203199
204-
![Mobile Applications > Native/MDK > com.sap.wizapp > Mobile Client Log Upload](select_and_download_log.png)
200+
![Mobile Applications > Native/MDK > btp.sdk.wizapp > Client Log Upload](select_and_download_log.png)
205201
206202
3. Select the **Error Logs** tab and you will see the log you just uploaded in the **Error** level list. If the log doesn't appear immediately, wait for a few moments, then click **Go** to refresh the view.
207203

59.8 KB
Loading

0 commit comments

Comments
 (0)