Changeset 17658


Ignore:
Timestamp:
04/07/14 12:06:29 (11 years ago)
Author:
toanqngu
Message:

Modify re-routing implementation on offline mode

Location:
issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSM.java

    r17423 r17658  
    44import java.nio.ByteOrder;
    55import java.nio.DoubleBuffer;
    6 
    7 import android.app.ProgressDialog;
    8 import android.content.Intent;
    96import android.opengl.GLSurfaceView;
    107import android.os.AsyncTask;
    11 import android.os.Build;
    128import android.os.Bundle;
     9import android.app.Activity;
     10import android.app.ProgressDialog;
    1311import android.util.DisplayMetrics;
    1412import android.view.GestureDetector;
    15 import android.view.GestureDetector.OnDoubleTapListener;
    16 import android.view.GestureDetector.OnGestureListener;
    1713import android.view.Gravity;
    1814import android.view.KeyEvent;
    1915import android.view.Menu;
    2016import android.view.MenuInflater;
    21 import android.view.MotionEvent;
    2217import android.view.View;
    2318import android.view.View.OnClickListener;
     19import android.view.GestureDetector.OnDoubleTapListener;
     20import android.view.GestureDetector.OnGestureListener;
     21import android.view.MotionEvent;
    2422import android.view.animation.AccelerateInterpolator;
    2523import android.view.animation.Animation;
     
    3533import android.widget.Spinner;
    3634import android.widget.ViewFlipper;
    37 // private static final int INVISIBLE = 0;
    38 // Loading the ISSM library locally
    39 // private IssmJni issmNative;
    40 // ,sealevel;
    41 
    42 public class ISSM extends BaseActivity implements OnClickListener,
     35import android.os.Build;
     36
     37public class ISSM extends Activity implements OnClickListener,
    4338                OnGestureListener, OnDoubleTapListener {
    4439        // private static final int INVISIBLE = 0;
     
    4641        private int screenHeight;
    4742        private DoubleBuffer buff;
    48         // Loading the ISSM library locally
    49         // private IssmJni issmNative;
     43        private IssmJni issmNative;
    5044        private String mapName;
    5145        private String issmFolder;
     
    6660        private Spinner spinner;
    6761        private boolean onSimulationScreen = false;
    68         private String url = "http://blackhawk2.jpl.nasa.gov/issm/solve?callback=?";
    6962
    7063        // ------------------------------------------------------------------------------------------------
     
    7366                super.onCreate(savedInstanceState);
    7467                setContentView(R.layout.main_issm);
    75                 transition();
    7668
    7769                // Set up a listener for double tap.
     
    9082                        }
    9183                }
    92                 Button homeTab = (Button) findViewById(R.id.play_tab);
    93                 homeTab.setOnClickListener(new View.OnClickListener() {
    94 
    95                         @Override
    96                         public void onClick(View v) {
    97                                 Intent i = new Intent(ISSM.this, MenuPage.class);
    98                                 startActivity(i);
    99                                 finish();
    100                         }
    101                 });
    102 
    103                 Button galleryTab = (Button) findViewById(R.id.gallery_tab);
    104                 galleryTab.setOnClickListener(new View.OnClickListener() {
    105 
    106                         @Override
    107                         public void onClick(View v) {
    108                                 Intent i = new Intent(ISSM.this, GalleryImage.class);
    109                                 startActivity(i);
    110                                 finish();
    111                         }
    112                 });
    113                 Button videoTab = (Button) findViewById(R.id.video_tab);
    114                 videoTab.setOnClickListener(new View.OnClickListener() {
    115 
    116                         @Override
    117                         public void onClick(View v) {
    118                                 // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
    119                                 // Intent i = new Intent(Intent.ACTION_VIEW);
    120                                 // i.setData(Uri.parse(url));
    121                                 Intent i = new Intent(ISSM.this, VideoActivity.class);
    122                                 startActivity(i);
    123                                 finish();
    124                         }
    125                 });
    126                 Button aboutTab = (Button) findViewById(R.id.about_tab);
    127                 aboutTab.setOnClickListener(new View.OnClickListener() {
    128 
    129                         @Override
    130                         public void onClick(View v) {
    131                                 Intent i = new Intent(ISSM.this, AboutActivity.class);
    132                                 startActivity(i);
    133                                 finish();
    134                         }
    135                 });
    136                 Button teamTab = (Button) findViewById(R.id.team_tab);
    137                 teamTab.setOnClickListener(new View.OnClickListener() {
    138 
    139                         @Override
    140                         public void onClick(View v) {
    141                                 // String url = "http://issm.jpl.nasa.gov/";
    142                                 // Intent i = new Intent(Intent.ACTION_VIEW);
    143                                 // i.setData(Uri.parse(url));
    144                                 // startActivity(i);
    145 
    146                                 Intent i = new Intent(ISSM.this, TeamActivity.class);
    147                                 startActivity(i);
    148                                 finish();
    149                         }
    150                 });
    151 
    15284                friction = MINIMUM + OFFSET;
    15385                // temperature = MINIMUM + OFFSET;
     
    169101                defaultMap = (ImageView) findViewById(R.id.defaultMap);
    170102                dialog = new ProgressDialog(this);
    171                 colorBar = (ColorBar) findViewById(R.id.colorbar);
     103                // colorBar = (ColorBar) findViewById(R.id.colorbar);
    172104                // load up the ISSM library and create double buffer in java
    173105                // which later on will be pass for native for allocation.
    174                 // issmNative = new IssmJni();
     106                issmNative = new IssmJni();
    175107                velocity = new Velocity();
    176108
     
    188120                                        colorMap.setColor(color);
    189121                                        colorBar.setColorMap(colorMap);
    190                                         // drawFigure();
     122                                        drawFigure();
    191123                                }
    192124                        }
     
    213145                }
    214146
    215                 // size = issmNative.createISSMModel(solution_type,issmFolder,file);
     147                size = issmNative.createISSMModel(solution_type, issmFolder, file);
    216148                buff = ByteBuffer.allocateDirect(size * 12 * 8)
    217149                                .order(ByteOrder.nativeOrder()).asDoubleBuffer();
     
    307239                        defaultMap.setImageResource(R.drawable.greenland_button);
    308240                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    309                                 defaultMap.setScaleX(1.12f);
    310                                 defaultMap.setScaleY(0.92f);
    311                                 defaultMap.setAlpha(1.0f);
     241                                // defaultMap.setScaleX(1.12f);
     242                                // defaultMap.setScaleY(0.92f);
     243                                // defaultMap.setAlpha(1.0f);
    312244                        } else {
    313245                                defaultMap.setAlpha(1);
     
    327259                        defaultMap.setImageResource(R.drawable.antarctica_button);
    328260                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    329                                 defaultMap.setAlpha(1.0f);
     261                                // defaultMap.setAlpha(1.0f);
    330262                        } else {
    331263                                defaultMap.setAlpha(1);
     
    367299                                        popupWindow.dismiss();
    368300                                        System.out.println("Friction = " + friction);
    369                                         // new CalculationTask().execute(friction,temperature);
     301                                        new CalculationTask().execute(friction, temperature);
    370302                                }
    371303                        });
     
    403335                        };
    404336                        thread.start();
    405                         // issmNative.solveISSMModel(target[0],buff);
     337                        issmNative.solveISSMModel(target[0], buff);
    406338                        // System.out.println("temperature = " + target[1]);
    407339                        // issmNative.solveISSMModel(target[0],target[1],buff);
     
    445377        }
    446378
    447         // -------------------------------------------------------------------------------------
    448 
    449         @Override
    450         public void onBackPressed() {
    451                 Intent i = new Intent(ISSM.this, MenuPage.class);
    452                 startActivity(i);
    453                 finish();
    454         }
    455 
    456379        // -----------------------------------------------------------------------------------
    457380        private void fadeImage() {
  • issm/mobile/android/ISSM_APP/src/gov/nasa/jpl/issm/ISSMWebActivity.java

    r17620 r17658  
    1414import android.view.View;
    1515import android.view.View.OnClickListener;
     16import android.view.Window;
    1617import android.webkit.WebResourceResponse;
    1718import android.webkit.WebView;
     
    2122
    2223        // URL of the index page of the ISSM web application
    23         private String srcPath = "++";
     24        // private String srcPath =
     25        // "http://issm.jpl.nasa.gov/externalicelab/index.html";
    2426        private String offPath = "file:///android_asset/externalicelab/index.html";
    2527        private final String KEY = "mode";
    2628        private String issmFolder = "";
    2729        private int MODE;
    28         // private String srcPath =
    29         // "http://www.csupomona.edu/~tqnguyen/CIS311/Project3/index.html";
     30        private String srcPath = "http://www.csupomona.edu/~lannguyen/ISSM_WEB/html/index.html";
    3031        private WebView myWebView;
    3132
     
    3334        protected void onCreate(Bundle savedInstanceState) {
    3435                super.onCreate(savedInstanceState);
     36                requestWindowFeature(Window.FEATURE_NO_TITLE);
    3537                setContentView(R.layout.activity_issmweb_online);
    36                 getActionBar().setCustomView(R.layout.actionbar_top_web);
    37                 getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
     38                // getActionBar().setCustomView(R.layout.actionbar_top_web);
     39                // getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    3840                MODE = getIntent().getExtras().getInt(KEY);
    3941
    40                 Button webHome = (Button) findViewById(R.id.web_home);
    41                 webHome.setOnClickListener(new OnClickListener() {
    42 
    43                         @Override
    44                         public void onClick(View v) {
    45                                 if (MODE == 0) {
    46                                         myWebView.loadUrl(srcPath);
    47                                 } else {
    48                                         myWebView.loadUrl(offPath);
    49                                 }
    50                         }
    51 
    52                 });
    53 
    54                 Button webRefresh = (Button) findViewById(R.id.web_refresh);
    55                 webRefresh.setOnClickListener(new OnClickListener() {
    56 
    57                         @Override
    58                         public void onClick(View v) {
    59                                 myWebView.loadUrl(myWebView.getOriginalUrl());
    60                                 // Log.i("srcUrl: ", srcPath);
    61                                 // Log.i("newUrl: ", myWebView.getOriginalUrl());
    62                         }
    63 
    64                 });
     42                // Button webHome = (Button) findViewById(R.id.web_home);
     43                // webHome.setOnClickListener(new OnClickListener() {
     44                //
     45                // @Override
     46                // public void onClick(View v) {
     47                // if (MODE == 0) {
     48                // myWebView.loadUrl(srcPath);
     49                // } else {
     50                // myWebView.loadUrl(offPath);
     51                // }
     52                // }
     53                //
     54                // });
     55                //
     56                // Button webRefresh = (Button) findViewById(R.id.web_refresh);
     57                // webRefresh.setOnClickListener(new OnClickListener() {
     58                //
     59                // @Override
     60                // public void onClick(View v) {
     61                // myWebView.loadUrl(myWebView.getOriginalUrl());
     62                // // Log.i("srcUrl: ", srcPath);
     63                // // Log.i("newUrl: ", myWebView.getOriginalUrl());
     64                // }
     65                //
     66                // });
    6567
    6668                // final ProgressDialog loading = new ProgressDialog(this);
     
    7779                                        if (url.startsWith("http")
    7880                                                        && !url.contains("http://thwaites.jpl.nasa.gov/fastcgi/visl-solve.py?callbacks")) {
    79                                                 myWebView.setVisibility(View.INVISIBLE);
     81                                                // myWebView.setVisibility(View.INVISIBLE);
     82                                                myWebView.stopLoading();
    8083                                                new AlertDialog.Builder(ISSMWebActivity.this)
    8184                                                                .setTitle("Error!")
    8285                                                                .setMessage(
    83                                                                                 "Option requires online mode. Please exit and enable connection to access the option.")
     86                                                                                "Option requires online mode. Exit and enable connection to access the option.")
    8487                                                                .setCancelable(false)
    8588                                                                .setPositiveButton("Okay",
     
    8891                                                                                                        DialogInterface dialog,
    8992                                                                                                        int id) {
    90                                                                                                 myWebView.loadUrl(offPath);
    91                                                                                                 new Handler().postDelayed(
    92                                                                                                                 new Runnable() {
    93                                                                                                                         @Override
    94                                                                                                                         public void run() {
    95                                                                                                                                 // This method
    96                                                                                                                                 // will be
    97                                                                                                                                 // executed once
    98                                                                                                                                 // the timer is
    99                                                                                                                                 // over
    100                                                                                                                                 myWebView
    101                                                                                                                                                 .setVisibility(View.VISIBLE);
    102                                                                                                                         }
    103                                                                                                                 }, 700);
     93                                                                                                if (!myWebView.getOriginalUrl()
     94                                                                                                                .equals(offPath)) {
     95                                                                                                        myWebView.loadUrl(offPath);
     96                                                                                                }
    10497                                                                                        }
    10598                                                                                }).show();
     
    131124                                return null;
    132125
    133                                 // URI uri = URI.create(url);
    134                                 // String scheme = uri.getScheme();
    135                                 // // If scheme not http(s), let the default webview manage it
    136                                 // if (!"http".equals(scheme) && !"https".equals(scheme)) {
    137                                 // return null;
    138                                 // }
    139 
    140                                 // URL url = uri.toURL();
    141                                 //
    142                                 // if(doCancelRequest(url)) {
    143                                 // // Empty response
    144                                 // Log.d(TAG, "URL filtered: " + url);
    145                                 // return new WebResourceResponse("text/plain", "UTF-8", new
    146                                 // EmptyInputStream());
    147                                 //
    148                                 // } else {
    149                                 // Log.d(TAG, "URL: " + url);
    150                                 //
    151                                 // HttpURLConnection conn = (HttpURLConnection)
    152                                 // url.openConnection();
    153                                 // conn.setRequestProperty("User-Agent",
    154                                 // mSettings.getUserAgentString());
    155                                 //
    156                                 // // Configure connections
    157                                 // configureConnection(conn);
    158                                 //
    159                                 // String mimeType = conn.getContentType();
    160                                 // String encoding = conn.getContentEncoding();
    161                                 //
    162                                 // if(mimeType != null && mimeType.contains(CONTENT_TYPE_SPLIT))
    163                                 // {
    164                                 // String[] split = mimeType.split(CONTENT_TYPE_SPLIT);
    165                                 // mimeType = split[0];
    166                                 //
    167                                 // Matcher matcher = CONTENT_TYPE_PATTERN.matcher(split[1]);
    168                                 // if(matcher.find()) {
    169                                 // encoding = matcher.group(1);
    170                                 // }
    171                                 // }
    172                                 //
    173                                 // InputStream is = conn.getInputStream();
    174                                 // return new WebResourceResponse(mimeType, encoding, is);
    175                                 // return null;
    176                                 // }
    177126                        }
    178127                });
     
    180129                myWebView.getSettings().setLoadWithOverviewMode(true);
    181130                myWebView.getSettings().setUseWideViewPort(true);
    182                 // myWebView.getSettings().setBuiltInZoomControls(true);
    183131                if (MODE == 0) {
    184132                        myWebView.loadUrl(srcPath);
Note: See TracChangeset for help on using the changeset viewer.