@Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == 114) {
      if (actionBar.isShowing()) actionBar.hide();
      else actionBar.show();
    }

    if (keyCode == 113) {
      if (actionBar.isShowing()) actionBar.hide();
      else actionBar.show();
    }

    Back(null);
    return super.onKeyDown(keyCode, event);
  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);

    ActionBar actionBar = getSupportActionBar();
    actionBar.hide();

    Intent intent = getIntent();
    url = intent.getStringExtra(INTENT_PARAMETER_URL);
    if (url == null) {
      url = Constants.BASE_URL_HTTPS;
    }

    webView = (WebView) findViewById(R.id.webView);
    webView.setWebChromeClient(new WebChromeClient());
    webView.setWebViewClient(new MyWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);

    String language = String.valueOf(Constants.CURRENT_CATROBAT_LANGUAGE_VERSION);
    String flavor = Constants.FLAVOR_DEFAULT;
    String version = Utils.getVersionName(getApplicationContext());
    String platform = Constants.PLATFORM_DEFAULT;
    webView
        .getSettings()
        .setUserAgentString(
            "Catrobat/" + language + " " + flavor + "/" + version + " Platform/" + platform);

    webView.loadUrl(url);

    webView.setDownloadListener(
        new DownloadListener() {
          @Override
          public void onDownloadStart(
              String url,
              String userAgent,
              String contentDisposition,
              String mimetype,
              long contentLength) {
            Log.e("TAG", "contentDisposition: " + contentDisposition + "   " + mimetype);
            if (contentDisposition.contains(Constants.CATROBAT_EXTENSION)) {
              DownloadUtil.getInstance()
                  .prepareDownloadAndStartIfPossible(WebViewActivity.this, url);
            } else {
              DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

              request.setTitle(
                  getString(R.string.notification_download_title_pending)
                      + " "
                      + DownloadUtil.getInstance().getProjectNameFromUrl(url));
              request.setDescription(getString(R.string.notification_download_pending));
              request.setNotificationVisibility(
                  DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
              request.setDestinationInExternalPublicDir(
                  Environment.DIRECTORY_DOWNLOADS,
                  DownloadUtil.getInstance().getProjectNameFromUrl(url)
                      + ANDROID_APPLICATION_EXTENSION);
              request.setMimeType(mimetype);

              registerReceiver(
                  onDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

              DownloadManager downloadManager =
                  (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
              downloadManager.enqueue(request);
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    if (Conf.codePoint == null) finish();

    this.point = Conf.codePoint;

    myTimer2 = new Timer();
    uiHandler2 = new Handler();

    myTimer3 = new Timer();
    uiHandler3 = new Handler();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    // add bar
    actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // add 1st tab
    tab1 = actionBar.newTab();
    tab1.setText(" 1 ");
    tab1.setTabListener(this);
    actionBar.addTab(tab1);

    // add 2nd tab
    tab2 = actionBar.newTab();
    tab2.setText(" 2 ");
    tab2.setTabListener(this);
    actionBar.addTab(tab2);

    // add 3nd tab
    tab3 = actionBar.newTab();
    tab3.setText(" 3 ");
    tab3.setTabListener(this);
    actionBar.addTab(tab3);

    // add 4nd tab
    tab4 = actionBar.newTab();
    tab4.setText(" 4 ");
    tab4.setTabListener(this);
    actionBar.addTab(tab4);

    actionBar.hide();

    // UPDATE STATUS
    myTimer2.schedule(
        new TimerTask() {
          @Override
          public void run() {
            uiHandler2.post(
                new Runnable() {
                  @Override
                  public void run() {
                    updateUpdateInfo();
                  }
                });
          };
        },
        0L,
        1L * 1000);

    isOnline();
  }