npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-android-quick-settings-tiles

v0.1.0

Published

Create custom Quick Settings tiles for your app

Downloads

5

Readme

react-native-android-quick-settings-tiles

Library only work for android 13 or latest

Create custom Quick Settings tiles for your app info

Screenshot

Installation

npm install react-native-android-quick-settings-tiles

Addition installation step

In MainActivity.java

  @Override
  protected void onStart() {
    super.onStart();
    AndroidQuickSettingsTilesModule.startSession(getIntent()); //add line
  }
  @Override
  public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    AndroidQuickSettingsTilesModule.onNewIntent(intent);  //add line
  }

In AndroidManifest.xml:

// ...
  <!-- TileService for "Launch a dialog from a tile" section -->
      <service
        android:name="com.reactnativeandroidquicksettingstiles.QSDialogService"
        android:icon="@drawable/more"
        android:label="@string/qs_dialog_tile_label"
        android:exported="true"
        android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
        <intent-filter>
          <action android:name="android.service.quicksettings.action.QS_TILE" />
        </intent-filter>
      </service>
      <!-- TileService for "Launch an activity from a tile" section -->
      <service
        android:name="com.reactnativeandroidquicksettingstiles.QSIntentService"
         android:icon="@drawable/other"
        android:label="@string/qs_intent_tile_label"
        android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
        <intent-filter>
          <action android:name="android.service.quicksettings.action.QS_TILE" />
        </intent-filter>
      </service>
     .....
      </application>

In res/values/strings:(optional)

    <string name="app_name">AndroidQuickSettingsTiles Example</string>
  <string name="tile_label">Quick Settings Sample</string>

  <string name="qs_dialog_tile_label">QS Dialog Launcher</string>
  <string name="qs_dialog_prompt">Change the tile state?</string>
  <string name="qs_dialog_active">Turn off</string>
  <string name="qs_dialog_inactive">Turn on</string>
  <string name="qs_dialog_cancel">Cancel</string>

  <string name="qs_intent_tile_label">QS Intent Launcher</string>
<!--  value init  -->
  <bool name="qs_dialog_default">true</bool>
  <bool name="qs_intent_default">true</bool>

In res/values/color: (optional)

  <color name="colorPrimaryDialog">#0F9D58</color>
  <color name="colorPrimaryDarkDialog">#0B8043</color>

In res/values/styles:(optional)

 <style name="HeadingFont" parent="@android:style/TextAppearance.Medium">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textSize">24sp</item>
    <item name="android:layout_marginTop">16dp</item>
    <item name="android:paddingLeft">16dp</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:layout_gravity">center</item>
  </style>

  <style name="BodyFont" parent="@style/HeadingFont">
    <item name="android:textSize">18sp</item>
    <item name="android:layout_marginTop">8sp</item>
    <item name="android:textColor">@color/colorPrimaryDark</item>
  </style>

Usage

import RNQuickSettings from "react-native-android-quick-settings-";

  React.useEffect(()=>{
    const get=async ()=>{
     const data=await RNQuickSettings.getLastChanged()
     console.log('data',data)
     if(data){
      Alert.alert("Alert","Get latest")
     }
     RNQuickSettings.addEventListener("onChange",(payload)=>{
      console.log('payload',payload)
      Alert.alert("Alert","Tile changed")
    })
    }
    get()
  },[])

Request to add tile

function request(option:optionRequest): Promise<resultRequest>;
        const result=await RNQuickSettings.request({
          isDialog:true,
          quickLabel:"QS Dialog Launcher", //same with label in manifest
          icon:"more"
        })

getLastChanged

When change a tile from quicksettings has triggered the application to open from a quit state, * this method will return a resultChanged containing the tile data, or null if * the app was opened via another method.

function getLastChanged(option:optionRequest): Promise<resultChanged>;
   const data=await RNQuickSettings.getLastChanged()

event listener

function addEventListener(option:optionRequest,handler(payload:resultChanged): =>void);
    RNQuickSettings.addEventListener("onChange",(payload)=>{
    })

resultRequest type

type resultRequest={
  type:"UNAVAILABLE"|"GRANTED";
  code?:number;
}

| type value | Notes | | --------------------- | ----------------------------------------------------------------- | | UNAVAILABLE | This feature is not available (only work on android 13 and later) | | GRANTED | The request is successfully |

| code value | Notes | | --------------------- | ----------------------------------------------------------------- | | 0 | |Quick setting is denied | 1 | |Quick setting already exists | 2 | |Add Quick setting success

optionRequest type

interface optionRequest{
  quickLabel:string;
  isDialog?:boolean; // default is false
  icon:string;
}
  • quickLabel: label of the tile to show to the user. This value cannot be null.
  • icon: to use in the tile shown to the user. This value cannot be null.
  • isDialog: flag to display dialog when change status of tile

Troubleshooting

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library