/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    App.getLogger().d(TAG, "SDK Version");
    App.getLogger().d(TAG, "SDK Version: " + Build.VERSION.SDK_INT);

    //        if (showAppRate())
    //		{
    //			LikeAppDialog dialog = LikeAppDialog.newInstance();
    //            dialog.show(getSupportFragmentManager(), TAG);
    //		}
    //		else if (showAppBetaTest())
    //        {
    //            BetaTestApplicationAlertDialog dialog =
    // BetaTestApplicationAlertDialog.newInstance();
    //            dialog.show(getSupportFragmentManager(), TAG);
    //        }
    //        else
    //		{
    //			GoToProxy();
    //		}

    //		LogWrapper.d(TAG, "Finish onCreate");
  }
    @Override
    public void handleMessage(Message message) {
      Bundle b = message.getData();

      App.getLogger().w(TAG, "handleMessage: " + b.toString());

      refreshUI();
    }
  public void listDBProxies(View caller) {
    TextView textViewTest = new TextView(this);
    testDBContainer.addView(textViewTest);
    textViewTest.setTextSize(10);

    Map<Long, ProxyEntity> savedProxies = App.getDBManager().getAllProxiesWithTAGs();
    List<ProxyEntity> list = new ArrayList<ProxyEntity>(savedProxies.values());
    for (ProxyEntity p : list) {
      textViewTest.append(p.toString() + "\n");
    }

    Map<Long, PacEntity> savedPac = App.getDBManager().getAllPac();
    List<PacEntity> pacslist = new ArrayList<PacEntity>(savedPac.values());
    for (PacEntity p : pacslist) {
      textViewTest.append(p.toString() + "\n");
    }
  }
  @Override
  protected void onStart() {
    super.onStart();

    setProgressBarVisibility(true);

    App.getLogger().d(TAG, "Start");
  }
 public void listDBTags(View caller) {
   TextView textViewTest = new TextView(this);
   testDBContainer.addView(textViewTest);
   textViewTest.setTextSize(10);
   List<TagEntity> list = App.getDBManager().getAllTags();
   for (TagEntity t : list) {
     textViewTest.append(t.toString() + "\n");
   }
 }
 public void listDBWifiAp(View caller) {
   TextView textViewTest = new TextView(this);
   textViewTest.setTextSize(10);
   testDBContainer.addView(textViewTest);
   Map<Long, WiFiAPEntity> savedAp = App.getDBManager().getAllWifiAp();
   List<WiFiAPEntity> list = new ArrayList<WiFiAPEntity>(savedAp.values());
   for (WiFiAPEntity p : list) {
     textViewTest.append(p.toString() + "\n");
   }
 }
  private boolean validateBypass() {
    String value = proxyBypass.getExclusionString();
    App.getLogger().d(TAG, "Exclusion list updated: " + value);

    ProxyStatusItem item = ProxyUtils.isProxyValidExclusionList(value);
    validationErrors.remove(item.statusCode);
    if (!item.result) {
      validationErrors.put(item.statusCode, item.message);
      return false;
    } else {
      selectedProxy.exclusion = value;
      return true;
    }
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Let's display the progress in the activity title bar, like the
    // browser app does.
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.webview);

    if (Build.VERSION.SDK_INT < 12)
      ProxyUtils.setWebViewProxy(
          getApplicationContext(), App.getProxyManager().getCachedConfiguration()); // Only
    // for
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);
    //		mWebView.setBackgroundColor(0x00000000);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.getSettings().setSupportZoom(true);
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

    final Activity activity = this;
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            activity.setTitle("Loading...");

            // Activities and WebViews measure progress with different
            // scales. The progress meter will automatically disappear when we reach 100%
            int activityProgress = progress * 100;
            App.getLogger()
                .d(TAG, "webprogress,activityprogress: " + progress + "," + activityProgress);
            activity.setProgress(activityProgress);

            if (progress == 100) activity.setTitle(R.string.app_name);
          }
        });

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.setWebViewClient(new LocalWebViewClient());

    Bundle extras = getIntent().getExtras();
    URL url = (URL) extras.getSerializable("URL");

    mWebView.loadUrl(url.toString());
  }
Пример #9
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {
    // update the main content by replacing fragments
    FragmentManager fragmentManager = this.getSupportFragmentManager();
    NavigationAction navigationAction = App.getNavigationManager().getAction(position);

    switch (navigationAction) {
      case WIFI_NETWORKS:
      case NOT_DEFINED:
      default:
        FragmentsUtils.changeFragment(
            fragmentManager,
            R.id.fragment_container,
            WiFiApListFragment.newInstance(position),
            false);
        break;

      case HTTP_PROXIES_LIST:
        FragmentsUtils.changeFragment(
            fragmentManager,
            R.id.fragment_container,
            ProxyListFragment.newInstance(position),
            false);
        break;

      case PAC_PROXIES_LIST:
        FragmentsUtils.changeFragment(
            fragmentManager, R.id.fragment_container, PacListFragment.newInstance(position), false);
        break;

      case HELP:
        FragmentsUtils.changeFragment(
            fragmentManager,
            R.id.fragment_container,
            HelpPrefsFragment.newInstance(position),
            false);
        break;

      case DEVELOPER:
        Intent testIntent = new Intent(getApplicationContext(), DeveloperOptionsActivity.class);
        startActivity(testIntent);
        break;
    }
  }
Пример #10
0
  @Override
  public void onResume() {
    super.onResume();

    Bundle args = getArguments();
    uiHandler = new UIHandler();
    validationErrors = new HashMap<ProxyStatusProperties, CharSequence>();

    if (args != null && args.containsKey(SELECTED_PROXY_ARG)) {
      cachedObjId = (UUID) getArguments().getSerializable(SELECTED_PROXY_ARG);
      selectedProxy = (ProxyEntity) App.getCacheManager().get(cachedObjId);
    }

    if (selectedProxy == null) {
      // TODO: temporary fix. needs improvements. remove cachemanager!
      NavigationUtils.GoToMainActivity(getActivity());
    }

    uiHandler.callRefreshUI();
  }
Пример #11
0
  private void checkValidation() {
    if (validateHost() && validatePort() && validateBypass()) {
      ((ProxyDetailActivity) getActivity()).enableSave();
    } else {
      ((ProxyDetailActivity) getActivity()).disableSave();
    }

    // TODO: Add check for duplicated configuration to Async handler
    proxyDuplicatedBanner.setVisibility(View.GONE);
    String host = selectedProxy.host;
    Integer port = selectedProxy.port;
    if (host != null && port != null) {
      List<Long> duplicatedIDs = App.getDBManager().findDuplicatedProxy(host, port);
      if (selectedProxy.isPersisted) {
        proxyDuplicatedBanner.setVisibility(UIUtils.booleanToVisibility(duplicatedIDs.size() > 1));
      } else {
        proxyDuplicatedBanner.setVisibility(UIUtils.booleanToVisibility(duplicatedIDs.size() > 0));
      }
    }
  }
Пример #12
0
  public void onSectionAttached(int number) {
    NavigationAction navigationAction = App.getNavigationManager().getAction(number);

    switch (navigationAction) {
      case WIFI_NETWORKS:
      case NOT_DEFINED:
      default:
        mTitle = getString(R.string.wifi_networks);
        break;

      case HTTP_PROXIES_LIST:
        mTitle = getString(R.string.static_proxies);
        break;

      case PAC_PROXIES_LIST:
        mTitle = getString(R.string.pac_proxies);
        break;

      case HELP:
        mTitle = getString(R.string.help);
        break;
    }
  }
    @Override
    protected Void doInBackground(Void... params) {
      if (_action == TestAction.CLEAR_ALL) {
        TestUtils.resetPreferences(_developerOptionsActivity);
        App.getDBManager().resetDB();
      } else if (_action == TestAction.ADD_EXAMPLE_PROXIES) {
        TestUtils.addProxyExamples(_developerOptionsActivity);
      } else if (_action == TestAction.ADD_TEST_WIFI_NETWORKS) {
        int numWifis = (Integer) _params[0];

        for (int i = 0; i <= numWifis; i++) {
          String ssid = TestUtils.createFakeWifiNetwork(_developerOptionsActivity);
          Timber.e("----------------------------------------------");
          publishProgress(
              String.format("Created #[%d / %d] TEST Wi-Fi network: %s", i, numWifis, ssid));

          try {
            Thread.sleep(500);
          } catch (InterruptedException e) {
            Timber.e(e, "Exception during sleep");
          }
        }
      } else if (_action == TestAction.REMOVE_TEST_WIFI_NETWORKS) {
        int removedCount = TestUtils.deleteFakeWifiNetworks(_developerOptionsActivity);
        publishProgress(String.format("Removed #[%d] TEST Wi-Fi networks", removedCount));
      } else if (_action == TestAction.RUN_STARTUP_ACTIONS) {
        App.getAppStats().updateInstallationDetails();

        publishProgress(App.getAppStats().toString());

        AsyncStartupActions async = new AsyncStartupActions(_developerOptionsActivity);
        async.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
      } else if (_action == TestAction.TOGGLE_DEMO_MODE) {
        // TODO: improve handling of preference cache
        Utils.checkDemoMode(_developerOptionsActivity);
        Utils.setDemoMode(_developerOptionsActivity, !App.getInstance().demoMode);
        Utils.checkDemoMode(_developerOptionsActivity);

        //                for (WiFiApConfig conf :
        // App.getWifiNetworksManager().getSortedWifiApConfigsList())
        //                {
        //                    if (App.getInstance().demoMode)
        //                        conf.setAPDescription(UIUtils.getRandomCodeName().toString());
        //                    else
        //                        conf.setAPDescription(null);
        //                }
      } else if (_action == TestAction.SET_ALL_PROXIES) {
        TestUtils.setProxyForAllAP(_developerOptionsActivity);
      } else if (_action == TestAction.CLEAR_ALL_PROXIES) {
        TestUtils.clearProxyForAllAP(_developerOptionsActivity);
      } else if (_action == TestAction.TEST_VALIDATION) {
        TestUtils.testValidation();
      } else {
        for (int i = 0; i < 10; i++) {
          switch (_action) {
            case ADD_PROXY:
              TestUtils.addRandomProxy();
              break;
            case TEST_SERIALIZATION:
              TestUtils.testSerialization();
              break;
            case ADD_TAGS:
              TestUtils.addTags();
              break;
            case UPDATE_TAGS:
              //                            TestUtils.addRandomProxy();
              break;
          }

          publishProgress(String.valueOf(i));
        }
      }

      return null;
    }
 @Override
 protected void onPause() {
   super.onPause();
   App.getLogger().d(TAG, "Pause");
 }
 @Override
 protected void onResume() {
   super.onResume();
   App.getLogger().d(TAG, "Resume");
 }
 @Override
 protected void onStop() {
   App.getLogger().d(TAG, "Stop");
   super.onStop();
 }
 public void onBackPressed() {
   App.getLogger().d(TAG, "Back Pressed");
   return;
 }
 @Override
 protected void onDestroy() {
   App.getLogger().d(TAG, "Destroy");
   super.onDestroy();
 }