Unverified Commit 444f5a73 authored by Naoto Ida's avatar Naoto Ida Committed by GitHub

Merge branch 'master' into master

parents 0a374b58 098c3791
...@@ -178,7 +178,7 @@ var DeviceInfo = require('react-native-device-info'); ...@@ -178,7 +178,7 @@ var DeviceInfo = require('react-native-device-info');
| App Version | `getVersion()` | `string` e.g. "1.1.0" | | | App Version | `getVersion()` | `string` e.g. "1.1.0" | |
| App Version (Readable) | `getReadableVersion()` | `string` e.g. "1.1.0.89" | | | App Version (Readable) | `getReadableVersion()` | `string` e.g. "1.1.0.89" | |
| Device Name | `getDeviceName()` | `string` e.g. "Becca's iPhone 6" | | | Device Name | `getDeviceName()` | `string` e.g. "Becca's iPhone 6" | |
| User Agent | `getUserAgent()` | `string` e.g. "Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)" | | | User Agent | `getUserAgent()` | `string` e.g. "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.009; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36" | |
| Device Locale | `getDeviceLocale()` | `string` e.g. "en-US" | | | Device Locale | `getDeviceLocale()` | `string` e.g. "en-US" | |
| Device Country | `getDeviceCountry()` | `string` e.g. "US" | | | Device Country | `getDeviceCountry()` | `string` e.g. "US" | |
| Timezone | `getTimezone()` | `string` e.g. "America/Mexico_City" | | | Timezone | `getTimezone()` | `string` e.g. "America/Mexico_City" | |
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#import "RNDeviceInfo.h" #import "RNDeviceInfo.h"
#import "DeviceUID.h" #import "DeviceUID.h"
#if !(TARGET_OS_TV)
#import <LocalAuthentication/LocalAuthentication.h> #import <LocalAuthentication/LocalAuthentication.h>
#endif
@interface RNDeviceInfo() @interface RNDeviceInfo()
@property (nonatomic) bool isEmulator; @property (nonatomic) bool isEmulator;
...@@ -192,6 +194,12 @@ RCT_EXPORT_MODULE() ...@@ -192,6 +194,12 @@ RCT_EXPORT_MODULE()
return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
} }
- (bool) is24Hour
{
NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];
return ([format rangeOfString:@"a"].location == NSNotFound);
}
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
UIDevice *currentDevice = [UIDevice currentDevice]; UIDevice *currentDevice = [UIDevice currentDevice];
...@@ -218,13 +226,18 @@ RCT_EXPORT_MODULE() ...@@ -218,13 +226,18 @@ RCT_EXPORT_MODULE()
@"timezone": self.timezone, @"timezone": self.timezone,
@"isEmulator": @(self.isEmulator), @"isEmulator": @(self.isEmulator),
@"isTablet": @(self.isTablet), @"isTablet": @(self.isTablet),
@"is24Hour": @(self.is24Hour),
}; };
} }
RCT_EXPORT_METHOD(isPinOrFingerprintSet:(RCTResponseSenderBlock)callback) RCT_EXPORT_METHOD(isPinOrFingerprintSet:(RCTResponseSenderBlock)callback)
{ {
#if TARGET_OS_TV
BOOL isPinOrFingerprintSet = false;
#else
LAContext *context = [[LAContext alloc] init]; LAContext *context = [[LAContext alloc] init];
BOOL isPinOrFingerprintSet = ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:nil]); BOOL isPinOrFingerprintSet = ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:nil]);
#endif
callback(@[[NSNumber numberWithBool:isPinOrFingerprintSet]]); callback(@[[NSNumber numberWithBool:isPinOrFingerprintSet]]);
} }
......
...@@ -89,6 +89,10 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -89,6 +89,10 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE; return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE;
} }
private Boolean is24Hour() {
return android.text.format.DateFormat.is24HourFormat(this.reactContext.getApplicationContext());
}
@ReactMethod @ReactMethod
public void isPinOrFingerprintSet(Callback callback) { public void isPinOrFingerprintSet(Callback callback) {
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); //api 16+ KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); //api 16+
...@@ -171,6 +175,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -171,6 +175,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants.put("timezone", TimeZone.getDefault().getID()); constants.put("timezone", TimeZone.getDefault().getID());
constants.put("isEmulator", this.isEmulator()); constants.put("isEmulator", this.isEmulator());
constants.put("isTablet", this.isTablet()); constants.put("isTablet", this.isTablet());
constants.put("is24Hour", this.is24Hour());
if (getCurrentActivity() != null && if (getCurrentActivity() != null &&
(getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED || (getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED ||
getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED || getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED ||
......
...@@ -20,6 +20,7 @@ export function getTimezone(): string; ...@@ -20,6 +20,7 @@ export function getTimezone(): string;
export function getInstanceID(): string; export function getInstanceID(): string;
export function isEmulator(): boolean; export function isEmulator(): boolean;
export function isTablet(): boolean; export function isTablet(): boolean;
export function is24Hour(): boolean;
export function isPinOrFingerprintSet(): (cb: (isPinOrFingerprintSet: boolean) => void) => void; export function isPinOrFingerprintSet(): (cb: (isPinOrFingerprintSet: boolean) => void) => void;
export function getFirstInstallTime(): number; export function getFirstInstallTime(): number;
export function getLastUpdateTime(): number; export function getLastUpdateTime(): number;
......
...@@ -74,7 +74,10 @@ module.exports = { ...@@ -74,7 +74,10 @@ module.exports = {
isTablet: function() { isTablet: function() {
return RNDeviceInfo.isTablet; return RNDeviceInfo.isTablet;
}, },
isPinOrFingerprintSet: function() { is24Hour: function() {
return RNDeviceInfo.is24Hour;
},
isPinOrFingerprintSet: function () {
return RNDeviceInfo.isPinOrFingerprintSet; return RNDeviceInfo.isPinOrFingerprintSet;
}, },
getFirstInstallTime: function() { getFirstInstallTime: function() {
......
...@@ -19,6 +19,7 @@ declare module.exports: { ...@@ -19,6 +19,7 @@ declare module.exports: {
getTimezone: () => string, getTimezone: () => string,
isEmulator: () => boolean, isEmulator: () => boolean,
isTablet: () => boolean, isTablet: () => boolean,
is24Hour: () => boolean,
isPinOrFingerprintSet: () => (cb: (isPinOrFingerprintSet: boolean) => void) => void, isPinOrFingerprintSet: () => (cb: (isPinOrFingerprintSet: boolean) => void) => void,
getAPILevel: () => number, getAPILevel: () => number,
getInstanceID: () => string, getInstanceID: () => string,
......
{ {
"name": "react-native-device-info", "name": "react-native-device-info",
"version": "0.12.1", "version": "0.12.2",
"description": "Get device information using react-native", "description": "Get device information using react-native",
"main": "deviceinfo.js", "main": "deviceinfo.js",
"typings": "./deviceinfo.d.ts", "typings": "./deviceinfo.d.ts",
......
...@@ -7,7 +7,6 @@ using System.Text.RegularExpressions; ...@@ -7,7 +7,6 @@ using System.Text.RegularExpressions;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using WinRTXamlToolkit.Controls;
namespace RNDeviceInfo namespace RNDeviceInfo
{ {
...@@ -38,6 +37,11 @@ namespace RNDeviceInfo ...@@ -38,6 +37,11 @@ namespace RNDeviceInfo
return !rgx.IsMatch(os); return !rgx.IsMatch(os);
} }
private bool is24Hour()
{
return DateTimeFormatInfo.CurrentInfo.ShortTimePattern.Contains("H");
}
public override IReadOnlyDictionary<string, object> Constants public override IReadOnlyDictionary<string, object> Constants
{ {
...@@ -113,6 +117,7 @@ namespace RNDeviceInfo ...@@ -113,6 +117,7 @@ namespace RNDeviceInfo
constants["isEmulator"] = IsEmulator(model); constants["isEmulator"] = IsEmulator(model);
constants["isTablet"] = IsTablet(os); constants["isTablet"] = IsTablet(os);
constants["carrier"] = "not available"; constants["carrier"] = "not available";
constants["is24Hour"] = is24Hour();
return constants; return constants;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment