ソースを参照

JSON界面与逻辑

詹子聪 5 年 前
コミット
5274ac4320

+ 5 - 0
app/src/main/AndroidManifest.xml

@@ -67,6 +67,11 @@
             android:name=".ui.home.search.SearchActivity"
             android:screenOrientation="portrait"
             android:theme="@style/TextInputStyle" />
+
+        <activity
+            android:name=".ui.home.tool.json.JsonActivity"
+            android:screenOrientation="portrait"
+            android:theme="@style/TextInputStyle" />
     </application>
 
 </manifest>

+ 13 - 0
app/src/main/java/com/itant/shibei/bean/JsonBean.java

@@ -0,0 +1,13 @@
+package com.itant.shibei.bean;
+
+/**
+ * Copyright (C), 2019-2020, Miekir
+ *
+ * @author Miekir
+ * @date 2020/8/13 20:20
+ * Description: json
+ */
+public class JsonBean {
+    public String email;
+    public String json;
+}

+ 2 - 1
app/src/main/java/com/itant/shibei/ui/home/tool/ToolFragment.java

@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
 
 import com.itant.shibei.R;
 import com.itant.shibei.manager.UserInfoManager;
+import com.itant.shibei.ui.home.tool.json.JsonActivity;
 import com.itant.shibei.ui.mine.login.LoginActivity;
 import com.miekir.common.utils.ToastTool;
 import com.miekir.mvp.view.BaseMVPFragment;
@@ -37,7 +38,7 @@ public class ToolFragment extends BaseMVPFragment implements View.OnClickListene
         switch (v.getId()) {
             case R.id.fl_get_json:
                 if (UserInfoManager.getInstance().isLogin()) {
-
+                    startActivity(new Intent(getActivity(), JsonActivity.class));
                 } else {
                     ToastTool.showShort("请先登录");
                     startActivity(new Intent(getActivity(), LoginActivity.class));

+ 51 - 0
app/src/main/java/com/itant/shibei/ui/home/tool/json/JsonActivity.java

@@ -0,0 +1,51 @@
+package com.itant.shibei.ui.home.tool.json;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.itant.shibei.R;
+import com.itant.shibei.base.BaseBeiActivity;
+import com.itant.shibei.bean.BeiUser;
+import com.itant.shibei.manager.UserInfoManager;
+
+public class JsonActivity extends BaseBeiActivity implements View.OnClickListener {
+    private BeiUser mUser;
+
+    private TextView tv_json_url;
+    private EditText et_json;
+
+    @Override
+    public int getLayoutID() {
+        return R.layout.activity_json;
+    }
+
+    @Override
+    public void initViews(Bundle savedInstanceState) {
+        mUser = UserInfoManager.getInstance().getBeiUser();
+        setTitle("GetJson微服务");
+
+        tv_json_url = findViewById(R.id.tv_json_url);
+        et_json = findViewById(R.id.et_json);
+        findViewById(R.id.fl_json_url).setOnClickListener(this);
+        findViewById(R.id.btn_save_json).setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.fl_json_url:
+                // todo 复制GET链接URL
+                break;
+
+            case R.id.btn_save_json:
+                // todo 保存JSON
+                break;
+
+            default:
+                break;
+        }
+    }
+}

+ 88 - 0
app/src/main/res/layout/activity_json.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/ll_search"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@color/white"
+    android:focusable="true"
+    android:focusableInTouchMode="true"
+    android:orientation="vertical">
+
+    <include layout="@layout/view_toolbar" />
+
+
+    <FrameLayout
+        android:id="@+id/fl_json_url"
+        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:gravity="center_vertical"
+            android:minHeight="@dimen/height_tab_bar"
+            android:orientation="vertical"
+            android:paddingStart="@dimen/activity_horizontal_margin"
+            android:paddingTop="@dimen/margin_s"
+            android:paddingEnd="@dimen/activity_horizontal_margin"
+            android:paddingBottom="@dimen/margin_s">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="你的专属GET链接(点击复制)"
+                android:textColor="@color/black_text_comfortable"
+                android:textSize="@dimen/text_sub_title"
+                android:textStyle="bold"/>
+
+            <TextView
+                android:id="@+id/tv_json_url"
+                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:maxLines="2"
+                android:ellipsize="end"/>
+        </LinearLayout>
+    </FrameLayout>
+
+
+    <include layout="@layout/view_divider_common" />
+
+    <EditText
+        android:id="@+id/et_json"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:background="@null"
+        android:gravity="start"
+        android:hint="请输入要提交到云端的JSON字符串(本客户端不校验JSON字符串格式)"
+        android:minHeight="@dimen/height_tab_bar"
+        android:padding="@dimen/margin_default"
+        android:textAllCaps="false"
+        android:textColor="@color/black_text_comfortable"
+        android:textColorHint="@color/gray_text_hint"
+        android:textSize="@dimen/text_normal_p" />
+
+    <include layout="@layout/view_divider_common" />
+
+    <android.widget.Button
+        android:id="@+id/btn_save_json"
+        style="?android:attr/borderlessButtonStyle"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/margin_default"
+        android:layout_marginTop="@dimen/margin_default"
+        android:layout_marginEnd="@dimen/margin_default"
+        android:layout_marginBottom="@dimen/margin_default"
+        android:background="@drawable/selector_btn"
+        android:minHeight="0dp"
+        android:paddingTop="@dimen/padding_full_width"
+        android:paddingBottom="@dimen/padding_full_width"
+        android:text="保存JSON字符串到云端"
+        android:textColor="@color/white"
+        android:textStyle="bold" />
+</LinearLayout>

+ 3 - 2
app/src/main/res/layout/activity_search.xml

@@ -6,7 +6,8 @@
     android:orientation="vertical"
     android:id="@+id/ll_search"
     android:focusable="true"
-    android:focusableInTouchMode="true">
+    android:focusableInTouchMode="true"
+    android:background="@color/colorPrimary">
 
     <include layout="@layout/view_toolbar"/>
 
@@ -16,7 +17,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:minHeight="@dimen/height_tab_bar"
-        android:background="@null"
+        android:background="@color/white"
         android:singleLine="true"
         android:paddingStart="@dimen/margin_default"
         android:paddingEnd="@dimen/margin_default"

+ 2 - 1
app/src/main/res/layout/fragment_tool.xml

@@ -41,7 +41,8 @@
                 android:layout_height="wrap_content"
                 android:text="GetJson微服务"
                 android:textSize="@dimen/text_sub_title"
-                android:textColor="@color/black_text" />
+                android:textColor="@color/black_text_comfortable"
+                android:textStyle="bold"/>
 
             <TextView
                 android:layout_width="wrap_content"