From 10671a6c9f8674d3229f2015dc0d73791873f3c2 Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Sat, 12 Feb 2022 19:27:16 +0530 Subject: [PATCH] Moved the declare-styleable attributes to fluentui_core attrs.xml & enum attributes to fluentui_listitem attrs.xml to reuse at module level. Attributes also prefixed with 'fluentui_' to avoid conflict with other UI library attributes --- .../fluentuidemo/demos/views/Cell.kt | 2 +- .../main/res/layout/activity_persona_view.xml | 2 +- .../src/main/res/values/attrs_cell.xml | 2 +- fluentui_core/src/main/res/values/attrs.xml | 11 +++++++++ .../res/layout/view_bottom_sheet_item.xml | 4 ++-- .../fluentui/listitem/ListItemView.kt | 23 +++++++++---------- .../fluentui/listitem/ListSubHeaderView.kt | 7 +++--- .../src/main/res/values/attrs.xml | 7 ++++++ .../src/main/res/values/attrs_list_item.xml | 22 +++++++++--------- .../main/res/values/attrs_list_sub_header.xml | 10 +++----- 10 files changed, 51 insertions(+), 39 deletions(-) diff --git a/FluentUI.Demo/src/main/java/com/microsoft/fluentuidemo/demos/views/Cell.kt b/FluentUI.Demo/src/main/java/com/microsoft/fluentuidemo/demos/views/Cell.kt index 39b1e7e7..aa25a6e0 100644 --- a/FluentUI.Demo/src/main/java/com/microsoft/fluentuidemo/demos/views/Cell.kt +++ b/FluentUI.Demo/src/main/java/com/microsoft/fluentuidemo/demos/views/Cell.kt @@ -50,7 +50,7 @@ class Cell : TemplateView { constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) { if (attrs != null) { val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.Cell) - title = styledAttrs.getString(R.styleable.Cell_title) + title = styledAttrs.getString(R.styleable.Cell_fluentui_title) description = styledAttrs.getString(R.styleable.Cell_description) val orientationOrdinal = styledAttrs.getInt(R.styleable.Cell_orientation, DEFAULT_ORIENTATION.ordinal) orientation = CellOrientation.values()[orientationOrdinal] diff --git a/FluentUI.Demo/src/main/res/layout/activity_persona_view.xml b/FluentUI.Demo/src/main/res/layout/activity_persona_view.xml index 24d068e3..f460624d 100644 --- a/FluentUI.Demo/src/main/res/layout/activity_persona_view.xml +++ b/FluentUI.Demo/src/main/res/layout/activity_persona_view.xml @@ -25,7 +25,7 @@ android:layout_height="wrap_content" app:avatarSize="xxlarge" app:email="@string/persona_email_kat_larsson" - app:footer="@string/persona_footer" + app:fluentui_footer="@string/persona_footer" app:name="@string/persona_name_kat_larsson" app:subtitle="@string/persona_email_kat_larsson" /> diff --git a/FluentUI.Demo/src/main/res/values/attrs_cell.xml b/FluentUI.Demo/src/main/res/values/attrs_cell.xml index 5642cecc..6924aac1 100644 --- a/FluentUI.Demo/src/main/res/values/attrs_cell.xml +++ b/FluentUI.Demo/src/main/res/values/attrs_cell.xml @@ -6,7 +6,7 @@ - + diff --git a/fluentui_core/src/main/res/values/attrs.xml b/fluentui_core/src/main/res/values/attrs.xml index 994d8dae..3dc3d230 100644 --- a/fluentui_core/src/main/res/values/attrs.xml +++ b/fluentui_core/src/main/res/values/attrs.xml @@ -89,4 +89,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/fluentui_drawer/src/main/res/layout/view_bottom_sheet_item.xml b/fluentui_drawer/src/main/res/layout/view_bottom_sheet_item.xml index 7d03bc88..6fb1782a 100644 --- a/fluentui_drawer/src/main/res/layout/view_bottom_sheet_item.xml +++ b/fluentui_drawer/src/main/res/layout/view_bottom_sheet_item.xml @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListItemView.kt b/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListItemView.kt index f5dd6e2a..8b978205 100644 --- a/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListItemView.kt +++ b/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListItemView.kt @@ -15,7 +15,6 @@ import android.view.View import android.widget.LinearLayout import android.widget.RelativeLayout import android.widget.TextView -import com.microsoft.fluentui.listitem.R import com.microsoft.fluentui.theming.FluentUIContextThemeWrapper import com.microsoft.fluentui.util.setContentAndUpdateVisibility import com.microsoft.fluentui.view.TemplateView @@ -289,25 +288,25 @@ open class ListItemView : TemplateView { // TODO: Add need examples in the demo that tests these attributes. Can inflate a layout in the adapter. val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.ListItemView) - title = styledAttrs.getString(R.styleable.ListItemView_title) ?: "" - subtitle = styledAttrs.getString(R.styleable.ListItemView_subtitle) ?: "" - footer = styledAttrs.getString(R.styleable.ListItemView_footer) ?: "" + title = styledAttrs.getString(R.styleable.ListItemView_fluentui_title) ?: "" + subtitle = styledAttrs.getString(R.styleable.ListItemView_fluentui_subtitle) ?: "" + footer = styledAttrs.getString(R.styleable.ListItemView_fluentui_footer) ?: "" - titleMaxLines = styledAttrs.getInt(R.styleable.ListItemView_titleMaxLines, DEFAULT_MAX_LINES) - subtitleMaxLines = styledAttrs.getInt(R.styleable.ListItemView_subtitleMaxLines, DEFAULT_MAX_LINES) - footerMaxLines = styledAttrs.getInt(R.styleable.ListItemView_footerMaxLines, DEFAULT_MAX_LINES) + titleMaxLines = styledAttrs.getInt(R.styleable.ListItemView_fluentui_titleMaxLines, DEFAULT_MAX_LINES) + subtitleMaxLines = styledAttrs.getInt(R.styleable.ListItemView_fluentui_subtitleMaxLines, DEFAULT_MAX_LINES) + footerMaxLines = styledAttrs.getInt(R.styleable.ListItemView_fluentui_footerMaxLines, DEFAULT_MAX_LINES) - val titleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_titleTruncateAt, DEFAULT_TRUNCATION.ordinal) + val titleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_fluentui_titleTruncateAt, DEFAULT_TRUNCATION.ordinal) titleTruncateAt = TextUtils.TruncateAt.values()[titleTruncateAtOrdinal] - val subtitleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_subtitleTruncateAt, DEFAULT_TRUNCATION.ordinal) + val subtitleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_fluentui_subtitleTruncateAt, DEFAULT_TRUNCATION.ordinal) subtitleTruncateAt = TextUtils.TruncateAt.values()[subtitleTruncateAtOrdinal] - val footerTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_footerTruncateAt, DEFAULT_TRUNCATION.ordinal) + val footerTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListItemView_fluentui_footerTruncateAt, DEFAULT_TRUNCATION.ordinal) footerTruncateAt = TextUtils.TruncateAt.values()[footerTruncateAtOrdinal] - val layoutDensityOrdinal = styledAttrs.getInt(R.styleable.ListItemView_layoutDensity, DEFAULT_LAYOUT_DENSITY.ordinal) + val layoutDensityOrdinal = styledAttrs.getInt(R.styleable.ListItemView_fluentui_layoutDensity, DEFAULT_LAYOUT_DENSITY.ordinal) layoutDensity = LayoutDensity.values()[layoutDensityOrdinal] - val customViewSizeOrdinal = styledAttrs.getInt(R.styleable.ListItemView_customViewSize, DEFAULT_CUSTOM_VIEW_SIZE.ordinal) + val customViewSizeOrdinal = styledAttrs.getInt(R.styleable.ListItemView_fluentui_customViewSize, DEFAULT_CUSTOM_VIEW_SIZE.ordinal) customViewSize = CustomViewSize.values()[customViewSizeOrdinal] styledAttrs.recycle() diff --git a/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListSubHeaderView.kt b/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListSubHeaderView.kt index 9bfb88bd..6a046f92 100644 --- a/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListSubHeaderView.kt +++ b/fluentui_listitem/src/main/java/com/microsoft/fluentui/listitem/ListSubHeaderView.kt @@ -14,7 +14,6 @@ import android.view.View import android.widget.LinearLayout import android.widget.RelativeLayout import android.widget.TextView -import com.microsoft.fluentui.listitem.R import com.microsoft.fluentui.theming.FluentUIContextThemeWrapper import com.microsoft.fluentui.util.ThemeUtil import com.microsoft.fluentui.util.setContentAndUpdateVisibility @@ -103,12 +102,12 @@ class ListSubHeaderView : TemplateView { // TODO: Add need examples in the demo that tests these attributes. Can inflate a layout in the adapter. val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.ListSubHeaderView) - title = styledAttrs.getString(R.styleable.ListSubHeaderView_title) ?: "" + title = styledAttrs.getString(R.styleable.ListSubHeaderView_fluentui_title) ?: "" - val titleColorOrdinal = styledAttrs.getInt(R.styleable.ListSubHeaderView_titleColor, DEFAULT_TITLE_COLOR.ordinal) + val titleColorOrdinal = styledAttrs.getInt(R.styleable.ListSubHeaderView_fluentui_titleColor, DEFAULT_TITLE_COLOR.ordinal) titleColor = TitleColor.values()[titleColorOrdinal] - val titleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListSubHeaderView_titleTruncateAt, DEFAULT_TRUNCATION.ordinal) + val titleTruncateAtOrdinal = styledAttrs.getInt(R.styleable.ListSubHeaderView_fluentui_titleTruncateAt, DEFAULT_TRUNCATION.ordinal) titleTruncateAt = TextUtils.TruncateAt.values()[titleTruncateAtOrdinal] styledAttrs.recycle() diff --git a/fluentui_listitem/src/main/res/values/attrs.xml b/fluentui_listitem/src/main/res/values/attrs.xml index 42c368c2..f82c51ef 100644 --- a/fluentui_listitem/src/main/res/values/attrs.xml +++ b/fluentui_listitem/src/main/res/values/attrs.xml @@ -16,4 +16,11 @@ + + + + + + + \ No newline at end of file diff --git a/fluentui_listitem/src/main/res/values/attrs_list_item.xml b/fluentui_listitem/src/main/res/values/attrs_list_item.xml index c364424f..ff4a2d98 100644 --- a/fluentui_listitem/src/main/res/values/attrs_list_item.xml +++ b/fluentui_listitem/src/main/res/values/attrs_list_item.xml @@ -6,35 +6,35 @@ - - - - - - - + + + + + + + - + - + - + - + diff --git a/fluentui_listitem/src/main/res/values/attrs_list_sub_header.xml b/fluentui_listitem/src/main/res/values/attrs_list_sub_header.xml index e3bc051d..6684c1c8 100644 --- a/fluentui_listitem/src/main/res/values/attrs_list_sub_header.xml +++ b/fluentui_listitem/src/main/res/values/attrs_list_sub_header.xml @@ -6,12 +6,8 @@ - - - - - - - + + + \ No newline at end of file