Example #1
1
  public static void checkFilterLayout(Solo solo) throws Exception {

    View ScrollBar = solo.getView("seekbar", 0);
    View TableRowOne = solo.getView("tableRow1", 0);
    View TableRowTwo = solo.getView("tableRow2", 0);
    View TableRowThree = solo.getView("tableRow3", 0);
    solo.sleep(3000);
    boolean views =
        ScrollBar.isShown()
            && TableRowOne.isShown()
            && TableRowTwo.isShown()
            && TableRowThree.isShown();
    junit.framework.Assert.assertTrue("views not found.", views);
  }
Example #2
1
 private static void drawToast(View v, Rect vRect) {
   // TODO Auto-generated method stub
   if (mToast != null) {
     View tv = mToast.getView();
     if (tv.getWidth() > 0 && tv.isShown()) {
       if (LOGD_ENABLED) Log.i(LOG_TAG, "==== " + tv.getWidth() + " " + tv.getHeight());
       Bitmap second = Utils.createPngScreenshot(tv, tv.getWidth(), tv.getHeight(), 0);
       if (LOGD_ENABLED)
         Log.d(
             LOG_TAG,
             "====== gravity "
                 + mToast.getGravity()
                 + " x y "
                 + mToast.getXOffset()
                 + " "
                 + mToast.getYOffset()
                 + " "
                 + mToast.getHorizontalMargin()
                 + " "
                 + mToast.getVerticalMargin());
       PointF fromPoint =
           new PointF(
               (v.getWidth() - tv.getWidth()) / 2,
               v.getHeight() - vRect.top - mToast.getYOffset() - tv.getHeight());
       if (LOGD_ENABLED)
         Log.i(LOG_TAG, "======= prepare menu view2  ========" + fromPoint.x + " " + fromPoint.y);
       mCapture = Utils.mixtureBitmap2(mCapture, second, fromPoint, 0, (float) 1.0);
     }
   }
 }
Example #3
0
 public boolean shouldBackExit() {
   if (isHoneycombOrGreater) {
     View fragment = this.findViewById(com.rj.processing.plasmasound.R.id.instsettings);
     View fragment2 = this.findViewById(com.rj.processing.plasmasound.R.id.audiosettings);
     System.out.println("fragment1" + fragment.isShown() + "   fragment2:" + fragment2.isShown());
     if (fragment.isShown() || fragment2.isShown()) {
       System.out.println("Hiding fragments");
       runOnUiThread(
           new Runnable() {
             public void run() {
               hideBoth();
             }
           });
       return false;
     } else {
       return true;
     }
   } else {
     if (frag == sequencer) {
       runTheremin(true, true);
       return false;
     }
     return true;
   }
 }
 public void terminate(View v) {
   if (mCommentLayout.isShown()) {
     hideCommentView();
   } else if (mCompanyLayout.isShown()) {
     hideCompanyView();
   } else {
     scrollToFinishActivity();
   }
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     if (mCommentLayout.isShown()) {
       hideCommentView();
     } else if (mCompanyLayout.isShown()) {
       hideCompanyView();
     } else {
       scrollToFinishActivity();
     }
   }
   return false;
 }
Example #6
0
  private void dumpSubView(View view, Element pElem) {
    if (view == null) {
      final View[] views = this.viewFetcher.getWindowDecorViews();
      view = viewFetcher.getRecentDecorView(views);
    }

    if (!view.isShown()) return;

    Element elem = pElem.addElement(view.getClass().getSimpleName());
    int[] local = new int[2];
    view.getLocationOnScreen(local);
    elem.addAttribute("x", local[0] + "");
    elem.addAttribute("y", local[1] + "");
    elem.addAttribute("w", view.getWidth() + "");
    elem.addAttribute("h", view.getHeight() + "");

    int id = view.getId();
    if (id != -1) elem.addAttribute("id", id + "");

    Matcher match = Pattern.compile("(?<=:id/).*?(?=\\})").matcher(view.toString());
    if (match.find()) elem.addAttribute("resId", match.group());

    if (view instanceof TextView) elem.addAttribute("text", ((TextView) view).getText().toString());

    if (view instanceof ViewGroup) {
      ViewGroup group = (ViewGroup) view;
      for (int i = 0; i < group.getChildCount(); i++) {
        View v = group.getChildAt(i);
        dumpSubView(v, elem);
      }
    }
  }
Example #7
0
  public View[] getViews(String id, boolean scroll, View parent) {
    Context targetContext = instrumentation.getTargetContext();
    String packageName = targetContext.getPackageName();
    int viewId = targetContext.getResources().getIdentifier(id, "id", packageName);
    // Log.i("AAAAAA","id:"+viewId);

    Set<View> uniqueViewsMatchingId = new LinkedHashSet<View>();
    long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout();

    while (SystemClock.uptimeMillis() <= endTime) {
      sleeper.sleep();
      List<View> list = null;
      if (parent == null) list = viewFetcher.getAllViews(true);
      else list = viewFetcher.getViews(parent, true);

      // LogEx.i("list in getViews: "+Arrays.deepToString(list.toArray()));

      for (View view : list) {
        Integer idOfView = Integer.valueOf(view.getId());
        if (idOfView.equals(viewId)
            && view.isShown()
            && view.getWidth() != 0
            && view.getHeight() != 0) {
          uniqueViewsMatchingId.add(view);
        }
      }
      if (scroll && scroller.scrollDown()) continue;
      break;
    }

    return uniqueViewsMatchingId.toArray(new View[0]);
  }
Example #8
0
  /**
   * Waits for a given view.
   *
   * @param view the view to wait for
   * @param timeout the amount of time in milliseconds to wait
   * @param scroll {@code true} if scrolling should be performed
   * @param checkIsShown {@code true} if view.isShown() should be used
   * @return {@code true} if view is shown and {@code false} if it is not shown before the timeout
   */
  public View waitForView(View view, int timeout, boolean scroll, boolean checkIsShown) {
    long endTime = SystemClock.uptimeMillis() + timeout;
    int retry = 0;

    if (view == null) return null;

    while (SystemClock.uptimeMillis() < endTime) {

      final boolean foundAnyMatchingView = searcher.searchFor(view);

      if (checkIsShown && foundAnyMatchingView && !view.isShown()) {
        sleeper.sleepMini();
        retry++;

        View identicalView = viewFetcher.getIdenticalView(view);
        if (identicalView != null && !view.equals(identicalView)) {
          view = identicalView;
        }

        if (retry > 5) {
          return view;
        }
        continue;
      }

      if (foundAnyMatchingView) {
        return view;
      }

      if (scroll) scroller.scrollDown();

      sleeper.sleep();
    }
    return view;
  }
 /** @Method: clearTopWindow @Description: 移除最顶层view */
 public void clearTopWindow(View view) {
   if (view != null && view.isShown()) {
     WindowManager windowManager =
         (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE);
     windowManager.removeView(view);
   }
 }
    @Override
    public void run() {
      // TODO Auto-generated method stub
      super.run();
      while (true && !isInterrupted()) {
        if (!view.isShown() && flag == true) {

          view.post(
              new Runnable() {

                @Override
                public void run() {
                  // TODO Auto-generated method stub
                  view.setVisibility(View.VISIBLE);
                  view.layout(0, 0, 1, 1);
                  // CommonUtil.tolog("post");
                  flag = true;
                }
              });
        } else {
          flag = true;
        }

        try {
          Thread.sleep(100);
          // CommonUtil.tolog("Thread sleep");
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
Example #11
0
 private static boolean isTouchEventHandled(final View view, final MotionEvent event) {
   if (view instanceof RightPaneBackgroundView) return false;
   if (!(view instanceof ViewGroup)) return true;
   final MotionEvent ev = MotionEvent.obtain(event);
   final float xf = ev.getX();
   final float yf = ev.getY();
   final float scrolledXFloat = xf + view.getScrollX();
   final float scrolledYFloat = yf + view.getScrollY();
   final Rect frame = new Rect();
   final int scrolledXInt = (int) scrolledXFloat;
   final int scrolledYInt = (int) scrolledYFloat;
   final int count = ((ViewGroup) view).getChildCount();
   for (int i = count - 1; i >= 0; i--) {
     final View child = ((ViewGroup) view).getChildAt(i);
     if (child.isShown() || child.getAnimation() != null) {
       child.getHitRect(frame);
       if (frame.contains(scrolledXInt, scrolledYInt)) {
         // offset the event to the view's coordinate system
         final float xc = scrolledXFloat - child.getLeft();
         final float yc = scrolledYFloat - child.getTop();
         ev.setLocation(xc, yc);
         if (isTouchEventHandled(child, ev)) return true;
       }
     }
   }
   return false;
 }
Example #12
0
 private void hideLayoutNote() {
   if (layoutNote != null && layoutNote.isShown()) {
     if (listMessages.size() > 0) {
       layoutNote.setVisibility(View.GONE);
     }
   }
 }
 @Override
 public boolean onBackPressed() {
   if (mFooter.isShown()) {
     if (!mUpdatedElements.isEmpty() || !mCherryElements.isEmpty()) {
       ConfirmDialogFragment confirmDialogFragment =
           new ConfirmDialogFragment() {
             @Override
             public void onClick(boolean positive) {
               if (positive) {
                 dismiss();
                 getSherlockActivity().getSupportFragmentManager().popBackStack();
               } else {
                 dismiss();
               }
             }
           };
       // Preparing arguments
       Bundle args =
           ConfirmDialogFragment.prepareArguments(
               R.string.pay_attention,
               R.string.sure_to_continue_without_save,
               R.string.yes_continue,
               R.string.cancel);
       ConfirmDialogFragment.show(getSherlockActivity(), confirmDialogFragment, args);
       return true;
     }
     setEditMode(false);
     return true;
   } else {
     return false;
   }
 }
Example #14
0
 /**
  * checks if the view is visible with the input id
  *
  * @param arguments id of the view
  * @return response with the status of the command
  */
 private CommandResponse isViewVisibleByViewId(String[] arguments) {
   CommandResponse result = new CommandResponse();
   String command = "the command isViewVisible";
   try {
     int viewId = Integer.parseInt(arguments[0]);
     command += "(" + viewId + ")";
     View view = this.solo.getView(viewId);
     if (view != null) {
       if (view.isShown()) {
         result.setResponse("view with ID: " + viewId + " is visible");
         result.setSucceeded(true);
       } else {
         result.setResponse("view with ID: " + viewId + " is not visible");
         result.setSucceeded(true);
       }
     } else {
       result.setResponse("view with ID: " + viewId + " is not found ");
       result.setSucceeded(false);
     }
   } catch (Throwable e) {
     result.setResponse(command + "failed due to " + e.getMessage());
     result.setSucceeded(false);
     Log.d(TAG, result.getResponse());
   }
   return result;
 }
 private void g(View view) {
   if (view != null && view.getVisibility() == 0) {
     if (view.isShown()) {
       view.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.disappear));
     }
     view.setVisibility(8);
   }
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   outState.putBoolean(FOOTER_VISIBLE, mFooter != null ? mFooter.isShown() : false);
   outState.putParcelableArrayList(OPTION_ITEMS_LIST, mOptionItems);
   outState.putStringArrayList(UPDATED_ITEMS, new ArrayList<String>(mUpdatedElements));
   outState.putStringArrayList(CHERRY_ITEMS, new ArrayList<String>(mCherryElements));
   super.onSaveInstanceState(outState);
 }
Example #17
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && mCommentLayout.isShown()) {
     mCommentLayout.setVisibility(View.VISIBLE);
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
 private static float maxVisibleQuiescentAlpha(float max, View v) {
   if (v.isShown()) {
     try {
       return Math.max(max, (Float) XposedHelpers.callMethod(v, "getQuiescentAlpha"));
     } catch (ClassCastException e) {
     }
   }
   return max;
 }
 public void showLoadView(boolean isShow) {
   if (isShow) {
     mLoadView.setVisibility(View.VISIBLE);
   } else {
     if (mLoadView.isShown()) {
       mLoadView.startAnimation(mAlphaHideTransformation);
       mLoadView.setVisibility(View.GONE);
     }
   }
 }
Example #20
0
  /**
   * Utility method for clicking on views exposing testing scenarios that are not possible when
   * using the actual app.
   *
   * @throws RuntimeException if the view is disabled or if the view or any of its parents are not
   *     visible.
   * @return Return value of the underlying click operation.
   */
  public boolean checkedPerformClick() {
    if (!realView.isShown()) {
      throw new RuntimeException("View is not visible and cannot be clicked");
    }
    if (!realView.isEnabled()) {
      throw new RuntimeException("View is not enabled and cannot be clicked");
    }

    AccessibilityUtil.checkViewIfCheckingEnabled(realView);
    return realView.performClick();
  }
 public void onGlobalLayout() {
   if (isShowing()) {
     View view = mAnchorView;
     if (view == null || !view.isShown()) {
       dismiss();
     } else if (isShowing()) {
       mPopup.show();
       return;
     }
   }
 }
  public static boolean isVisible(Object v) {
    if (!(v instanceof View)) {
      return true;
    }
    View view = (View) v;

    if (view.getHeight() == 0 || view.getWidth() == 0) {
      return false;
    }

    return view.isShown() && viewFetcher.isViewSufficientlyShown(view);
  }
Example #23
0
 /**
  * clicks on a view
  *
  * @param view the view to click
  * @throws Exception
  */
 private void clickOnView(View view, boolean immediatly, boolean longClick) throws Exception {
   if (view.isShown()) {
     if (longClick) {
       this.solo.clickLongOnView(view);
     } else {
       this.solo.clickOnView(view, immediatly);
     }
   } else {
     throw new Exception(
         "clickOnView FAILED view: " + view.getClass().getSimpleName() + " is not shown");
   }
 }
Example #24
0
 @Override
 public void onGlobalLayout() {
   if (isShowing()) {
     final View anchor = mAnchorView;
     if (anchor == null || !anchor.isShown()) {
       dismiss();
     } else if (isShowing()) {
       // Recompute window size and position
       mPopup.show();
     }
   }
 }
 @Override
 public void onClick() {
   if (view != null) {
     animateShowing();
     if (view.isShown()) {
       hideRecycler();
       EventTrackerHelper.sendEvent("FloatingHorizontalLayout", "OnClick", "Hide");
     } else {
       showRecycler();
       EventTrackerHelper.sendEvent("FloatingHorizontalLayout", "onClick", "Show");
     }
   }
 }
Example #26
0
 private static void drawMenu(View v, Rect vRect) {
   // TODO Auto-generated method stub
   if (mMenu != null) {
     if (Utils.isPlatformICSAndAbove()) {
       if (false) {
         View pv =
             InvokeMenuBuilder.getmPresenters(
                 mMenu, 0, (ViewGroup) mActivity.getWindow().getDecorView());
         if (pv.getWidth() > 0 && pv.isShown()) {
           if (LOGD_ENABLED)
             Log.d(LOG_TAG, "======= prepare menu view2  ========" + pv.getHeight());
           Bitmap second = Utils.createPngScreenshot2(pv, pv.getWidth(), pv.getHeight(), 0);
           PointF fromPoint = new PointF(0, v.getHeight() - vRect.top - pv.getHeight());
           if (LOGD_ENABLED)
             Log.d(
                 LOG_TAG,
                 "======= prepare menu view2  ========" + fromPoint.x + " " + fromPoint.y);
           mCapture = Utils.mixtureBitmap2(mCapture, second, fromPoint, 0, (float) 0.9);
           Utils.saveScreenshot(mActivity, "/sdcard/menuics" + pos + ".jpg", mCapture, true);
           pos++;
         }
       }
     } else {
       View mv = InvokeMenuBuilder.getMenuView(mMenu, 0, (ViewGroup) v);
       if (mv.getWidth() > 0 && mv.isShown()) {
         if (LOGD_ENABLED) Log.d(LOG_TAG, "======= prepare menu view2  ========" + mv.getHeight());
         Bitmap second = Utils.createPngScreenshot2(mv, mv.getWidth(), mv.getHeight(), 0);
         PointF fromPoint = new PointF(0, v.getHeight() - vRect.top - mv.getHeight());
         if (LOGD_ENABLED)
           Log.d(
               LOG_TAG, "======= prepare menu view2  ========" + fromPoint.x + " " + fromPoint.y);
         mCapture = Utils.mixtureBitmap2(mCapture, second, fromPoint, 0, (float) 0.9);
       }
     }
   }
 }
Example #27
0
  public View getViewIdx(int index, String id) {
    View view = null;
    int i = 0;

    while (view == null && (i++) < 10) {
      // LogEx.i("try get by id "+id+": "+i);

      sleep(2000);
      view = getter.getView(getId(id), index);
    }

    if (view != null && view.isShown()) return view;

    return null;
  }
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   paramsF = mParams;
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       initialX = paramsF.x;
       initialY = paramsF.y;
       initialTouchX = event.getRawX();
       initialTouchY = event.getRawY();
       animateShowing();
       break;
     case MotionEvent.ACTION_UP:
       if (AppHelper.isEdged(context)) {
         moveToEdge();
       } else {
         if (AppHelper.isSavePositionEnabled(context)) {
           AppHelper.savePosition(context, paramsF.y, paramsF.x);
         }
       }
       animateHidden();
       break;
     case MotionEvent.ACTION_MOVE:
       if (paramsF.y < 0) {
         paramsF.y = 0;
       }
       if (paramsF.y >= 0 || paramsF.y <= (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.x = initialX + (int) (event.getRawX() - initialTouchX);
         paramsF.y = initialY + (int) (event.getRawY() - initialTouchY);
         try {
           windowManager.updateViewLayout(FloatingHorizontalLayout.this.floatingImage, paramsF);
           if (view.isShown()) {
             showRecycler();
           }
         } catch (Exception e) {
           e.printStackTrace();
         }
         animateShowing();
       } else if (paramsF.y > (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.y = (szWindow.y - AppHelper.getFinalSize(context));
       }
       break;
   }
   return false;
 }
Example #29
0
  public View[] getViews(
      Method method, String value, View parent, boolean scroll, long timeout, View scroller) {
    if (timeout <= 0) timeout = Timeout.getSmallTimeout();
    long endTime = SystemClock.uptimeMillis() + timeout;

    Set<View> uniqueViewsMatchingId = new LinkedHashSet<View>();
    Pattern targetTextPattern = null;
    int targetId = 0;
    if (Method.REGEX_TEXT == method) targetTextPattern = Pattern.compile(value);
    else if (Method.ID == method) {
      Context targetContext = instrumentation.getTargetContext();
      String packageName = targetContext.getPackageName();
      targetId = targetContext.getResources().getIdentifier(value, "id", packageName);
    }
    while (SystemClock.uptimeMillis() <= endTime) {
      sleeper.sleep();
      List<View> list = null;
      if (parent == null) list = viewFetcher.getAllViews(true);
      else list = viewFetcher.getViews(parent, true);

      for (View view : list) {
        if (!view.isShown() || view.getWidth() == 0 || view.getHeight() == 0) continue;

        if (method == Method.REGEX_TEXT
            && (view instanceof TextView)
            && targetTextPattern.matcher(((TextView) view).getText()).find())
          uniqueViewsMatchingId.add(view);
        else if (method == Method.PLAIN_TEXT
            && (view instanceof TextView)
            && ((TextView) view).getText().toString().contains(value))
          uniqueViewsMatchingId.add(view);
        else if (method == Method.CLASS && view.getClass().getSimpleName().matches(value))
          uniqueViewsMatchingId.add(view);
        else if (method == Method.ID && view.getId() == targetId) uniqueViewsMatchingId.add(view);
      }

      if (scroll && scrollEx(Scroller.DOWN, false, scroller)) continue;

      break;
    }

    return uniqueViewsMatchingId.toArray(new View[0]);
  }
Example #30
-1
  public View[] getViews(View parent, String text, boolean scroll) {
    text = ".*" + text + ".*";

    Set<View> uniqueViewsMatchingId = new LinkedHashSet<View>();
    long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout();

    while (SystemClock.uptimeMillis() <= endTime) {
      sleeper.sleep();
      List<View> list = null;
      if (parent == null) list = viewFetcher.getAllViews(true);
      else list = viewFetcher.getViews(parent, true);

      for (View view : list) {
        if ((view instanceof TextView)
            && view.isShown()
            && ((TextView) view).getText().toString().matches(text)
            && view.getWidth() != 0
            && view.getHeight() != 0) {
          uniqueViewsMatchingId.add(view);
        }
      }
      if (scroll && scroller.scrollDown()) continue;

      break;
    }

    return uniqueViewsMatchingId.toArray(new View[0]);
  }