Skip to content

Commit

Permalink
chore: rename package due to collaborator conflict iteration two
Browse files Browse the repository at this point in the history
  • Loading branch information
tarikfp committed Jun 28, 2024
1 parent 84655c6 commit afd9e08
Show file tree
Hide file tree
Showing 40 changed files with 207 additions and 330 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ The [example app](/example/) demonstrates usage of the library. You need to run

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/PowerSaverCheckerExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-power-saver`.
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/PowerSaverDetectorExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-power-saver-detector`.

To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-power-saver` under `Android`.
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-power-saver-detector` under `Android`.

You can use various commands from the root directory to work with the project.

Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# React Native Power Saver Checker
# React Native Power Saver Detector

[![npm version](https://img.shields.io/npm/v/react-native-power-saver.svg)](https://www.npmjs.com/package/react-native-power-saver)

`react-native-power-saver` is a React Native library that provides methods for checking Low Power Mode on iOS and Power Saver Mode on Android, as well as navigating to the Power Saver Mode settings on Android.
`react-native-power-saver-detector` is a React Native library that provides methods for checking Low Power Mode on iOS and Power Saver Mode on Android, as well as navigating to the Power Saver Mode settings on Android.

## Installation

To install the library, use either npm or yarn:

```sh
npm install react-native-power-saver
npm install react-native-power-saver-detector
# or
yarn add react-native-power-saver
yarn add react-native-power-saver-detector
```

### Linking

For React Native 0.60 and above, the library should be automatically linked. For older versions, you will need to link the library manually:

```sh
react-native link react-native-power-saver
react-native link react-native-power-saver-detector
```

For iOS, don't forget to run `pod install` after linking the library:
Expand Down Expand Up @@ -48,9 +46,9 @@ Checks if Low Power Mode is enabled on iOS.
#### Example

```typescript
import { PowerSaverChecker } from 'react-native-power-saver';
import { PowerSaverDetector } from 'react-native-power-saver-detector';

PowerSaverChecker.isLowPowerModeEnabled().then((isEnabled) => {
PowerSaverDetector.isLowPowerModeEnabled().then((isEnabled) => {
console.log('Low Power Mode enabled:', isEnabled);
});
```
Expand All @@ -66,9 +64,9 @@ Synchronously checks if Power Saver Mode is enabled on Android.
#### Example

```typescript
import { PowerSaverChecker } from 'react-native-power-saver';
import { PowerSaverDetector } from 'react-native-power-saver-detector';

const isEnabled = PowerSaverChecker.isPowerSaverModeEnabledSync();
const isEnabled = PowerSaverDetector.isPowerSaverModeEnabledSync();
console.log('Power Saver Mode enabled (sync):', isEnabled);
```

Expand All @@ -83,9 +81,9 @@ Asynchronously checks if Power Saver Mode is enabled on Android.
#### Example

```typescript
import { PowerSaverChecker } from 'react-native-power-saver';
import { PowerSaverDetector } from 'react-native-power-saver-detector';

PowerSaverChecker.isPowerSaverModeEnabled().then((isEnabled) => {
PowerSaverDetector.isPowerSaverModeEnabled().then((isEnabled) => {
console.log('Power Saver Mode enabled (async):', isEnabled);
});
```
Expand All @@ -97,9 +95,9 @@ Navigates to the Power Saver Mode settings on Android.
#### Example

```typescript
import { PowerSaverChecker } from 'react-native-power-saver';
import { PowerSaverDetector } from 'react-native-power-saver-detector';

PowerSaverChecker.openPowerSaverSettings();
PowerSaverDetector.openPowerSaverSettings();
```

## Contributing
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ if (isNewArchitectureEnabled()) {
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PowerSaverChecker_" + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PowerSaverDetector_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PowerSaverChecker_" + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PowerSaverDetector_" + name]).toInteger()
}

def supportsNamespace() {
Expand All @@ -43,7 +43,7 @@ def supportsNamespace() {

android {
if (supportsNamespace()) {
namespace "com.powersaverchecker"
namespace "com.powersaverdetector"

sourceSets {
main {
Expand Down
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PowerSaverChecker_kotlinVersion=1.7.0
PowerSaverChecker_minSdkVersion=21
PowerSaverChecker_targetSdkVersion=31
PowerSaverChecker_compileSdkVersion=31
PowerSaverChecker_ndkversion=21.4.7075529
PowerSaverDetector_kotlinVersion=1.7.0
PowerSaverDetector_minSdkVersion=21
PowerSaverDetector_targetSdkVersion=31
PowerSaverDetector_compileSdkVersion=31
PowerSaverDetector_ndkversion=21.4.7075529
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.powersaverchecker">
package="com.powersaverdetector">
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.powersaverchecker;
package com.powersaverdetector;

import android.content.Context;
import android.content.Intent;
Expand All @@ -13,25 +13,25 @@
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

@ReactModule(name = PowerSaverCheckerModule.NAME)
public class PowerSaverCheckerModule extends ReactContextBaseJavaModule {
public static final String NAME = "PowerSaverChecker";
@ReactModule(name = PowerSaverDetectorModule.NAME)
public class PowerSaverDetectorModule extends ReactContextBaseJavaModule {
public static final String NAME = "PowerSaverDetector";
private static ReactApplicationContext reactContext;


public PowerSaverCheckerModule(ReactApplicationContext context) {
public PowerSaverDetectorModule(ReactApplicationContext context) {
super(context);
reactContext = context;

}

@NonNull
@Override
@NonNull
public String getName() {
return NAME;
}

@ReactMethod(isBlockingSynchronousMethod = true)

@ReactMethod(isBlockingSynchronousMethod = true)
public Boolean isPowerSaverModeEnabledSync() {
PowerManager powerManager = (PowerManager) reactContext.getSystemService(Context.POWER_SERVICE);
if (powerManager == null) {
Expand Down Expand Up @@ -80,5 +80,4 @@ public void openPowerSaverSettings() {
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.powersaverchecker;
package com.powersaverdetector;

import androidx.annotation.NonNull;

Expand All @@ -11,12 +11,12 @@
import java.util.Collections;
import java.util.List;

public class PowerSaverCheckerPackage implements ReactPackage {
public class PowerSaverDetectorPackage implements ReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new PowerSaverCheckerModule(reactContext));
modules.add(new PowerSaverDetectorModule(reactContext));
return modules;
}

Expand Down
105 changes: 0 additions & 105 deletions example/Gemfile.lock

This file was deleted.

4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.powersavercheckerexample"
namespace "com.powersaverdetectorexample"
defaultConfig {
applicationId "com.powersavercheckerexample"
applicationId "com.powersaverdetectorexample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.powersavercheckerexample
package com.powersaverdetectorexample

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
Expand All @@ -11,7 +11,7 @@ class MainActivity : ReactActivity() {
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "PowerSaverCheckerExample"
override fun getMainComponentName(): String = "PowerSaverDetectorExample"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.powersavercheckerexample
package com.powersaverdetectorexample

import android.app.Application
import com.facebook.react.PackageList
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">PowerSaverCheckerExample</string>
<string name="app_name">PowerSaverDetectorExample</string>
</resources>
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'PowerSaverCheckerExample'
rootProject.name = 'PowerSaverDetectorExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
4 changes: 2 additions & 2 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "PowerSaverCheckerExample",
"displayName": "PowerSaverCheckerExample"
"name": "PowerSaverDetectorExample",
"displayName": "PowerSaverDetectorExample"
}
2 changes: 1 addition & 1 deletion example/ios/File.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// File.swift
// PowerSaverCheckerExample
// PowerSaverDetectorExample
//

import Foundation
4 changes: 2 additions & 2 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if linkage != nil
use_frameworks! :linkage => linkage.to_sym
end

target 'PowerSaverCheckerExample' do
target 'PowerSaverDetectorExample' do
config = use_native_modules!

use_react_native!(
Expand All @@ -23,7 +23,7 @@ target 'PowerSaverCheckerExample' do
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

target 'PowerSaverCheckerExampleTests' do
target 'PowerSaverDetectorExampleTests' do
inherit! :complete
# Pods for testing
end
Expand Down
Loading

0 comments on commit afd9e08

Please sign in to comment.