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-system-settings

v1.0.4

Published

Provides accessing some Android system setting values like localization, language, country, simCountry, networkCountry, timeZone, is24HourFormat, oritentation, screen layout and ui mode type.

Downloads

39

Readme

react-native-system-settings

This module has been prepared by according to Android Configuration class; https://developer.android.com/reference/android/content/res/Configuration.html

Note:

  • Getting the user country: country value of localization object may be tricky in Android systems. To find the certain user country you might check simCountry and networkCountry values of localization object.
  • The module doesn't include the all configuration values. However some additional setting values exist like UI Mode Type and is24HourFormat.
  • The module doesn't handle the changes of the phone states in real-time (for instance orientation changes)
  • Contributions are welcomed. A feature that provides setting the system settings would be great. Another feature that provides getting the system settings from iOS would also be great.

installation

With rnpm using;

  1. Run the command of npm i --save react-native-system-settings in the console.
  2. Link the native module by using the command below:

$ rnpm link react-native-system-settings

  1. And finally run the command of react-native run-android

Manually;

  1. Run the command of npm i --save react-native-system-settings in the console.

  2. In your settings.gradle add the lines below:

    include ':systemsettings'
    project(':systemsettings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-settings/android')
  3. In your android/app/build.gradle add the following line:

    dependencies {
        compile fileTree(dir: "libs", include: ["*.jar"])
        compile "com.android.support:appcompat-v7:23.0.1"
        compile "com.facebook.react:react-native:+"
    		compile project(':systemsettings')  // <-- Add this line
    }
  4. The package needs to be provided in the getPackages method of the MainActivity.java file. This file exists under the android folder in your react-native application directory. The path to this file is: android/app/src/main/java/com/your-app-name/MainActivity.java.

    import com.systemsettings.SystemSettingsPackage;  // <-- Add this line
    
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new SystemSettingsPackage()  // <-- Also add this line
    		);
    }
  5. And finally run the command of react-native run-android

usage

Define a new module variable by using ES6 syntax; import SystemSettings from 'react-native-system-settings'; or by using require method; var SystemSettings = require('react-native-system-settings'); then system settings can gotten in somewhere in code:

SystemSettings.get(
	settings => console.log('settings: ', settings)
)

Also promise-then can be used:

SystemSettings.get().then(settings => console.log('settings: ', settings)).done()

Also ES7 async-await method can be used!

class App extends React.Component {
	componentWillMount() {
		this._loadInitialState()
	}
	
	_loadInitialState = async () => {
		try {
			let settings = await SystemSettings.get()
			// Now settings variable would be filled and can be used!
		} catch (error) {}
	};
}

Sample result from Galaxy S3 (Genymotion);

```
{
	densityDpi: 320,
	fontScale: 1,
	hardKeyboardHidden: "no",
	keyboard: "qwerty",
	keyboardHidden: "no",
	localization: {
		country: "US",
		displayCountry: "United States",
		displayLanguage: "English",
		displayName: "English (United States)",
		is24HourFormat: false,
		language: "en",
		locale: "en_US",
		networkCountry: "US",
		simCountry: "US",
		timeZone: {
			ID: "Europe/Amsterdam",
			displayName: {
				long: "Amsterdam Standard Time",
				short: "GMT+01:00",
			},
			offset: 3600000
		}
	},
	orientation: "portrait",
	screenHeightDp: 615,
	screenLayout: "normal",
	screenWidthDp: 360,
	smallestScreenWidthDp: 360,
	uiModeType: "normal"
}
```

The values that can be existed in result object;

  • densityDpi: Number
  • fontScale: Number
  • hardKeyboardHidden: One of 'undefined', 'no' or 'yes' strings
  • keyboardHidden: One of 'undefined', 'no' or 'yes' strings
  • keyboard: One of 'undefined', 'nokeys', 'qwerty' or '12key' strings
  • orientation: One of 'undefined', 'portrait', 'landscape' or 'square' strings
  • screenLayout: One of 'small', 'normal', 'large', 'xlarge' or 'undefined' strings small: The screen is at least approximately 320x426 dp units. normal: The screen is at least approximately 320x470 dp units. large: The screen is at least approximately 480x640 dp units. xlarge: The screen is at least approximately 720x960 dp units. undefined: A screen layout size value indicating that no size has been set.
  • screenHeightDp: Number
  • screenWidthDp: Number
  • smallestScreenWidthDp: Number
  • uiModeType: One of 'undefined', 'normal', 'desk', 'car', 'television', 'appliance' or 'watch' strings
  • localization: object localization.country: One of 'US', 'GB', 'DE', 'FR', ... strings localization.displayCountry: One of 'United States', 'United Kingdom', ... strings localization.displayLanguage: One of 'English', 'Deutsch', ... strings localization.displayName: One of 'English (United States)', 'Deutsch (Deutschland)', ... strings localization.is24HourFormat: One of true and false values localization.language: One of 'en', 'de', 'fr', 'tr', ... strings localization.locale: One of 'en_US', 'de_DE', 'de_AT', 'fr_FR', 'tr_TR', ... strings localization.networkCountry: One of 'US', 'GB', 'DE', 'FR', ... strings localization.simCountry: One of 'US', 'GB', 'DE', 'FR', ... strings localization.timeZone: object localization.timezone.ID: String localization.timezone.displayName: object localization.timezone.displayname.short: String localization.timezone.displayName.long: String localization.timezone.offset: Number of offset in milliseconds

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.