New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-kiosk-view

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-kiosk-view

PACKAGE DISCRIPTION HERE

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-kiosk-view

A simple kiosk mode for Android in react native.

Does not work with Expo because of its native dependencies.

Installation

npm install react-native-kiosk-view

Android Changes

In MainActivity.java add the following code:

//...
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.kioskview.Immersive;

public class MainActivity extends ReactActivity {
  //...
  @Override
  public void onBackPressed() {
		if( !Immersive.getActive() ) super.onBackPressed();
		else Immersive.fullscreen(getWindow(), MainActivity.this);
  }

  @Override
  protected void onPause() {
		super.onPause();
		if(Immersive.getActive()) Immersive.moveToFront(getTaskId(),(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
  }

  @Override
  protected void onResume() {
		super.onResume();
		if(Immersive.getActive()) Immersive.fullscreen(getWindow(), MainActivity.this);
  }

  @Override
  protected void onUserLeaveHint() {
		super.onUserLeaveHint();
		if(Immersive.getActive()) {
			Immersive.moveToFront(getTaskId(), (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
			Immersive.fullscreen(getWindow(), MainActivity.this);
		}
  }
}

Add below permissions in AndroidManifest.xml:

<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />

The <intent-filter> should be atleast:

<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.HOME" />
  <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Usage

import * as React from 'react';
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
import Kiosk from 'react-native-kiosk-view';

export default function App() {
  const handleFullScreen = () => Kiosk.fullscreen();

  const handleExitFullScreen = () => Kiosk.exitFullscreen();

  return (
    <View style={styles.container}>
      <TouchableOpacity onPress={handleFullScreen}>
        <Text>Enter Kiosk Mode{'\n'}</Text>
      </TouchableOpacity>

      <TouchableOpacity onPress={handleExitFullScreen}>
        <Text>Exit Kiosk Mode</Text>
      </TouchableOpacity>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

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

Keywords

FAQs

Package last updated on 23 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc