Git Product home page Git Product logo

steadyview's Introduction

Release

⛵ SteadyView library for Android and Wear 🏝️

More info

Please see the SteadyScreen project for more details.

Project components

  • Stilly app: The engine behind the scenes.
  • SteadyService library: If you want to implement your own screen stabilizer service that won't need Stilly.
  • SteadyViews library: Ready-to-use "Steady…" implementations of most common Android layouts (like e.g. LinearLayout or ConstraintLayout).
  • SteadyView library (this): Core classes and methods. To be used for custom View or ViewGroup implementations.

To use this library in your app

This library enables you to implement the functionality in your own custom View or ViewGroup. If you need ready-to-use "Steady…" implementations of most common Android layouts (like e.g. LinearLayout or ConstraintLayout), you can use the SteadyViews library instead.

  1. Add the following line to your build.gradle file (find more info at https://jitpack.io/#Sublimis/SteadyView):
implementation 'com.github.Sublimis:SteadyView:v1.3.1'
  1. Let your custom android.view.View or android.view.ViewGroup implement the lib.sublimis.steadyview.ISteadyView interface. This helper interface has no required methods, only a few methods that you can call from your code.
  2. Call the ISteadyView.super.initSteadyView() in every constructor of your custom view.
  3. Override the android.view.View.performAccessibilityAction(int, Bundle) method, from which you should call the ISteadyView.super.performSteadyViewAction(int, Bundle), like so:
   @Override
   public boolean performAccessibilityAction(final int action, @Nullable final Bundle arguments)
   {
      final boolean status = ISteadyView.super.performSteadyViewAction(action, arguments);

      return super.performAccessibilityAction(action, arguments) || status;
   }
  1. Install and enable the Stilly screen stabilizer accessibility service from the Play Store.
  2. Enjoy!

Enable or disable programatically

Call the ISteadyView.setSteadyViewEnabled(final boolean enabled) method on your ISteadyView to disable or (re)enable the functionality:

MyCustomView extends View implements ISteadyView
{
   ...
}

MyCustomView myCustomView = new MyCustomView();

...

myCustomView.setSteadyViewEnabled(false);

...

myCustomView.setSteadyViewEnabled(true);

Note, this does not disable/enable the service, it just tells the View to ignore all service inputs. Call the boolean ISteadyView.isSteadyViewEnabled() on your ISteadyView to check the enabled state.

Example

Below is the complete implementation of the functionality in a custom view that overrides the plain android.view.View.

If you need ready-to-use "Steady…" implementations of the most common Android layouts (like e.g. LinearLayout or ConstraintLayout), you can use the SteadyViews library instead.

import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;
import lib.sublimis.steadyview.ISteadyView;

public class SteadyView extends View implements ISteadyView
{
   public SteadyView(final Context context)
   {
      super(context);

      ISteadyView.super.initSteadyView();
   }

   public SteadyView(final Context context, @Nullable final AttributeSet attrs)
   {
      super(context, attrs);

      ISteadyView.super.initSteadyView();
   }

   public SteadyView(final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr)
   {
      super(context, attrs, defStyleAttr);

      ISteadyView.super.initSteadyView();
   }

   public SteadyView(final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr, final int defStyleRes)
   {
      super(context, attrs, defStyleAttr, defStyleRes);

      ISteadyView.super.initSteadyView();
   }

   @Override
   public boolean performAccessibilityAction(final int action, @Nullable final Bundle arguments)
   {
      final boolean status = ISteadyView.super.performSteadyViewAction(action, arguments);

      return super.performAccessibilityAction(action, arguments) || status;
   }
}

steadyview's People

Contributors

sublimis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.