use of android.support.annotation.RequiresApi in project Hyperion-Android by willowtreeapps.
the class ViewAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final View view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
Rect rect = new Rect();
String value;
attributes.add(new ViewAttribute<>("Id", new ResourceValue(view.getResources(), view.getId())));
value = attributeTranslator.translatePx(view.getHeight());
attributes.add(new ViewAttribute<>("Height", value));
value = attributeTranslator.translatePx(view.getWidth());
attributes.add(new ViewAttribute<>("Width", value));
attributes.add(new ViewAttribute<>("Baseline", view.getBaseline()));
view.getGlobalVisibleRect(rect);
attributes.add(new ViewAttribute<>("GlobalLeft", String.valueOf(rect.left)));
attributes.add(new ViewAttribute<>("GlobalTop", String.valueOf(rect.top)));
attributes.add(new ViewAttribute<>("GlobalRight", String.valueOf(rect.right)));
attributes.add(new ViewAttribute<>("GlobalBottom", String.valueOf(rect.bottom)));
view.getLocalVisibleRect(rect);
attributes.add(new ViewAttribute<>("LocalLeft", String.valueOf(rect.left)));
attributes.add(new ViewAttribute<>("LocalTop", String.valueOf(rect.top)));
attributes.add(new ViewAttribute<>("LocalRight", String.valueOf(rect.right)));
attributes.add(new ViewAttribute<>("LocalBottom", String.valueOf(rect.bottom)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
attributes.add(new ViewAttribute<>("InLayout", view.isInLayout()));
}
attributes.add(new MutableBooleanViewAttribute("Clickable", view.isClickable()) {
@Override
protected void mutate(Boolean value) {
view.setClickable(value);
}
});
attributes.add(new MutableBooleanViewAttribute("LongClickable", view.isLongClickable()) {
@Override
protected void mutate(Boolean value) {
view.setLongClickable(value);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("ContextClickable", view.isContextClickable()));
}
attributes.add(new MutableBooleanViewAttribute("Enabled", view.isEnabled()) {
@Override
protected void mutate(Boolean value) {
view.setEnabled(value);
}
});
attributes.add(new MutableBooleanViewAttribute("Activated", view.isActivated()) {
@Override
protected void mutate(Boolean value) {
view.setActivated(value);
}
});
attributes.add(new MutableBooleanViewAttribute("Selected", view.isSelected()) {
@Override
protected void mutate(Boolean value) {
view.setSelected(value);
}
});
attributes.add(new ViewAttribute<>("AttachedToWindow", ViewCompat.isAttachedToWindow(view)));
attributes.add(new ViewAttribute<>("Dirty", view.isDirty()));
attributes.add(new MutableBooleanViewAttribute("IsFocusable", view.isFocusable()) {
@Override
protected void mutate(Boolean value) {
view.setFocusable(value);
}
});
attributes.add(new MutableBooleanViewAttribute("IsFocusableInTouchMode", view.isFocusableInTouchMode()) {
@Override
protected void mutate(Boolean value) {
view.setFocusableInTouchMode(value);
}
});
attributes.add(new ViewAttribute<>("HasFocus", view.hasFocus()));
attributes.add(new ViewAttribute<>("HasFocusable", view.hasFocusable()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
attributes.add(new ViewAttribute<>("HasTransientState", view.hasTransientState()));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("ForegroundGravity", new GravityValue(view.getForegroundGravity())));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
attributes.add(new MutableStringViewAttribute("TransitionName", view.getTransitionName()) {
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
protected void mutate(CharSequence value) {
view.setTransitionName(value.toString());
}
});
attributes.add(new ViewAttribute<>("Elevation", view.getElevation()));
}
attributes.add(new ViewAttribute<>("BackgroundTintMode", new PorterDuffModeValue(ViewCompat.getBackgroundTintMode(view))));
attributes.add(Collectors.createColorAttribute(view, "BackgroundTint", ViewCompat.getBackgroundTintList(view)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(new ViewAttribute<>("AccessibilityClassName", view.getAccessibilityClassName()));
}
return attributes;
}
use of android.support.annotation.RequiresApi in project Hyperion-Android by willowtreeapps.
the class ViewGroupAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final ViewGroup view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new ViewAttribute<>("ChildCount", view.getChildCount()));
attributes.add(new MutableBooleanViewAttribute("MotionEventSplittingEnabled", view.isMotionEventSplittingEnabled()) {
@Override
protected void mutate(Boolean value) {
view.setMotionEventSplittingEnabled(value);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
attributes.add(new ViewAttribute<>("LayoutMode", new LayoutModeValue(view.getLayoutMode())));
attributes.add(new MutableBooleanViewAttribute("ClipChildren", view.getClipChildren()) {
@Override
protected void mutate(Boolean value) {
view.setClipChildren(value);
}
});
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
attributes.add(new MutableBooleanViewAttribute("ClipToPadding", view.getClipToPadding()) {
@Override
protected void mutate(Boolean value) {
view.setClipToPadding(value);
}
});
attributes.add(new ViewAttribute<>("TouchscreenBlocksFocus", view.getTouchscreenBlocksFocus()));
attributes.add(new MutableBooleanViewAttribute("IsTransitionGroup", view.isTransitionGroup()) {
@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
protected void mutate(Boolean value) {
view.setTransitionGroup(value);
}
});
}
attributes.add(new ViewAttribute<>("DelayChildPressed", view.shouldDelayChildPressedState()));
return attributes;
}
use of android.support.annotation.RequiresApi in project focus-android by mozilla-mobile.
the class TextActionActivity method onCreate.
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SafeIntent intent = new SafeIntent(getIntent());
final CharSequence searchTextCharSequence = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
final String searchText;
if (searchTextCharSequence != null) {
searchText = searchTextCharSequence.toString();
} else {
searchText = "";
}
final String searchUrl = UrlUtils.createSearchUrl(this, searchText);
final Intent searchIntent = new Intent(this, MainActivity.class);
searchIntent.setAction(Intent.ACTION_VIEW);
searchIntent.putExtra(MainActivity.EXTRA_TEXT_SELECTION, true);
searchIntent.setData(Uri.parse(searchUrl));
startActivity(searchIntent);
finish();
}
use of android.support.annotation.RequiresApi in project MusicLake by caiyonglong.
the class PlayFragment method initViews.
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void initViews() {
// 初始化控件
topContainer = rootView.findViewById(R.id.top_container);
mSlidingUpPaneLayout = (SlidingUpPanelLayout) rootView.getParent().getParent();
// 初始化viewpager
if (mViewPager != null) {
setupViewPager(mViewPager);
mViewPager.setPageTransformer(false, new DepthPageTransformer());
mViewPager.setOffscreenPageLimit(1);
mViewPager.setCurrentItem(0);
}
}
use of android.support.annotation.RequiresApi in project MusicLake by caiyonglong.
the class SystemUtils method isNoSwitch.
/**
* 判断调用该设备中“有权查看使用权限的应用”这个选项的APP有没有打开
*
* @return
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static boolean isNoSwitch() {
long dujinyang = System.currentTimeMillis();
UsageStatsManager usageStatsManager = (UsageStatsManager) MusicApp.getAppContext().getSystemService(Context.USAGE_STATS_SERVICE);
List<UsageStats> queryUsageStats = null;
if (usageStatsManager != null) {
queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, 0, dujinyang);
}
if (queryUsageStats == null || queryUsageStats.isEmpty()) {
return false;
}
return true;
}
Aggregations