Переглянути джерело

1.完成RedAnt Mobile Android Mode List用户界面和交互。
2.完成RedAnt Mobile Android Search数据加载。

Pen Li 8 роки тому
батько
коміт
ca3d80b9d7

+ 133 - 121
RedAnt Mobile/app/src/main/AndroidManifest.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.usai.redant.redantmobile">
+          package="com.usai.redant.redantmobile">
 
     <uses-permission android:name="android.permission.CAMERA"/>
     <uses-permission android:name="android.permission.VIBRATE"/>
@@ -10,7 +10,6 @@
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
-
     <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
 
     <application
@@ -21,13 +20,12 @@
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
-
         <activity
             android:name=".ServerSettingActivity"
             android:label="@string/title_activity_service_setting"
             android:screenOrientation="portrait"/>
-
-        <activity android:name=".LoginActivity"
+        <activity
+            android:name=".LoginActivity"
             android:label="@string/title_activity_full_screen_login"
             android:screenOrientation="portrait"
             android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
@@ -42,152 +40,166 @@
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>
+        <activity
+            android:name="com.usai.redant.raimage.MainActivity"
+            android:label="@string/app_name"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light">
 
-
-    <activity
-        android:name="com.usai.redant.raimage.MainActivity"
-        android:label="@string/app_name"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light">
-
-        <!--
+            <!--
              <intent-filter>
             <action android:name="android.intent.action.MAIN" />
 
             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
-        -->
-    </activity>
-    <activity
-        android:name="com.usai.redant.raimage.CaptureActivity"
-        android:clearTaskOnLaunch="true"
-        android:label="Scan"
-        android:screenOrientation="sensorLandscape"
-        android:stateNotNeeded="true"
-        android:theme="@style/CaptureTheme"
-        android:windowSoftInputMode="stateAlwaysHidden">
-
-        <!--
+            -->
+        </activity>
+        <activity
+            android:name="com.usai.redant.raimage.CaptureActivity"
+            android:clearTaskOnLaunch="true"
+            android:label="Scan"
+            android:screenOrientation="sensorLandscape"
+            android:stateNotNeeded="true"
+            android:theme="@style/CaptureTheme"
+            android:windowSoftInputMode="stateAlwaysHidden">
+
+            <!--
              <intent-filter>
             <action android:name="android.intent.action.MAIN" />
 
             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
-        -->
-    </activity>
-    <activity
-        android:name="com.usai.redant.raimage.UploadQueueActivity"
-        android:label="Upload queue"
-        android:screenOrientation="sensorLandscape"
-        android:theme="@style/CaptureTheme"/>
-    <activity
-        android:name="com.usai.redant.raimage.PreferencesActivity"
-        android:label="@string/preferences_name"
-        android:stateNotNeeded="true"/>
-    <activity
-        android:name="com.usai.redant.raimage.PhotoPreviewActivity"
-        android:label="Photo preview"
-        android:screenOrientation="sensorLandscape"
-        android:windowSoftInputMode="stateHidden|adjustResize"/>
-
-    <receiver android:name="com.usai.redant.raimage.BootReceiver">
-        <intent-filter android:priority="2147483647">
-            <action android:name="android.intent.action.BOOT_COMPLETED"/>
-            <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
-        </intent-filter>
-    </receiver>
-
-    <service
-        android:name="com.usai.redant.raimage.UploadService"
-        android:label="usai upload service">
-        <intent-filter>
-            <action android:name="com.usai.raimage.uploadservice"/>
-        </intent-filter>
-    </service>
-
-    <activity
-        android:name="com.usai.redant.raimage.AboutActivity"
-        android:label="@string/title_activity_about"
-        android:screenOrientation="sensorLandscape"/>
-    <activity
-        android:name="com.usai.redant.raimage.LicenseActivity"
-        android:label="@string/title_activity_license"
-        android:screenOrientation="sensorLandscape"/>
-
-
-
+            -->
+        </activity>
+        <activity
+            android:name="com.usai.redant.raimage.UploadQueueActivity"
+            android:label="Upload queue"
+            android:screenOrientation="sensorLandscape"
+            android:theme="@style/CaptureTheme"/>
+        <activity
+            android:name="com.usai.redant.raimage.PreferencesActivity"
+            android:label="@string/preferences_name"
+            android:stateNotNeeded="true"/>
+        <activity
+            android:name="com.usai.redant.raimage.PhotoPreviewActivity"
+            android:label="Photo preview"
+            android:screenOrientation="sensorLandscape"
+            android:windowSoftInputMode="stateHidden|adjustResize"/>
+
+        <receiver android:name="com.usai.redant.raimage.BootReceiver">
+            <intent-filter android:priority="2147483647">
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
+            </intent-filter>
+        </receiver>
 
-    <activity
-        android:name="com.usai.redant.raimage.ModeActivity"
-        android:theme="@style/Base.Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.uploadSettingActivity"
-        android:theme="@style/Base.Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.POP.PopActivity"
-        android:label="@string/app_name"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light"
-        android:windowSoftInputMode="stateHidden|adjustResize"/>
-    <activity
-        android:name="com.usai.redant.raimage.Model.ModelActivity"
-        android:label="@string/app_name"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light"
-        android:windowSoftInputMode="stateHidden|adjustResize"/>
-    <activity
-        android:name="com.usai.redant.raimage.PhotoList.PhotoListActivity"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.PhotoList.NewPhotoPreviewActivity"
-        android:label="@string/app_name"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.Model.ManufactureListActivity"
-        android:theme="@style/Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.UploadList.UploadListActivity"
-        android:theme="@style/Theme.AppCompat.Light"/>
-    <activity
-        android:name="com.usai.redant.raimage.TaskActivity"
-        android:theme="@style/Theme.AppCompat.Light"/>
+        <service
+            android:name="com.usai.redant.raimage.UploadService"
+            android:label="usai upload service">
+            <intent-filter>
+                <action android:name="com.usai.raimage.uploadservice"/>
+            </intent-filter>
+        </service>
 
-    <activity android:name="com.usai.redant.raimage.PhotoList.PhotoGridActivity"
-        android:stateNotNeeded="true"
-        android:theme="@style/Theme.AppCompat.Light">
-    </activity>
+        <activity
+            android:name="com.usai.redant.raimage.AboutActivity"
+            android:label="@string/title_activity_about"
+            android:screenOrientation="sensorLandscape"/>
+        <activity
+            android:name="com.usai.redant.raimage.LicenseActivity"
+            android:label="@string/title_activity_license"
+            android:screenOrientation="sensorLandscape"/>
+        <activity
+            android:name="com.usai.redant.raimage.ModeActivity"
+            android:theme="@style/Base.Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.uploadSettingActivity"
+            android:theme="@style/Base.Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.POP.PopActivity"
+            android:label="@string/app_name"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light"
+            android:windowSoftInputMode="stateHidden|adjustResize"/>
+        <activity
+            android:name="com.usai.redant.raimage.Model.ModelActivity"
+            android:label="@string/app_name"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light"
+            android:windowSoftInputMode="stateHidden|adjustResize"/>
+        <activity
+            android:name="com.usai.redant.raimage.PhotoList.PhotoListActivity"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.PhotoList.NewPhotoPreviewActivity"
+            android:label="@string/app_name"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.Model.ManufactureListActivity"
+            android:theme="@style/Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.UploadList.UploadListActivity"
+            android:theme="@style/Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.TaskActivity"
+            android:theme="@style/Theme.AppCompat.Light"/>
+        <activity
+            android:name="com.usai.redant.raimage.PhotoList.PhotoGridActivity"
+            android:stateNotNeeded="true"
+            android:theme="@style/Theme.AppCompat.Light">
+        </activity>
 
         <!-- CommonEditor -->
 
-        <activity android:name="com.usai.redant.CommonEditor.CommonEditorActivity">
+        <activity android:name="com.usai.redant.CommonEditor.CommonEditorActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ImageUploadActivity">
+        <activity android:name="com.usai.redant.CommonEditor.ImageUploadActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ImageViewActivity">
+        <activity android:name="com.usai.redant.CommonEditor.ImageViewActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.BundleModelActivity">
+        <activity android:name="com.usai.redant.CommonEditor.BundleModelActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.AddressEditorActivity">
+        <activity android:name="com.usai.redant.CommonEditor.AddressEditorActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.CreditCardEditorActivity">
+        <activity android:name="com.usai.redant.CommonEditor.CreditCardEditorActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.ContactListActivity">
+        <activity android:name="com.usai.redant.CommonEditor.ContactListActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.EnumSlectActivity">
+        <activity android:name="com.usai.redant.CommonEditor.EnumSlectActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.DatePickerActivity">
+        <activity android:name="com.usai.redant.CommonEditor.DatePickerActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.MonthPickerActivity">
+        <activity android:name="com.usai.redant.CommonEditor.MonthPickerActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
-        <activity android:name="com.usai.redant.CommonEditor.SignatureActivity">
+        <activity android:name="com.usai.redant.CommonEditor.SignatureActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
 
         <!-- Result -->
-        <activity android:name="com.usai.redant.Result.SearchResultActivity">
+        <activity android:name="com.usai.redant.Result.SearchResultActivity"
+                  android:theme="@style/Theme.AppCompat.Light">>
         </activity>
 
-</application>
+        <!-- RedAnt Mobile -->
+        <activity
+            android:name=".ModeListActivity"
+            android:theme="@style/Theme.AppCompat.Light">
+        </activity>
+        <activity android:name="com.usai.redant.Search.RamSearchActivity"
+                  android:theme="@style/Theme.AppCompat.Light">
+        </activity>
+    </application>
 
 </manifest>

+ 134 - 113
RedAnt Mobile/app/src/main/java/com/usai/redant/CommonEditor/CommonEditorActivity.java

@@ -42,6 +42,7 @@ import com.usai.redant.CommonEditor.CommonEditor.CommonEditorSignatureCellHolder
 import com.usai.redant.CommonEditor.CommonEditor.CommonEditorSwitchCellHolder;
 import com.usai.redant.CommonEditor.CommonEditor.CommonEditorTextViewCellHolder;
 import com.usai.redant.redantmobile.R;
+import com.usai.redant.util.Network;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -80,11 +81,29 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
     }
 
+    public JSONObject request_editor(String request_url,Bundle params) {
+        return null;
+    }
+
     public static class subitem_data {
         public JSONObject params;
         public JSONArray missingfields;
     }
 
+    private ProgressDialog showProgressAlert(String title,String msg) {
+        ProgressDialog pd = new ProgressDialog(this);
+        pd.setTitle(title);
+        pd.setMessage(msg);
+        /**
+         * false,表示 ProgressDialog 是不能通过 Back 键取消
+         * 数据加载完成后必须要调用 ProgressDialog 的 dismiss() 方法来关闭对话框
+         * */
+        pd.setCancelable(false);
+        pd.show();
+
+        return pd;
+    }
+
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.action_bar_menu,menu);
@@ -113,14 +132,21 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
         if (content_data_download != null) {
             outState.putString("download_content",content_data_download.toString());
         }
+
+        if (service_url != null) {
+            outState.putString("request_url",service_url);
+        }
+
+        outState.putInt("url_type",url_type);
+        outState.putBundle("params",selfParams);
     }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_main);
+        setContentView(R.layout.activity_common_editor);
 
-        service_url = "http://192.168.0.133:8080/site/isales/getAddCustomer.htm";
+//        service_url = "http://192.168.0.133:8080/site/isales/getAddCustomer.htm";
 
         listView = (ExpandableListView)findViewById(R.id.list_view);
 
@@ -147,7 +173,6 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
         listView.setAdapter(adapter);
 
-//        loadData();
 
         if (savedInstanceState != null) {
             String control_str = savedInstanceState.getString("control_content");
@@ -165,16 +190,101 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 content_data_download = null;
             }
 
-        }
+            service_url = savedInstanceState.getString("request_url");
+            url_type = savedInstanceState.getInt("url_type");
+            selfParams = savedInstanceState.getBundle("params");
 
-        if (content_data_download == null || content_data_control == null) {
-            JSONObject obj = Utils.testJson(true);
-            if (obj != null) {
-                handleJson(obj);
+        } else {
+            service_url = getIntent().getStringExtra("request_url");
+            url_type = getIntent().getIntExtra("url_type",URL_REMOTE);
+
+            Bundle params = getIntent().getBundleExtra("params");
+            if (params != null) {
+                selfParams = params;
             }
-        }
+
+            final ProgressDialog pd = showProgressAlert("Loading","Please wait");
+            new Thread(new Runnable() {
+                @Override
+                public void run() {
+
+                    if (url_type == URL_REMOTE) {
+                        final JSONObject obj = request_editor(service_url,selfParams);
+
+
+                        runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+
+                                pd.dismiss();
+
+                                if (obj != null) {
+
+                                    int result = obj.optInt("result");
+                                    if (result == 2) {
+
+                                        content_data_download = copyDirtyTo(content_data_download,obj);
+                                        content_data_control = translateChange(content_data_download,changed_data);
+
+
+                                        download_success();
+                                        defaulExpandSections();
+                                        adapter.notifyDataSetChanged();
+
+                                    } else {
+                                        Utils.message_alert(mCtx,"Warning","Error");
+                                    }
+
+                                } else {
+                                    Utils.message_alert(mCtx,"Warning","Error");
+                                }
+
+                            }
+                        });
+
+                    } else {
+
+                        try {
+
+                            InputStreamReader isr = new InputStreamReader(getAssets().open(service_url + ".json"),"UTF-8");
+                            BufferedReader br = new BufferedReader(isr);
+                            String line;
+                            StringBuilder builder = new StringBuilder();
+                            while((line = br.readLine()) != null){
+                                builder.append(line);
+                            }
+                            br.close();
+                            isr.close();
+                            content_data_download = new JSONObject(builder.toString());//builder读取了JSON中的数据。
+
+                            request_fill();
+
+                            content_data_control = translateChange(content_data_download,changed_data);
+
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    pd.dismiss();
+                                    adapter.notifyDataSetChanged();
+                                }
+                            });
 
 
+                        } catch (Exception e) {
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    pd.dismiss();
+                                }
+                            });
+                            e.printStackTrace();
+                        }
+
+                    }
+
+                }
+            }).start();
+        }
 
     }
 
@@ -726,99 +836,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
     }
 
 
-    public void loadData() {
-
-        if (service_url == null || service_url.isEmpty()) {
-            return;
-        }
-
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                HttpURLConnection connection = null;
-                try {
-
-                    URL url = new URL(service_url);
-                    connection = (HttpURLConnection)url.openConnection();
-                    connection.setRequestMethod("POST");
-                    connection.setConnectTimeout(1500);
-                    connection.setReadTimeout(1500);
-                    connection.setUseCaches(false);
-                    connection.setDoInput(true);
-                    connection.setDoOutput(true);
-                    connection.setRequestProperty("Content-Type","multipart/form-data; boundary=AaB03x");
-                    connection.setRequestProperty("Connection","close");
-
-                    OutputStreamWriter outputStreamWriter = new OutputStreamWriter(connection.getOutputStream());
-                    outputStreamWriter.write("password=123456&app_ver=170814&idfv=D3CE97F6-3586-4804-B7E6-7C7AB027A235&ipad_perm={\"submit_order_logout\":\"true\",\"can_submit_order\":\"true\",\"can_set_tearsheet_price\":\"true\",\"can_update_contact_info\":\"true\",\"can_see_price\":\"true\",\"alert_sold_in_quantities\":\"true\",\"can_show_price\":\"true\",\"can_create_portfolio\":\"true\",\"can_set_cart_price\":\"true\",\"save_order_logout\":\"true\",\"can_create_order\":\"true\"}&app_short_ver=1.90&user=Admin");
-
-                    InputStream inputStream = connection.getInputStream();
-                    readInputStream(inputStream);
-
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }).start();
-    }
-
     JSONObject changed_data;
-    private void readInputStream(InputStream inputStream) {
-        try {
-            // 对获取到到输入流读取
-            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
-            StringBuilder response = new StringBuilder();
-            String line;
-            while ((line = reader.readLine()) != null) {
-                response.append(line);
-            }
-            JSONObject object = new JSONObject(response.toString());
-
-            int result = object.optInt("result");
-            if (result == 2) {
-
-                content_data_download = copyDirtyTo(content_data_download,object);
-                content_data_control = translateChange(content_data_download,changed_data);
-
-                download_success();
-                adapter.notifyDataSetChanged();
-
-            } else {
-
-            }
-
-
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    private void handleJson(final JSONObject object) {
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                int result = object.optInt("result");
-                if (result == 2) {
-
-                    content_data_download = copyDirtyTo(content_data_download,object);
-                    content_data_control = translateChange(content_data_download,changed_data);
-
-                    download_success();
-                    runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            defaulExpandSections();
-                            adapter.notifyDataSetChanged();
-                        }
-                    });
-
-                } else {
-                    Utils.message_alert(mCtx,"Warning","Error");
-                }
-            }
-        }).start();
-    }
 
     public JSONObject copyDirtyTo(JSONObject dirty, JSONObject to) {
 
@@ -980,12 +998,14 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
         if (lastEditText != null) {
             endEditting();
         }
+
+        final ProgressDialog pd = showProgressAlert("Loading","Please wait");
+
         if (url_type == URL_REMOTE) {
 
-            final ProgressDialog pd = Utils.waiting_alert(mCtx,"loading","please wait");
             if (trigger != null) {
                 try {
-                    selfParams.put("refresh_trigger",trigger);
+                    selfParams.putString("refresh_trigger",trigger);
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
@@ -999,13 +1019,13 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                         String key = iterator.next();
                         String obj_str = "" + refresh_params.optString(key);
                         try {
-                            selfParams.put(key,obj_str);
+                            selfParams.putString(key,obj_str);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
                     }
 
-                    final JSONObject editor_json = Utils.request_editor(service_url,selfParams);
+                    final JSONObject editor_json = request_editor(service_url,selfParams);
 
                     runOnUiThread(new Runnable() {
                         @Override
@@ -1052,15 +1072,16 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
 
                 content_data_control = translateChange(content_data_download,changed_data);
                 adapter.notifyDataSetChanged();
-
+                pd.dismiss();
             } catch (Exception e) {
                 e.printStackTrace();
+                pd.dismiss();
             }
 
         }
     }
 
-    public JSONObject selfParams = new JSONObject();
+    public Bundle selfParams = new Bundle();
     public JSONObject get_refresh_param() {
         try {
             JSONObject params = new JSONObject();
@@ -1069,7 +1090,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             for (int pc = 0; pc < param_count; pc++) {
                 String param_name = param_names.optString("val_" + pc);
                 String param_val = getValue(param_name);
-                selfParams.put(param_name,param_val);
+                selfParams.putString(param_name,param_val);
             }
             return params;
 
@@ -2423,7 +2444,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             holder.startMark.setVisibility(View.INVISIBLE);
         }
 
-        if (cancommit == false && required.equals("true") && (value == null || value.length() == 0)) {
+        if (cancommit == false && required != null && required.equals("true") && (value == null || value.length() == 0)) {
             // 阴影 red
         } else {
             // 无阴影
@@ -3126,10 +3147,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
         }
     }
 
-    static int URL_REMOTE = 1;
-    static int URL_LOCAL = 0;
-    static int URL_NONE = 2;
-    static int URL_RESTORE = 3;
+    public static int URL_REMOTE = 1;
+    public static int URL_LOCAL = 0;
+    public static int URL_NONE = 2;
+    public static int URL_RESTORE = 3;
     // 如何处理commoneditor action 类型调用的返回值
     static int ACTION_SAVE_DATA = 0;
     static int ACTION_FILL_SECTION = 1;

+ 2 - 1
RedAnt Mobile/app/src/main/java/com/usai/redant/CommonEditor/Utils.java

@@ -6,6 +6,7 @@ import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.os.Bundle;
 import android.os.Environment;
 
 import org.json.JSONObject;
@@ -254,7 +255,7 @@ public class Utils {
         return null;
     }
 
-    public static JSONObject request_editor(String request_url,JSONObject params) {
+    public static JSONObject request_editor(String request_url,Bundle params) {
 
         return null;
     }

+ 27 - 0
RedAnt Mobile/app/src/main/java/com/usai/redant/Search/RamSearchActivity.java

@@ -0,0 +1,27 @@
+package com.usai.redant.Search;
+
+import android.os.Bundle;
+
+import com.usai.redant.CommonEditor.CommonEditorActivity;
+import com.usai.redant.redantmobile.R;
+import com.usai.redant.util.Network;
+
+import org.json.JSONObject;
+
+public class RamSearchActivity extends CommonEditorActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+//        setContentView(R.layout.activity_ram_search);
+    }
+
+    @Override
+    public JSONObject request_editor(String request_url, Bundle params) {
+
+        params.putString("_action","ant_mobile");
+        params.putString("_operate","getCondition");
+
+        return Network.request_editor(request_url,params);
+    }
+}

+ 12 - 4
RedAnt Mobile/app/src/main/java/com/usai/redant/redantmobile/LoginActivity.java

@@ -35,6 +35,7 @@ import com.usai.redant.util.Network;
 import com.usai.redant.util.RAUtil;
 import com.usai.redant.util.dbgUtil;
 
+import org.json.JSONArray;
 import org.json.JSONObject;
 
 import java.util.HashSet;
@@ -158,10 +159,14 @@ public class LoginActivity extends AppCompatActivity {
                 RedAntApplication.user = m_sName;
                 RedAntApplication.password = m_sPassword;
                 RedAntApplication.server_info = json;
+
                 Intent intent = new Intent();
-                intent.setClass(LoginActivity.this, ModeActivity.class);
+                intent.setClass(LoginActivity.this, ModeListActivity.class);
+//                intent.putExtra("mode_list",)
+                JSONArray mode_list = json.optJSONArray("mode_list");
+                String mode_list_str = mode_list.toString();
+                intent.putExtra("mode_list",mode_list_str);
 
-                dbgUtil.fileLog("user "+m_sName+" login @server "+RedAntApplication.active_address);
                 startActivity(intent);
                 finish();
             }
@@ -396,6 +401,8 @@ public class LoginActivity extends AppCompatActivity {
                 .getSharedPreferences("redant mobile", 0);
 
 
+
+
         HashSet<String> user_list= (HashSet<String>) pref.getStringSet("user_list",new HashSet<String>());
         user_list.toArray(new String[0]);
 
@@ -427,7 +434,7 @@ public class LoginActivity extends AppCompatActivity {
 
         String u = pref.getString("user", null);
         String p = pref.getString("password", null);
-        String s = pref.getString("aa", null);
+        String s = pref.getString("serverName", null);
         if (u != null && p != null)
         {
             try
@@ -445,6 +452,7 @@ public class LoginActivity extends AppCompatActivity {
         }
 
         m_etServer.setText(s);
+        RedAntApplication.server = pref.getString("serverAddress",null);
 
         m_etPassword
                 .setOnEditorActionListener(new TextView.OnEditorActionListener()
@@ -515,7 +523,7 @@ public class LoginActivity extends AppCompatActivity {
         boolean pop = checkAllPermission();
         if(!pop)
         {
-            if(TextUtils.isEmpty(RedAntApplication.station_name))
+            if(TextUtils.isEmpty(RedAntApplication.server))
             {
                 Intent intent = new Intent();
                 intent.setClass(LoginActivity.this,ServerSettingActivity.class);

+ 289 - 0
RedAnt Mobile/app/src/main/java/com/usai/redant/redantmobile/ModeListActivity.java

@@ -0,0 +1,289 @@
+package com.usai.redant.redantmobile;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.AbsoluteSizeSpan;
+import android.text.style.ForegroundColorSpan;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.ImageButton;
+import android.widget.ListView;
+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.raimage.ModeActivity;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class ModeListActivity extends AppCompatActivity {
+
+    private JSONArray mModeList;
+    private ListView mListView;
+    private ModeAdapter mAdapter;
+    private Context mContext;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_mode_list);
+        mContext = this;
+
+        String modeList_string;
+        String title;
+        if (savedInstanceState == null) {
+            modeList_string = getIntent().getStringExtra("mode_list");
+            title = getIntent().getStringExtra("title");
+        } else {
+            modeList_string = savedInstanceState.getString("mode_list");
+            title = savedInstanceState.getString("title");
+        }
+
+        if (title != null) {
+            setTitle(title);
+        }
+
+        if (modeList_string != null && !modeList_string.isEmpty()) {
+            try {
+                mModeList = new JSONArray(modeList_string);
+                Log.d("Mode List", "onCreate: ");
+            } catch (JSONException e) {
+                mModeList = null;
+                e.printStackTrace();
+            }
+        } else {
+            mModeList = null;
+        }
+
+        mListView = (ListView)findViewById(R.id.ram_mode_list_view);
+        mAdapter = new ModeAdapter();
+        mListView.setAdapter(mAdapter);
+
+        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
+                JSONObject modeItem = (JSONObject) mAdapter.getItem(i);
+                String type = modeItem.optString("type");
+                if (type != null) {
+                    if (type.equals("predef_query")) {
+
+                        processPredefQuery(modeItem);
+
+                    } else if (type.equals("query")) {
+
+                        processQuery(modeItem);
+
+                    } else if (type.equals("local_func")) {
+
+                        processLocalFunc(modeItem);
+
+                    } else if (type.equals("submode")) {
+
+                        processSubmode(modeItem);
+
+                    }
+                }
+            }
+        });
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+
+        if (mModeList != null) {
+            outState.putString("mode_list",mModeList.toString());
+        }
+
+        CharSequence title = getTitle();
+        if (title != null) {
+            outState.putString("title",title.toString());
+        }
+    }
+
+
+    private void processPredefQuery(JSONObject modeInfo) {
+        try {
+            String query_id = modeInfo.getString("query_id");
+            String title = modeInfo.optString("title");
+
+            Intent intent = new Intent(mContext, SearchResultActivity.class);
+            intent.putExtra("query_id",query_id);
+            if (title != null) {
+                intent.putExtra("title",title);
+            }
+
+            startActivity(intent);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void processQuery(JSONObject modeInfo) {
+        try {
+            String title = modeInfo.optString("title");
+            String query_id = modeInfo.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, RamSearchActivity.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();
+        }
+    }
+
+    private void processLocalFunc(JSONObject modeInfo) {
+        try {
+//            String title = modeInfo.getString("title");
+            String module = modeInfo.getString("module");
+
+            if (module != null) {
+
+                if (module.equals("tools_change_pwd")) {
+                    Log.d("Mode List", "processLocalFunc: change password");
+                } else if (module.equals("raimage_mode")) {
+
+                    JSONObject serverinfo = new JSONObject();
+                    JSONArray mode_list = modeInfo.getJSONArray("ext_data");
+                    serverinfo.put("modellist",mode_list);
+                    RedAntApplication.server_info = serverinfo;
+
+                    Intent intent = new Intent(mContext, ModeActivity.class);
+                    startActivity(intent);
+                }
+
+            }
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void processSubmode(JSONObject modeInfo) {
+        try {
+
+            Intent intent = new Intent(mContext,ModeListActivity.class);
+
+            JSONArray mode_list = modeInfo.getJSONArray("mode_list");
+            String title = modeInfo.getString("name");
+
+            intent.putExtra("mode_list",mode_list.toString());
+            intent.putExtra("title",title);
+
+            startActivity(intent);
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private class ModeAdapter extends BaseAdapter {
+
+        private class ModeViewHolder {
+            TextView name_lb;
+            ImageButton setting_btn;
+            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);
+            }
+        }
+
+        @Override
+        public int getCount() {
+            if (mModeList == null) {
+                return 0;
+            }
+            return mModeList.length();
+        }
+
+        @Override
+        public Object getItem(int i) {
+            if (mModeList == null) {
+                return null;
+            }
+            return mModeList.opt(i);
+        }
+
+        @Override
+        public long getItemId(int i) {
+            return i;
+        }
+
+        @Override
+        public View getView(int i, View view, ViewGroup viewGroup) {
+
+            View cell = null;
+            ModeViewHolder holder = null;
+            if (view == null) {
+
+                cell = LayoutInflater.from(mContext).inflate(R.layout.ram_mode_cell,null);
+                holder = new ModeViewHolder(cell);
+
+            } else {
+
+                cell = view;
+                holder = (ModeViewHolder)cell.getTag();
+
+            }
+
+            JSONObject modeItem = (JSONObject) getItem(i);
+            String type = modeItem.optString("type");
+            if (type == null && type.equals("query")) {
+                holder.setting_btn.setVisibility(View.VISIBLE);
+            } else {
+                holder.setting_btn.setVisibility(View.INVISIBLE);
+            }
+
+            String name = modeItem.optString("name");
+            String desc = modeItem.optString("description");
+            if (desc == null || desc.isEmpty() || name == null || name.isEmpty()) {
+                holder.name_lb.setText(name);
+            } else {
+                String str = name + " -- " + desc;
+                Spannable span = new SpannableString(str);
+                    /* 设置字体大小
+                     * AbsoluteSizeSpan: boolean dip,如果为true,表示前面的字体大小单位为dip,否则为像素
+                     * start:
+                     * end:
+                     * 区间开闭:
+                     */
+                span.setSpan(new AbsoluteSizeSpan(15,true),name.length() + 1,str.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+                    /* 设置字体颜色
+                     *
+                     */
+                span.setSpan(new ForegroundColorSpan(Color.RED),name.length() + 1,str.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+                span.setSpan(new AbsoluteSizeSpan(17,true), 0, name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+                span.setSpan(new ForegroundColorSpan(Color.BLACK),0,name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+                holder.name_lb.setText(span);
+            }
+
+            return cell;
+        }
+    }
+}

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

@@ -1641,4 +1641,18 @@ public class Network
 			return null;
 		}
 	}
+
+
+	public static JSONObject request_editor(String request_url,Bundle params) {
+
+		String json_string = getJson(request_url,params);
+
+		try {
+			return new JSONObject(json_string);
+		} catch (JSONException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
 }

+ 19 - 0
RedAnt Mobile/app/src/main/res/layout/activity_mode_list.xml

@@ -0,0 +1,19 @@
+<?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.redantmobile.ModeListActivity">
+
+
+    <ListView
+        android:id="@+id/ram_mode_list_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+>
+
+    </ListView>
+
+
+</RelativeLayout>

+ 10 - 0
RedAnt Mobile/app/src/main/res/layout/activity_ram_search.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.usai.redant.Search.RamSearchActivity">
+
+</android.support.constraint.ConstraintLayout>

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

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/ram_mode_name_lb"
+        android:layout_width="0dp"
+        android:layout_height="50dp"
+        android:layout_weight="4"
+        android:layout_margin="5dp"
+        android:textSize="17sp"
+        android:layout_gravity="start|center_vertical"
+        android:gravity="start|center_vertical"
+        android:textColor="#000000"
+        />
+
+    <ImageButton
+        android:id="@+id/ram_mode_setting_btn"
+        android:layout_width="0dp"
+        android:layout_height="50dp"
+        android:layout_gravity="center_vertical|end"
+        android:layout_weight="1"
+        android:background="#00000000"
+        android:scaleType="centerInside"
+        android:src="@drawable/camera"/>
+
+
+
+</LinearLayout>