Exemple #1
0
    @Override
    public void onLaunched(boolean isVpnMode) {
        isLaunched = true;
        ActivityCompat.invalidateOptionsMenu(this);

        ImageView star = (ImageView) findViewById(R.id.star);
        stopBlinkingImage(star);
        enableImage(star);
        stopBlinkingStatus();

        startBlinkingImage((ImageView) findViewById(R.id.freeInternetArrow));
        startBlinkingStatus(_(R.string.status_free_internet_connecting));
        if (isVpnMode) {
            clearNotification();
            if (LaunchService.isVpnRunning()) {
                onFreeInternetChanged(true);
            } else {
                startVpn();
            }
        } else {
            if (ApkUtils.isInstalled(this, "fq.router")) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        ApkUtils.uninstall(MainActivity.this, "fq.router");
                    }
                }).start();
            }
            checkWifiRepeater();
            checkPickAndPlay();
            ConnectFreeInternetService.execute(this);
        }
    }
Exemple #2
0
 public void exit() {
     if (LaunchService.isVpnRunning()) {
         Toast.makeText(this, R.string.vpn_exit_hint, 5000).show();
         return;
     }
     ExitService.execute(this);
     showNotification(_(R.string.status_exiting));
     sendBroadcast(new ExitingIntent());
 }
Exemple #3
0
 private void checkFreeInternet() {
     if (ShellUtils.isRooted()) {
         CheckFreeInternetService.execute(this);
     } else {
         if (LaunchService.isVpnRunning()) {
             onFreeInternetChanged(true);
         }
     }
 }
Exemple #4
0
 private void showNotification(String text) {
     if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("NotificationEnabled", true)) {
         clearNotification();
         return;
     }
     if (LaunchService.isVpnRunning()) {
         clearNotification();
         return;
     }
     displayNotification(this, text);
 }
Exemple #5
0
 private void startVpn() {
     if (LaunchService.isVpnRunning()) {
         LogUtils.e("vpn is already running, do not start it again");
         return;
     }
     Intent intent = VpnService.prepare(MainActivity.this);
     if (intent == null) {
         onActivityResult(ASK_VPN_PERMISSION, RESULT_OK, null);
     } else {
         startActivityForResult(intent, ASK_VPN_PERMISSION);
     }
 }
Exemple #6
0
 public void updateStatus(String status) {
     LogUtils.i(status);
     TextView textView = (TextView) findViewById(R.id.statusTextView);
     if (!textView.getText().toString().startsWith("Error:")) {
         textView.setText(status);
         if (LaunchService.isVpnRunning()) {
             clearNotification();
         } else {
             showNotification(status);
         }
     }
 }
Exemple #7
0
 @Override
 public void onFreeInternetChanged(boolean isConnected) {
     ImageView freeInternetArrow = (ImageView) findViewById(R.id.freeInternetArrow);
     stopBlinkingImage(freeInternetArrow);
     stopBlinkingStatus();
     if (isConnected) {
         updateStatus(_(R.string.status_free_internet_connected));
         enableImage(freeInternetArrow);
         checkUpdate();
     } else {
         clearStatus();
         disableImage(freeInternetArrow);
     }
     if (LaunchService.isVpnRunning()) {
         ToggleButton button = (ToggleButton) findViewById(R.id.freeInternetButton);
         button.setChecked(isConnected);
     } else {
         enableFreeInternetButton(isConnected);
     }
 }