예제 #1
0
파일: Runner.java 프로젝트: rtayek/Cb7
  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.
  }
예제 #2
0
파일: Runner.java 프로젝트: rtayek/Cb7
  @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);
  }
예제 #3
0
파일: Runner.java 프로젝트: rtayek/Cb7
 @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.");
 }