package com.ic.launcher.loop;
+import android.content.Intent;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.View;
+import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;
//处理点击事件
mainPageAdapter.setOnItemClickListener(item -> {
//打开应用
+ int packageNameResId = item.getPackageNameResId();
+ String packageName = getString(packageNameResId);
+ if (!TextUtils.isEmpty(packageName)) {
+ Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(packageName);
+ if (launchIntentForPackage != null) {
+ launchIntentForPackage.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(launchIntentForPackage);
+ } else {
+ Toast.makeText(this, getString(R.string.no_application_tips_text),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
});
looperPage.registerOnPageChangeCallback(onPageChangeCallback);
}
<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.ic.launcher.loop.view.MainPageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<TextView
+ android:id="@+id/time_tv"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="首页"
- android:textColor="@color/white" />
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:includeFontPadding="false"
+ android:text="00:00"
+ android:textColor="@color/white"
+ android:textSize="120sp" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="22dp"
+ android:layout_marginRight="22dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/date_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:includeFontPadding="false"
+ android:text="02-30"
+ android:textColor="@color/white"
+ android:textSize="40sp" />
+
+ <TextView
+ android:id="@+id/week_date_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:includeFontPadding="false"
+ android:text="星期天"
+ android:textColor="@color/white"
+ android:textSize="40sp" />
+
+ </FrameLayout>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:orientation="horizontal">
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/out_temp" />
+
+ <TextView
+ android:id="@+id/out_temp_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="24.0"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/heart_rate" />
+
+ <TextView
+ android:id="@+id/heart_rate_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="98"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/spo2" />
+
+ <TextView
+ android:id="@+id/blood_oxygen_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="120"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <ImageView
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@mipmap/body_temp" />
+
+ <TextView
+ android:id="@+id/body_temp_tv"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="36.5"
+ android:textColor="@color/white"
+ android:textSize="24sp" />
+
+
+ </LinearLayout>
+ </LinearLayout>
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
+</com.ic.launcher.loop.view.MainPageView>
\ No newline at end of file
<string name="app_title_settings">设定</string>
<!--Package name-->
- <string name="app_package_name_temperature">体温</string>
- <string name="app_package_name_health">健康</string>
- <string name="app_package_name_sport">运动</string>
- <string name="app_package_name_weather">天气</string>
- <string name="app_package_name_phone">电话</string>
- <string name="app_package_name_ic_talk">微聊</string>
- <string name="app_package_name_contact">联系人</string>
- <string name="app_package_name_camera">拍照</string>
- <string name="app_package_name_photo">相册</string>
- <string name="app_package_name_sms">短信</string>
- <string name="app_package_name_record">记录</string>
- <string name="app_package_name_sign">签到</string>
- <string name="app_package_name_settings">设定</string>
+ <string name="app_package_name_temperature">com.ic.temperature</string>
+ <string name="app_package_name_health">com.ic.blood</string>
+ <string name="app_package_name_sport">com.ic.sport</string>
+ <string name="app_package_name_weather">com.ic.weather</string>
+ <string name="app_package_name_phone">com.ic.dial</string>
+ <string name="app_package_name_ic_talk">com.ic.icwetalk</string>
+ <string name="app_package_name_contact">com.ic.iccontact</string>
+ <string name="app_package_name_camera">com.eqc.camera</string>
+ <string name="app_package_name_photo">com.eqc.gallery</string>
+ <string name="app_package_name_sms">com.ic.sms</string>
+ <string name="app_package_name_record">com.ic.record</string>
+ <string name="app_package_name_sign">com.ic.sign</string>
+ <string name="app_package_name_settings">com.eqc.setting</string>
+ <string name="no_application_tips_text">未找到相关应用.</string>
</resources>
\ No newline at end of file