Browse Source

Apex Mobile
修复detail 无菜单按钮的bug
修复communication 不支持富文本标签的问题

Ray Zhang 8 years ago
parent
commit
91d1732afc

+ 4 - 0
Apex Mobile/app/app.iml

@@ -92,14 +92,18 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res_stripped" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
       <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/transforms" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />

+ 3 - 3
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.usai.apex"
-    android:versionCode="15"
-    android:versionName="A180427"> <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
+    android:versionCode="16"
+    android:versionName="A180515"> <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
     <uses-sdk
         android:minSdkVersion="14"
         android:targetSdkVersion="18" />
@@ -345,7 +345,7 @@
         <activity android:name=".LicenseActivity" />
         <activity android:name=".TestActivity"></activity>
         <activity android:name=".mainframe.NewDetailActivity"
-            android:theme="@style/FixedActionbarTheme"
+            android:theme="@style/DetailActionbarTheme"
             android:screenOrientation="portrait"></activity>
     </application>
 

+ 3 - 1
Apex Mobile/app/src/main/java/com/usai/apex/DetailFragment.java

@@ -898,6 +898,7 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 						JSONObject msgObj = groupobj.getJSONObject("item" + j);
 
 						String sender = msgObj.optString("Sender");
+
 						String msg = msgObj.optString("msg");
 						String time = msgObj.optString("mst_time");
 						final String email_url = msgObj.optString("email_url");
@@ -908,7 +909,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
 						Button sendBtn = msgitem.findViewById(R.id.comm_send_msg_btn);
 
 						senderTv.setText(sender);
-						msgTv.setText(msg);
+//						msgTv.setText(msg);
+						msgTv.setText(Html.fromHtml(msg));
 						timeTv.setText(time);
 						sendBtn.setOnClickListener(new OnClickListener() {
                             @Override

+ 1 - 1
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/LoginFragment.java

@@ -78,7 +78,7 @@ public class LoginFragment extends Fragment/* implements OnClickListener */
 		View view = inflater.inflate(R.layout.fragment_login, null);
 		TextView tv_ver = (TextView) view.findViewById(R.id.tv_ver);
 		try {
-			tv_ver.setText(getText(R.string.str_ver)+"2.11." +ApexTrackingApplication.get_instance().getPackageManager().getPackageInfo(
+			tv_ver.setText(getText(R.string.str_ver)+"2.2.1." +ApexTrackingApplication.get_instance().getPackageManager().getPackageInfo(
 						"com.usai.apex", 0).versionName);
 		} catch (NameNotFoundException e1) {
 			// TODO Auto-generated catch block

+ 178 - 36
Apex Mobile/app/src/main/java/com/usai/apex/mainframe/NewDetailActivity.java

@@ -1,8 +1,11 @@
 package com.usai.apex.mainframe;
 
 //import android.app.Fragment;
+import android.app.AlertDialog;
 import android.content.BroadcastReceiver;
+import android.content.DialogInterface;
 import android.content.Intent;
+import android.database.sqlite.SQLiteDatabase;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
@@ -10,19 +13,22 @@ import android.support.v4.app.Fragment;
 import android.support.v4.view.ViewPager;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
+import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.EditText;
 import android.widget.TextView;
 
 import com.usai.apex.ApexTrackingApplication;
-import com.usai.apex.ContainerSearchActivity;
 import com.usai.apex.DetailFragment;
 import com.usai.apex.R;
+import com.usai.apex.Result.AMResultActivity;
 import com.usai.apex.ViewPagerAdapter;
 import com.usai.util.commonUtil;
+import com.usai.util.dbUtil;
 
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -32,7 +38,7 @@ import java.util.HashMap;
 public class NewDetailActivity extends AppCompatActivity {
 
 
-
+    HashMap<String,String> contentmap = new HashMap<String ,String>();
     HashMap<Integer, Integer> menu_map		= new HashMap<Integer, Integer>();
 
     String							function_name;
@@ -50,7 +56,7 @@ public class NewDetailActivity extends AppCompatActivity {
 //    boolean login=false;
     BroadcastReceiver br;
 
-    Menu actionbutton;
+//    Menu actionbutton;
 
     private void setCustomActionBar() {
         ActionBar.LayoutParams lp =new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
@@ -86,53 +92,169 @@ public class NewDetailActivity extends AppCompatActivity {
         actionBar.setDisplayShowTitleEnabled(true);
     }
     @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        actionbutton = menu;
-        getMenuInflater().inflate(R.menu.quick_search,menu);
-        return  true;
+    public boolean onCreateOptionsMenu(Menu menu)
+    {
+        // Inflate the menu; this adds items to the action bar if it is present.
+
+        if (function_name.equals("Cargo Tracking")) {
+            getMenuInflater().inflate(R.menu.cargo_menu, menu);
+        } else {
+            getMenuInflater().inflate(R.menu.detail, menu);
+        }
+        return true;
     }
 
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case android.R.id.home:
+        switch (item.getItemId())
+        {
+            case R.id.action_close:
+
                 finish();
-//                Toast.makeText(this, "switch mode", Toast.LENGTH_SHORT).show();
+//				if (SearchResultActivity.instance != null) {
+//					SearchResultActivity.instance.finish();
+//				}
+//				if (SearchListActivity.instance != null) {
+//					SearchListActivity.instance.finish();
+//				}
+                Intent intent = new Intent(this, RootActivity.class);
 
-//                if (login && (viewPager.getCurrentItem() == 0 || viewPager.getCurrentItem() == 1)) {
-//                    boolean personMode = ApexTrackingApplication.get_instance().getPersonMode();
-//                    personMode = !personMode;
-//                    ApexTrackingApplication.get_instance().setPersonMode(personMode);
-//
-//                    if (personMode) {
-//                        getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo_p);
-//                    } else {
-//                        getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo);
-//                    }
-//
-//                    Intent intent = new Intent("com.apex.broadcast.person_mode");
-//                    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
-//                }
+//                Intent intent = new Intent(context, LoginView.class);
+                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
-                break;
-            case R.id.quick_search:
 
-                Intent intent = new Intent();
-                intent.setClass(NewDetailActivity.this,ContainerSearchActivity.class);
                 startActivity(intent);
-
-//                Toast.makeText(this,"跳转至container search activity",Toast.LENGTH_LONG).show();
                 break;
+            case android.R.id.home:
+                finish();
+                break;
+            case R.id.action_addto_favorite:
+//	            LayoutInflater factory = LayoutInflater.from(this);
+//	            final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
+                final View edit = new EditText(this);
+                new AlertDialog.Builder(this)
+                        .setIconAttribute(android.R.attr.alertDialogIcon)
+                        .setTitle(R.string.str_createname)
+                        .setView(edit)
+                        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int whichButton) {
+                                String name = ((EditText)edit).getText().toString();
+                                if(TextUtils.isEmpty(name))
+                                {
+                                    new android.app.AlertDialog.Builder(NewDetailActivity.this)
+                                            .setTitle("Warning")
+                                            .setMessage("Name can not be empty.")
+
+                                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+                                                @Override
+                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                }
+                                            })
+                                            .show();
+                                    return;
+                                }
+
+                                String param = getIntent().toUri(0);
+
+                                SQLiteDatabase db = dbUtil.OpenDB(
+                                        ApexTrackingApplication.get_instance(), null, true);
+                                db.execSQL("insert into favorites(name,params,user,create_time,module_name) values('"
+                                        + name
+                                        + "','"
+                                        + param
+                                        + "','"
+                                        + ApexTrackingApplication.get_user()
+                                        + "',"
+                                        + System.currentTimeMillis()
+                                        + ",'"
+                                        +getIntent().getStringExtra("function_name")+ "')");
+                                dbUtil.CloseDB(db);
+
+                                /* User clicked OK so do some stuff */
+                            }
+                        })
+                        .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int whichButton) {
+
+                                /* User clicked cancel so do some stuff */
+                            }
+                        })
+                        .create().show();
+                return true;
+
+            case R.id.action_search_document: {
+                String cargo_str = contentmap.get("Tracking");
+                try {
+                    JSONObject cargo_json = new JSONObject(cargo_str);
+                    String hbol = cargo_json.optString("hbol");
+                    if (hbol != null && hbol.length() > 0) {
+
+                        Bundle parms = new Bundle();
+                        parms.putString("bol",hbol);
+                        parms.putString("module_name","Download Document");
+                        Intent resultIntent = new Intent(this, AMResultActivity.class);
+                        resultIntent.putExtra("query_params",parms);
+                        startActivity(resultIntent);
+
+                    } else {
+                        showAlter("There is no hbol to search");
+                    }
+
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                    showAlter("There is no hbol to search");
+                }
+
+            }
+            break;
+
+            case R.id.action_share_detail: {
+
+                Intent share = new Intent();
+                share.setAction(Intent.ACTION_SEND);
+//				share.putExtra(Intent.EXTRA_STREAM, uri);
+                share.setType("text/plain");
 
-        }
 
+
+
+                if (email_content != null) {
+                    share.putExtra(Intent.EXTRA_TEXT, email_content);   //附带的说明信息
+                }
+                if (email_subject != null) {
+                    share.putExtra(Intent.EXTRA_SUBJECT, email_subject);
+                }
+                if (email_to != null) {
+                    share.putExtra(Intent.EXTRA_EMAIL, email_to.split(","));
+                }
+
+//        share.putExtra(Intent.EXTRA_CC, new String[]{"ray.zhang@united-cn.net"});
+//        startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
+                startActivity(Intent.createChooser(share, "Share"));
+            }
+            break;
+        }
         return super.onOptionsItemSelected(item);
     }
 
+    public void showAlter(String msg) {
+        new AlertDialog.Builder(this)
+                .setMessage(msg)
+                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialogInterface, int i) {
+
+                    }
+                })
+                .show();
+    }
     @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
-
+        outState.putSerializable("menu_map", menu_map);
+        outState.putSerializable("contentmap", contentmap);
 //        outState.putBoolean("login",login);
     }
 
@@ -176,6 +298,25 @@ public class NewDetailActivity extends AppCompatActivity {
         setCustomActionBar();
 
 
+        if (savedInstanceState != null)
+        {
+            menu_map = (HashMap<Integer, Integer>) savedInstanceState
+                    .getSerializable("menu_map");
+//            tabmap = (LinkedHashMap<String, Integer>) savedInstanceState
+//                    .getSerializable("tabmap");
+            contentmap = (HashMap<String, String>) savedInstanceState.getSerializable("contentmap");
+        }
+        else
+        {
+            int count = getIntent().getIntExtra("actions_count", 0);
+            for (int i = 0; i < count; i++)
+            {
+                int vid = commonUtil.generateViewId();
+//                tabmap.put(getIntent().getStringExtra("action" + i), vid);
+            }
+        }
+
+
         function_name = getIntent().getStringExtra("function_name");
 
 //        if(function_name.equals("Ocean Booking"))
@@ -238,7 +379,7 @@ public class NewDetailActivity extends AppCompatActivity {
                 new BottomNavigationView.OnNavigationItemSelectedListener() {
                     @Override
                     public boolean onNavigationItemSelected(@NonNull MenuItem item) {
-                        actionbutton.getItem(0).setVisible(false);
+//                        actionbutton.getItem(0).setVisible(false);
 //                        getSupportActionBar().setHomeAsUpIndicator(R.drawable.apexlogo);
 //                        getSupportActionBar().setDisplayShowTitleEnabled(false);
 
@@ -596,8 +737,8 @@ public class NewDetailActivity extends AppCompatActivity {
 
         if(true)
         {
-            if(actionbutton!=null)
-                actionbutton.getItem(0).setVisible(true);
+//            if(actionbutton!=null)
+//                actionbutton.getItem(0).setVisible(true);
 
             bottomNavigationView.getChildAt(0).setSelected(true);
             bottomNavigationView.getMenu().clear();
@@ -638,6 +779,7 @@ public class NewDetailActivity extends AppCompatActivity {
 
                 Fragment f;
                 f= new DetailFragment();
+                ((DetailFragment)f).set_content( contentmap.get(title));
                 f.setArguments(bundle);
 
                 adapter.addFragment(f);
@@ -755,7 +897,7 @@ public class NewDetailActivity extends AppCompatActivity {
     }
     public void save_content(String which,String content)
     {
-//        contentmap.put(which, content);
+        contentmap.put(which, content);
 
         try {
 

+ 0 - 1
Apex Mobile/app/src/main/res/layout/commu_item_msg.xml

@@ -27,7 +27,6 @@
         android:layout_marginStart="8dp"
         android:layout_marginTop="8dp"
         android:text="message"
-        android:textStyle="bold"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/comm_sender_tv" />
 

+ 2 - 2
Apex Mobile/app/src/main/res/menu/cargo_menu.xml

@@ -27,8 +27,8 @@
     <item
         android:id="@+id/action_close"
         android:icon="@drawable/ic_exit"
-        android:orderInCategory="200"
+        android:orderInCategory="0"
         android:title="Close"
-        app:showAsAction="never" />
+        app:showAsAction="ifRoom" />
 
 </menu>

+ 2 - 2
Apex Mobile/app/src/main/res/menu/detail.xml

@@ -27,7 +27,7 @@
         android:id="@+id/action_close"
 
         android:icon="@drawable/ic_exit"
-        android:orderInCategory="200"
+        android:orderInCategory="0"
         android:title="Close"
-        app:showAsAction="never" />
+        app:showAsAction="ifRoom" />
 </menu>