@Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   Intent intent = getIntent();
   Uri uri = intent.getData();
   if (uri != null) {
     MainActivity.addLink(this, uri.toString());
     Uri newUri = Uri.parse("view-source:" + uri.toString());
     startChrome(newUri);
   }
   if (Intent.ACTION_SEND.equals(intent.getAction())) {
     Bundle extras = intent.getExtras();
     if (extras != null) {
       String text = extras.getString(Intent.EXTRA_TEXT);
       Pattern pattern = Pattern.compile(URL_PATTERN);
       if (text != null) {
         Matcher m = pattern.matcher(text);
         if (m.find()) {
           String url = m.group(1);
           MainActivity.addLink(this, url);
           Uri newUri = Uri.parse("view-source:" + url);
           startChrome(newUri);
         }
       }
     }
   }
   this.finish();
 }
 @Override
 public void onDrawerStateChanged(int newState) {
   if (Ref.alive(activityRef)) {
     MainActivity activity = activityRef.get();
     activity.refreshPlayerItem();
     activity.syncSlideMenu();
   }
 }
 /**
  * onClick
  *
  * <p>extracts the relai that was clicked, and asks the ipx to open then close the corresponding
  * relai
  */
 @Override
 public void onClick(View view) {
   Ipx800Control ipx = context.getIpx();
   if (view instanceof Button) {
     Button button = (Button) view;
     // Log.d(TAG, "hit the button " + button.getHint()+ "id = "+button.getId());
     try {
       int port2trigger = Integer.parseInt("" + button.getHint());
       // Log.d(TAG, "would trigger ipx out "+port2trigger);
       try {
         ipx.set(port2trigger, true);
         ipx.set(port2trigger, false);
       } catch (Exception e) {
         Toast.makeText(context, "error:" + e, Toast.LENGTH_LONG).show();
       }
     } catch (NumberFormatException e) {
       // ok, we hit a special button....
       if (button.getId() == R.id.servernameValue) context.callSettings();
       else if (button.getHint().equals("fill_me")) context.callSettings();
       // else Log.e(TAG,"unknown button code: "+button.getHint());
     }
   }
 }
Exemple #4
0
  Runner(final Group group, String router, String routerPrefix, final MainActivity mainActivity) {
    super(group, router, routerPrefix);
    // group, model, colors, audio observer are all set up now.
    this.mainActivity = mainActivity;
    gui = new Gui(mainActivity, group, model);
    String key = "com.tayek.tablet.sharedPreferencesKey";
    sharedPreferences = mainActivity.getSharedPreferences(key, Context.MODE_PRIVATE);
    // sharedPreferences.edit().clear().commit(); // only if we have to
    pl("router: " + router + ", prefix: " + routerPrefix);
    pl("preferences: " + sharedPreferences.getAll());
    ((AndroidPrefs) prefs)
        .setDelegate(
            new AndroidPrefs() {
              @Override
              public String get(String key) {
                return sharedPreferences.getString(key, "");
              }

              @Override
              public void put(String key, String value) {
                sharedPreferences.edit().putString(key, value).commit();
              }

              @Override
              public Map<String, ?> map() {
                return sharedPreferences.getAll();
              }

              @Override
              public String toString() {
                return sharedPreferences.getAll().toString();
              }
            });
    pl("prefs: " + prefs);
    // Exec.exec("settings put global captive_portal_detection_enabled 0 ");
    // loopSleep=10_000;
    // prefs.clear();
    // try clearing the prefs to see if it fixed the problem
    // that conrad found on sunday.
  }
Exemple #5
0
  @Override
  protected void loop(int n) {
    p("start runner loop " + mainActivity + ", group: " + group);
    if (heartbeatperiod != 0 && n % heartbeatperiod == 0)
      pl("android id: " + mainActivity.androidId + ", loop: " + n);

    super.loop(n);
    if (!isNetworkInterfaceUp) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  mainActivity.networkStuff.checkWifi();
                }
              },
              "checkwifi")
          .start();
    }
    mainActivity.runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            boolean isServerRunning = tablet != null && tablet.isServerRunning();
            gui.serverStatus.setBackgroundColor(
                Colors.aColor(isServerRunning ? Colors.green : Colors.red));
            gui.wifiStatus.setBackgroundColor(
                Colors.aColor(isNetworkInterfaceUp ? Colors.green : Colors.red));
            gui.routerStatus.setBackgroundColor(
                Colors.aColor(isRouterOk ? Colors.green : Colors.red));
            gui.singleStatus.setBackgroundColor(
                Colors.aColor(
                    isServerRunning && isNetworkInterfaceUp && isRouterOk
                        ? Colors.green
                        : Colors.red));
          }
        });
    p("end runner loop " + mainActivity);
  }
Exemple #6
0
 @Override
 public void buildGui(MessageReceiver.Model model) {
   pl("building gui.");
   final RelativeLayout relativeLayout = gui.builGui();
   gui.setStatusVisibility(
       gui.status[0].getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
   mainActivity.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           mainActivity.setContentView(relativeLayout);
         }
       });
   hasATablet = gui;
   model.addObserver(gui);
   p("building gui adapter.");
   guiAdapterABC = gui.buildGuiAdapter();
   gui.guiAdapterABC = guiAdapterABC;
   hasATablet.setTablet(null);
   guiAdapterABC.setTablet(null);
   p("gui adapter: " + guiAdapterABC);
   p("gui built.");
 }