Skip to content

Commit

Permalink
init: replaceCursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Jan 27, 2024
0 parents commit 13c414e
Show file tree
Hide file tree
Showing 55 changed files with 1,951 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build

on:
push:
branches: [ master ]
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/workflows/issue.yml'
- '**.md'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Build the app
run: |
if [ ! -f "gradlew" ]; then gradle wrapper; fi
chmod +x gradlew
./gradlew assemble --stacktrace
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: my-build-apk
path: app/build/outputs/apk

- name: Upload mapping
uses: actions/upload-artifact@v3
with:
name: mapping
path: app/build/outputs/mapping
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 LY <ly-niko@qq.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Replace Cursor

Replace mouse cursor with a custom one.

自定义包括鼠标指针、触控点在内的各种图片资源。

Note: You can use Magisk + [RRO](https://source.android.com/docs/core/runtime/rros) for better experience.
See `magisk` folder for more information.
(be aware of SELinux context, btw.)

## How to use / 用法

> Tested on: None
1. Select `System framework` (package name may be `android` or `system` or empty, [see this](https://github.com/LSPosed/LSPosed/releases/tag/v1.9.1)) in module scope and activate the module
2. Force stop module
3. Add resources to change. Please make sure that image sizes are bigger than hotspot (cursor left-top corner / touch point), otherwise nothing will show.
4. Reboot (you MUST reboot when you modify anything, or changes will not be applied until next reboot)
5. Reverse engineer `/system/framework/framework-res.apk` to find out the resource ID of the cursor you want to replace.

For MiPad users, install [MaxMiPad](https://github.com/Xposed-Modules-Repo/com.yifeplayte.maxmipadinput/releases/latest) and enable `No Magic Pointer`.

## Common resources / 常用资源

From MIUI 13, Android 12.

| Resource ID | Desciption | HotSpot |
|--------------------|----------------------------------------------------------------|----------|
| pointer_spot_touch | Touch point | (22, 22) |
| pointer_arrow | Mouse Pointer (Arrow) | (5, 5) |
| pointer_hand | Mouse Pointer (Hand, for example when hover on sth. clickable) | (9, 4) |

Mouse-related resource-id may have a `_large` suffix, used when `Accessibility` -> `Large mouse pointer`(`大号鼠标指针`) is enabled.

## Module Scope

- android

## Project URL

Home URL: <https://github.com/Young-Lord/replaceCursor>

Xposed Modules Repo URL: <https://github.com/Xposed-Modules-Repo/moe.lyniko.replacecursor>

## License

Apache-2.0 License or MIT License are all OK.

## Thanks

- <https://github.com/thesandipv/pointer_replacer> (doesn't work for me)
- <https://github.com/hujiayucc/R-Pointer> (per-app configuration)
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
72 changes: 72 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'moe.lyniko.replacecursor'
compileSdk 34

defaultConfig {
applicationId "moe.lyniko.replacecursor"
minSdk 29
targetSdk 34
versionCode 202
versionName "2.0.2"
}

buildTypes {
release {
zipAlignEnabled true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-debug'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
buildConfig true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.3'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {
// module stuff
compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'me.zhanghai.compose.preference:library:1.0.0'

// ui stuff
implementation "com.google.accompanist:accompanist-drawablepainter:0.28.0"
implementation "androidx.navigation:navigation-compose:2.7.6"
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'


debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
33 changes: 33 additions & 0 deletions app/magisk/META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/sbin/sh

#################
# Initialization
#################

umask 022

# echo before loading util_functions
ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}

#########################
# Load util_functions.sh
#########################

OUTFD=$2
ZIPFILE=$3

mount /data 2>/dev/null

[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk

install_module
exit 0
1 change: 1 addition & 0 deletions app/magisk/META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#MAGISK
5 changes: 5 additions & 0 deletions app/magisk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Example Magisk module for replacing cursor.

Modified by LY at <https://github.com/Xposed-Modules-Repo/moe.lyniko.replacecursor>

Change SELinux context: `su -c chcon u:object_r:vendor_overlay_file:s0 /data/adb/modules/pointer_replacer_rro/system/vendor/overlay/allusive_rro_sign.apk`
6 changes: 6 additions & 0 deletions app/magisk/module.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=pointer_replacer_rro
name=Pointer Replacer RRO
version=v2.0
versionCode=2
author=thesandipv
description=Magisk Implementation of Pointer Replacer RRO, from https://github.com/sandipv22/pointer_replacer/
24 changes: 24 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class moe.lyniko.replacecursor.MainHook
# -keep class rikka.shizuku.SystemServiceHelper
# -keep class android.** { *; }
50 changes: 50 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HideRecentTask"
android:name="moe.lyniko.replacecursor.MyApplication"
tools:targetApi="31">
<meta-data
android:name="xposedmodule"
android:value="true"/>
<meta-data
android:name="xposeddescription"
android:value="@string/xposeddescription" />
<meta-data
android:name="xposedminversion"
android:value="93"/>
<meta-data
android:name="xposedsharedprefs"
android:value="true"/>
<meta-data
android:name="xposedscope"
android:resource="@array/xposedscope"/>
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS"/>
</intent-filter>
</activity>
<provider
android:name="moe.lyniko.replacecursor.ImageProvider"
android:authorities="moe.lyniko.replacecursor.ImageProvider"
android:exported="true"
android:enabled="true"
android:directBootAware="true" />
</application>

</manifest>
1 change: 1 addition & 0 deletions app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
moe.lyniko.replacecursor.MainHook
Loading

0 comments on commit 13c414e

Please sign in to comment.