Ejemplo n.º 1
1
  protected TabView openUrlInTab(
      String url, long urlLoadStartTime, boolean setAsCurrentTab, boolean hasShownAppPicker) {
    setHiddenByUser(false);

    if (getActiveTabCount() == 0) {
      mBubbleDraggable.setVisibility(View.VISIBLE);
      collapseBubbleFlow(0);
      mBubbleFlowDraggable.setVisibility(View.GONE);
      // Only do this snap if ContentView is showing. No longer obliterates slide-in animation
      if (contentViewShowing()) {
        mBubbleDraggable.snapToBubbleView();
      } else {
        Point bubbleRestingPoint = Settings.get().getBubbleRestingPoint();
        int fromX = Settings.get().getBubbleStartingX(bubbleRestingPoint);
        mBubbleDraggable.slideOnScreen(
            fromX,
            bubbleRestingPoint.y,
            bubbleRestingPoint.x,
            bubbleRestingPoint.y,
            Constant.BUBBLE_SLIDE_ON_SCREEN_TIME);
      }
    }

    TabView result =
        mBubbleFlowDraggable.openUrlInTab(
            url, urlLoadStartTime, setAsCurrentTab, hasShownAppPicker);
    showBadge(getActiveTabCount() > 1 ? true : false);
    ++mBubblesLoaded;

    mOpenUrlInfos.add(new OpenUrlInfo(url, urlLoadStartTime));

    return result;
  }
Ejemplo n.º 2
0
  private boolean handleResolveInfo(
      ResolveInfo resolveInfo, String urlAsString, long urlLoadStartTime) {
    if (Settings.get().didRecentlyRedirectToApp(urlAsString)) {
      return false;
    }

    boolean isLinkBubble =
        resolveInfo.activityInfo != null
            && resolveInfo.activityInfo.packageName.equals(mAppPackageName);
    if (isLinkBubble == false
        && MainApplication.loadResolveInfoIntent(mContext, resolveInfo, urlAsString, -1)) {
      if (getActiveTabCount() == 0 && Prompt.isShowing() == false) {
        finish();
      }

      String title =
          String.format(
              mContext.getString(R.string.link_loaded_with_app),
              resolveInfo.loadLabel(mContext.getPackageManager()));
      MainApplication.saveUrlInHistory(mContext, resolveInfo, urlAsString, title);
      Settings.get().addRedirectToApp(urlAsString);
      Settings.get()
          .trackLinkLoadTime(
              System.currentTimeMillis() - urlLoadStartTime,
              Settings.LinkLoadType.AppRedirectInstant,
              urlAsString);
      return true;
    }

    return false;
  }
Ejemplo n.º 3
0
  public static void destroy() {
    if (sInstance == null) {
      throw new RuntimeException("No instance to destroy");
    }

    Settings.get().saveData();

    MainApplication app = (MainApplication) sInstance.mContext.getApplicationContext();
    Bus bus = app.getBus();
    bus.unregister(sInstance);

    if (Settings.get().isIncognitoMode()) {
      CookieManager cookieManager = CookieManager.getInstance();
      if (cookieManager != null && cookieManager.hasCookies()) {
        cookieManager.removeAllCookie();
      }
    }

    if (Constant.PROFILE_FPS) {
      sInstance.mWindowManager.removeView(sInstance.mTextView);
    }
    sInstance.mBubbleDraggable.destroy();
    sInstance.mBubbleFlowDraggable.destroy();
    sInstance.mCanvasView.destroy();
    sInstance.mChoreographer.removeFrameCallback(sInstance);
    sInstance.endAppPolling();
    sInstance = null;
  }
Ejemplo n.º 4
0
 @Override
 public void exec(List<String> parameter) {
   int y = Integer.parseInt(parameter.get(0));
   int x =
       Settings.get(SetKeys.WIN_WIDTH) == null
           ? 0
           : Settings.get(SetKeys.WIN_WIDTH, Integer.class);
   Settings.setWindowResolution(x, y);
 }
  /** Update the settings associated with this smoother */
  public void updateSettings() {

    // Handle the smoothing argument and translate to a class
    //  to a smoothing postprocessor.

    if (Settings.has(Val.Smooth) && Settings.get(Val.Smooth).length() > 0) {
      String[] upd = Settings.getArray(Val.Postprocessor);
      String cname = "skyview.data.BoxSmoother";
      boolean found = false;
      for (String anUpd : upd) {
        if (cname.equals(anUpd)) {
          found = true;
          break;
        }
      }
      if (!found) {
        // Put smooth before other postprocessors.
        if (Settings.has(Val.Postprocessor)) {
          Settings.put(Val.Postprocessor, cname + "," + Settings.get(Val.Postprocessor));
        } else {
          Settings.put(Val.Postprocessor, cname);
        }
      }
    }

    // If the user has requested graphic content, then they shouldn't
    // have to say they want a graphic image.
    if (Settings.has(Val.Invert)
        || Settings.has(Val.LUT)
        || Settings.has(Val.Scaling)
        || Settings.has(Val.quicklook)
        || Settings.has(Val.imagej)) {
      Settings.add(Val.Postprocessor, "skyview.ij.IJProcessor");
      if (!Settings.has(Val.quicklook) && !Settings.has(Val.quicklook)) {
        Settings.add(Val.quicklook, "jpg");
      }
    }

    // Set JPEGs as the default quicklook format.
    if (Settings.has(Val.quicklook)) {
      String ql = Settings.get(Val.quicklook);
      if (ql == null || ql.length() == 0) {
        Settings.put(Val.quicklook, "jpeg");
      }
    }

    // If the user has requested the AddingMosaicker, then
    // they should use the null image finder.
    if (Settings.has(Val.Mosaicker)) {
      String mos = Settings.get(Val.Mosaicker);
      if (mos.indexOf("AddingMosaicker") >= 0) {
        Settings.put(Val.imagefinder, "Bypass");
      }
    }
  }
Ejemplo n.º 6
0
 public void onOrientationChanged() {
   Config.init(mContext);
   Settings.get().onOrientationChange();
   mBubbleDraggable.onOrientationChanged();
   mBubbleFlowDraggable.onOrientationChanged();
   MainApplication.postEvent(mContext, mOrientationChangedEvent);
 }
Ejemplo n.º 7
0
  private void initSettings() {
    settings = Settings.get(this);

    if (TextUtils.isEmpty(settings.getMmsc())) {
      initApns();
    }
  }
Ejemplo n.º 8
0
 protected void configClient(HttpClientBuilder cb, Settings settings) throws HTTPException {
   cb.useSystemProperties();
   String agent = (String) settings.get(Prop.USER_AGENT);
   if (agent != null) cb.setUserAgent(agent);
   setInterceptors(cb);
   cb.setContentDecoderRegistry(contentDecoderMap);
 }
Ejemplo n.º 9
0
  public void autoContentDisplayLinkLoaded(TabView tab) {
    // Ensure this is not an edge case where the Tab has already been destroyed, re #254
    if (getActiveTabCount() == 0 || isTabActive(tab) == false) {
      return;
    }

    if (Settings.get().getAutoContentDisplayLinkLoaded()) {
      displayTab(tab);
    }
  }
Ejemplo n.º 10
0
 @SuppressWarnings("unused")
 @Subscribe
 public void onStateChangedEvent(MainApplication.StateChangedEvent event) {
   closeAllBubbles(false);
   final Vector<String> urls = Settings.get().loadCurrentTabs();
   if (urls.size() > 0) {
     for (String url : urls) {
       MainApplication.openLink(mContext, url, null);
     }
   }
 }
Ejemplo n.º 11
0
 @Override
 public void apply(Settings value, Settings current, Settings previous) {
   for (String key : value.getAsMap().keySet()) {
     assert loggerPredicate.test(key);
     String component = key.substring("logger.".length());
     if ("level".equals(component)) {
       continue;
     }
     if ("_root".equals(component)) {
       final String rootLevel = value.get(key);
       if (rootLevel == null) {
         Loggers.setLevel(
             ESLoggerFactory.getRootLogger(),
             ESLoggerFactory.LOG_DEFAULT_LEVEL_SETTING.get(settings));
       } else {
         Loggers.setLevel(ESLoggerFactory.getRootLogger(), rootLevel);
       }
     } else {
       Loggers.setLevel(ESLoggerFactory.getLogger(component), value.get(key));
     }
   }
 }
Ejemplo n.º 12
0
  public boolean reloadAllTabs(Context context) {
    CrashTracking.log("MainController.reloadAllTabs()");
    boolean reloaded = false;
    closeAllBubbles(false);
    final Vector<String> urls = Settings.get().loadCurrentTabs();
    if (urls.size() > 0) {
      for (String url : urls) {
        MainApplication.openLink(context.getApplicationContext(), url, null);
        reloaded = true;
      }
    }

    return reloaded;
  }
Ejemplo n.º 13
0
 public boolean onBegin() {
   threadId = 412;
   UberPaint p =
       new UberPaint("ArteFalconry", threadId, getClass().getAnnotation(Manifest.class).version());
   p.skills.add(new Skill(Skills.HUNTER));
   p.skills.add(new Skill(Skills.PRAYER));
   strategies.add(new ReGetFalcon());
   strategies.add(new DropJunk());
   strategies.add(new CatchKebbit());
   strategies.add(new TakeFalcon());
   Options.add("spotted", Skills.getRealLevel(Skills.HUNTER) <= 69);
   Options.add("dark", Skills.getRealLevel(Skills.HUNTER) >= 57);
   Options.add("dashing", Skills.getRealLevel(Skills.HUNTER) >= 69);
   p.infoColumnValues = new String[] {"Status:", "Kebbits caught:", "Run time:"};
   p.addFrame("options");
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 356, "Hunt spotted: ", Options.getBoolean("spotted"), 65) {
             public void onPress() {
               if (Options.getBoolean("dashing") || Options.getBoolean("dark")) {
                 Options.flip("spotted");
                 setKebbits();
               }
             }
           });
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 371, "Hunt dark: ", Options.getBoolean("dark"), 74) {
             public void onPress() {
               if (Options.getBoolean("spotted") || Options.getBoolean("dashing")) {
                 Options.flip("dark");
                 setKebbits();
               }
             }
           });
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 387, "Hunt dashing: ", Options.getBoolean("dashing"), 18) {
             public void onPress() {
               if (Options.getBoolean("spotted") || Options.getBoolean("dark")) {
                 Options.flip("dashing");
                 setKebbits();
               }
             }
           });
   setKebbits();
   ReGetFalcon.oldSetting = Settings.get(334);
   paintType = p;
   return true;
 }
Ejemplo n.º 14
0
 /** TODO: Kommentar */
 public static File resolveFile(String filepath) {
   Pattern p = Pattern.compile("%(.+?)%");
   Matcher m = p.matcher(filepath);
   Settings env = CfgSettings.open(".environment", "System Environment für java");
   while (m.find() == true) {
     String f = m.group(1);
     String rep = env.get(f, "");
     if (StringTool.isNothing(rep)) {
       rep = System.getenv(f);
     }
     filepath = m.replaceFirst(rep);
   }
   // pathname=pathname.replaceAll("%(.+?)%",env.get("$1",""));
   log.log("Abgeleiteter Pfadname: " + filepath, Log.DEBUGMSG);
   return new File(filepath);
 }
Ejemplo n.º 15
0
 @Override
 public boolean activate() {
   int index = 0;
   final Tile[] tiles = GlobalConstant.TILE_ROCKS[Checks.isGold()];
   for (int i = 1; i < tiles.length; i++) {
     if (Calculations.distanceTo(tiles[i]) < Calculations.distanceTo(tiles[index])) index = i;
   }
   if (GlobalConstant.WIELDED_ID != -1
       && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.getCurrent().equals(Tabs.ATTACK))
       && Settings.get(300) == 1000) {
     if (Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) return true;
   }
   return !Banker.isDepositOpen()
       && ((inCombat() /* && Calculations.distanceTo(tiles[index]) < 8 && !Inventory.isFull()*/)
           || Checks.isOutside()
           || (GlobalConstant.KEEP_ALIVE
               && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10));
 }
Ejemplo n.º 16
0
 @Override
 public synchronized void settings(Settings settings) throws IOException {
   if (closed) throw new IOException("closed");
   int length = settings.size() * 6;
   byte type = TYPE_SETTINGS;
   byte flags = FLAG_NONE;
   int streamId = 0;
   frameHeader(streamId, length, type, flags);
   for (int i = 0; i < Settings.COUNT; i++) {
     if (!settings.isSet(i)) continue;
     int id = i;
     if (id == 4) id = 3; // SETTINGS_MAX_CONCURRENT_STREAMS renumbered.
     else if (id == 7) id = 4; // SETTINGS_INITIAL_WINDOW_SIZE renumbered.
     sink.writeShort(id);
     sink.writeInt(settings.get(i));
   }
   sink.flush();
 }
Ejemplo n.º 17
0
  private void doEdit(WebPageContext page) throws IOException, ServletException {
    final Type type = page.paramOrDefault(Type.class, "type", Type.JAVA);
    final File file = getFile(page);
    final StringBuilder codeBuilder = new StringBuilder();

    if (file != null) {
      if (file.exists()) {
        if (file.isDirectory()) {
          // Can't edit a directory.

        } else {
          codeBuilder.append(IoUtils.toString(file, StandardCharsets.UTF_8));
        }

      } else {
        String filePath = file.getPath();

        if (filePath.endsWith(".java")) {
          filePath = filePath.substring(0, filePath.length() - 5);

          for (File sourceDirectory : CodeUtils.getSourceDirectories()) {
            String sourceDirectoryPath = sourceDirectory.getPath();

            if (filePath.startsWith(sourceDirectoryPath)) {
              String classPath = filePath.substring(sourceDirectoryPath.length());

              if (classPath.startsWith(File.separator)) {
                classPath = classPath.substring(1);
              }

              int lastSepAt = classPath.lastIndexOf(File.separatorChar);

              if (lastSepAt < 0) {
                codeBuilder.append("public class ");
                codeBuilder.append(classPath);

              } else {
                codeBuilder.append("package ");
                codeBuilder.append(
                    classPath.substring(0, lastSepAt).replace(File.separatorChar, '.'));
                codeBuilder.append(";\n\npublic class ");
                codeBuilder.append(classPath.substring(lastSepAt + 1));
              }

              codeBuilder.append(" {\n}");
              break;
            }
          }
        }
      }

    } else {
      Set<String> imports = findImports();

      imports.add("com.psddev.dari.db.*");
      imports.add("com.psddev.dari.util.*");
      imports.add("java.util.*");

      String includes = Settings.get(String.class, INCLUDE_IMPORTS_SETTING);

      if (!ObjectUtils.isBlank(includes)) {
        Collections.addAll(imports, includes.trim().split("\\s*,?\\s+"));
      }

      String excludes = Settings.get(String.class, EXCLUDE_IMPORTS_SETTING);

      if (!ObjectUtils.isBlank(excludes)) {
        for (String exclude : excludes.trim().split("\\s*,?\\s+")) {
          imports.remove(exclude);
        }
      }

      for (String i : imports) {
        codeBuilder.append("import ");
        codeBuilder.append(i);
        codeBuilder.append(";\n");
      }

      codeBuilder.append('\n');
      codeBuilder.append("public class Code {\n");
      codeBuilder.append("    public static Object main() throws Throwable {\n");

      String query = page.param(String.class, "query");
      String objectClass = page.paramOrDefault(String.class, "objectClass", "Object");

      if (query == null) {
        codeBuilder.append("        return null;\n");

      } else {
        codeBuilder
            .append("        Query<")
            .append(objectClass)
            .append("> query = ")
            .append(query)
            .append(";\n");
        codeBuilder
            .append("        PaginatedResult<")
            .append(objectClass)
            .append("> result = query.select(0L, 10);\n");
        codeBuilder.append("        return result;\n");
      }

      codeBuilder.append("    }\n");
      codeBuilder.append("}\n");
    }

    new DebugFilter.PageWriter(page) {
      {
        List<Object> inputs = CodeDebugServlet.Static.getInputs(getServletContext());
        Object input = inputs == null || inputs.isEmpty() ? null : inputs.get(0);
        String name;

        if (file == null) {
          name = null;

        } else {
          name = file.toString();
          int slashAt = name.lastIndexOf('/');

          if (slashAt > -1) {
            name = name.substring(slashAt + 1);
          }
        }

        startPage("Code Editor", name);
        writeStart("div", "class", "row-fluid");

        if (input != null) {
          writeStart(
              "div",
              "class",
              "codeInput",
              "style",
              "bottom: 65px; position: fixed; top: 55px; width: 18%; z-index: 1000;");
          writeStart("h2").writeHtml("Input").writeEnd();
          writeStart(
              "div",
              "style",
              "bottom: 0; overflow: auto; position: absolute; top: 38px; width: 100%;");
          writeObject(input);
          writeEnd();
          writeEnd();
          writeStart("style", "type", "text/css");
          write(".codeInput pre { white-space: pre; word-break: normal; word-wrap: normal; }");
          writeEnd();
          writeStart("script", "type", "text/javascript");
          write("$('.codeInput').hover(function() {");
          write("$(this).css('width', '50%');");
          write("}, function() {");
          write("$(this).css('width', '18%');");
          write("});");
          writeEnd();
        }

        writeStart(
            "div",
            "class",
            input != null ? "span9" : "span12",
            "style",
            input != null ? "margin-left: 20%" : null);
        writeStart(
            "form",
            "action",
            page.url(null),
            "class",
            "code",
            "method",
            "post",
            "style",
            "margin-bottom: 70px;",
            "target",
            "result");
        writeElement("input", "name", "action", "type", "hidden", "value", "run");
        writeElement("input", "name", "type", "type", "hidden", "value", type);
        writeElement("input", "name", "file", "type", "hidden", "value", file);
        writeElement(
            "input",
            "name",
            "jspPreviewUrl",
            "type",
            "hidden",
            "value",
            page.param(String.class, "jspPreviewUrl"));

        writeStart("textarea", "name", "code");
        writeHtml(codeBuilder);
        writeEnd();
        writeStart(
            "div",
            "class",
            "form-actions",
            "style",
            "bottom: 0; left: 0; margin: 0; padding: 10px 20px; position:fixed; right: 0; z-index: 1000;");
        writeElement("input", "class", "btn btn-primary", "type", "submit", "value", "Run");
        writeStart(
            "label",
            "class",
            "checkbox",
            "style",
            "display: inline-block; margin-left: 10px; white-space: nowrap;");
        writeElement("input", "name", "isLiveResult", "type", "checkbox");
        writeHtml("Live Result");
        writeEnd();
        writeStart(
            "label",
            "style",
            "display: inline-block; margin-left: 10px; white-space: nowrap;",
            "title",
            "Shortcut: ?_vim=true");
        boolean vimMode = page.param(boolean.class, "_vim");
        writeStart(
            "label",
            "class",
            "checkbox",
            "style",
            "display: inline-block; margin-left: 10px; white-space: nowrap;");
        writeElement(
            "input",
            "name",
            "_vim",
            "type",
            "checkbox",
            "value",
            "true",
            vimMode ? "checked" : "_unchecked",
            "true");
        writeHtml("Vim Mode");
        writeEnd();
        writeEnd();
        writeElement(
            "input",
            "class",
            "btn btn-success pull-right",
            "name",
            "isSave",
            "type",
            "submit",
            "value",
            "Save");
        writeElement(
            "input",
            "class",
            "btn pull-right",
            "style",
            "margin-right: 10px;",
            "name",
            "clearCode",
            "type",
            "submit",
            "value",
            "Clear");
        writeEnd();
        writeEnd();

        writeStart(
            "div",
            "class",
            "resultContainer",
            "style",
            "background: rgba(255, 255, 255, 0.8);"
                + "border-color: rgba(0, 0, 0, 0.2);"
                + "border-style: solid;"
                + "border-width: 0 0 0 1px;"
                + "max-height: 45%;"
                + "top: 55px;"
                + "overflow: auto;"
                + "padding: 0px 20px 5px 10px;"
                + "position: fixed;"
                + "z-index: 3;"
                + "right: 0px;"
                + "width: 35%;");
        writeStart("h2").writeHtml("Result").writeEnd();
        writeStart("div", "class", "frame", "name", "result");
        writeEnd();
        writeEnd();

        writeStart("script", "type", "text/javascript");
        write("$('body').frame();");
        write("var $codeForm = $('form.code');");

        write("var lineMarkers = [ ];");
        write("var columnMarkers = [ ];");
        write("var codeMirror = CodeMirror.fromTextArea($('textarea')[0], {");
        write("'indentUnit': 4,");
        write("'lineNumbers': true,");
        write("'lineWrapping': true,");
        write("'matchBrackets': true,");
        write("'mode': 'text/x-java'");
        write("});");

        // Save code to local storage when the user stops typing for 1 second
        write("if (window.localStorage !== undefined) {");
        write("var baseCode = $('textarea[name=code]').text();");

        write("var windowStorageCodeKey = 'bsp.codeDebugServlet.code';");
        write(
            "if (window.localStorage.getItem(windowStorageCodeKey) !== null && window.localStorage.getItem(windowStorageCodeKey).trim()) {");
        write("codeMirror.getDoc().setValue(window.localStorage.getItem(windowStorageCodeKey))");
        write("}");

        write("var typingTimer;");
        write("codeMirror.on('keydown', function() {");
        write("clearTimeout(typingTimer);");
        write("});");
        write("codeMirror.on('keyup', function() {");
        write("clearTimeout(typingTimer);");
        write("typingTimer = setTimeout(function(){");
        write(
            "window.localStorage.setItem(windowStorageCodeKey, codeMirror.getDoc().getValue());},");
        write("1000);");
        write("});");
        write("}");

        // Reset code to original page load value and clear window storage
        write("$('.form-actions input[name=clearCode]').on('click', function(e) {");
        write("e.preventDefault();");
        write("if (baseCode !== undefined && baseCode.trim()) {");
        write("codeMirror.getDoc().setValue(baseCode);");
        write("if (window.localStorage !== undefined) {");
        write("window.localStorage.removeItem(windowStorageCodeKey);");
        write("}");
        write("}");
        write("});");

        write("codeMirror.on('change', $.throttle(1000, function() {");
        write("if ($codeForm.find(':checkbox[name=isLiveResult]').is(':checked')) {");
        write("$codeForm.submit();");
        write("}");
        write("}));");

        write("$('input[name=_vim]').change(function() {");
        write("codeMirror.setOption('vimMode', $(this).is(':checked'));");
        write("});");
        write("$('input[name=_vim]').change();");

        int line = page.param(int.class, "line");
        if (line > 0) {
          write("var line = ");
          write(String.valueOf(line));
          write(" - 1;");
          write("codeMirror.setCursor(line);");
          write("codeMirror.addLineClass(line, 'selected', 'selected');");
          write("$(window).scrollTop(codeMirror.cursorCoords().top - $(window).height() / 2);");
        }

        write("var $resultContainer = $('.resultContainer');");
        write("$resultContainer.find('.frame').bind('load', function() {");
        write(
            "$.each(lineMarkers, function() { codeMirror.clearMarker(this); codeMirror.setLineClass(this, null, null); });");
        write("$.each(columnMarkers, function() { this.clear(); });");
        write("var $frame = $(this).find('.syntaxErrors li').each(function() {");
        write("var $error = $(this);");
        write("var line = parseInt($error.attr('data-line')) - 1;");
        write("var column = parseInt($error.attr('data-column')) - 1;");
        write("if (line > -1 && column > -1) {");
        write("lineMarkers.push(codeMirror.setMarker(line, '!'));");
        write("codeMirror.setLineClass(line, 'errorLine', 'errorLine');");
        write(
            "columnMarkers.push(codeMirror.markText({ 'line': line, 'ch': column }, { 'line': line, 'ch': column + 1 }, 'errorColumn'));");
        write("}");
        write("});");
        write("});");
        writeEnd();

        writeEnd();
        writeEnd();
        endPage();
      }

      @Override
      public void startBody(String... titles) throws IOException {
        writeStart("body");
        writeStart("div", "class", "navbar navbar-fixed-top");
        writeStart("div", "class", "navbar-inner");
        writeStart("div", "class", "container-fluid");
        writeStart("span", "class", "brand");
        writeStart("a", "href", DebugFilter.Static.getServletPath(page.getRequest(), ""));
        writeHtml("Dari");
        writeEnd();
        writeHtml("Code Editor \u2192 ");
        writeEnd();

        writeStart(
            "form",
            "action",
            page.url(null),
            "method",
            "get",
            "style",
            "float: left; height: 40px; line-height: 40px; margin: 0; padding-left: 10px;");
        writeStart(
            "select",
            "class",
            "span6",
            "name",
            "file",
            "onchange",
            "$(this).closest('form').submit();");
        writeStart("option", "value", "");
        writeHtml("PLAYGROUND");
        writeEnd();
        for (File sourceDirectory : CodeUtils.getSourceDirectories()) {
          writeStart("optgroup", "label", sourceDirectory);
          writeStart(
              "option",
              "selected",
              sourceDirectory.equals(file) ? "selected" : null,
              "value",
              sourceDirectory);
          writeHtml("NEW CLASS IN ").writeHtml(sourceDirectory);
          writeEnd();
          writeFileOption(file, sourceDirectory, sourceDirectory);
          writeEnd();
        }
        writeEnd();
        writeEnd();

        includeStylesheet("/_resource/chosen/chosen.css");
        includeScript("/_resource/chosen/chosen.jquery.min.js");
        writeStart("script", "type", "text/javascript");
        write("(function() {");
        write("$('select[name=file]').chosen({ 'search_contains': true });");
        write("})();");
        writeEnd();
        writeEnd();
        writeEnd();
        writeEnd();
        writeStart("div", "class", "container-fluid", "style", "padding-top: 54px;");
      }

      private void writeFileOption(File file, File sourceDirectory, File source)
          throws IOException {
        if (source.isDirectory()) {
          for (File child : source.listFiles()) {
            writeFileOption(file, sourceDirectory, child);
          }

        } else {
          writeStart(
              "option", "selected", source.equals(file) ? "selected" : null, "value", source);
          writeHtml(source.toString().substring(sourceDirectory.toString().length()));
          writeEnd();
        }
      }
    };
  }
 /**
  * Returns true if the value associated with the supplied key isn't set to disabled.
  *
  * @param setting The setting to check if is disabled.
  * @return True if the setting is enabled.
  */
 public boolean isEnabled(String setting) {
   String val = settings.get(setting);
   return val != null && !val.equalsIgnoreCase(Settings.MODE_DISABLED);
 }
 /**
  * Returns true if the setting is in fatal mode. Used when determining if the rule should fail a
  * build.
  *
  * @param setting The configuration item to check if in fatal mode.
  * @return True when the setting is in fatal mode.
  */
 public boolean inFatalMode(String setting) {
   String val = settings.get(setting);
   return val != null && val.equalsIgnoreCase(Settings.MODE_FATAL);
 }
 /** @return True if automatic updates are enabled and run for each enforcer build */
 public boolean updateAlways() {
   String val = settings.get(Settings.UPDATE_DATABASE);
   return val != null && val.equalsIgnoreCase(Settings.UPDATES_AUTO);
 }
 /** @return True if daily updates are enabled */
 public boolean updateDaily() {
   String val = settings.get(Settings.UPDATE_DATABASE);
   return val != null && val.equalsIgnoreCase(Settings.UPDATES_DAILY);
 }
 /**
  * Returns true if automatic updates are enabled.
  *
  * @return True if automatic updates of database are enabled.
  */
 public boolean updatesEnabled() {
   String val = settings.get(Settings.UPDATE_DATABASE);
   return val != null
       && (val.equalsIgnoreCase(Settings.UPDATES_AUTO)
           || val.equalsIgnoreCase(Settings.UPDATES_DAILY));
 }
/** Delivers NetarchiveSuite notifications by email. */
public class EMailNotifications extends Notifications {

  /** The error logger we notify about error messages on. */
  private static final Logger log = LoggerFactory.getLogger(EMailNotifications.class);

  /** The default place in classpath where the settings file can be found. */
  private static String DEFAULT_SETTINGS_CLASSPATH =
      "dk/netarkivet/common/utils/EMailNotificationsSettings.xml";

  /*
   * The static initialiser is called when the class is loaded. It will add default values for all settings defined in
   * this class, by loading them from a settings.xml file in classpath.
   */
  static {
    Settings.addDefaultClasspathSettings(DEFAULT_SETTINGS_CLASSPATH);
  }

  /**
   * <b>settings.common.notifications.receiver</b>: <br>
   * The setting for the receiver of email notifications.
   */
  public static String MAIL_RECEIVER_SETTING = "settings.common.notifications.receiver";

  /**
   * <b>settings.common.notifications.sender</b>: <br>
   * The setting for the sender of email notifications (and receiver of bounces).
   */
  public static String MAIL_SENDER_SETTING = "settings.common.notifications.sender";

  /**
   * <b>settings.common.notifications.subjectPrefix</b>: <br>
   * The subject prefix for the mail-notifications.
   */
  public static String MAIL_SUBJECTPREFIX_SETTING = "settings.common.notifications.subjectPrefix";

  /** The email receiver of the errors. */
  private static final String MAIL_RECEIVER = Settings.get(MAIL_RECEIVER_SETTING);
  /** The email sender of the errors. */
  private static final String MAIL_SENDER = Settings.get(MAIL_SENDER_SETTING);

  /** Subject prefix for notifications by mail. */
  private static String SUBJECT_PREFIX = Settings.get(MAIL_SUBJECTPREFIX_SETTING);

  /**
   * Sends a notification including an exception.
   *
   * @param message The message to notify about.
   * @param eventType The type of notification
   * @param e The exception to notify about.
   */
  public void notify(String message, NotificationType eventType, Throwable e) {
    if (message == null) {
      message = "";
    }
    sendMailNotifications(message, eventType, e);
  }

  /**
   * Send mailNotications.
   *
   * @param message The message body itself
   * @param eventType Type of notification
   * @param e An exception (can be null)
   */
  private void sendMailNotifications(String message, NotificationType eventType, Throwable e) {
    String subjectPrefix = SUBJECT_PREFIX + "-" + eventType + ": ";

    // Subject is a specified string + first line of error message
    String subject = subjectPrefix + message.split("\n")[0];

    // Body consists of four parts.
    StringBuffer body = new StringBuffer();

    // 1: The host of the message
    body.append("Host: " + SystemUtils.getLocalHostName() + "\n");
    body.append("Date: " + new Date().toString() + "\n");

    // 2: The origin of the message, found by inspecting stack trace
    for (StackTraceElement elm : Thread.currentThread().getStackTrace()) {
      if (!elm.toString().startsWith(getClass().getName())
          && !elm.toString().startsWith(Notifications.class.getName())
          && !elm.toString().startsWith(Thread.class.getName())) {
        body.append(elm.toString() + "\n");
        break;
      }
    }

    // 3: The given message
    body.append(message + "\n");

    // 4: Optionally the exception
    if (e != null) {
      body.append(ExceptionUtils.getStackTrace(e));
    }

    try {
      // Send the mail
      EMailUtils.sendEmail(MAIL_RECEIVER, MAIL_SENDER, subject, body.toString());

      // Log as error

      log.error("Mailing {}{}", subjectPrefix, message, e);
    } catch (Exception e1) {
      // On trouble: Log and print it to system out, it's the best we can
      // do!

      String msg =
          "Could not send email on "
              + eventType.toString().toLowerCase()
              + " notification:\n"
              + body.toString()
              + "\n";
      System.err.println(msg);
      e1.printStackTrace(System.err);
      log.error(msg, e1);
    }
  }
}
Ejemplo n.º 24
0
 public static boolean isRunEnabled() {
   return Settings.get(Settings.SETTING_RUN_ENABLED) == 1;
 }
Ejemplo n.º 25
0
  protected MainController(Context context, EventHandler eventHandler) {
    Util.Assert(sInstance == null, "non-null instance");
    sInstance = this;
    mContext = context;
    mAppPackageName = mContext.getPackageName();
    mEventHandler = eventHandler;

    mAppPoller = new AppPoller(context);
    mAppPoller.setListener(mAppPollerListener);

    mCanAutoDisplayLink = true;

    mCanDisplay = true;

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    if (Constant.PROFILE_FPS) {
      mTextView = new TextView(mContext);
      mTextView.setTextColor(0xff00ffff);
      mTextView.setTextSize(32.0f);
      mWindowManagerParams.gravity = Gravity.TOP | Gravity.LEFT;
      mWindowManagerParams.x = 500;
      mWindowManagerParams.y = 16;
      mWindowManagerParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
      mWindowManagerParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
      mWindowManagerParams.type = WindowManager.LayoutParams.TYPE_PHONE;
      mWindowManagerParams.flags =
          WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
              | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
      mWindowManagerParams.format = PixelFormat.TRANSPARENT;
      mWindowManagerParams.setTitle("LinkBubble: Debug Text");
      mWindowManager.addView(mTextView, mWindowManagerParams);
    }

    mUpdateScheduled = false;
    mChoreographer = Choreographer.getInstance();
    mCanvasView = new CanvasView(mContext);

    MainApplication app = (MainApplication) mContext.getApplicationContext();
    Bus bus = app.getBus();
    bus.register(this);

    updateIncognitoMode(Settings.get().isIncognitoMode());

    LayoutInflater inflater = LayoutInflater.from(mContext);

    mBubbleDraggable = (BubbleDraggable) inflater.inflate(R.layout.view_bubble_draggable, null);
    Point bubbleRestingPoint = Settings.get().getBubbleRestingPoint();
    int fromX = Settings.get().getBubbleStartingX(bubbleRestingPoint);
    mBubbleDraggable.configure(
        fromX,
        bubbleRestingPoint.y,
        bubbleRestingPoint.x,
        bubbleRestingPoint.y,
        Constant.BUBBLE_SLIDE_ON_SCREEN_TIME,
        mCanvasView);

    mBubbleDraggable.setOnUpdateListener(
        new BubbleDraggable.OnUpdateListener() {
          @Override
          public void onUpdate(Draggable draggable, float dt) {
            if (!draggable.isDragging()) {
              mBubbleFlowDraggable.syncWithBubble(draggable);
            }
          }
        });

    mBubbleFlowDraggable = (BubbleFlowDraggable) inflater.inflate(R.layout.view_bubble_flow, null);
    mBubbleFlowDraggable.configure(null);
    mBubbleFlowDraggable.collapse(0, null);
    mBubbleFlowDraggable.setBubbleDraggable(mBubbleDraggable);
    mBubbleFlowDraggable.setVisibility(View.GONE);

    mBubbleDraggable.setBubbleFlowDraggable(mBubbleFlowDraggable);
  }
Ejemplo n.º 26
0
  public TabView openUrl(
      final String urlAsString,
      long urlLoadStartTime,
      final boolean setAsCurrentTab,
      String openedFromAppName) {

    Analytics.trackOpenUrl(openedFromAppName);

    if (wasUrlRecentlyLoaded(urlAsString, urlLoadStartTime)
        && !urlAsString.equals(mContext.getString(R.string.empty_bubble_page))) {
      Toast.makeText(mContext, R.string.duplicate_link_will_not_be_loaded, Toast.LENGTH_SHORT)
          .show();
      return null;
    }

    URL url;
    try {
      url = new URL(urlAsString);
    } catch (MalformedURLException e) { // If this is not a valid scheme, back out. #271
      Toast.makeText(mContext, mContext.getString(R.string.unsupported_scheme), Toast.LENGTH_SHORT)
          .show();
      if (getActiveTabCount() == 0 && Prompt.isShowing() == false) {
        finish();
      }
      return null;
    }

    if (Settings.get().redirectUrlToBrowser(url)) {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setData(Uri.parse(urlAsString));
      intent.setFlags(
          Intent.FLAG_ACTIVITY_NEW_TASK
              | Intent.FLAG_ACTIVITY_CLEAR_TOP
              | Intent.FLAG_ACTIVITY_SINGLE_TOP);
      if (MainApplication.openInBrowser(mContext, intent, false)) {
        if (getActiveTabCount() == 0 && Prompt.isShowing() == false) {
          finish();
        }

        String title =
            String.format(
                mContext.getString(R.string.link_redirected),
                Settings.get().getDefaultBrowserLabel());
        MainApplication.saveUrlInHistory(mContext, null, urlAsString, title);
        return null;
      }
    }

    boolean showAppPicker = false;

    PackageManager packageManager = mContext.getPackageManager();
    final List<ResolveInfo> resolveInfos =
        Settings.get().getAppsThatHandleUrl(url.toString(), packageManager);
    ResolveInfo defaultAppResolveInfo = Settings.get().getDefaultAppForUrl(url, resolveInfos);
    if (resolveInfos != null && resolveInfos.size() > 0) {
      if (defaultAppResolveInfo != null) {
        if (handleResolveInfo(defaultAppResolveInfo, urlAsString, urlLoadStartTime)) {
          return null;
        }
      } else if (resolveInfos.size() == 1) {
        if (handleResolveInfo(resolveInfos.get(0), urlAsString, urlLoadStartTime)) {
          return null;
        }
      } else {
        // If LinkBubble is a valid resolve target, do not show other options to open the content.
        for (ResolveInfo info : resolveInfos) {
          if (info.activityInfo.packageName.startsWith("com.linkbubble.playstore")) {
            showAppPicker = false;
            break;
          } else {
            showAppPicker = true;
          }
        }
      }
    }

    boolean openedFromItself = false;
    if (null != openedFromAppName
        && (openedFromAppName.equals(Analytics.OPENED_URL_FROM_NEW_TAB)
            || openedFromAppName.equals(Analytics.OPENED_URL_FROM_HISTORY))) {
      showAppPicker = true;
      openedFromItself = true;
    }
    mCanAutoDisplayLink = true;
    final TabView result =
        openUrlInTab(urlAsString, urlLoadStartTime, setAsCurrentTab, showAppPicker);

    // Show app picker after creating the tab to load so that we have the instance to close if
    // redirecting to an app, re #292.
    if (!openedFromItself
        && showAppPicker
        && MainApplication.sShowingAppPickerDialog == false
        && 0 != resolveInfos.size()) {
      AlertDialog dialog =
          ActionItem.getActionItemPickerAlert(
              mContext,
              resolveInfos,
              R.string.pick_default_app,
              new ActionItem.OnActionItemDefaultSelectedListener() {
                @Override
                public void onSelected(ActionItem actionItem, boolean always) {
                  boolean loaded = false;
                  for (ResolveInfo resolveInfo : resolveInfos) {
                    if (resolveInfo.activityInfo.packageName.equals(actionItem.mPackageName)
                        && resolveInfo.activityInfo.name.equals(actionItem.mActivityClassName)) {
                      if (always) {
                        Settings.get().setDefaultApp(urlAsString, resolveInfo);
                      }

                      // Jump out of the loop and load directly via a BubbleView below
                      if (resolveInfo.activityInfo.packageName.equals(mAppPackageName)) {
                        break;
                      }

                      loaded =
                          MainApplication.loadIntent(
                              mContext,
                              actionItem.mPackageName,
                              actionItem.mActivityClassName,
                              urlAsString,
                              -1,
                              true);
                      break;
                    }
                  }

                  if (loaded) {
                    Settings.get().addRedirectToApp(urlAsString);
                    closeTab(result, contentViewShowing(), false);
                    if (getActiveTabCount() == 0 && Prompt.isShowing() == false) {
                      finish();
                    }
                    // L_WATCH: L currently lacks getRecentTasks(), so minimize here
                    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                      MainController.get().switchToBubbleView();
                    }
                  }
                }
              });

      dialog.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
              MainApplication.sShowingAppPickerDialog = false;
            }
          });

      dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
      Util.showThemedDialog(dialog);
      MainApplication.sShowingAppPickerDialog = true;
    }

    return result;
  }
 public static int get(Settings settings, int id) {
   return settings.get(id);
 }
Ejemplo n.º 28
0
 @Override
 public void execute() {
   if (GlobalConstant.WIELDED_ID != -1
       && Settings.get(300) == 1000
       && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) {
     if (Players.getLocal().getAppearance()[GlobalConstant.WEAPON] != GlobalConstant.EXCALIBUR
         && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.INVENTORY.open())) {
       final Item excalibur = Inventory.getItem(GlobalConstant.EXCALIBUR);
       if (excalibur != null) {
         excalibur.getWidgetChild().click(true);
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return Players.getLocal().getAppearance()[GlobalConstant.WEAPON]
                     == GlobalConstant.EXCALIBUR;
               }
             },
             (long) Random.nextInt(750, 1500));
       }
     } else if (Tabs.getCurrent().equals(Tabs.ATTACK) || Tabs.ATTACK.open()) {
       final WidgetChild bar = Widgets.get(884, 4);
       if (bar.validate()) {
         bar.click(true);
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return Settings.get(300) != 1000;
               }
             },
             (long) Random.nextInt(400, 800));
       }
     }
     return;
   }
   if (GlobalConstant.KEEP_ALIVE
       && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10) {
     if (Checks.isOutside()) {
       if (Players.getLocal().getAnimation() == -1) {
         final WidgetChild[] widgets = {Widgets.get(750, 2), Widgets.get(750, 6)};
         if (widgets[0].validate() && widgets[1].validate()) {
           if (widgets[Random.nextInt(0, widgets.length)].interact("Rest"))
             PauseHandler.pause(
                 new PauseHandler.Condition() {
                   @Override
                   public boolean validate() {
                     return Players.getLocal().getAnimation() != -1;
                   }
                 },
                 (long) Random.nextInt(750, 1500));
         }
       }
       Task.sleep(400, 800);
     } else {
       if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 5) {
         if (Traverse.walk(GlobalConstant.TILE_BANK)) {
           PauseHandler.pause(
               new PauseHandler.Condition() {
                 @Override
                 public boolean validate() {
                   return Walking.getDestination() == null
                       || Calculations.distanceTo(Walking.getDestination()) < 8;
                 }
               },
               (long) Random.nextInt(500, 1000));
         }
       }
     }
   } else {
     if (Checks.isOutside()) {
       final SceneObject ladder = SceneEntities.getNearest(GlobalConstant.ROPE_DOWN_ID);
       if (ladder != null && ladder.interact("Climb"))
         PauseHandler.pause(
             new PauseHandler.Condition() {
               @Override
               public boolean validate() {
                 return !Checks.isOutside();
               }
             },
             750l);
       else if (ladder != null && Calculations.distanceTo(ladder) > 5)
         PauseHandler.walk(ladder, (long) Random.nextInt(250, 750));
     } else if (inCombat() || Players.getLocal().isInCombat()) {
       final Tile rockTile = GlobalConstant.TILE_ROCKS[Checks.isGold()][Mine.getCurrent()];
       if (true
           || Calculations.distanceTo(GlobalConstant.TILE_BANK)
               < Calculations.distanceTo(rockTile)) {
         if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 6
             && Traverse.walk(GlobalConstant.TILE_BANK)) {
           PauseHandler.pause(
               new PauseHandler.Condition() {
                 @Override
                 public boolean validate() {
                   return Walking.getDestination() == null
                       || Calculations.distanceTo(Walking.getDestination()) < 8;
                 }
               },
               (long) Random.nextInt(200, 500));
         }
       } else {
         final SceneObject rock = SceneEntities.getAt(rockTile);
         final NPC npc =
             NPCs.getNearest(
                 new Filter<NPC>() {
                   @Override
                   public boolean accept(final NPC npc) {
                     return npc.getInteracting() != null
                         && npc.getInteracting().equals(Players.getLocal())
                         && Arrays.binarySearch(GlobalConstant.LRC_NPC, npc.getId()) >= 0;
                   }
                 });
         if (rock != null && npc != null) {
           final Tile hardcodedSafe =
               GlobalConstant.MINE_GOLD && Mine.getCurrent() == 0
                   ? GlobalConstant.GOLD_SAFE_SPOT
                   : !GlobalConstant.MINE_GOLD && Mine.getCurrent() == 2
                       ? GlobalConstant.COAL_SAFE_SPOT
                       : null;
           if (hardcodedSafe != null) {
             hardcodedSafe
                 .randomize(0, Mine.getCurrent() == 2 ? 4 : 1, 1, Mine.getCurrent() == 0 ? -4 : 1)
                 .clickOnMap();
           } else {
             final Tile[] bounds = rock.getArea().getBoundingTiles();
             Arrays.sort(
                 bounds,
                 new Comparator<Tile>() {
                   @Override
                   public int compare(final Tile t1, final Tile t2) {
                     return Calculations.distance(t1, npc.getLocation())
                             < Calculations.distance(t2, npc.getLocation())
                         ? 1
                         : -1;
                   }
                 });
             final int[][] flags = Walking.getCollisionFlags(Game.getPlane());
             final Tile colOffset =
                 Walking.getCollisionOffset(Game.getPlane())
                     .derive(Game.getBaseX(), Game.getBaseY());
             Tile toWalk = null;
             for (final int[] offset : new int[][] {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}) {
               final Tile derive = bounds[0].derive(offset[0], offset[1]);
               if (Nodes.walkable(flags, colOffset, derive)) {
                 if (toWalk == null
                     || Calculations.distance(derive, npc) > Calculations.distance(toWalk, npc))
                   toWalk = derive;
               }
             }
             if (toWalk != null) {
               if (!toWalk.isOnScreen()) Camera.turnTo(toWalk);
               toWalk.interact("Walk here");
             }
           }
           Task.sleep(100, 300);
           final int lp = Checks.getLP();
           final Timer timer = new Timer((long) Random.nextInt(7500, 10000));
           while (Players.getLocal().isInCombat()
               && Checks.getLP() >= lp
               && !Context.get().getScriptHandler().isPaused()
               && timer.isRunning()) Task.sleep(200, 800);
         }
       }
     }
   }
 }
Ejemplo n.º 29
0
  public void deinit(Appendable out, boolean force) throws Exception {
    Settings settings = new Settings(platform.getConfigFile());

    if (!force) {
      Justif justify = new Justif(80, 40);
      StringBuilder sb = new StringBuilder();
      Formatter f = new Formatter(sb);

      try {
        String list = listFiles(platform.getGlobal());
        if (list != null) {
          f.format("In global default environment:%n");
          f.format(list);
        }

        list = listFiles(platform.getLocal());
        if (list != null) {
          f.format("In local default environment:%n");
          f.format(list);
        }

        if (settings.containsKey(JPM_CACHE_GLOBAL)) {
          list = listFiles(IO.getFile(settings.get(JPM_CACHE_GLOBAL)));
          if (list != null) {
            f.format("In global configured environment:%n");
            f.format(list);
          }
        }

        if (settings.containsKey(JPM_CACHE_LOCAL)) {
          list = listFiles(IO.getFile(settings.get(JPM_CACHE_LOCAL)));
          if (list != null) {
            f.format("In local configured environment:%n");
            f.format(list);
          }
        }

        list = listSupportFiles();
        if (list != null) {
          f.format("jpm support files:%n");
          f.format(list);
        }

        f.format("%n%n");

        f.format(
            "All files listed above will be deleted if deinit is run with the force flag set"
                + " (\"jpm deinit -f\" or \"jpm deinit --force\"%n%n");
        f.flush();

        justify.wrap(sb);
        out.append(sb.toString());
      } finally {
        f.close();
      }
    } else { // i.e. if(force)
      int count = 0;
      File[] caches = {platform.getGlobal(), platform.getLocal(), null, null};
      if (settings.containsKey(JPM_CACHE_LOCAL)) {
        caches[2] = IO.getFile(settings.get(JPM_CACHE_LOCAL));
      }
      if (settings.containsKey(JPM_CACHE_GLOBAL)) {
        caches[3] = IO.getFile(settings.get(JPM_CACHE_GLOBAL));
      }
      ArrayList<File> toDelete = new ArrayList<File>();

      for (File cache : caches) {
        if (cache == null || !cache.exists()) {
          continue;
        }
        listFiles(cache, toDelete);
        if (toDelete.size() > count) {
          count = toDelete.size();
          if (!cache.canWrite()) {
            reporter.error(PERMISSION_ERROR + " (" + cache + ")");
            return;
          }
          toDelete.add(cache);
        }
      }
      listSupportFiles(toDelete);

      for (File f : toDelete) {
        if (f.exists() && !f.canWrite()) {
          reporter.error(PERMISSION_ERROR + " (" + f + ")");
        }
      }
      if (reporter.getErrors().size() > 0) {
        return;
      }

      for (File f : toDelete) {
        if (f.exists()) {
          IO.deleteWithException(f);
        }
      }
    }
  }
Ejemplo n.º 30
0
 /**
  * Writes {@code other} into this. If any setting is populated by this and {@code other}, the
  * value and flags from {@code other} will be kept.
  */
 void merge(Settings other) {
   for (int i = 0; i < COUNT; i++) {
     if (!other.isSet(i)) continue;
     set(i, other.flags(i), other.get(i));
   }
 }