Search in sources :

Example 71 with RequiresApi

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;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) MutableStringViewAttribute(com.willowtreeapps.hyperion.attr.MutableStringViewAttribute) RequiresApi(android.support.annotation.RequiresApi) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) NonNull(android.support.annotation.NonNull)

Example 72 with RequiresApi

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;
}
Also used : ArrayList(java.util.ArrayList) RequiresApi(android.support.annotation.RequiresApi) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) ViewAttribute(com.willowtreeapps.hyperion.attr.ViewAttribute) MutableBooleanViewAttribute(com.willowtreeapps.hyperion.attr.MutableBooleanViewAttribute) NonNull(android.support.annotation.NonNull)

Example 73 with RequiresApi

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();
}
Also used : SafeIntent(mozilla.components.utils.SafeIntent) SafeIntent(mozilla.components.utils.SafeIntent) Intent(android.content.Intent) RequiresApi(android.support.annotation.RequiresApi)

Example 74 with RequiresApi

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);
    }
}
Also used : DepthPageTransformer(com.cyl.musiclake.view.DepthPageTransformer) RequiresApi(android.support.annotation.RequiresApi)

Example 75 with RequiresApi

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;
}
Also used : UsageStatsManager(android.app.usage.UsageStatsManager) UsageStats(android.app.usage.UsageStats) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)28 View (android.view.View)25 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 Allocation (android.renderscript.Allocation)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 Cipher (javax.crypto.Cipher)8 SuppressLint (android.annotation.SuppressLint)7 Uri (android.net.Uri)7