441 lines
22 KiB
XML
441 lines
22 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<FrameLayout
|
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
xmlns:tools="http://schemas.android.com/tools"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:background="@color/home_index_background">
|
|
|
|
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:layout_gravity="center_horizontal"
|
|
android:orientation="vertical"
|
|
app:maxContentWidth="720dp">
|
|
|
|
<!-- 整页滚动兼容折叠横屏和大字体,设备宫格不再单独嵌套滚动。 -->
|
|
|
|
<androidx.core.widget.NestedScrollView
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:fillViewport="true"
|
|
android:scrollbars="none">
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:clipChildren="false"
|
|
android:clipToPadding="false"
|
|
android:orientation="vertical">
|
|
|
|
<!-- 首页只绘制业务内容,系统状态栏和底部导航由 MainActivity 处理。 -->
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginStart="24dp"
|
|
android:layout_marginEnd="16dp"
|
|
android:layout_marginTop="26dp"
|
|
android:clipChildren="false"
|
|
android:clipToPadding="false"
|
|
android:gravity="center_vertical"
|
|
android:orientation="horizontal">
|
|
|
|
<TextView
|
|
android:id="@+id/tv_home_title"
|
|
style="@style/HomeIndexText"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginEnd="28dp"
|
|
android:layout_weight="1"
|
|
android:ellipsize="end"
|
|
android:fontFamily="sans-serif"
|
|
android:gravity="center_vertical"
|
|
android:maxLines="1"
|
|
android:text="@string/device_home_title"
|
|
android:textSize="26sp"
|
|
app:autoSizeTextType="uniform"
|
|
app:autoSizeMinTextSize="18sp"
|
|
app:autoSizeMaxTextSize="26sp"
|
|
app:autoSizeStepGranularity="1sp"
|
|
android:textStyle="bold" />
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_notifications"
|
|
android:layout_width="38dp"
|
|
android:layout_height="38dp"
|
|
android:layout_gravity="center"
|
|
android:background="@drawable/home_index_action_background"
|
|
android:clickable="true"
|
|
android:focusable="true"
|
|
android:elevation="5dp"
|
|
android:outlineProvider="background"
|
|
android:contentDescription="@string/device_home_notifications"
|
|
android:src="@mipmap/icon_home_notifications" />
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_add_device"
|
|
android:layout_width="38dp"
|
|
android:layout_height="38dp"
|
|
android:layout_gravity="center"
|
|
android:layout_marginStart="10dp"
|
|
android:background="@drawable/home_index_action_background"
|
|
android:elevation="5dp"
|
|
android:outlineProvider="background"
|
|
android:contentDescription="@string/device_home_add_device"
|
|
android:src="@mipmap/icon_home_add_device" />
|
|
</LinearLayout>
|
|
|
|
<!-- 天气为固定示例;点击城市仅演示权限申请,后续再接入实际信息提供方。 -->
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginHorizontal="24dp"
|
|
android:layout_marginTop="5dp"
|
|
android:gravity="center_vertical"
|
|
android:orientation="horizontal">
|
|
|
|
<LinearLayout
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="match_parent"
|
|
android:gravity="center_vertical"
|
|
android:orientation="horizontal">
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_home_weather"
|
|
android:layout_width="14dp"
|
|
android:layout_height="14dp"
|
|
android:layout_marginEnd="4dp"
|
|
android:contentDescription="@null"
|
|
android:src="@mipmap/icon_home_weather" />
|
|
|
|
<TextView
|
|
android:id="@+id/tv_home_weather"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:ellipsize="end"
|
|
android:fontFamily="sans-serif"
|
|
android:includeFontPadding="false"
|
|
android:maxLines="1"
|
|
android:text="@string/device_home_weather_demo"
|
|
android:textColor="#222222"
|
|
android:textSize="14sp"
|
|
tools:text="26°C · Sunny" />
|
|
</LinearLayout>
|
|
|
|
<LinearLayout
|
|
android:id="@+id/ll_home_location"
|
|
android:layout_width="0dp"
|
|
android:layout_height="match_parent"
|
|
android:layout_marginStart="10dp"
|
|
android:layout_weight="1"
|
|
android:background="?attr/selectableItemBackgroundBorderless"
|
|
android:clickable="true"
|
|
android:focusable="true"
|
|
android:gravity="center_vertical"
|
|
android:orientation="horizontal">
|
|
|
|
<ImageView
|
|
android:layout_width="14dp"
|
|
android:layout_height="14dp"
|
|
android:layout_marginEnd="4dp"
|
|
android:contentDescription="@null"
|
|
android:src="@mipmap/icon_home_location" />
|
|
|
|
<TextView
|
|
android:id="@+id/tv_home_location"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_weight="1"
|
|
android:ellipsize="end"
|
|
android:fontFamily="sans-serif"
|
|
android:includeFontPadding="false"
|
|
android:maxLines="1"
|
|
android:text="@string/device_home_location_pending"
|
|
android:textColor="#222222"
|
|
android:textSize="14sp"
|
|
tools:text="Addis Ababa" />
|
|
</LinearLayout>
|
|
</LinearLayout>
|
|
|
|
<androidx.cardview.widget.CardView
|
|
android:id="@+id/cv_home_statistics"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:minHeight="134dp"
|
|
android:layout_marginHorizontal="24dp"
|
|
android:layout_marginTop="30dp"
|
|
app:cardBackgroundColor="@color/device_home_orange"
|
|
app:cardCornerRadius="16dp"
|
|
app:cardElevation="0dp"
|
|
app:cardPreventCornerOverlap="false">
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:baselineAligned="false"
|
|
android:orientation="horizontal">
|
|
|
|
<LinearLayout
|
|
android:id="@+id/ll_charcoal_saved"
|
|
style="@style/HomeIndexStatColumn"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_weight="1">
|
|
|
|
<FrameLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="44dp">
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_charcoal_saved"
|
|
android:layout_width="36dp"
|
|
android:layout_height="36dp"
|
|
android:layout_gravity="bottom|center_horizontal"
|
|
android:importantForAccessibility="no"
|
|
android:src="@mipmap/icon_home_charcoal" />
|
|
</FrameLayout>
|
|
|
|
<TextView
|
|
android:id="@+id/tv_charcoal_saved"
|
|
style="@style/HomeIndexStatValue"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/device_home_zero_charcoal" />
|
|
|
|
<TextView
|
|
style="@style/HomeIndexStatLabel"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/device_home_charcoal_saved" />
|
|
</LinearLayout>
|
|
|
|
<View
|
|
style="@style/HomeIndexStatDivider"
|
|
android:layout_width="1dp"
|
|
android:layout_height="44dp" />
|
|
|
|
<LinearLayout
|
|
android:id="@+id/ll_balance"
|
|
style="@style/HomeIndexStatColumn"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_weight="1">
|
|
|
|
<FrameLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="44dp">
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_balance"
|
|
android:layout_width="44dp"
|
|
android:layout_height="44dp"
|
|
android:layout_gravity="bottom|center_horizontal"
|
|
android:importantForAccessibility="no"
|
|
android:src="@mipmap/icon_home_balance" />
|
|
</FrameLayout>
|
|
|
|
<TextView
|
|
android:id="@+id/tv_balance"
|
|
style="@style/HomeIndexStatValue"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/device_home_zero" />
|
|
|
|
<TextView
|
|
style="@style/HomeIndexStatLabel"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/device_home_balance" />
|
|
</LinearLayout>
|
|
|
|
<View
|
|
style="@style/HomeIndexStatDivider"
|
|
android:layout_width="1dp"
|
|
android:layout_height="44dp" />
|
|
|
|
<LinearLayout
|
|
android:id="@+id/ll_electricity_saved"
|
|
style="@style/HomeIndexStatColumn"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_weight="1">
|
|
|
|
<FrameLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="44dp">
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_electricity_saved"
|
|
android:layout_width="36dp"
|
|
android:layout_height="36dp"
|
|
android:layout_gravity="bottom|center_horizontal"
|
|
android:importantForAccessibility="no"
|
|
android:src="@mipmap/icon_home_electricity" />
|
|
</FrameLayout>
|
|
|
|
<TextView
|
|
android:id="@+id/tv_electricity_saved"
|
|
style="@style/HomeIndexStatValue"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/device_home_zero" />
|
|
|
|
<TextView
|
|
style="@style/HomeIndexStatLabel"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/home_index_electricity_saved" />
|
|
</LinearLayout>
|
|
</LinearLayout>
|
|
</androidx.cardview.widget.CardView>
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginHorizontal="24dp"
|
|
android:layout_marginTop="12dp"
|
|
android:gravity="center_vertical"
|
|
android:orientation="horizontal">
|
|
|
|
<TextView
|
|
android:id="@+id/tv_my_devices"
|
|
style="@style/HomeIndexText"
|
|
android:layout_width="0dp"
|
|
android:layout_height="wrap_content"
|
|
android:layout_weight="1"
|
|
android:accessibilityHeading="true"
|
|
android:text="@string/device_home_my_devices"
|
|
android:textSize="16sp"
|
|
android:textStyle="bold" />
|
|
|
|
<TextView
|
|
android:id="@+id/tv_manage_devices"
|
|
style="@style/HomeIndexText"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:minHeight="36dp"
|
|
android:layout_marginStart="8dp"
|
|
android:clickable="true"
|
|
android:focusable="true"
|
|
android:background="?attr/selectableItemBackground"
|
|
android:gravity="center_vertical|end"
|
|
android:text="@string/device_home_manage"
|
|
android:textColor="@color/home_index_manage_action"
|
|
android:textSize="16sp"
|
|
android:textStyle="bold"
|
|
android:visibility="gone"
|
|
tools:visibility="visible" />
|
|
</LinearLayout>
|
|
|
|
<FrameLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginHorizontal="18.5dp"
|
|
android:layout_marginTop="3dp"
|
|
android:clipChildren="false"
|
|
android:clipToPadding="false">
|
|
|
|
<!-- 两列设备卡片统一边距,随外层页面滚动。 -->
|
|
|
|
<androidx.recyclerview.widget.RecyclerView
|
|
android:id="@+id/rv_devices"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:nestedScrollingEnabled="false"
|
|
android:clipChildren="false"
|
|
android:clipToPadding="false"
|
|
android:paddingBottom="12dp"
|
|
android:scrollbars="none"
|
|
android:visibility="gone"
|
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
|
app:spanCount="2"
|
|
tools:itemCount="4"
|
|
tools:listitem="@layout/device_index_item" />
|
|
|
|
<LinearLayout
|
|
android:id="@+id/sv_empty_devices"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:orientation="vertical"
|
|
android:clipChildren="false"
|
|
android:clipToPadding="false"
|
|
android:scrollbars="none">
|
|
|
|
<androidx.cardview.widget.CardView
|
|
android:id="@+id/cv_empty_devices"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_marginHorizontal="5.5dp"
|
|
android:layout_marginTop="0dp"
|
|
android:layout_marginBottom="12dp"
|
|
app:cardBackgroundColor="@android:color/white"
|
|
app:cardCornerRadius="16dp"
|
|
app:cardElevation="0dp"
|
|
app:cardPreventCornerOverlap="false">
|
|
|
|
<LinearLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:gravity="center_horizontal"
|
|
android:orientation="vertical"
|
|
android:paddingTop="34dp">
|
|
|
|
<ImageView
|
|
android:id="@+id/iv_empty_devices"
|
|
android:layout_width="65dp"
|
|
android:layout_height="65dp"
|
|
android:layout_gravity="center"
|
|
android:contentDescription="@null"
|
|
android:src="@mipmap/icon_add_device" />
|
|
|
|
<TextView
|
|
android:id="@+id/tv_empty_devices"
|
|
style="@style/HomeIndexText"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:minHeight="21dp"
|
|
android:layout_marginHorizontal="12dp"
|
|
android:layout_marginTop="14dp"
|
|
android:gravity="center"
|
|
android:text="@string/device_home_empty_message"
|
|
android:textColor="#1F2329"
|
|
android:textSize="16sp"
|
|
android:textStyle="bold" />
|
|
|
|
<androidx.cardview.widget.CardView
|
|
android:id="@+id/btn_empty_add_device"
|
|
android:layout_width="104dp"
|
|
android:layout_height="40dp"
|
|
android:layout_marginTop="38dp"
|
|
android:layout_marginBottom="28dp"
|
|
android:clickable="true"
|
|
android:contentDescription="@string/device_home_add_device"
|
|
android:focusable="true"
|
|
android:foreground="?attr/selectableItemBackground"
|
|
app:cardBackgroundColor="@color/device_home_orange"
|
|
app:cardCornerRadius="20dp"
|
|
app:cardElevation="0dp"
|
|
app:cardPreventCornerOverlap="false">
|
|
|
|
<TextView
|
|
style="@style/HomeIndexText"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:gravity="center"
|
|
android:text="@string/device_home_add_device"
|
|
android:textColor="@android:color/white"
|
|
android:textSize="14sp" />
|
|
</androidx.cardview.widget.CardView>
|
|
</LinearLayout>
|
|
</androidx.cardview.widget.CardView>
|
|
</LinearLayout>
|
|
</FrameLayout>
|
|
</LinearLayout>
|
|
</androidx.core.widget.NestedScrollView>
|
|
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
|
</FrameLayout>
|