Esempio n. 1
0
  @Test
  public void shouldNotBeFocusableByDefault() throws Exception {
    assertFalse(view.isFocusable());

    view.setFocusable(true);
    assertTrue(view.isFocusable());
  }
Esempio n. 2
0
  @Test
  public void testFocusable() {
    assertFalse(view.isFocusable());

    view.setFocusable(true);
    assertTrue(view.isFocusable());

    view.setFocusable(false);
    assertFalse(view.isFocusable());
  }
Esempio n. 3
0
 public View a(int paramInt1, int paramInt2) {
   View localView2 = null;
   View localView1 = null;
   int i;
   if (paramInt2 == -1) {
     i = this.f.size();
     paramInt2 = 0;
     if (paramInt2 < i) {
       localView2 = (View) this.f.get(paramInt2);
       if (localView2.isFocusable()) {
         if (this.e.d(localView2) > paramInt1) {}
         for (int k = 1; ; k = 0) {
           if (k != StaggeredGridLayoutManager.b(this.e)) {
             break label92;
           }
           paramInt2 += 1;
           localView1 = localView2;
           break;
         }
       }
     }
     label92:
     return localView1;
   }
   paramInt2 = this.f.size() - 1;
   localView1 = localView2;
   if (paramInt2 >= 0) {
     localView2 = (View) this.f.get(paramInt2);
     if (localView2.isFocusable()) {
       if (this.e.d(localView2) > paramInt1) {
         i = 1;
         label149:
         if (StaggeredGridLayoutManager.b(this.e)) {
           break label184;
         }
       }
       label184:
       for (int j = 1; ; j = 0) {
         if (i != j) {
           break label190;
         }
         paramInt2 -= 1;
         localView1 = localView2;
         break;
         i = 0;
         break label149;
       }
     }
   }
   label190:
   return localView1;
 }
Esempio n. 4
0
  @Test
  public void testFocusableWhenLoadedFromXml() {
    LinearLayout root = new LinearLayout(null);
    ShadowView.inflate(new Activity(), R.layout.views, root);

    View defaultView = root.findViewById(R.id.default_view);
    assertFalse(defaultView.isFocusable());

    View focusableFalseView = root.findViewById(R.id.focusable_false_view);
    assertFalse(focusableFalseView.isFocusable());

    View focusableTrueView = root.findViewById(R.id.focusable_true_view);
    assertTrue(focusableTrueView.isFocusable());
  }
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   /*Log.i(TAG, "MyWebView.MyOnTouchListener: isFocusable = " +
   ((MyWebView)OffscreenWebView.this.getView()).isFocusable() +
   ", hasFocus = " + ((MyWebView)OffscreenWebView.this.getView()).hasFocus() +
   " Subview: isFocusable = " + v.isFocusable() + ", isFocusableInTouchMode = " + v.isFocusableInTouchMode() +
   ", hasFocus = " + v.hasFocus());*/
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
     case MotionEvent.ACTION_UP:
       if (v.isFocusable()) {
         if (!v.hasFocus()) {
           Log.i(
               TAG,
               "MyWebView.MyOnTouchListener [" + event.getAction() + "]: requesting focus.");
           // v.requestFocusFromTouch();
           v.requestFocus();
         } else {
           Log.i(
               TAG,
               "MyWebView.MyOnTouchListener [" + event.getAction() + "]: already has focus.");
         }
       } else {
         Log.i(
             TAG,
             "MyWebView.MyOnTouchListener[" + event.getAction() + "]: not focusable item.");
       }
       break;
   }
   return false;
 }
 // originally:
 // http://stackoverflow.com/questions/5418510/disable-the-touch-events-for-all-the-views
 // modified for the needs here
 public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
   int childCount = viewGroup.getChildCount();
   for (int i = 0; i < childCount; i++) {
     View view = viewGroup.getChildAt(i);
     if (view.isFocusable()) view.setEnabled(enabled);
     if (view instanceof ViewGroup) {
       enableDisableViewGroup((ViewGroup) view, enabled);
     } else if (view instanceof ListView) {
       if (view.isFocusable()) view.setEnabled(enabled);
       ListView listView = (ListView) view;
       int listChildCount = listView.getChildCount();
       for (int j = 0; j < listChildCount; j++) {
         if (view.isFocusable()) listView.getChildAt(j).setEnabled(false);
       }
     }
   }
 }
Esempio n. 7
0
  /**
   * Updates the selection rectangle and attempts to shift focus away from the provided view. Clears
   * active TTS.
   *
   * @param view
   */
  private void announceSelectionLost(View view) {
    // TODO(alanv): Add an additional TYPE_VIEW_HOVER_OFF event type that
    // fires a KickBack vibration and (probably) clears active TalkBack
    // utterances.

    if (mSpeechAvailable) {
      mTTS.speak("", TextToSpeech.QUEUE_FLUSH, null);
    }

    if (mVibrator != null) {
      if (view.isFocusable()) {
        mVibrator.vibrate(mFocusLostFocusablePattern, -1);
      } else {
        mVibrator.vibrate(mFocusLostPattern, -1);
      }
    }

    mSelectedRect.setEmpty();
  }
Esempio n. 8
0
 private static String m91a(View view) {
   char c = 'F';
   char c2 = '.';
   StringBuilder stringBuilder = new StringBuilder(128);
   stringBuilder.append(view.getClass().getName());
   stringBuilder.append('{');
   stringBuilder.append(Integer.toHexString(System.identityHashCode(view)));
   stringBuilder.append(' ');
   switch (view.getVisibility()) {
     case 0:
       stringBuilder.append('V');
       break;
     case 4:
       stringBuilder.append('I');
       break;
     case 8:
       stringBuilder.append('G');
       break;
     default:
       stringBuilder.append('.');
       break;
   }
   stringBuilder.append(view.isFocusable() ? 'F' : '.');
   stringBuilder.append(view.isEnabled() ? 'E' : '.');
   stringBuilder.append(view.willNotDraw() ? '.' : 'D');
   stringBuilder.append(view.isHorizontalScrollBarEnabled() ? 'H' : '.');
   stringBuilder.append(view.isVerticalScrollBarEnabled() ? 'V' : '.');
   stringBuilder.append(view.isClickable() ? 'C' : '.');
   stringBuilder.append(view.isLongClickable() ? 'L' : '.');
   stringBuilder.append(' ');
   if (!view.isFocused()) {
     c = '.';
   }
   stringBuilder.append(c);
   stringBuilder.append(view.isSelected() ? 'S' : '.');
   if (view.isPressed()) {
     c2 = 'P';
   }
   stringBuilder.append(c2);
   stringBuilder.append(' ');
   stringBuilder.append(view.getLeft());
   stringBuilder.append(',');
   stringBuilder.append(view.getTop());
   stringBuilder.append('-');
   stringBuilder.append(view.getRight());
   stringBuilder.append(',');
   stringBuilder.append(view.getBottom());
   int id = view.getId();
   if (id != -1) {
     stringBuilder.append(" #");
     stringBuilder.append(Integer.toHexString(id));
     Resources resources = view.getResources();
     if (!(id == 0 || resources == null)) {
       String str;
       switch (-16777216 & id) {
         case 16777216:
           str = "android";
           break;
         case 2130706432:
           str = "app";
           break;
         default:
           try {
             str = resources.getResourcePackageName(id);
             break;
           } catch (NotFoundException e) {
             break;
           }
       }
       String resourceTypeName = resources.getResourceTypeName(id);
       String resourceEntryName = resources.getResourceEntryName(id);
       stringBuilder.append(" ");
       stringBuilder.append(str);
       stringBuilder.append(":");
       stringBuilder.append(resourceTypeName);
       stringBuilder.append("/");
       stringBuilder.append(resourceEntryName);
     }
   }
   stringBuilder.append("}");
   return stringBuilder.toString();
 }
 private static String a(View paramView)
 {
   char c3 = 'F';
   char c2 = '.';
   StringBuilder localStringBuilder = new StringBuilder(128);
   localStringBuilder.append(paramView.getClass().getName());
   localStringBuilder.append('{');
   localStringBuilder.append(Integer.toHexString(System.identityHashCode(paramView)));
   localStringBuilder.append(' ');
   char c1;
   label118:
   label135:
   label152:
   label169:
   label186:
   label203:
   label220:
   label244:
   label261:
   int n;
   Object localObject;
   switch (paramView.getVisibility())
   {
   default: 
     localStringBuilder.append('.');
     if (paramView.isFocusable())
     {
       c1 = 'F';
       localStringBuilder.append(c1);
       if (!paramView.isEnabled()) {
         break label562;
       }
       c1 = 'E';
       localStringBuilder.append(c1);
       if (!paramView.willNotDraw()) {
         break label568;
       }
       c1 = '.';
       localStringBuilder.append(c1);
       if (!paramView.isHorizontalScrollBarEnabled()) {
         break label574;
       }
       c1 = 'H';
       localStringBuilder.append(c1);
       if (!paramView.isVerticalScrollBarEnabled()) {
         break label580;
       }
       c1 = 'V';
       localStringBuilder.append(c1);
       if (!paramView.isClickable()) {
         break label586;
       }
       c1 = 'C';
       localStringBuilder.append(c1);
       if (!paramView.isLongClickable()) {
         break label592;
       }
       c1 = 'L';
       localStringBuilder.append(c1);
       localStringBuilder.append(' ');
       if (!paramView.isFocused()) {
         break label598;
       }
       c1 = c3;
       localStringBuilder.append(c1);
       if (!paramView.isSelected()) {
         break label604;
       }
       c1 = 'S';
       localStringBuilder.append(c1);
       c1 = c2;
       if (paramView.isPressed()) {
         c1 = 'P';
       }
       localStringBuilder.append(c1);
       localStringBuilder.append(' ');
       localStringBuilder.append(paramView.getLeft());
       localStringBuilder.append(',');
       localStringBuilder.append(paramView.getTop());
       localStringBuilder.append('-');
       localStringBuilder.append(paramView.getRight());
       localStringBuilder.append(',');
       localStringBuilder.append(paramView.getBottom());
       n = paramView.getId();
       if (n != -1)
       {
         localStringBuilder.append(" #");
         localStringBuilder.append(Integer.toHexString(n));
         localObject = paramView.getResources();
         if ((n != 0) && (localObject != null)) {
           switch (0xFF000000 & n)
           {
           }
         }
       }
     }
     break;
   }
   for (;;)
   {
     try
     {
       paramView = ((Resources)localObject).getResourcePackageName(n);
       String str = ((Resources)localObject).getResourceTypeName(n);
       localObject = ((Resources)localObject).getResourceEntryName(n);
       localStringBuilder.append(" ");
       localStringBuilder.append(paramView);
       localStringBuilder.append(":");
       localStringBuilder.append(str);
       localStringBuilder.append("/");
       localStringBuilder.append((String)localObject);
     }
     catch (Resources.NotFoundException paramView)
     {
       label562:
       label568:
       label574:
       label580:
       label586:
       label592:
       label598:
       label604:
       continue;
     }
     localStringBuilder.append("}");
     return localStringBuilder.toString();
     localStringBuilder.append('V');
     break;
     localStringBuilder.append('I');
     break;
     localStringBuilder.append('G');
     break;
     c1 = '.';
     break label118;
     c1 = '.';
     break label135;
     c1 = 'D';
     break label152;
     c1 = '.';
     break label169;
     c1 = '.';
     break label186;
     c1 = '.';
     break label203;
     c1 = '.';
     break label220;
     c1 = '.';
     break label244;
     c1 = '.';
     break label261;
     paramView = "app";
     continue;
     paramView = "android";
   }
 }