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-toggle-loud-speaker

v1.2.0

Published

A node modules can open loud speaker for react native. Support for ios and android.

Downloads

4

Readme

React Native Toggle Loud Speaker

A node modules can open loud speaker for react native. Support for ios and android.

This package was forked from huutq88/react-native-toggle-loud-speaker

I updated the target and compile SDK to 31, and fixed a build error by changing compile() to implementation

I also edited the Java code so the method LoudSpeaker.open() can turn the speaker on/off by adding the parameter true/false. Originally, this package was turning it on, but never off. This part of the code was not implemented by the original author.

Since I'm not a Java developper, I wasn't able to improve it more than that. But all contributions are welcome.

NOTA: The update I made are for Android only.

NPM NPM JavaScript Style Guide JavaScript Style Guide JavaScript Style Guide NPM

Installation

npm install react-native-toggle-loud-speaker

Installation (iOS)

  • Drag LoudSpeaker.xcodeproj to your project on Xcode.
  • Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libLoudSpeaker.a from the Products folder inside the LoudSpeaker.xcodeproj.

Installation (Android)

You don't need this for RN >= 60

...
include ':react-native-toggle-loud-speaker'
project(':react-native-toggle-loud-speaker').projectDir = new File(settingsDir, '../node_modules/react-native-toggle-loud-speaker/android')

You don't need this for RN >= 60

  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-toggle-loud-speaker')
}
  • register module (in MainApplication.java) You don't need this for RN >= 60
......
import com.loudspeaker.LoudSpeakerPackage;  // <--- import
......

@Override
protected List<ReactPackage> getPackages() {
   ......
   new LoudSpeakerPackage(),            // <------ add here
   ......
}

Usage

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  TouchableOpacity
} from 'react-native';
import LoudSpeaker from 'react-native-toggle-loud-speaker'

export default class App extends Component<{}> {
  enableSpeaker = () => {
    LoudSpeaker.open(true)
  }
  disableSpeaker = () => {
    LoudSpeaker.open(false)
  }	
  
  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity onPress={this.enableSpeaker} style={styles.button}>
	        <Text>Enable</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={this.disableSpeaker} style={styles.button}>
	        <Text>Disable</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  button: {
    height: 45, 
    width: 150, 
    backgroundColor: 'red',
    margin: 10
  },
});

Changelog

1.2.0

  • Changed toggle behavior by enable/disable behavior

1.1.0

  • Updated Compile SDK to 31
  • Updated Target SDK to 31
  • Updated buildtool to 31.0.0
  • Fixed Could not find method compile() build error
  • Changed Java code for open() methode to toggle speaker on/off