@maximilien0405/capacitor-android-launcher 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Maximilien0405CapacitorAndroidLauncher.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +39 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/maximilien0405/androidlauncher/AndroidLauncher.java +36 -0
- package/android/src/main/java/com/maximilien0405/androidlauncher/AndroidLauncherPlugin.java +36 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +45 -0
- package/dist/esm/definitions.d.ts +7 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/plugin.cjs.js +8 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +11 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'Maximilien0405CapacitorAndroidLauncher'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "Maximilien0405CapacitorAndroidLauncher",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "Maximilien0405CapacitorAndroidLauncher",
|
|
10
|
+
targets: ["AndroidLauncherPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "AndroidLauncherPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/AndroidLauncherPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "AndroidLauncherPluginTests",
|
|
25
|
+
dependencies: ["AndroidLauncherPlugin"],
|
|
26
|
+
path: "ios/Tests/AndroidLauncherPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @maximilien0405/capacitor-android-launcher
|
|
2
|
+
|
|
3
|
+
A Capacitor plugin that lets your Android app request to become the system launcher (home screen app), remove itself as the launcher, and check if it's currently the default launcher.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install capacitor-android-launcher
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
And then import it like that :
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { AndroidLauncher } from '@maximilien0405/capacitor-android-launcher';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Methods
|
|
19
|
+
|
|
20
|
+
``requestLauncherRole(): Promise<{ granted: boolean }>``
|
|
21
|
+
Prompts the user to set your app as the default launcher.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
const { granted } = await AndroidLauncher.requestLauncherRole();
|
|
25
|
+
```
|
|
26
|
+
<br>
|
|
27
|
+
``removeLauncherRole(): Promise<void>``
|
|
28
|
+
Opens system settings so the user can choose another default launcher.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
await AndroidLauncher.removeLauncherRole();
|
|
32
|
+
```
|
|
33
|
+
<br>
|
|
34
|
+
``isLauncherDefault(): Promise<{ isDefault: boolean }>``
|
|
35
|
+
Checks if your app is currently the default launcher.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const { isDefault } = await AndroidLauncher.isLauncherDefault();
|
|
39
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.maximilien0405.androidlauncher"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.maximilien0405.androidlauncher;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.ComponentName;
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.content.Intent;
|
|
7
|
+
import android.content.pm.PackageManager;
|
|
8
|
+
|
|
9
|
+
public class AndroidLauncher {
|
|
10
|
+
private final Activity activity;
|
|
11
|
+
|
|
12
|
+
public AndroidLauncher(Activity activity) {
|
|
13
|
+
this.activity = activity;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void requestLauncherRole() {
|
|
17
|
+
Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
18
|
+
intent.addCategory(Intent.CATEGORY_HOME);
|
|
19
|
+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
20
|
+
activity.startActivity(intent);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void removeLauncherRole() {
|
|
24
|
+
Intent intent = new Intent(Settings.ACTION_HOME_SETTINGS);
|
|
25
|
+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
26
|
+
activity.startActivity(intent);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public boolean isLauncherApp() {
|
|
30
|
+
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
31
|
+
intent.addCategory(Intent.CATEGORY_HOME);
|
|
32
|
+
final ResolveInfo res = activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
33
|
+
if (res == null || res.activityInfo == null) return false;
|
|
34
|
+
return activity.getPackageName().equals(res.activityInfo.packageName);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.maximilien0405.androidlauncher;
|
|
2
|
+
|
|
3
|
+
import android.content.Intent;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
7
|
+
|
|
8
|
+
@CapacitorPlugin(name = "AndroidLauncher")
|
|
9
|
+
public class AndroidLauncherPlugin extends Plugin {
|
|
10
|
+
private AndroidLauncher implementation;
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public void load() {
|
|
14
|
+
implementation = new AndroidLauncher(getActivity());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@com.getcapacitor.PluginMethod
|
|
18
|
+
public void requestLauncherRole(PluginCall call) {
|
|
19
|
+
implementation.requestLauncherRole();
|
|
20
|
+
call.resolve();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@com.getcapacitor.PluginMethod
|
|
24
|
+
public void removeLauncherRole(PluginCall call) {
|
|
25
|
+
implementation.removeLauncherRole();
|
|
26
|
+
call.resolve();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@com.getcapacitor.PluginMethod
|
|
30
|
+
public void isLauncherApp(PluginCall call) {
|
|
31
|
+
boolean isLauncher = implementation.isLauncherApp();
|
|
32
|
+
JSObject ret = new JSObject();
|
|
33
|
+
ret.put("isLauncher", isLauncher);
|
|
34
|
+
call.resolve(ret);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AndroidLauncherPlugin",
|
|
4
|
+
"slug": "androidlauncherplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "requestLauncherRole",
|
|
10
|
+
"signature": "() => Promise<void>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<void>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "",
|
|
15
|
+
"complexTypes": [],
|
|
16
|
+
"slug": "requestlauncherrole"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "removeLauncherRole",
|
|
20
|
+
"signature": "() => Promise<void>",
|
|
21
|
+
"parameters": [],
|
|
22
|
+
"returns": "Promise<void>",
|
|
23
|
+
"tags": [],
|
|
24
|
+
"docs": "",
|
|
25
|
+
"complexTypes": [],
|
|
26
|
+
"slug": "removelauncherrole"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "isLauncherApp",
|
|
30
|
+
"signature": "() => Promise<{ isLauncher: boolean; }>",
|
|
31
|
+
"parameters": [],
|
|
32
|
+
"returns": "Promise<{ isLauncher: boolean; }>",
|
|
33
|
+
"tags": [],
|
|
34
|
+
"docs": "",
|
|
35
|
+
"complexTypes": [],
|
|
36
|
+
"slug": "islauncherapp"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"properties": []
|
|
40
|
+
},
|
|
41
|
+
"interfaces": [],
|
|
42
|
+
"enums": [],
|
|
43
|
+
"typeAliases": [],
|
|
44
|
+
"pluginConfigs": []
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface AndroidLauncherPlugin {\n requestLauncherRole(): Promise<void>;\n removeLauncherRole(): Promise<void>;\n isLauncherApp(): Promise<{ isLauncher: boolean }>;\n}"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AndroidLauncherPlugin {
|
|
2
|
+
requestLauncherRole(): Promise<void>;
|
|
3
|
+
removeLauncherRole(): Promise<void>;
|
|
4
|
+
isLauncherApp(): Promise<{
|
|
5
|
+
isLauncher: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
declare const AndroidLauncher: AndroidLauncherPlugin;
|
|
9
|
+
export * from './definitions';
|
|
10
|
+
export { AndroidLauncher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQjD,MAAM,eAAe,GAAG,cAAc,CAAwB,iBAAiB,CAAC,CAAC;AAEjF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nexport interface AndroidLauncherPlugin {\n requestLauncherRole(): Promise<void>;\n removeLauncherRole(): Promise<void>;\n isLauncherApp(): Promise<{ isLauncher: boolean }>;\n}\n\nconst AndroidLauncher = registerPlugin<AndroidLauncherPlugin>('AndroidLauncher');\n\nexport * from './definitions';\nexport { AndroidLauncher };"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AndroidLauncher = registerPlugin('AndroidLauncher');\nexport * from './definitions';\nexport { AndroidLauncher };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var capacitorAndroidLauncher = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const AndroidLauncher = core.registerPlugin('AndroidLauncher');
|
|
5
|
+
|
|
6
|
+
exports.AndroidLauncher = AndroidLauncher;
|
|
7
|
+
|
|
8
|
+
return exports;
|
|
9
|
+
|
|
10
|
+
})({}, capacitorExports);
|
|
11
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AndroidLauncher = registerPlugin('AndroidLauncher');\nexport * from './definitions';\nexport { AndroidLauncher };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maximilien0405/capacitor-android-launcher",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Capacitor plugin to set your android app as launcher.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"Maximilien0405CapacitorAndroidLauncher.podspec"
|
|
17
|
+
],
|
|
18
|
+
"author": "Maximilien Z.",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/maximilien0405/capacitor-android-launcher.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/maximilien0405/capacitor-android-launcher/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"plugin",
|
|
30
|
+
"native"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
34
|
+
"verify:ios": "xcodebuild -scheme Maximilien0405CapacitorAndroidLauncher -destination generic/platform=iOS",
|
|
35
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
|
+
"verify:web": "npm run build",
|
|
37
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
39
|
+
"eslint": "eslint . --ext ts",
|
|
40
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
|
+
"swiftlint": "node-swiftlint",
|
|
42
|
+
"docgen": "docgen --api AndroidLauncherPlugin --output-readme README.md --output-json dist/docs.json",
|
|
43
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
44
|
+
"clean": "rimraf ./dist",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@capacitor/android": "^7.0.0",
|
|
50
|
+
"@capacitor/core": "^7.0.0",
|
|
51
|
+
"@capacitor/docgen": "^0.3.0",
|
|
52
|
+
"@capacitor/ios": "^7.0.0",
|
|
53
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
54
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
55
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
|
+
"prettier-plugin-java": "^2.6.6",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"rollup": "^4.30.1",
|
|
61
|
+
"swiftlint": "^2.0.0",
|
|
62
|
+
"typescript": "~4.1.5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@capacitor/core": ">=7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": "@ionic/prettier-config",
|
|
68
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
71
|
+
},
|
|
72
|
+
"capacitor": {
|
|
73
|
+
"android": {
|
|
74
|
+
"src": "android"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|