// [region] events
 @Override
 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
   CompInfo item = (CompInfo) lvReceiver.getItemAtPosition(position);
   boolean bRet = false;
   if (item.enabled) {
     // item.component.getComponentName()
     LogApi.logDisableComponent(item.component.getComponentName().toString());
     bRet = ComponentUtils.doDisableComponent(item.component.getComponentName());
     if (bRet) {
       item.enabled = false;
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setText(R.string.comp_disabled);
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setTextColor(Color.RED);
     } else {
       Toast.makeText(this, R.string.operation_failed, Toast.LENGTH_LONG).show();
     }
   } else if (!item.enabled) {
     LogApi.logEnableComponent(item.component.getComponentName().toString());
     bRet = ComponentUtils.doEnabledComponent(item.component.getComponentName());
     if (bRet) {
       item.enabled = true;
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setText(R.string.comp_enabled);
       ((TextView) view.findViewById(R.id.itemReceiverStatus)).setTextColor(0xFF008000);
     } else {
       Toast.makeText(this, R.string.operation_failed, Toast.LENGTH_LONG).show();
     }
   }
   setResult(RESULT_OK);
   return false;
 }
Example #2
0
  private void doInstallSystemApp(final String path) {
    progressSysapp.setAppName(getString(R.string.installing));
    progressSysapp.setVisibility(View.VISIBLE);

    LogApi.logInstallSystemApp(path);

    final Handler h =
        new Handler() {

          @Override
          public void handleMessage(Message msg) {
            if (msg.what == 1) {
              Toast.makeText(
                      getActivity(),
                      (msg.arg1 == 1 ? R.string.install_ok : R.string.install_fail),
                      Toast.LENGTH_LONG)
                  .show();
              progressSysapp.setVisibility(View.GONE);
              doStartLoad();
            }
            super.handleMessage(msg);
          }
        };

    ApkUtils.installSystemApp(getActivity(), path, h);
  }
Example #3
0
 // [region] life circle
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.layout_about);
   init();
   showAppVersion();
   showSystemFitable();
   showDebugStatus();
   LogApi.logEnterAbout();
   fitableClick = 0;
 }
  private void scanDeprecatedHostsT() {
    LogApi.logCleanDeprecatedHosts();
    progressDeprecated.setAppName(getString(R.string.testing));
    progressDeprecated.setVisibility(View.VISIBLE);
    itemScan.setEnabled(false);

    final Handler h =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {

            if (msg.what == 1) {
              progressDeprecated.setVisibility(View.GONE);
              itemScan.setEnabled(true);
              adapter.notifyDataSetChanged();

              boolean ret = DIPairUtils.saveHosts(lstDeprecated);
              if (ret) {
                Toast.makeText(getActivity(), R.string.save_hosts_succ, Toast.LENGTH_LONG).show();
                getActivity().finish();
              } else {
                Toast.makeText(getActivity(), R.string.save_hosts_error, Toast.LENGTH_LONG).show();
              }
            } else if (msg.what == 2) {
              progressDeprecated.setProgress((String) msg.obj);
            }
            super.handleMessage(msg);
          }
        };

    new Thread(
            new Runnable() {

              @Override
              public void run() {
                String ping = "";
                int count = lstDeprecated.size();
                for (int i = count - 1; i >= 0; i--) {
                  Message msg = new Message();
                  msg.what = 2;
                  msg.obj = lstDeprecated.get(i).ip;
                  h.sendMessage(msg);

                  ping = PingUtils.ping(lstDeprecated.get(i).ip);
                  if (ping.equals("") || ping.equals("timeout")) {
                    lstDeprecated.remove(i);
                  }
                }
                h.sendEmptyMessage(1);
              }
            })
        .start();
  }
Example #5
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   LogApi.logEnterSysapp();
 }
 @Override
 public void onCreate(android.os.Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   LogApi.logEnterDeprecatedHosts();
 };