Bugstick


Source link: https://github.com/justasm/Bugstick

Bugstick

Flexible joystick widget for Android.

Why Bugstick?

Other joystick widgets are a hassle to include in modern Gradle-based Android projects, support only limited visual customization, and suffer from overly prescriptive output.

So how does Bugstick solve these issues?

  • Painless Dependency - try it out quickly with a simple Gradle dependency.

  • Configurable Look - the joystick base and stick are a completely decoupled, standard ViewGroup - View pair. Use an ImageView, Button, LinearLayout, or any other View as the stick, and use standard Drawables to theme Bugstick so it looks at home in your app.

  • Unopinionated Output - the widget reports proportional offset of the stick from its center as well as the current angle via a standard listener interface. Choose to interpret these raw outputs in the way that suits your use case.

Usage

Add it to your project using Gradle:

compile 'com.jmedeisis:bugstick:0.2.2'

Example XML layout file:

<com.jmedeisis.bugstick.Joystick
  android:id="@+id/joystick"
  android:layout_width="@dimen/base_size"
  android:layout_height="@dimen/base_size"
  android:background="@drawable/bg_base">

<!-- You may use any View here. -->
  <Button

android:layout_width="@dimen/stick_size"

android:layout_height="@dimen/stick_size"

android:background="@drawable/bg_stick" />  </com.jmedeisis.bugstick.Joystick>

Note that the Joystick ViewGroup supports only one direct child, but that child can be another ViewGroup such as a FrameLayout with multiple children.

After inflating the layout, you will typically listen for joystick events using a JoystickListener:

Joystick joystick = (Joystick) findViewById(R.id.joystick);
 joystick.setJoystickListener(new JoystickListener() {

  @Override
  public void onDown() {

// ..
  
}

@Override
  public void onDrag(float degrees, float offset) {

// ..
  
}

@Override
  public void onUp() {

// ..
  
}
 
}
);

Please refer to the included sample project for a thorough example.

Configuration

You can configure the following attributes for the Joystick class:

  • start_on_first_touch - If true (default), the stick activates immediately on the initial touch. If false, the user must begin to drag their finger across the joystick for the stick to activate.

  • force_square - If true (default), the joystick always measures itself to force a square layout.

  • radius - If specified, this is the maximum physical offset from the center that the stick is allowed to move. If not specified (default), the radius is determined based on the dimensions of the base and the stick.

  • motion_constraint - One of None (default), Horizontal, or Vertical. Specifies whether the stick motion should be constrained to a particular direction. If None, the stick is allowed to move freely around the center of the base.

Example configuration:

<com.jmedeisis.bugstick.Joystick
  android:id="@+id/joystick"
  android:layout_width="@dimen/base_width"
  android:layout_height="match_parent"
  android:background="@drawable/bg_base"
  app:start_on_first_touch="false"
  app:force_square="false"
  app:radius="@dimen/stick_offset_max_radius"
  app:motion_constraint="Vertical">

<!-- Any View here. -->  </com.jmedeisis.bugstick.Joystick>

Development

Pull requests are welcome and encouraged for bugfixes and features such as:

  • accessibility support
  • more powerful motion constraints, e.g. constrain to arbitrary path

License

Bugstick is licensed under the terms of the MIT License.

Resources

A custom LayoutManager to build a Gallery or a ViewPager like RecyclerView that shows items in a center-locked and support both HORIZONTAL and VERTICAL scroll.And View Recycle Machine is also supported.

Custom tab layout which can be used as a material TabLayout alternative and consists basic functionality which Google's TabLayout has.

EtiyaBadgeTab is a Tab library for Android. As an alternative to the Tab library used on Android, it offers badge support and various customizations.

Graphics related utils for the Android platform.

A helper library to ease the most repetitive codes with simple reusable attributes.

AKUAH can help you with many repetitive tasks of daily life development.

I am using this library in my own projects from quit a time. Now I decided to share in for public use. I have not implemented all the features I used to have in my old library but will keep adding them and some new features.

A semicircular seekbar view for selecting angle from 0° to 180°.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes