Просмотр исходного кода

1.修复Common Editor Android在文本输入时错误。
2.完成RedAnt Mobile Android Search Setting。
3.修改Common Editor EnumSelect,增加SearchBar。
4.修复Common Editor EnumSelect在搜索过程中选择时错误。

Pen Li 8 лет назад
Родитель
Сommit
de79bce7d8

+ 1 - 0
RedAnt Mobile/app/app.iml

@@ -101,6 +101,7 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />

+ 53 - 25
RedAnt Mobile/app/src/main/AndroidManifest.xml

@@ -153,43 +153,67 @@
 
         <!-- CommonEditor -->
 
-        <activity android:name="com.usai.redant.CommonEditor.CommonEditorActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.CommonEditorActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ImageUploadActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.ImageUploadActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ImageViewActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.ImageViewActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.BundleModelActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.BundleModelActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.AddressEditorActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.AddressEditorActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.CreditCardEditorActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.CreditCardEditorActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ContactListActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.ContactListActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.EnumSlectActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.EnumSlectActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.DatePickerActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.DatePickerActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.MonthPickerActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.MonthPickerActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.SignatureActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.CommonEditor.SignatureActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
 
         <!-- Result -->
-        <activity android:name="com.usai.redant.Result.SearchResultActivity"
-                  android:theme="@style/Theme.AppCompat.Light">>
+        <activity
+            android:name="com.usai.redant.Result.SearchResultActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+            >
         </activity>
 
         <!-- RedAnt Mobile -->
@@ -197,7 +221,11 @@
             android:name=".ModeListActivity"
             android:theme="@style/Theme.AppCompat.Light">
         </activity>
-        <activity android:name="com.usai.redant.Search.RamSearchActivity"
+        <activity
+            android:name="com.usai.redant.Search.RamSearchActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+        </activity>
+        <activity android:name="com.usai.redant.Search.RamSearchSettingActivity"
                   android:theme="@style/Theme.AppCompat.Light">
         </activity>
     </application>

+ 74 - 53
RedAnt Mobile/app/src/main/java/com/usai/redant/CommonEditor/CommonEditorActivity.java

@@ -53,6 +53,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
@@ -506,7 +507,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
     }
 
-    private void showWarningAlert(String msg) {
+    public void showWarningAlert(String msg) {
 
         new AlertDialog.Builder(mCtx)
                 .setTitle("Warning")
@@ -2322,8 +2323,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
         if (cancommit == false && required.equals("true") && (value == null || value.length() == 0)) {
             // 阴影 red
+            holder.title_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
         } else {
             // 无阴影
+            holder.title_lb.setBackground(null);
         }
 
     }
@@ -2420,53 +2423,61 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
     private void loadImageForPosition(int group, int child, int item_tag, final String path) {
 
-        return;
+//        return;
 
-//        if (path == null || path.isEmpty()) {
-//            return;
-//        }
-//        new Thread(new Runnable() {
-//            @Override
-//            public void run() {
-//                HttpURLConnection cnn = null;
-//                Bitmap bitmap = null;
-//                try {
-//                    URL url = new URL(path);
-//                    cnn = (HttpURLConnection)url.openConnection();
-//                    cnn.setRequestMethod("GET");
-//                    cnn.setUseCaches(false);
-//                    cnn.setConnectTimeout(1500);
-//                    cnn.setReadTimeout(1500);
-//                    bitmap = BitmapFactory.decodeStream(cnn.getInputStream());
-//                    if (bitmap == null) {
-//                        // 缓存not found
-//                        bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
-//                    }
-//
-//
-//                } catch (IOException e) {
-//                    e.printStackTrace();
-//
-//                    bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
-//
-//                } finally {
-//                    if (cnn != null) {
-//                        cnn.disconnect();
-//                    }
-//                    if (bitmap == null) {
-//                        bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
-//                    }
-//                    Utils.cacheImage(path,bitmap);
-//                    // 更新数据,刷新行
-//                    runOnUiThread(new Runnable() {
-//                        @Override
-//                        public void run() {
-//                            adapter.notifyDataSetChanged();
-//                        }
-//                    });
-//                }
-//            }
-//        }).start();
+        if (path == null || path.isEmpty()) {
+            return;
+        }
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                HttpURLConnection cnn = null;
+                Bitmap bitmap = null;
+
+
+                try {
+
+                    bitmap = Utils.loadCacheImage(path,null);
+
+
+                    if (bitmap == null) {
+                        URL url = new URL(path);
+                        cnn = (HttpURLConnection)url.openConnection();
+                        cnn.setRequestMethod("GET");
+                        cnn.setUseCaches(false);
+                        cnn.setConnectTimeout(1500);
+                        cnn.setReadTimeout(1500);
+                        bitmap = BitmapFactory.decodeStream(cnn.getInputStream());
+                        if (bitmap == null) {
+                            // 缓存not found
+                            bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
+                        }
+                    }
+
+
+                } catch (IOException e) {
+                    e.printStackTrace();
+
+                    bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
+
+                } finally {
+                    if (cnn != null) {
+                        cnn.disconnect();
+                    }
+                    if (bitmap == null) {
+                        bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
+                    }
+                    Utils.cacheImage(path,bitmap);
+                    // 更新数据,刷新行
+                    runOnUiThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            adapter.notifyDataSetChanged();
+                        }
+                    });
+                }
+            }
+        }).start();
     }
 
     public void setUpEditCellHolder(final CommonEditorEditCellHolder holder, View cell, JSONObject item_json, boolean readonly, int group, int child) {
@@ -2478,6 +2489,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
         String keyboard = null;
         String required = null;
 
+       if (holder.textWatcher != null) {
+           holder.text_field.removeTextChangedListener(holder.textWatcher);
+       }
         // 重用时先保存
         if (holder.text_field.getText().length() > 0) {
             editTextEndEditing(holder.text_field,true,holder.group,holder.child);
@@ -2584,8 +2598,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
         if (cancommit == false && required != null && required.equals("true") && (value == null || value.length() == 0)) {
             // 阴影 red
+            holder.name_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
         } else {
             // 无阴影
+            holder.name_lb.setBackground(null);
         }
 
 
@@ -2839,8 +2855,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
             if (cancommit == false && required.equals("true") && (value == null || value.length() == 0)) {
                 // 阴影 red
+                holder.title_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
             } else {
                 // 无阴影
+                holder.title_lb.setBackground(null);
             }
 
         } catch (Exception e) {
@@ -3197,7 +3215,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
     }
 
-    private Context mCtx = this;
+    public Context mCtx = this;
 
     /**Month Picker*/
     public void MPValueChanged(String value,int group,int child) {
@@ -3933,7 +3951,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                     new Thread(new Runnable() {
                         @Override
                         public void run() {
-                            final JSONObject editor_json = Utils.commoneditor_partialrefresh(final_params,url);
+                            final JSONObject editor_json = Network.commoneditor_partialrefresh(final_params,url);
 
                             runOnUiThread(new Runnable() {
                                 @Override
@@ -4030,7 +4048,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                         @Override
                         public void run() {
 
-                            final JSONObject editor_json = Utils.commoneditor_partialrefresh(final_params,url);
+                            final JSONObject editor_json = Network.commoneditor_partialrefresh(final_params,url);
 
                             runOnUiThread(new Runnable() {
                                 @Override
@@ -4397,6 +4415,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             } else {
 
                 editTextEndEditing(et,is_text_field,group,child);
+                endEditting();
                 lastEditText = null;
                 last_edit_group = -1;
                 last_edit_child = -1;
@@ -4419,7 +4438,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
     }
 
     public void editTextEndEditing(EditText et,boolean is_text_field,int group,int child) {
-        Log.e("Edit", "end editing");
+        Log.d("Edit", "end editing");
         if (is_text_field) {
 
             JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
@@ -4427,7 +4446,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 return;
             }
             String fillText = item_json.optString("fill");
-            if (fillText != null && et.getText().length() == 0) {
+
+            // 没有判断fillText empty会导致重复不断的调用focusChange,并且不能输入
+            if (fillText != null && et.getText().length() == 0 && !fillText.isEmpty()) {
                 et.setText(fillText);
             }
             textFieldSetValue(et.getText().toString(),group,child);
@@ -4481,7 +4502,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
     }
 
     public void editTextBeginEditing(EditText et,boolean is_text_field,int group,int child) {
-        Log.e("Edit", "begin editing");
+        Log.d("Edit", "begin editing");
 
         lastEditText = et;
         last_edit_group = group;

+ 128 - 14
RedAnt Mobile/app/src/main/java/com/usai/redant/CommonEditor/EnumSlectActivity.java

@@ -5,11 +5,14 @@ import android.content.Intent;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.BaseAdapter;
+import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
@@ -55,6 +58,85 @@ public class EnumSlectActivity extends AppCompatActivity {
         }
     }
 
+    public class SearchBarWatcher implements TextWatcher {
+
+        Context mCtx;
+        EditText textView;
+
+        public SearchBarWatcher(Context ctx,EditText textView) {
+            this.mCtx = ctx;
+            this.textView = textView;
+
+
+        }
+
+        String origin_text;
+        String string;
+        int start_position;
+        int change_length; // 修改原文长度
+        int new_string_length;
+
+
+        /**
+         * s        改变前的内容
+         * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
+         * count    选中s中的内容长度(发生改变的原内容长度),未选中为0
+         * after    新添加的内容长度,删除为0
+         * */
+        @Override
+        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+//            Log.d("TextChange", "before Text Changed: " + s + " Start: " + start + " Count: " + count + " After: " + after);
+
+            origin_text = s.toString();
+            start_position = start;
+            change_length = count;
+            new_string_length = after;
+        }
+
+        /**
+         * s        改变后的内容
+         * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
+         * before   选中s中的内容长度(发生改变的原内容长度),未选中为0
+         * count    增加内容长度,删除内容为0
+         * */
+        @Override
+        public void onTextChanged(CharSequence s, int start, int before, int count) {
+//            Log.d("TextChange", "on Text Changed: " + s + " Start: " + start + " Before: " + before + " Count: " + count);
+        }
+
+        @Override
+        public void afterTextChanged(Editable s) {
+
+            /**
+             * 文本处理
+             * */
+            if (new_string_length == 0) {
+                string = "";
+            } else {
+                string = s.toString().substring(start_position,start_position + new_string_length);
+            }
+
+            if (change_length == 0) { // 新加内容
+
+            } else { // 替换原文或删除原文
+
+            }
+
+            /**
+             * 业务逻辑
+             * */
+
+            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n")) {
+                textView.setText(origin_text);
+                return;
+            }
+
+            mKeywords = s.toString();
+            adapter.notifyDataSetChanged();
+
+        }
+    }
+
 
     private int maxSelect;
     private int mGroup;
@@ -72,6 +154,8 @@ public class EnumSlectActivity extends AppCompatActivity {
     private EnumAdapter adapter;
     private Context mCtx;
 
+    private EditText searchBar;
+
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -82,6 +166,9 @@ public class EnumSlectActivity extends AppCompatActivity {
 
         setTitle(mTitle);
 
+        searchBar = (EditText)findViewById(R.id.common_editor_enum_search_bar);
+        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx,searchBar));
+
         enum_list_view = (ListView)findViewById(R.id.enum_list_view);
 
         adapter = new EnumAdapter(mCtx);
@@ -142,6 +229,8 @@ public class EnumSlectActivity extends AppCompatActivity {
             try {
                 if (mSingleSelect) {
 
+                    boolean is_worked = false;
+
                     if (mKeywords == null || mKeywords.isEmpty()) {
 
                         for (int i = 0; i < mCadedate.optInt("count"); i++) {
@@ -152,6 +241,8 @@ public class EnumSlectActivity extends AppCompatActivity {
                             } else {
                                 val_json.put("check","0");
                             }
+                            is_worked = i == position;
+
                             mCadedate.put("val_" + i,val_json);
 
                         } // for
@@ -175,33 +266,54 @@ public class EnumSlectActivity extends AppCompatActivity {
 
                             if (count - 1 == position) {
                                 val_json = search_json;
-                            }
-                        } // for cc
 
-                        for (int sc = 0; sc < mCadedate.optInt("count"); sc++) {
+                                //==========
+                                int select = val_json.optInt("check");
+                                if (select != 0) {
+                                    val_json.put("check","0");
+                                } else {
+                                    val_json.put("check","1");
+                                }
 
-                            JSONObject sc_json = mCadedate.optJSONObject("val_" + sc);
-                            if (sc_json.optString("value").equals(val_json.optString("value"))) {
-                                sc_json.put("check","1");
-                            } else {
-                                sc_json.put("check","0");
+                                is_worked = select == 0;
+
+                                mCadedate.put("val_" + cc,val_json);
+
+                                break;
                             }
-                            mCadedate.put("val_" + sc,sc_json);
+                        } // for cc
 
-                        } // for sc
+//                        for (int sc = 0; sc < mCadedate.optInt("count"); sc++) {
+//
+//                            JSONObject sc_json = mCadedate.optJSONObject("val_" + sc);
+//
+//                            if (sc_json.optString("value").equals(val_json.optString("value"))) {
+//                                sc_json.put("check","1");
+//                            } else {
+//                                sc_json.put("check","0");
+//                            }
+//                            mCadedate.put("val_" + sc,sc_json);
+//
+//                        } // for sc
 
 
                     }
 
-                    if (mAuto_close) {
-                        finish();
+                    if (is_worked) {
+                        if (mAuto_close) {
+                            finish();
+                        } else {
+                            adapter.notifyDataSetChanged();
+                        }
                     } else {
                         adapter.notifyDataSetChanged();
                     }
 
+
                 } // single select
                 else {
 
+                    int index = position;
                     JSONObject val_json = null;
                     if (mKeywords == null || mKeywords.isEmpty()) {
                         val_json = mCadedate.optJSONObject("val_" + position);
@@ -220,6 +332,8 @@ public class EnumSlectActivity extends AppCompatActivity {
 
                             if (count - 1 == position) {
                                 val_json = search_json;
+                                index = i;
+                                break;
                             }
                         }
                     }
@@ -239,7 +353,7 @@ public class EnumSlectActivity extends AppCompatActivity {
                         }
                         val_json.put("check","1");
                     }
-                    mCadedate.put("val_" + position,val_json);
+                    mCadedate.put("val_" + index,val_json);
 
                 }
                 adapter.notifyDataSetChanged();
@@ -333,7 +447,7 @@ public class EnumSlectActivity extends AppCompatActivity {
                 val_json = mCadedate.optJSONObject("val_" + position);
             } else {
                 int count = 0;
-                for (int i = 0; i < val_json.optInt("count"); i++) {
+                for (int i = 0; i < mCadedate.optInt("count"); i++) {
                     if (count >= filter_count) {
                         break;
                     }

Разница между файлами не показана из-за своего большого размера
+ 93 - 34
RedAnt Mobile/app/src/main/java/com/usai/redant/CommonEditor/Utils.java


+ 61 - 29
RedAnt Mobile/app/src/main/java/com/usai/redant/Result/SearchResultActivity.java

@@ -200,6 +200,14 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
     private void setupUI() {
         try {
+            if (resultData == null) {
+                return;
+            } else {
+                int result = resultData.getInt("result");
+                if (result != 2) {
+                    return;
+                }
+            }
             JSONObject layout = resultData.getJSONObject("layout");
 
             JSONObject header = layout.getJSONObject("header");
@@ -301,43 +309,62 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
 
                 try {
 
-                    Thread.sleep(2000);
-
-                    InputStream in = getResources().openRawResource( R.raw.result);
-                    int length = in.available();
-                    byte[] buffer = new byte[length];
-                    in.read(buffer);
-                    String res = new String(buffer,"utf8");
-                    in.close();
+//                    Thread.sleep(2000);
+//
+//                    InputStream in = getResources().openRawResource( R.raw.result);
+//                    int length = in.available();
+//                    byte[] buffer = new byte[length];
+//                    in.read(buffer);
+//                    String res = new String(buffer,"utf8");
+//                    in.close();
+//
+//                    JSONObject newJson = new JSONObject(res);
+
+                    mParams.putInt("offset",adapter.getCount());
+                    JSONObject newJson = Network.query(mParams);
+
+                    if (newJson != null) {
+
+                        int result = newJson.getInt("result");
+                        if (result == 2) {
+                            JSONObject newData = newJson.getJSONObject("data");
+                            int add_count = newData.getInt("count");
+
+                            JSONObject data = resultData.getJSONObject("data");
+                            int count = data.getInt("count");
+
+                            for (int i = 0; i < add_count; i++) {
+                                JSONArray new_data_item = newData.getJSONArray("item_" + i);
+                                if (new_data_item != null) {
+                                    data.put("item_" + count++,new_data_item);
+                                }
+                            }
+                            data.put("count",count);
+                            resultData.put("data",data);
 
-                    JSONObject newJson = new JSONObject(res);
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    setupUI();
+                                    loadComplete();
+                                    adapter.notifyDataSetChanged();
+                                }
+                            });
+                        } else {
+                            String msg = newJson.getString("msg");
+                            if (msg == null || msg.isEmpty()) {
+                                msg = "Some error occurred";
+                            }
+                            showAlert(msg);
+                        }
 
-                    JSONObject newData = newJson.getJSONObject("data");
-                    int add_count = newData.getInt("count");
 
-                    JSONObject data = resultData.getJSONObject("data");
-                    int count = data.getInt("count");
-
-                    for (int i = 0; i < add_count; i++) {
-                        JSONArray new_data_item = newData.getJSONArray("item_" + i);
-                        if (new_data_item != null) {
-                            data.put("item_" + count++,new_data_item);
-                        }
                     }
-                    data.put("count",count);
-                    resultData.put("data",data);
 
-                    runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            setupUI();
-                            loadComplete();
-                            adapter.notifyDataSetChanged();
-                        }
-                    });
 
                 } catch (Exception e) {
                     Log.e("Result", "onCreate: ",e);
+                    showAlert("Some error occurred");
                 }
 
 
@@ -543,6 +570,11 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
         public int getCount() {
             if (resultData == null) {
                 return 0;
+            } else {
+                int result = resultData.optInt("result");
+                if (result != 2) {
+                    return 0;
+                }
             }
             try {
                 JSONObject data = resultData.getJSONObject("data");

+ 114 - 0
RedAnt Mobile/app/src/main/java/com/usai/redant/Search/RamSearchSettingActivity.java

@@ -0,0 +1,114 @@
+package com.usai.redant.Search;
+
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.ExpandableListView;
+
+import com.usai.redant.CommonEditor.CommonEditorActivity;
+import com.usai.redant.redantmobile.R;
+import com.usai.redant.util.Network;
+import com.usai.redant.util.RAUtil;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+public class RamSearchSettingActivity extends CommonEditorActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+
+
+        hasChildView = true;
+        setContentView(R.layout.activity_ram_search_setting);
+        listView = (ExpandableListView)findViewById(R.id.ram_search_setting_list_view);
+
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+
+        getMenuInflater().inflate(R.menu.ram_search_setting_menu,menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        if (item.getItemId() == R.id.ram_search_setting_save) {
+
+            JSONObject upparams = check_cancomit(false);
+
+            try {
+
+                JSONObject hidden_params = content_data_download.optJSONObject("hidden_params");
+
+                if (hidden_params != null) {
+
+                    Iterator<String> iterator = hidden_params.keys();
+                    while (iterator.hasNext()) {
+                        String key = iterator.next();
+                        Object value = hidden_params.get(key);
+                        if (value != null) {
+                            upparams.put(key,value);
+                        }
+                    }
+                }
+
+                upparams.put("query_id",selfParams.getString("query_id"));
+
+                final Bundle bundle = RAUtil.Json2Bundle(upparams);
+
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+
+                        final JSONObject contentDic = Network.save_query_setting(bundle);
+
+                        runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    if (contentDic == null) {
+                                        showWarningAlert("Some error occurred");
+                                    } else {
+                                        int result = contentDic.getInt("result");
+                                        if (result == 2) {
+                                            finish();
+                                        } else {
+                                            String msg = contentDic.getString("msg");
+                                            if (msg == null || msg.isEmpty()) {
+                                                msg = "Some error occurred";
+                                            }
+                                            showWarningAlert(msg);
+                                        }
+                                    }
+
+                                } catch (JSONException e) {
+                                    e.printStackTrace();
+                                }
+
+                            }
+                        });
+
+
+                    }
+                }).start();
+
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+
+        }
+
+        return true;
+    }
+
+    @Override
+    public JSONObject request_editor(String request_url, Bundle params) {
+        return Network.request_setting(request_url,params);
+    }
+}

+ 35 - 1
RedAnt Mobile/app/src/main/java/com/usai/redant/redantmobile/ModeListActivity.java

@@ -22,6 +22,7 @@ import android.widget.TextView;
 import com.usai.redant.CommonEditor.CommonEditorActivity;
 import com.usai.redant.Result.SearchResultActivity;
 import com.usai.redant.Search.RamSearchActivity;
+import com.usai.redant.Search.RamSearchSettingActivity;
 import com.usai.redant.raimage.ModeActivity;
 
 import org.json.JSONArray;
@@ -205,10 +206,41 @@ public class ModeListActivity extends AppCompatActivity {
         private class ModeViewHolder {
             TextView name_lb;
             ImageButton setting_btn;
+            int position;
             ModeViewHolder(View cell) {
                 name_lb = (TextView)cell.findViewById(R.id.ram_mode_name_lb);
                 setting_btn = (ImageButton)cell.findViewById(R.id.ram_mode_setting_btn);
                 cell.setTag(this);
+
+                setting_btn.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        JSONObject modeItem = (JSONObject) getItem(position);
+
+                        try {
+
+                            String title = modeItem.optString("name");
+                            String query_id = modeItem.getString("query_id");
+
+                            Bundle bundle = new Bundle();
+                            if (title != null) {
+                                bundle.putString("title",title);
+                            }
+                            bundle.putString("query_id",query_id);
+
+                            Intent intent = new Intent(mContext, RamSearchSettingActivity.class);
+                            intent.putExtra("params",bundle);
+                            intent.putExtra("request_url",RedAntApplication.server);
+                            intent.putExtra("url_type", CommonEditorActivity.URL_REMOTE);
+
+                            startActivity(intent);
+
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+
+                    }
+                });
             }
         }
 
@@ -252,7 +284,7 @@ public class ModeListActivity extends AppCompatActivity {
 
             JSONObject modeItem = (JSONObject) getItem(i);
             String type = modeItem.optString("type");
-            if (type == null && type.equals("query")) {
+            if (type != null && type.equals("query")) {
                 holder.setting_btn.setVisibility(View.VISIBLE);
             } else {
                 holder.setting_btn.setVisibility(View.INVISIBLE);
@@ -283,6 +315,8 @@ public class ModeListActivity extends AppCompatActivity {
                 holder.name_lb.setText(span);
             }
 
+            holder.position = i;
+
             return cell;
         }
     }

+ 105 - 0
RedAnt Mobile/app/src/main/java/com/usai/redant/util/Network.java

@@ -63,6 +63,7 @@ import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.UnrecoverableKeyException;
+import java.util.Iterator;
 import java.util.Set;
 import java.util.UUID;
 
@@ -1645,6 +1646,10 @@ public class Network
 
 	public static JSONObject request_editor(String request_url,Bundle params) {
 
+		if (request_url == null || request_url.isEmpty() || params == null) {
+			return null;
+		}
+
 		String json_string = getJson(request_url,params);
 
 		if (json_string == null || json_string.isEmpty()) {
@@ -1659,6 +1664,80 @@ public class Network
 		}
 	}
 
+	public static JSONObject request_setting(String request_url, Bundle params) {
+
+		if (request_url == null || request_url.isEmpty() || params == null) {
+			return null;
+		}
+
+		params.putString("_action","ant_mobile");
+		params.putString("_operate","search_setting");
+
+		return request_editor(request_url,params);
+	}
+
+	public static JSONObject commoneditor_partialrefresh(JSONObject params,String url) {
+
+		Bundle bundle = new Bundle();
+		Iterator<String> keys = params.keys();
+		try {
+			while (keys.hasNext()) {
+				String key = keys.next();
+				Object obj = params.get(key);
+
+				if (obj instanceof Boolean)
+				{
+					bundle.putBoolean(key,((Boolean) obj).booleanValue());
+				}
+				else if(obj instanceof Byte)
+				{
+					bundle.putByte(key, ((Byte) obj).byteValue());
+				}
+				else if(obj instanceof Character)
+				{
+					bundle.putChar(key, ((Character) obj).charValue());
+				}
+				else if(obj instanceof Double)
+				{
+					bundle.putDouble(key, ((Double) obj).doubleValue());
+				}
+				else if(obj instanceof Float)
+				{
+					bundle.putFloat(key, ((Float) obj).floatValue());
+				}
+				else if(obj instanceof Integer)
+				{
+					bundle.putInt(key, ((Integer) obj).intValue());
+				}
+				else if(obj instanceof Long)
+				{
+					bundle.putLong(key, ((Long) obj).longValue());
+				}
+				else if(obj instanceof Short)
+				{
+					bundle.putShort(key, ((Short) obj).shortValue());
+				}
+				else if(obj instanceof String)
+				{
+					bundle.putString(key, obj.toString());
+				}
+
+			}
+
+			String json_string = getJson(url,bundle);
+
+			if (json_string == null || json_string.isEmpty()) {
+				return null;
+			}
+
+			return new JSONObject(json_string);
+
+		} catch (JSONException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
 	public static JSONObject query(Bundle params) {
 
 		params.putString("_action","ant_mobile");
@@ -1678,4 +1757,30 @@ public class Network
 		}
 	}
 
+	public static JSONObject save_query_setting(Bundle upparams) {
+
+		if (upparams == null) {
+			return null;
+		}
+
+		upparams.putString("_action","ant_mobile");
+		upparams.putString("_operate","save_searchsetting");
+
+		String json_string = getJson(RedAntApplication.server,upparams);
+
+		if (json_string == null || json_string.isEmpty()) {
+			return null;
+		}
+
+		try {
+			return new JSONObject(json_string);
+		} catch (JSONException e) {
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+
+
 }

+ 13 - 0
RedAnt Mobile/app/src/main/res/drawable/circle_corner_border.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="10dp"/>
+
+    <solid android:color="@color/clear_color"/>
+
+    <stroke
+        android:width="1dp"
+        android:color="@color/dark_gray"
+        />
+
+</shape>

+ 18 - 0
RedAnt Mobile/app/src/main/res/drawable/red_border.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!--背景色-->
+    <solid android:color="#FFFFFF" />
+
+    <!--边框颜色-->
+    <stroke
+        android:width="0.01dp"
+        android:color="#ff0000" />
+
+    <padding
+        android:bottom="1dp"
+        android:left="1dp"
+        android:right="1dp"
+        android:top="1dp" />
+
+</shape>

+ 33 - 2
RedAnt Mobile/app/src/main/res/layout/activity_enum_slect.xml

@@ -1,16 +1,47 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
+<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="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:orientation="vertical"
     tools:context="com.usai.redant.CommonEditor.EnumSlectActivity">
 
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        >
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="50dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginEnd="10dp"
+            android:layout_marginTop="5dp"
+            android:layout_marginBottom="5dp"
+            android:background="@drawable/circle_corner_border"
+            >
+            <EditText
+                android:id="@+id/common_editor_enum_search_bar"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginStart="5dp"
+                android:background="@null"
+                android:hint="filter"
+                android:imeOptions="actionGo"
+                android:maxLines="1"
+                />
+        </RelativeLayout>
+
+    </RelativeLayout>
+
     <ListView
         android:id="@+id/enum_list_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+
         />
 
 
-</RelativeLayout>
+</LinearLayout>

+ 16 - 0
RedAnt Mobile/app/src/main/res/layout/activity_ram_search_setting.xml

@@ -0,0 +1,16 @@
+<?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="match_parent"
+    tools:context="com.usai.redant.Search.RamSearchSettingActivity">
+
+
+    <ExpandableListView
+        android:id="@+id/ram_search_setting_list_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        />
+
+</RelativeLayout>

+ 1 - 0
RedAnt Mobile/app/src/main/res/layout/ram_mode_cell.xml

@@ -2,6 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+              android:descendantFocusability="blocksDescendants"
     android:orientation="horizontal">
 
     <TextView

+ 14 - 0
RedAnt Mobile/app/src/main/res/menu/ram_search_setting_menu.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <item
+        android:id="@+id/ram_search_setting_save"
+        android:title="Save"
+        app:showAsAction="always"
+        android:icon="@drawable/camera"
+        >
+
+    </item>
+
+</menu>

Некоторые файлы не были показаны из-за большого количества измененных файлов