liuzhenxing 3 年之前
父節點
當前提交
ecb91ce1b4

+ 2 - 0
.idea/misc.xml

@@ -11,6 +11,7 @@
         <entry key="app/src/main/res/layout/activity_change_progress.xml" value="0.1" />
         <entry key="app/src/main/res/layout/activity_display.xml" value="0.11610486891385768" />
         <entry key="app/src/main/res/layout/activity_list.xml" value="0.19300911854103345" />
+        <entry key="app/src/main/res/layout/activity_list_edit.xml" value="0.12208713272543059" />
         <entry key="app/src/main/res/layout/activity_main.xml" value="0.3546195652173913" />
         <entry key="app/src/main/res/layout/activity_qr.xml" value="0.19300911854103345" />
         <entry key="app/src/main/res/layout/activity_wifi_login.xml" value="0.16236068895643363" />
@@ -41,6 +42,7 @@
         <entry key="app/src/main/res/layout/item_xpstyle.xml" value="0.20199275362318841" />
         <entry key="app/src/main/res/layout/view_cancel_sure.xml" value="0.1" />
         <entry key="app/src/main/res/layout/view_content.xml" value="0.19300911854103345" />
+        <entry key="app/src/main/res/layout/view_empty.xml" value="0.1" />
         <entry key="app/src/main/res/layout/view_message_text.xml" value="0.1" />
         <entry key="app/src/main/res/layout/view_sure.xml" value="0.1" />
         <entry key="app/src/main/res/layout/view_textview.xml" value="0.1" />

+ 18 - 2
app/src/main/java/com/xplora/xpsettings/Activity/ApnEditActivity.java

@@ -25,7 +25,7 @@ public class ApnEditActivity extends BaseActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_list);
+        setContentView(R.layout.activity_list_edit);
         initData();
         initView();
     }
@@ -44,6 +44,10 @@ public class ApnEditActivity extends BaseActivity {
         BaseModel model = new BaseModel();
         model.cellType = Constant.CellType.CANCEL_SURE;
         mDataList.add(model);
+
+        BaseModel model1 = new BaseModel();
+        model1.cellType = Constant.CellType.EMPTY;
+        mDataList.add(model1);
     }
 
     private void initView() {
@@ -57,7 +61,7 @@ public class ApnEditActivity extends BaseActivity {
         public void handleMessage(@NonNull Message msg) {
             super.handleMessage(msg);
             if (msg.what == Constant.MSG_TEXTEDIT_FINISH) {
-                String s = (String)msg.obj;
+                String s = (String) msg.obj;
                 switch (msg.arg1) {
                     case 0:
                         mApnModel.apn_name = s.trim();
@@ -77,6 +81,8 @@ public class ApnEditActivity extends BaseActivity {
                     default:
                         break;
                 }
+                mDataList.get(msg.arg1).value = s.trim();
+                mAdapter.setBaseObjects(mDataList);
             } else if (msg.what == Constant.MSG_CANCEL_CLICK) {
                 Intent intent = new Intent();
                 intent.setAction(Constant.INENT_RESULT_ACTION_CANCEL);
@@ -91,4 +97,14 @@ public class ApnEditActivity extends BaseActivity {
             }
         }
     };
+
+    @Override
+    public void onBackPressed() {
+        boolean isKeyboard = mAdapter.isKeyboardVisible();
+        if (isKeyboard) {
+            mAdapter.closeKeyboard();
+        } else {
+            super.onBackPressed();
+        }
+    }
 }

+ 5 - 3
app/src/main/java/com/xplora/xpsettings/Activity/ApnListActivity.java

@@ -51,11 +51,11 @@ public class ApnListActivity extends BaseActivity {
     private void addBaseMode(ApnModel apnModel) {
         String[] stringList = getResources().getStringArray(R.array.apn_titls_array);
         String apnName = apnModel.apn_name.trim();
-        String mcc = stringList[3] + apnModel.mcc;
-        String mnc = stringList[4] + apnModel.mnc;
+        String mcc = stringList[3] + " : " + apnModel.mcc;
+        String mnc = stringList[4] + " : " + apnModel.mnc;
         BaseModel model = new BaseModel();
         model.title = apnName;
-        model.subTitle = mcc + " " + mnc;
+        model.subTitle = mcc + "   " + mnc;
         model.isShowArrow = true;
         model.cellType = Constant.CellType.TITLE_SUBTITLE;
         mDataList.add(model);
@@ -112,6 +112,8 @@ public class ApnListActivity extends BaseActivity {
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
+        if (data == null)
+            return;
         if (data.getAction().equals(Constant.INENT_RESULT_ACTION)) {
             ApnModel apnModel = (ApnModel)data.getSerializableExtra(Constant.INENT_RESULT_VALUE);
             mApnList.add(apnModel);

+ 29 - 3
app/src/main/java/com/xplora/xpsettings/Adapter/BaseListAdapter.java

@@ -24,6 +24,7 @@ import com.xplora.xpsettings.Model.BaseModel;
 import com.xplora.xpsettings.Model.IconProgressModel;
 import com.xplora.xpsettings.R;
 import com.xplora.xpsettings.Utils.Constant;
+import com.xplora.xpsettings.Utils.KeyUtils;
 import com.xplora.xpsettings.Utils.ResUtils;
 
 import java.util.ArrayList;
@@ -32,6 +33,7 @@ import java.util.List;
 public class BaseListAdapter extends ArrayAdapter<BaseModel> {
     private Handler mHandler = null;
     List<BaseModel> mBaseObjects = new ArrayList<>();
+    private KeyUtils mKeyUtils = null;
 
     public BaseListAdapter(Context context, int textViewResourceId, List objects) {
         super(context, textViewResourceId, objects);
@@ -80,6 +82,8 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
             view = LayoutInflater.from(getContext()).inflate(R.layout.view_sure, null);
         } else if (model.cellType == Constant.CellType.MESSAGE) {
             view = LayoutInflater.from(getContext()).inflate(R.layout.view_message_text, null);
+        } else if (model.cellType == Constant.CellType.EMPTY) {
+            view = LayoutInflater.from(getContext()).inflate(R.layout.view_empty, null);
         }
 
         assert view != null;
@@ -169,15 +173,18 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
         }
 
         if (itemEdit != null) {
-            TextWatcher watcher = new TextWatcher() {
+            itemEdit.setText(model.value);
+            itemEdit.addTextChangedListener(new TextWatcher() {
                 @Override
                 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 
                 }
+
                 @Override
                 public void onTextChanged(CharSequence s, int start, int before, int count) {
 
                 }
+
                 @Override
                 public void afterTextChanged(Editable s) {
                     if (mHandler == null)
@@ -188,8 +195,14 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
                     message.obj = s.toString();
                     mHandler.sendMessage(message);
                 }
-            };
-            itemEdit.addTextChangedListener(watcher);
+            });
+
+            view.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    mKeyUtils = new KeyUtils(getContext(), itemEdit);
+                }
+            });
         }
 
         return view;
@@ -198,4 +211,17 @@ public class BaseListAdapter extends ArrayAdapter<BaseModel> {
     public void setBaseObjects(List<BaseModel> objects) {
         mBaseObjects = objects;
     }
+
+    public void closeKeyboard() {
+        if (mKeyUtils != null) {
+            mKeyUtils.closeKeyboard();
+        }
+    }
+
+    public boolean isKeyboardVisible() {
+        if (mKeyUtils != null) {
+            return mKeyUtils.isKeyboardVisible();
+        }
+        return false;
+    }
 }

+ 1 - 0
app/src/main/java/com/xplora/xpsettings/Utils/Constant.java

@@ -37,6 +37,7 @@ public class Constant {
         CANCEL_SURE,
         SURE,
         MESSAGE,
+        EMPTY,
     }
 
     public enum E_SEEKBAR_TYPE {

+ 10 - 0
app/src/main/java/com/xplora/xpsettings/Utils/KeyUtils.java

@@ -6,6 +6,7 @@ import android.inputmethodservice.Keyboard;
 import android.inputmethodservice.KeyboardView;
 import android.text.Editable;
 import android.util.Log;
+import android.view.View;
 import android.widget.EditText;
 
 import com.xplora.xpsettings.R;
@@ -43,6 +44,7 @@ public class KeyUtils {
             mKeyboardView.setKeyboard(mKeyboard);
             mKeyboardView.setPreviewEnabled(false);   //这个是,效果图按住是出来的预览图。
             mKeyboardView.setEnabled(true);
+            mKeyboardView.setVisibility(View.VISIBLE);
 
             KeyboardView.OnKeyboardActionListener mListener = new KeyboardView.OnKeyboardActionListener() {
                 @Override
@@ -248,4 +250,12 @@ public class KeyUtils {
             this.LABEL = LABEL;
         }
     }
+
+    public void closeKeyboard() {
+        mKeyboardView.setVisibility(View.GONE);
+    }
+
+    public boolean isKeyboardVisible() {
+        return mKeyboardView.getVisibility() == View.VISIBLE;
+    }
 }

+ 69 - 0
app/src/main/res/layout/activity_list_edit.xml

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/black"
+    >
+
+    <ListView
+        android:id="@+id/activity_listview"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="40dp"
+        >
+    </ListView>
+
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/empty_view"
+        android:visibility="gone">
+
+        <TextView
+            android:id="@+id/empty_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="65dp"
+            android:textSize="12sp"
+            android:textFontWeight="400"
+            android:textColor="#FFFFFFFF"
+            android:fontFamily="Roboto"
+            android:textAlignment="center"
+            />
+
+        <Button
+            android:id="@+id/empty_button"
+            android:layout_width="80dp"
+            android:layout_height="28dp"
+            android:layout_centerHorizontal="true"
+            android:layout_alignParentBottom="true"
+            android:layout_marginBottom="25dp"
+            android:textSize="12sp"
+            android:textFontWeight="400"
+            android:textColor="#FFFFFFFF"
+            android:fontFamily="Roboto"
+            android:text="+"
+            android:backgroundTint="@color/xp_green"
+            style="@style/xp_style_button_all"
+            />
+    </RelativeLayout>
+
+    <android.inputmethodservice.KeyboardView
+        android:id="@+id/main_keyview"
+        android:background="@color/black"
+        android:layout_width="match_parent"
+        android:layout_height="125dp"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:keyBackground="@color/black"
+        android:keyTextColor="@color/white"
+        android:layout_gravity="center"
+        android:keyTextSize="14sp"
+        android:labelTextSize="14sp"
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        />
+
+</RelativeLayout>

+ 4 - 3
app/src/main/res/layout/item_title_edit.xml

@@ -2,11 +2,11 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
-    android:layout_height="40dp">
+    android:layout_height="30dp">
 
     <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="40dp"
+        android:layout_height="30dp"
         >
 
         <TextView
@@ -36,9 +36,10 @@
             android:background="@null"
             android:maxLines="1"
             android:lines="1"
-            android:inputType="text"
+            android:inputType="none"
             android:imeOptions="actionDone"
             tools:ignore="TextFields"
+            android:enabled="false"
             />
 
     </RelativeLayout>

+ 13 - 0
app/src/main/res/layout/view_empty.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="40dp">
+
+    </RelativeLayout>
+
+</RelativeLayout>