项目作者: jsramraj

项目描述 :
Simple tooltip (aka Showcase/IntroView) library for Android
高级语言: Java
项目地址: git://github.com/jsramraj/tooltip.git
创建时间: 2020-04-29T07:47:18Z
项目社区:https://github.com/jsramraj/tooltip

开源协议:MIT License

下载


ToolTipView For android

ToolTipView is a simple tooltip/intro/showcase library for Android

Screenshots

Default view with optional title Fully customizable Individual customization

Demo

How this differs from other intro libraries?

With other libraries, you have to create the showcase cards yourself from each individual activities. But with this library, you just have inject the tips and all the target view’s id at once.

Usage

Initiate

Using json data (Refer the Sample json data section for the format)

  1. public class ToolTipApp extends Application {
  2. @Override
  3. public void onCreate() {
  4. super.onCreate();
  5. //Adding static tip information to be shown in activities
  6. ToolTipComposer.Builder tipComposerBuilder = new ToolTipComposer.Builder();
  7. tipComposerBuilder.addStaticTip(this, "tooltip_data.json");
  8. ToolTipManager.init(this, tipComposerBuilder.build());
  9. }
  10. }

By manually

  1. ToolTipComposer.Builder tipComposerBuilder = new ToolTipComposer.Builder();
  2. String[] identifiers = new String[]{"helloWorldLabel", String.valueOf(R.id.empName), "designation"};
  3. String[] tips = new String[]{"Tips for hello world", "Name of the logged in employee", "Role of the employee in the company"};
  4. tipComposerBuilder.addStaticTips("MainActivity", identifiers, tips, null);
  5. ToolTipManager.init(this, tipComposerBuilder.build());

Adding tips individually

  1. ToolTipComposer.Builder tipComposerBuilder = new ToolTipComposer.Builder();
  2. tipComposerBuilder.addStaticTip(LoginActivity.class.getSimpleName(), String.valueOf(R.id.checkboxRemember), "Remember me", "Check this box to store the session details." )
  3. ToolTipManager.init(this, tipComposerBuilder.build());

Customize the appearance of the tips

  1. ToolTipConfig globalConfig = new ToolTipConfig();
  2. globalConfig.setTipMessageStyleResId(R.style.tipTextStyleGlobal);
  3. globalConfig.setTipTitleStyleResId(R.style.tipTitleTextStyleGlobal);
  4. tipComposerBuilder.setGlobalConfig(globalConfig);

Customize the appearance of a individual tip

  1. @Override
  2. public ToolTipConfig configForTip(ToolTip tip) {
  3. if (tip.getResourceId() == R.id.etEmail) {
  4. // to show home individual tips can be customized
  5. ToolTipConfig config = new ToolTipConfig();
  6. config.setTipMessageStyleResId(R.style.emailTipTextStyle);
  7. return config;
  8. }
  9. return null;
  10. }

Sample json data of tips

  1. {
  2. "MainActivity": [
  3. {
  4. "id": "empName",
  5. "message": "Name of the logged in employee"
  6. },
  7. {
  8. "id": "designation",
  9. "message": "Role of the employee in the company"
  10. }
  11. ],
  12. "LoginActivity": [
  13. {
  14. "id": "etEmail",
  15. "message": "Enter a valid email address"
  16. },
  17. {
  18. "id": "etPassword",
  19. "title": "Password",
  20. "message": "Password should contain atleast 8 characters long"
  21. },
  22. {
  23. "id": "checkboxRemember",
  24. "title": "Remember Me",
  25. "message": "Check this to persist your session details"
  26. }
  27. ]
  28. }

How to include

This library is published in Jitpack

  1. Add the JitPack repository to your build file
    Add it in your root build.gradle at the end of repositories:
    1. allprojects {
    2. repositories {
    3. maven { url 'https://jitpack.io' }
    4. }
    5. }
  2. Add the dependency
    1. dependencies {
    2. implementation 'com.github.jsramraj:tooltip:$version'
    3. }
    Just replace the $version with the appropriate version number, for e.g v0.1

License

MIT