Advertisement
minafaw3

MainActivity

Dec 13th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.02 KB | None | 0 0
  1. package com.example.easywebapp;
  2.  
  3.  
  4. import java.io.File;
  5. import java.io.UnsupportedEncodingException;
  6. import java.net.URLDecoder;
  7.  
  8. import android.annotation.SuppressLint;
  9. import android.app.Activity;
  10. import android.app.AlertDialog;
  11. import android.app.DownloadManager;
  12. import android.content.Context;
  13. import android.content.DialogInterface;
  14. import android.content.Intent;
  15. import android.graphics.Bitmap;
  16. import android.media.MediaPlayer;
  17. import android.media.MediaPlayer.OnCompletionListener;
  18. import android.media.MediaPlayer.OnErrorListener;
  19. import android.net.Uri;
  20. import android.os.Build;
  21. import android.os.Bundle;
  22. import android.os.Environment;
  23. import android.view.Gravity;
  24. import android.view.Menu;
  25. import android.view.MenuItem;
  26. import android.view.MotionEvent;
  27. import android.view.View;
  28. import android.view.ViewGroup;
  29. import android.webkit.JsPromptResult;
  30. import android.webkit.JsResult;
  31. import android.webkit.MimeTypeMap;
  32. import android.webkit.ValueCallback;
  33. import android.webkit.WebChromeClient;
  34. import android.webkit.WebSettings.PluginState;
  35. import android.webkit.WebSettings.RenderPriority;
  36. import android.webkit.WebView;
  37. import android.webkit.WebViewClient;
  38. import android.widget.FrameLayout;
  39. import android.widget.ProgressBar;
  40. import android.widget.RelativeLayout;
  41. import android.widget.TextView;
  42. import android.widget.VideoView;
  43.  
  44. import com.google.ads.AdRequest;
  45. import com.google.ads.AdSize;
  46. import com.google.ads.AdView;
  47.  
  48.  
  49.  
  50. public class MainActivity extends Activity {
  51. private WebView mainWebView;
  52. private String HomeUrl, AppName, ShareUrl, AD_ID, sdrUrl, ext;
  53. private VideoView mVideoView;
  54. private RelativeLayout mContentView;
  55. private FrameLayout mCustomViewContainer;
  56. private WebChromeClient.CustomViewCallback mCustomViewCallback;
  57. private AdView adView;
  58. Integer vidPosition;
  59. ProgressBar progressBar;
  60.  
  61.  
  62.  
  63. @SuppressWarnings("deprecation")
  64. @SuppressLint({"CutPasteId","NewApi", "SetJavaScriptEnabled"})
  65. @Override
  66. protected void onCreate(Bundle savedInstanceState) {
  67. super.onCreate(savedInstanceState);
  68. setContentView(R.layout.activity_main);
  69.  
  70.  
  71. // ========================Create adView
  72. AD_ID = getString(R.string.admob_publisher_id);
  73. adView = new AdView(this, AdSize.BANNER, AD_ID);
  74.  
  75. /* // Dynamic add LinearLayout
  76. // android:id="@+id/adLayout"
  77. LinearLayout layout = (LinearLayout)findViewById(R.id.adLayout);
  78.  
  79. // Add adView
  80. layout.addView(adView);*/
  81.  
  82. // Initiate a generic request to load it with an ad
  83. adView.loadAd(new AdRequest());
  84.  
  85.  
  86.  
  87.  
  88. //========================== home url
  89. HomeUrl = getString(R.string.base_url);
  90.  
  91. //First share link
  92. ShareUrl = HomeUrl;
  93.  
  94. // App name url
  95. AppName = getString(R.string.app_name);
  96.  
  97. //Find objects with ID
  98. mainWebView = (WebView) findViewById(R.id.webView1);
  99. progressBar = (ProgressBar)findViewById(R.id.progressBar1);
  100.  
  101. // focus with touch
  102. mainWebView.setFocusable(true);
  103. mainWebView.setFocusableInTouchMode(true);
  104. mainWebView.requestFocus(View.FOCUS_DOWN|View.FOCUS_UP);
  105. mainWebView.getSettings().setLightTouchEnabled(true);
  106.  
  107. // enabled Java Script
  108. mainWebView.getSettings().setJavaScriptEnabled(true);
  109. mainWebView.getSettings().setPluginState(PluginState.ON_DEMAND);
  110. mainWebView.getSettings().setDomStorageEnabled(true);
  111. //mainWebView.getSettings().setUseWideViewPort(true);
  112.  
  113. //Customaze Web View
  114. mainWebView.setWebViewClient(new MyCustomWebViewClient());
  115. mainWebView.setWebChromeClient(new MyChromeClient());
  116.  
  117. //Webview scroll
  118. mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
  119.  
  120. //Cache enable
  121. mainWebView.getSettings().setAppCacheEnabled(true);
  122. mainWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
  123.  
  124. // Load Home url
  125. mainWebView.loadUrl(HomeUrl);
  126.  
  127.  
  128. mainWebView.setOnTouchListener(new View.OnTouchListener() {
  129. @Override
  130. public boolean onTouch(View v, MotionEvent event) {
  131. switch (event.getAction()) {
  132. case MotionEvent.ACTION_DOWN:
  133. case MotionEvent.ACTION_UP:
  134. if (!v.hasFocus()) {
  135. v.requestFocus();
  136. v.requestFocusFromTouch();
  137. }
  138. break;
  139. }
  140. return false;
  141. }
  142. });
  143.  
  144. Bundle extras = getIntent().getExtras();
  145. if (extras != null) {
  146.  
  147. String value = extras.getString("url");
  148. //mainWebView.getSettings().setUseWideViewPort(true);
  149. mainWebView.loadUrl(value);
  150.  
  151. }
  152.  
  153. // Menu category
  154. TextView text1= (TextView) findViewById(R.id.title_bar_home);
  155. text1.setOnClickListener(new View.OnClickListener() {
  156.  
  157. @Override
  158. public void onClick(View v) {
  159. // TODO Auto-generated method stub
  160. mainWebView.loadUrl(HomeUrl);
  161. }
  162. });
  163.  
  164. // Menu category
  165. TextView text2= (TextView) findViewById(R.id.title_bar_share);
  166. text2.setOnClickListener(new View.OnClickListener() {
  167.  
  168. @Override
  169. public void onClick(View v) {
  170. // TODO Auto-generated method stub
  171. Intent intent = new Intent(Intent.ACTION_SEND);
  172. intent.setType("text/plain");
  173. intent.putExtra(Intent.EXTRA_TEXT, ShareUrl);
  174. intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Interesting for you!");
  175. startActivity(Intent.createChooser(intent, "Share via"));
  176. }
  177. });
  178. }
  179.  
  180.  
  181. private class MyCustomWebViewClient extends WebViewClient {
  182.  
  183.  
  184. @Override
  185. public void onPageStarted(WebView view, String url, Bitmap favicon) {
  186. // TODO Auto-generated method stub
  187. super.onPageStarted(view, url, favicon);
  188.  
  189. // On load Spinner visible
  190. progressBar.setVisibility(View.VISIBLE);
  191. view.setVisibility(View.GONE);
  192.  
  193. }
  194.  
  195. //@SuppressWarnings("deprecation")
  196. @Override
  197. public void onPageFinished(WebView view, String url) {
  198. // TODO Auto-generated method stub
  199. super.onPageFinished(view, url);
  200.  
  201. // On load Spinner hide
  202. progressBar.setVisibility(View.GONE);
  203. view.setVisibility(View.VISIBLE);
  204.  
  205.  
  206. }
  207.  
  208. @SuppressLint("NewApi")
  209. @Override
  210. public boolean shouldOverrideUrlLoading(WebView view, String url) {
  211. //share page or link
  212. ShareUrl = url;
  213.  
  214. // One touch call link <a href="tel:777777777">Call</a>
  215. if (url.startsWith("tel:"))
  216. {
  217. Intent intent = new Intent(Intent.ACTION_DIAL,
  218. Uri.parse(url));
  219. startActivity(intent);
  220. }
  221.  
  222. else
  223.  
  224. // One touch sms link <a href="sms:1717171717">Sms</a>
  225. if (url.startsWith("sms:"))
  226. {
  227. Intent message = new Intent(Intent.ACTION_SENDTO,
  228. Uri.parse(url));
  229. startActivity(message);
  230. }
  231.  
  232. // One share text or url link <a href="share:share text">share text</a>
  233. else
  234. if (url.startsWith("share:"))
  235. {
  236. String[] share_link = url.split(":");
  237. try {
  238. String ID= URLDecoder.decode(share_link[1], "UTF-8");
  239. Intent intent = new Intent(Intent.ACTION_SEND);
  240. intent.setType("text/plain");
  241. intent.putExtra(Intent.EXTRA_TEXT, "http://www.youtube.com/watch?v="+ID);
  242. intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Interesting for you!");
  243. startActivity(Intent.createChooser(intent, "Share via"));
  244.  
  245. } catch (UnsupportedEncodingException e) {
  246. // TODO Auto-generated catch block
  247. e.printStackTrace();
  248. }
  249.  
  250. }
  251. // One touch image link <a href="test.jpg">Image</a>
  252. else
  253.  
  254. if(url.endsWith(".jpg") || url.endsWith(".png") || url.endsWith(".gif") || url.endsWith(".JPG") || url.endsWith(".jpeg") )
  255. {
  256. Intent intent=new Intent (MainActivity.this, Image.class);
  257. intent.putExtra("href", url);
  258. startActivity(intent);
  259.  
  260.  
  261. }
  262. else
  263. // else if it's a 3GP file link
  264. if(url.endsWith(".3gp")){
  265. Uri uri = Uri.parse(url);
  266. Intent intent = new Intent(Intent.ACTION_VIEW);
  267. intent.setDataAndType(uri, "video/3gp");
  268. startActivity(intent);
  269. return true;
  270. }
  271. else
  272. //Link mp4 file <a href="http://mosaicdesign.uz/test.mp4">Download mp4</a>
  273. if(url.endsWith(".mp4")){
  274.  
  275. if(url.startsWith("download")){
  276. String[] download_link = url.split(":");
  277.  
  278. try {
  279. //<a href="download:http://mosaicdesign.uz/test.mp4">Download mp4</a>
  280. sdrUrl= URLDecoder.decode(download_link[1], "UTF-8")+":"+URLDecoder.decode(download_link[2], "UTF-8");
  281. ext = MimeTypeMap.getFileExtensionFromUrl(sdrUrl);
  282.  
  283.  
  284. if (ext != null) {
  285. MimeTypeMap mime = MimeTypeMap.getSingleton();
  286. String mimeType = mime.getMimeTypeFromExtension(ext);
  287.  
  288. if (mimeType != null) {
  289. if (ext.toLowerCase().contains("mp4")) {
  290. DownloadManager mdDownloadManager = (DownloadManager) MainActivity.this
  291. .getSystemService(Context.DOWNLOAD_SERVICE);
  292. DownloadManager.Request request = new DownloadManager.Request(
  293. Uri.parse(sdrUrl));
  294. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE);
  295. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
  296. request.setAllowedOverRoaming(true);
  297. File destinationFile = new File(
  298. Environment.getExternalStorageDirectory(),
  299. getFileName(sdrUrl, ext));
  300.  
  301. request.setDestinationUri(Uri.fromFile(destinationFile));
  302. mdDownloadManager.enqueue(request);
  303.  
  304. }
  305. }
  306. }
  307. return true;
  308. } catch (UnsupportedEncodingException e) {
  309. // TODO Auto-generated catch block
  310. e.printStackTrace();
  311. }
  312. }
  313. else
  314. {
  315. Uri uri = Uri.parse(url);
  316. Intent intent = new Intent(Intent.ACTION_VIEW);
  317. intent.setDataAndType(uri, "video/mp4");
  318. startActivity(intent);
  319. return true;
  320. }
  321.  
  322. }
  323.  
  324.  
  325. else
  326.  
  327. //Open MP3 file <a href="http://mosaicdesign.uz/test.mp3">Download mp3</a>
  328. if(url.endsWith(".mp3") || url.endsWith(".MP3")){
  329. // Download files
  330.  
  331. if(url.startsWith("download")){
  332. String[] download_link = url.split(":");
  333.  
  334. try {
  335. //<a href="download:http://mosaicdesign.uz/test.mp3">Download mp3</a>
  336. sdrUrl= URLDecoder.decode(download_link[1], "UTF-8")+":"+URLDecoder.decode(download_link[2], "UTF-8");
  337.  
  338. //ext=url.substring(url.lastIndexOf("."));
  339. ext = MimeTypeMap.getFileExtensionFromUrl(sdrUrl);
  340.  
  341.  
  342. if (ext != null) {
  343. MimeTypeMap mime = MimeTypeMap.getSingleton();
  344. String mimeType = mime.getMimeTypeFromExtension(ext);
  345.  
  346. if (mimeType != null) {
  347. if (ext.toLowerCase().contains("mp3")) {
  348. DownloadManager mdDownloadManager = (DownloadManager) MainActivity.this
  349. .getSystemService(Context.DOWNLOAD_SERVICE);
  350. DownloadManager.Request request = new DownloadManager.Request(
  351. Uri.parse(sdrUrl));
  352. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE);
  353. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
  354. request.setAllowedOverRoaming(true);
  355. File destinationFile = new File(
  356. Environment.getExternalStorageDirectory(),
  357. getFileName(sdrUrl, ext));
  358.  
  359. request.setDestinationUri(Uri.fromFile(destinationFile));
  360. mdDownloadManager.enqueue(request);
  361.  
  362. }
  363. }
  364. }
  365. return true;
  366. } catch (UnsupportedEncodingException e) {
  367. // TODO Auto-generated catch block
  368. e.printStackTrace();
  369. }
  370. }
  371. else
  372. {
  373. Uri uri = Uri.parse(url);
  374. Intent intent = new Intent(Intent.ACTION_VIEW);
  375. intent.setDataAndType(uri, "audio/mp3");
  376. startActivity(intent);
  377. return true;
  378. }
  379.  
  380. }
  381.  
  382. //View file < a href="www.text.com/test.txt"> View text</a>
  383. if (
  384.  
  385. url.endsWith(".pdf")
  386. || url.endsWith(".txt")
  387. || url.endsWith(".doc")
  388. || url.endsWith(".docx")
  389. || url.endsWith(".xls")
  390. || url.endsWith(".xlsx")
  391. || url.endsWith(".ppt")
  392. || url.endsWith(".pptx")
  393. || url.endsWith(".pages")
  394. || url.endsWith(".ai")
  395. || url.endsWith(".psd")
  396. || url.endsWith(".tiff")
  397. || url.endsWith(".dxf")
  398. || url.endsWith(".svg")
  399. || url.endsWith(".eps")
  400. || url.endsWith(".ps")
  401. || url.endsWith(".ttf")
  402. || url.endsWith(".xps")
  403. || url.endsWith(".zip")
  404. || url.endsWith(".rar")
  405.  
  406. )
  407. {
  408. if(url.startsWith("download")){
  409. String[] download_link = url.split(":");
  410.  
  411. try {
  412.  
  413. sdrUrl= URLDecoder.decode(download_link[1], "UTF-8")+":"+URLDecoder.decode(download_link[2], "UTF-8");
  414. ext = MimeTypeMap.getFileExtensionFromUrl(sdrUrl);
  415.  
  416.  
  417. if (ext != null) {
  418. MimeTypeMap mime = MimeTypeMap.getSingleton();
  419. String mimeType = mime.getMimeTypeFromExtension(ext);
  420.  
  421. if (mimeType != null) {
  422.  
  423. DownloadManager mdDownloadManager = (DownloadManager) MainActivity.this
  424. .getSystemService(Context.DOWNLOAD_SERVICE);
  425. DownloadManager.Request request = new DownloadManager.Request(
  426. Uri.parse(sdrUrl));
  427. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE);
  428. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
  429. request.setAllowedOverRoaming(true);
  430. File destinationFile = new File(
  431. Environment.getExternalStorageDirectory(),
  432. getFileName(sdrUrl, ext));
  433.  
  434. request.setDestinationUri(Uri.fromFile(destinationFile));
  435. mdDownloadManager.enqueue(request);
  436.  
  437.  
  438. }
  439. }
  440. return true;
  441. } catch (UnsupportedEncodingException e) {
  442. // TODO Auto-generated catch block
  443. e.printStackTrace();
  444. }
  445. }
  446. else
  447. {
  448. String googleDocs = "https://docs.google.com/viewer?url=";
  449. mainWebView.loadUrl(googleDocs + url);
  450. return true;
  451. }
  452. }
  453.  
  454. else
  455.  
  456. if(url.startsWith("http:") || url.startsWith("https:")) {view.loadUrl(url); }
  457. return true;
  458. }
  459.  
  460. @Override
  461. public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
  462.  
  463. view.loadUrl("file:///android_asset/error.html");
  464.  
  465. }
  466. }
  467.  
  468. private class MyChromeClient extends WebChromeClient implements OnCompletionListener, OnErrorListener {
  469.  
  470. FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = new FrameLayout.LayoutParams(
  471. ViewGroup.LayoutParams.WRAP_CONTENT,
  472. ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
  473.  
  474. @Override
  475. public void onShowCustomView(View view, int requestedOrientation,
  476. WebChromeClient.CustomViewCallback callback) // Available in API level 14+, deprecated in API level 18+
  477. {
  478. onShowCustomView(view, callback);
  479. if(Build.VERSION.SDK_INT >=14) {
  480. if (view instanceof FrameLayout) {
  481. mainWebView.addView(view, new FrameLayout.LayoutParams(
  482. ViewGroup.LayoutParams.MATCH_PARENT,
  483. ViewGroup.LayoutParams.MATCH_PARENT,
  484. Gravity.CENTER));
  485. mainWebView.setVisibility(View.VISIBLE);
  486. }
  487. }
  488. }
  489.  
  490.  
  491. @Override
  492. public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
  493.  
  494. if (view instanceof FrameLayout) {
  495.  
  496. // mainWebView is the view that the video should've played inside.
  497. mainWebView = (WebView)findViewById(R.id.webView1);
  498.  
  499. mCustomViewContainer = (FrameLayout) view;
  500. mCustomViewCallback = callback;
  501.  
  502. // mainLayout is the root layout that (ex. the layout that contains the webview)
  503. mContentView = (RelativeLayout)findViewById(R.id.RootLayout);
  504. if (mCustomViewContainer.getFocusedChild() instanceof VideoView) {
  505. mVideoView = (VideoView) mCustomViewContainer.getFocusedChild();
  506.  
  507. // frame.removeView(video);
  508. mContentView.setVisibility(View.GONE);
  509. mCustomViewContainer.setVisibility(View.VISIBLE);
  510. setContentView(mCustomViewContainer);
  511. mVideoView.setOnCompletionListener((OnCompletionListener) this);
  512. mVideoView.setOnErrorListener((OnErrorListener) this);
  513. mVideoView.start();
  514.  
  515. }
  516. }
  517. }
  518.  
  519. public void onHideCustomView() {
  520. if (mVideoView == null){
  521. return;
  522. }else{
  523. // Hide the custom view.
  524. mVideoView.setVisibility(View.GONE);
  525. // Remove the custom view from its container.
  526. mCustomViewContainer.removeView(mVideoView);
  527. mVideoView = null;
  528. mCustomViewContainer.setVisibility(View.GONE);
  529. mCustomViewCallback.onCustomViewHidden();
  530. // Show the content view.
  531. mContentView.setVisibility(View.VISIBLE);
  532. }
  533. }
  534.  
  535. public void onCompletion(MediaPlayer mp) {
  536. mp.stop();
  537. mCustomViewContainer.setVisibility(View.GONE);
  538. onHideCustomView();
  539. setContentView(mContentView);
  540. }
  541. @SuppressWarnings("unused")
  542. public void onPrepared(MediaPlayer mp) {
  543.  
  544. mCustomViewCallback.onCustomViewHidden();
  545. }
  546. public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
  547. setContentView(mContentView);
  548. return true;
  549. }
  550. //Java script alert dialog
  551. @Override
  552. public boolean onJsAlert(WebView view, String url, String message,
  553. final JsResult result) {
  554. new AlertDialog.Builder(MainActivity.this)
  555. .setTitle("Attention !")
  556. .setMessage(message)
  557. .setPositiveButton(R.string.ok,
  558. new AlertDialog.OnClickListener() {
  559. public void onClick(DialogInterface dialog, int which) {
  560. // do your stuff here
  561. result.confirm();
  562. }
  563. }).setCancelable(false).create().show();
  564. return true;
  565. }
  566.  
  567. //Java script confirm dialog
  568. @Override
  569. public boolean onJsConfirm(WebView view, String url, String message,
  570. final JsResult result) {
  571. new AlertDialog.Builder(MainActivity.this)
  572. .setTitle("Confirm !")
  573. .setMessage(message)
  574. .setPositiveButton(R.string.ok,
  575. new AlertDialog.OnClickListener() {
  576. public void onClick(DialogInterface dialog, int which) {
  577. // do your stuff here
  578. result.confirm();
  579. }
  580. }).setCancelable(false).create().show();
  581. return true;
  582. }
  583.  
  584. //Java script Prompt dialog
  585. @Override
  586. public boolean onJsPrompt(WebView view, String url, String message,
  587. String defaultValue, final JsPromptResult result) {
  588. new AlertDialog.Builder(MainActivity.this)
  589. .setTitle("Prompt Alert !")
  590. .setMessage(message)
  591. .setPositiveButton(R.string.ok,
  592. new AlertDialog.OnClickListener() {
  593. public void onClick(DialogInterface dialog, int which) {
  594. // do your stuff here
  595. result.confirm();
  596. }
  597. }).setCancelable(false).create().show();
  598. return true;
  599. }
  600.  
  601. };
  602.  
  603.  
  604.  
  605. @Override
  606. public boolean onCreateOptionsMenu(Menu menu) {
  607. // Inflate the menu; this adds items to the action bar if it is present.
  608. getMenuInflater().inflate(R.menu.mainmenu, menu);
  609. return true;
  610. }
  611.  
  612. @Override
  613. public boolean onOptionsItemSelected(MenuItem item) {
  614. switch (item.getItemId()) {
  615. case R.id.action_rate:
  616. Intent i = new Intent(Intent.ACTION_VIEW);
  617. i.setData(Uri.parse("market://details?id=" + getPackageName()));
  618. startActivity(i);
  619. break;
  620. case R.id.action_refresh:
  621. mainWebView.loadUrl( "javascript:window.location.reload( true )" );
  622. break;
  623. case R.id.action_exit:
  624. finish();
  625. break;
  626. default:
  627. break;
  628. }
  629.  
  630. return true;
  631. }
  632.  
  633. @Override
  634. protected void onPause() {
  635.  
  636. if(mCustomViewContainer != null){
  637.  
  638. vidPosition = mVideoView.getCurrentPosition();
  639. }
  640.  
  641. super.onPause();
  642. }
  643.  
  644. @Override
  645. protected void onResume() {
  646.  
  647. if(mCustomViewContainer != null){
  648.  
  649. mVideoView.seekTo(vidPosition);
  650. }
  651. super.onResume();
  652. }
  653. @Override
  654. public void onBackPressed() {
  655. if(mCustomViewContainer != null){
  656.  
  657. mVideoView.stopPlayback();
  658. mCustomViewContainer.setVisibility(View.GONE);
  659.  
  660. if (mVideoView == null){
  661.  
  662. return;
  663. }else{
  664.  
  665. // Hide the custom view.
  666. mVideoView.setVisibility(View.GONE);
  667. // Remove the custom view from its container.
  668. mCustomViewContainer.removeView(mVideoView);
  669. mVideoView = null;
  670. mCustomViewContainer.setVisibility(View.GONE);
  671. mCustomViewCallback.onCustomViewHidden();
  672. // Show the content view.
  673. mContentView.setVisibility(View.VISIBLE);
  674. setContentView(mContentView);
  675. mCustomViewContainer = null;
  676. }
  677. }else if(mainWebView.canGoBack()){
  678.  
  679. mainWebView.goBack();
  680.  
  681. }else{
  682.  
  683. super.onBackPressed();
  684. }
  685. }
  686.  
  687.  
  688. public String getFileName(String url, String ext1) {
  689. String filenameWithoutExtension = "";
  690. filenameWithoutExtension = String.valueOf(System.currentTimeMillis()+"."+ext1);
  691.  
  692. return filenameWithoutExtension;
  693. }
  694. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement