Skip to content

Commit

Permalink
Fix AndroidManifest.xml namespace deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Jan 7, 2024
1 parent 1269ded commit 5b013ad
Show file tree
Hide file tree
Showing 23 changed files with 530 additions and 652 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
[*.bat]
end_of_line = crlf

[*.gradle]
[*.{gradle,xml}]
indent_size = 4

[*.md]
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.bat text eol=crlf
*.pbxproj -text
21 changes: 21 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Verify

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
prepack:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts/*

- run: yarn install --frozen-lockfile
- run: yarn prepack
15 changes: 0 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

Expand All @@ -64,6 +52,3 @@ example/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
4 changes: 0 additions & 4 deletions .hooks/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion RNPermissions.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.source = { :git => package["repository"]["url"], :tag => s.version }
s.source_files = "ios/*.{h,m,mm}"
s.source_files = "ios/*.{h,m,mm}", "ios/StoreKit/*.{h,m,mm}", "ios/FaceID/*.{h,m,mm}", "ios/Calendars/*.{h,m,mm}", "ios/LocationAlways/*.{h,m,mm}", "ios/PhotoLibraryAddOnly/*.{h,m,mm}", "ios/Microphone/*.{h,m,mm}", "ios/SpeechRecognition/*.{h,m,mm}", "ios/LocationWhenInUse/*.{h,m,mm}", "ios/PhotoLibrary/*.{h,m,mm}", "ios/Camera/*.{h,m,mm}", "ios/Contacts/*.{h,m,mm}", "ios/Motion/*.{h,m,mm}", "ios/CalendarsWriteOnly/*.{h,m,mm}", "ios/AppTrackingTransparency/*.{h,m,mm}", "ios/LocationAccuracy/*.{h,m,mm}", "ios/Bluetooth/*.{h,m,mm}", "ios/MediaLibrary/*.{h,m,mm}", "ios/Notifications/*.{h,m,mm}", "ios/Reminders/*.{h,m,mm}"

if ENV['RCT_NEW_ARCH_ENABLED'] == "1" then
install_modules_dependencies(s)
Expand Down
9 changes: 9 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ android {

if (project.android.hasProperty("namespace")) {
namespace "com.zoontek.rnpermissions"

buildFeatures {
buildConfig true
}
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"

This comment has been minimized.

Copy link
@mikehardy

mikehardy Jan 8, 2024

nice trick! Kind of fancy, but also not really tricky or anything, all normal directives from gradle.

}
}
}
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 21)
Expand Down
4 changes: 1 addition & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zoontek.rnpermissions">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.zoontek.rnpermissions">
</manifest>
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
34 changes: 17 additions & 17 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:name=".MainApplication"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
9 changes: 9 additions & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const path = require('path');
const pkg = require('../package.json');

const resolverConfig = {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
alias: {[pkg.name]: path.resolve(__dirname, '../src')},
};

module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [['module-resolver', resolverConfig]],
};
2 changes: 1 addition & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import {AppRegistry} from 'react-native';
import {Provider as PaperProvider} from 'react-native-paper';
import {App} from './App';
import {name as appName} from './app.json';
import {App} from './src/App';

let Main = () => (
<PaperProvider>
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ PODS:
- React-jsi (= 0.73.1)
- React-logger (= 0.73.1)
- React-perflogger (= 0.73.1)
- RNPermissions (4.0.2):
- RNPermissions (4.0.3):
- React-Core
- RNVectorIcons (10.0.3):
- glog
Expand Down Expand Up @@ -1382,7 +1382,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: 93a4c84e46a85c3fc9678abd4f6923b785226ea7
React-utils: debda2c206770ee2785bdebb7f16d8db9f18838a
ReactCommon: ddb128564dcbfa0287d3d1a2d10f8c7457c971f6
RNPermissions: c0129233665fc85253f53e3b6d0de4c743f3834a
RNPermissions: eb92347d8228887d9480984b6426d5b1f4eb0ec5
RNVectorIcons: 210f910e834e3485af40693ad4615c1ec22fc02b
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 4f53dc50008d626fa679c7a1cb4bed898f8c0bde
Expand Down
27 changes: 26 additions & 1 deletion example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
const path = require('path');
const pkg = require('../package.json');

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const escape = require('escape-string-regexp');
const exclusionList = require('metro-config/src/defaults/exclusionList');

const peerDependencies = Object.keys(pkg.peerDependencies);
const root = path.resolve(__dirname, '..');
const projectNodeModules = path.join(__dirname, 'node_modules');
const rootNodeModules = path.join(root, 'node_modules');

// We need to make sure that only one version is loaded for peerDependencies
// So we block them at the root, and alias them to the versions in example's node_modules
const blacklistRE = exclusionList(
peerDependencies.map((name) => new RegExp(`^${escape(path.join(rootNodeModules, name))}\\/.*$`)),
);

const extraNodeModules = peerDependencies.reduce((acc, name) => {
acc[name] = path.join(projectNodeModules, name);
return acc;
}, {});

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {};
const config = {
projectRoot: __dirname,
watchFolders: [root],
resolver: {blacklistRE, extraNodeModules},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
10 changes: 5 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
"node": ">=18"
},
"scripts": {
"clean-modules": "rm -rf ./node_modules/react-native-permissions/{example,node_modules}",
"clean": "rm -rf ./node_modules ./ios/Pods",
"preinstall": "cd .. && yarn prepack && cd example",
"postinstall": "yarn clean-modules && pod-install",
"preinstall": "cd .. && yarn && yarn build && cd example",
"postinstall": "yarn pod-install",
"start": "react-native start",
"reinstall": "yarn clean && yarn install"
},
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.1",
"react-native-paper": "^5.11.6",
"react-native-permissions": "../",
"react-native-permissions": "link:../",
"react-native-safe-area-context": "^4.8.2",
"react-native-vector-icons": "^10.0.3",
"react-native-windows": "0.73.2"
Expand All @@ -28,7 +27,8 @@
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "^0.73.18",
"@react-native/metro-config": "^0.73.2",
"@types/react": "^18.2.46",
"@types/react": "^18.2.47",
"babel-plugin-module-resolver": "^5.0.0",
"pod-install": "0.1.39",
"typescript": "^5.3.3"
}
Expand Down
7 changes: 3 additions & 4 deletions example/App.tsx → example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export const App = () => {
</Appbar.Header>

<ScrollView>
{PERMISSIONS_VALUES.map((item, index) => {
const value = PERMISSIONS_VALUES[index];
{PERMISSIONS_VALUES.map((item) => {
const parts = item.split('.');
const name = parts[parts.length - 1];

Expand All @@ -82,7 +81,7 @@ export const App = () => {
icon="eye-outline"
mode="contained"
onPress={() => {
RNPermissions.check(value)
RNPermissions.check(item)
.then((status) => {
showSnackbar(`check(${name})`, status);
})
Expand All @@ -100,7 +99,7 @@ export const App = () => {
icon="help-circle-outline"
mode="contained"
onPress={() => {
RNPermissions.request(value)
RNPermissions.request(item)
.then((status) => {
showSnackbar(`request(${name})`, status);
})
Expand Down
29 changes: 22 additions & 7 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
{
"compilerOptions": {
"module": "ESNext",
"lib": ["ES2017"],
"jsx": "react-native",
"lib": ["ES2016"],
"moduleResolution": "Node",
"target": "ESNext",

"allowJs": false,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"isolatedModules": true
"declaration": true,
"sourceMap": true,
"stripInternal": true,
"skipLibCheck": true,

"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

"paths": {
"react-native-permissions": ["../src"]
}
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": ["src"],
"exclude": ["node_modules", "babel.config.js", "metro.config.js"]
}
Loading

0 comments on commit 5b013ad

Please sign in to comment.