詹子聪 5 anni fa
parent
commit
b70a23513c

+ 13 - 7
app/src/main/java/com/itant/shibei/ui/home/tool/ToolFragment.java

@@ -30,6 +30,7 @@ public class ToolFragment extends BaseMVPFragment implements View.OnClickListene
         rootView.findViewById(R.id.fl_get_json).setOnClickListener(this);
         rootView.findViewById(R.id.fl_pc_template).setOnClickListener(this);
         rootView.findViewById(R.id.fl_weather).setOnClickListener(this);
+        rootView.findViewById(R.id.fl_yiji).setOnClickListener(this);
     }
 
     @Override
@@ -56,13 +57,18 @@ public class ToolFragment extends BaseMVPFragment implements View.OnClickListene
                 break;
 
             case R.id.fl_weather:
-                // 天气界面
-                if (UserInfoManager.getInstance().isLogin()) {
-                    startActivity(new Intent(getActivity(), WeatherActivity.class));
-                } else {
-                    ToastTool.showShort("请先登录");
-                    startActivity(new Intent(getActivity(), LoginActivity.class));
-                }
+                // 天气界面 todo
+                startActivity(new Intent(getActivity(), WeatherActivity.class));
+//                if (UserInfoManager.getInstance().isLogin()) {
+//                    startActivity(new Intent(getActivity(), WeatherActivity.class));
+//                } else {
+//                    ToastTool.showShort("请先登录");
+//                    startActivity(new Intent(getActivity(), LoginActivity.class));
+//                }
+                break;
+
+            case R.id.fl_yiji:
+                // 宜忌信息
                 break;
             default:
                 break;

+ 39 - 3
app/src/main/java/com/itant/shibei/ui/home/tool/weather/WeatherActivity.java

@@ -3,17 +3,25 @@ package com.itant.shibei.ui.home.tool.weather;
 
 import android.os.Bundle;
 import android.view.View;
+import android.widget.EditText;
 import android.widget.TextView;
 
+import com.itant.shibei.BuildConfig;
 import com.itant.shibei.R;
 import com.itant.shibei.base.BaseBeiActivity;
 import com.itant.shibei.bean.BeiUser;
 import com.itant.shibei.manager.UserInfoManager;
+import com.itant.shibei.tool.SystemTool;
+import com.miekir.common.utils.ToastTool;
 
 /**
  * 天气界面
  */
 public class WeatherActivity extends BaseBeiActivity implements View.OnClickListener {
+    private static final String FORMAT_URL = "%s/shibei/weather";
+    private static final String FORMAT_EMAIL = "\"email\":\"%s\"";
+    private static final String FORMAT_TOKEN = "\"token\":\"%s\"";
+
     private BeiUser mUser;
 
     private TextView tv_weather_url;
@@ -31,26 +39,54 @@ public class WeatherActivity extends BaseBeiActivity implements View.OnClickList
         setTitle("日期天气API");
 
         tv_weather_url = findViewById(R.id.tv_weather_url);
+        tv_weather_url.setText(String.format(FORMAT_URL, BuildConfig.BASE_URL));
         tv_header_email = findViewById(R.id.tv_header_email);
+        tv_header_email.setText(String.format(FORMAT_EMAIL, mUser.email));
         tv_header_token = findViewById(R.id.tv_header_token);
+        tv_header_token.setText(String.format(FORMAT_TOKEN, mUser.token));
 
         findViewById(R.id.fl_weather_url).setOnClickListener(this);
         findViewById(R.id.fl_header_email).setOnClickListener(this);
         findViewById(R.id.fl_header_token).setOnClickListener(this);
+
+        EditText et_weather = findViewById(R.id.et_weather);
+        et_weather.setText("{\n" +
+                "  \"temperatureLow\": 28.5,\n" +
+                "  \"temperatureHigh\": 30.5,\n" +
+                "  \"temperatureNow\": 29.2,\n" +
+                "  \"wind\": \"无持续风,微风\",\n" +
+                "  \"air\": \"优\",\n" +
+                "  \"desc\": \"阵雨转多云\"\n" +
+                "}");
     }
 
     @Override
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.fl_weather_url:
-                // todo 复制GET链接URL
+                // 复制GET链接URL
+                if (SystemTool.copyText(getApplicationContext(), tv_weather_url.getText().toString())) {
+                    ToastTool.showShort("复制成功");
+                } else {
+                    ToastTool.showShort("复制失败");
+                }
                 break;
 
             case R.id.fl_header_email:
-                // todo 复制header参数email
+                // 复制header参数email
+                if (SystemTool.copyText(getApplicationContext(), tv_header_email.getText().toString())) {
+                    ToastTool.showShort("复制成功");
+                } else {
+                    ToastTool.showShort("复制失败");
+                }
                 break;
             case R.id.fl_header_token:
-                // todo 复制header参数token
+                // 复制header参数token
+                if (SystemTool.copyText(getApplicationContext(), tv_header_token.getText().toString())) {
+                    ToastTool.showShort("复制成功");
+                } else {
+                    ToastTool.showShort("复制失败");
+                }
                 break;
             default:
                 break;

+ 32 - 7
app/src/main/res/layout/activity_weather.xml

@@ -32,9 +32,9 @@
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="你的专属GET链接(点击复制)"
+                android:text="GET请求链接(点击复制)"
                 android:textColor="@color/black_text_comfortable"
-                android:textSize="@dimen/text_sub_title"
+                android:textSize="@dimen/text_normal_p"
                 android:textStyle="bold"/>
 
             <TextView
@@ -73,9 +73,9 @@
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="Header参数1(点击复制value)"
+                android:text="Header参数1(点击复制)"
                 android:textColor="@color/black_text_comfortable"
-                android:textSize="@dimen/text_sub_title"
+                android:textSize="@dimen/text_normal_p"
                 android:textStyle="bold"/>
 
             <TextView
@@ -114,9 +114,9 @@
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="Header参数2(点击复制value)"
+                android:text="Header参数2(点击复制)"
                 android:textColor="@color/black_text_comfortable"
-                android:textSize="@dimen/text_sub_title"
+                android:textSize="@dimen/text_normal_p"
                 android:textStyle="bold"/>
 
             <TextView
@@ -133,8 +133,33 @@
 
     <include layout="@layout/view_divider_common" />
 
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingStart="@dimen/margin_default"
+        android:paddingEnd="@dimen/margin_default"
+        android:paddingTop="@dimen/margin_ss"
+        android:paddingBottom="@dimen/margin_ss"
+        android:layout_marginTop="@dimen/margin_sss"
+        android:textColor="@color/black_droid_text"
+        android:textStyle="bold"
+        android:textSize="@dimen/text_normal_s"
+        android:text="返回示例:"/>
+
     <EditText
+        android:id="@+id/et_weather"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:editable="false" />
+        android:gravity="start"
+        android:background="@color/white"
+        android:textIsSelectable="true"
+        android:paddingStart="@dimen/margin_default"
+        android:paddingEnd="@dimen/margin_default"
+        android:paddingTop="@dimen/margin_ss"
+        android:paddingBottom="@dimen/margin_ss"
+        android:textSize="@dimen/text_normal_p"
+        android:textColor="@color/black_text_comfortable"
+        android:textColorHint="@color/gray_text_hint"
+        android:editable="false"
+        android:text=""/>
 </LinearLayout>

+ 44 - 7
app/src/main/res/layout/fragment_tool.xml

@@ -39,8 +39,8 @@
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="PC装机模板"
-                android:textSize="@dimen/text_sub_title"
+                android:text="电脑装机模板"
+                android:textSize="@dimen/text_normal_p"
                 android:textColor="@color/black_text_comfortable"
                 android:textStyle="bold"/>
 
@@ -78,7 +78,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:text="GetJson微服务"
-                android:textSize="@dimen/text_sub_title"
+                android:textSize="@dimen/text_normal_p"
                 android:textColor="@color/black_text_comfortable"
                 android:textStyle="bold"/>
 
@@ -93,7 +93,6 @@
     </FrameLayout>
 
     <include layout="@layout/view_divider_common" />
-
     <FrameLayout
         android:id="@+id/fl_weather"
         android:layout_width="match_parent"
@@ -115,8 +114,8 @@
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="日期天气API(限时免费)"
-                android:textSize="@dimen/text_sub_title"
+                android:text="天气API"
+                android:textSize="@dimen/text_normal_p"
                 android:textColor="@color/black_text_comfortable"
                 android:textStyle="bold"/>
 
@@ -126,7 +125,45 @@
                 android:layout_marginTop="@dimen/margin_sss"
                 android:textColor="@color/gray_text_s"
                 android:textSize="@dimen/text_normal_s"
-                android:text="返回当天日期、天气、宜忌信息"/>
+                android:text="返回今日天气信息(限时免费)"/>
         </LinearLayout>
     </FrameLayout>
+    <include layout="@layout/view_divider_common" />
+
+    <FrameLayout
+        android:id="@+id/fl_yiji"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        android:foreground="?attr/selectableItemBackground">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:minHeight="@dimen/height_tab_bar"
+            android:orientation="vertical"
+            android:paddingStart="@dimen/activity_horizontal_margin"
+            android:paddingEnd="@dimen/activity_horizontal_margin"
+            android:paddingTop="@dimen/margin_s"
+            android:paddingBottom="@dimen/margin_s"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="黄历API"
+                android:textSize="@dimen/text_normal_p"
+                android:textColor="@color/black_text_comfortable"
+                android:textStyle="bold"/>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="@dimen/margin_sss"
+                android:textColor="@color/gray_text_s"
+                android:textSize="@dimen/text_normal_s"
+                android:text="返回当天宜忌信息(限时免费)"/>
+        </LinearLayout>
+    </FrameLayout>
+    <include layout="@layout/view_divider_common" />
 </LinearLayout>