Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
Massi-X committed Sep 26, 2023
0 parents commit 1bcc59e
Show file tree
Hide file tree
Showing 29 changed files with 1,334 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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
release/

# 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

# Common credential files
**/credentials.json
**/client_secrets.json
**/client_secret.json
*creds*
*.dat
*password*
*.httr-oauth*

# Mac/OSX
.DS_Store
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<table>
<tr>
<td width="200" style="border: none;">
<img src="app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" alt="Module icon"/>
</td>
<td style="border: none;">
<h2>Vibration Enable for Battery Saver</h2>
</td>
</tr>
</table>

## About this
This simple app was born because I always missed calls when in battery saver with vibration mode enabled, but why? Because Google thinks that vibration consumes so much juice it is a good idea to disable it completely when the battery is low. While this is understandable, they should also consider that the phone won't ring, so how do you find out someone is calling?

To fix this simply install the app and follow the instruction to enable Accessibility access and you will get your vibration back 🤩.

Find the latest release [here](https://github.com/Massi-X/vibrationenable/releases/latest).

## Development
Pull the main repo, make the appropriate changes, then compile it using [Android Studio](https://developer.android.com/studio). Should work out of the box.

## Donation
If you like to support me, you can donate. Any help is greatly appreciated. Thank you!

<a target="_blank" href="https://paypal.me/firemetris"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="paypal"/></a>

**Bitcoin:** 1Pig6XJxXGBj1v3r6uLrFUSHwyX8GPopRs

**Monero:** 89qdmpDsMm9MUvpsG69hbRMcGWeG2D26BdATw1iXXZwi8DqSEstJGcWNkenrXtThCAAJTpjkUNtZuQvxK1N5xSyb18eXzPD

## License
`SPDX-License-Identifier: AGPL-3.0`<br>
This work is licensed under <a target="_blank" href="https://spdx.org/licenses/AGPL-3.0.html">GNU Affero General Public License v3.0</a><br>
By using this project you agree to the terms.
33 changes: 33 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id 'com.android.application'
}

android {
compileSdk 33
compileSdkVersion 33
buildToolsVersion '33.0.0'
namespace 'com.metris.vibrationfix'

defaultConfig {
applicationId "com.metris.vibrationfix"
minSdk 21 //5.0 Lollipop
targetSdk 33
versionCode 7
versionName "1.0.2"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
22 changes: 22 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
-keepattributes EnclosingMethod
38 changes: 38 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Don't declare any permission to let the app be hidden -->

<application
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/Theme.VibrationFix">
<activity android:name="com.metris.vibrationfix.MainActivity" />

<service
android:name=".DummyService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:label="@string/app_name"
android:exported="false">
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/service_config" />
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>

<activity-alias
android:name=".MainAlias"
android:exported="true"
android:targetActivity="com.metris.vibrationfix.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
</application>

</manifest>
12 changes: 12 additions & 0 deletions app/src/main/java/com/metris/vibrationfix/DummyService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.metris.vibrationfix;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class DummyService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
75 changes: 75 additions & 0 deletions app/src/main/java/com/metris/vibrationfix/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.metris.vibrationfix;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Objects;

public class MainActivity extends Activity {
private AlertDialog alert;
private boolean dismissForConfigChange = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//hide all the graphics because we use the dialog only
setTitle("");
overridePendingTransition(0, 0);

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Theme_Dialog)
.setTitle(R.string.dialog_title)
.setMessage(R.string.info_text)
.setNeutralButton(R.string.accessibility_page, (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(R.string.hide_app, (dialog, which) -> {
Toast.makeText(this, R.string.goodbye, Toast.LENGTH_LONG).show();
//hide in the standard Android way (supported on Android 10+ because no permissions)
MainActivity.this.getPackageManager().setComponentEnabledSetting(
new ComponentName(BuildConfig.APPLICATION_ID, BuildConfig.APPLICATION_ID + ".MainAlias"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
})
.setPositiveButton(R.string.support_me, (dialog, which) ->
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_store)))))
.setOnDismissListener((dialog) -> {
if (!dismissForConfigChange)
new Handler(Objects.requireNonNull(Looper.myLooper())).postDelayed(MainActivity.this::finish, 250);
dismissForConfigChange = false;
});

alert = builder.create();
alert.setOnShowListener(dialogInterface -> {
TextView msg = alert.findViewById(android.R.id.message);
if (msg != null)
msg.setMovementMethod(LinkMovementMethod.getInstance());
});
alert.show();
}

@Override
protected void onDestroy() {
super.onDestroy();
if (alert != null && alert.isShowing()) {
dismissForConfigChange = true;
alert.dismiss();
}
}
}
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108"
android:tint="@android:color/white">
<group
android:scaleX="0.9225"
android:scaleY="0.9225"
android:translateX="31.86"
android:translateY="31.86">
<path
android:fillColor="@android:color/white"
android:pathData="M0,29.75V18.25H3V29.75ZM6,34.15V13.85H9V34.15ZM45,29.75V18.25H48V29.75ZM39,34.15V13.85H42V34.15ZM15,42Q13.8,42 12.9,41.1Q12,40.2 12,39V9Q12,7.8 12.9,6.9Q13.8,6 15,6H33Q34.2,6 35.1,6.9Q36,7.8 36,9V39Q36,40.2 35.1,41.1Q34.2,42 33,42ZM15,39H33Q33,39 33,39Q33,39 33,39V9Q33,9 33,9Q33,9 33,9H15Q15,9 15,9Q15,9 15,9V39Q15,39 15,39Q15,39 15,39ZM15,39Q15,39 15,39Q15,39 15,39V9Q15,9 15,9Q15,9 15,9Q15,9 15,9Q15,9 15,9V39Q15,39 15,39Q15,39 15,39Z" />
</group>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#424242</color>
<color name="text">#fafafa</color>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-v22/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<style name="Theme" parent="android:Theme.DeviceDefault.Light.Dialog.Alert"/>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values-v31/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#FFEBEE</color>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#fff</color>
<color name="text">#424242</color>
<color name="buttons">@color/text</color>
<color name="ic_launcher_background">#EF5350</color>
</resources>
24 changes: 24 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<resources>
<string name="app_name" translatable="false">Vibration Enable</string>
<string name="url_store" translatable="false">https://play.google.com/store/apps/dev?id=5916168791200129933</string>

<string name="dialog_title">Vibration Enable by Massi-X</string>
<string name="info_text">Vibration Enable is a simple app to restore vibration when the device has battery saver turned on.
\nBy default when battery saver is \'ON\' vibration will be disabled, I can understand why but if you leave the phone on vibrate mode only you will
miss everything because the phone will not ring nor vibrate.
\n
\nTo fix this simply enable accessibility service for the app, this will be enough to make the phone vibrate again. The accessibility service is only a dummy one,
no data will be ever collected.
\n
\nIf you would like to support my work you can buy one of my other apps, Thank you!
\nIf you like instead to stop me worrying you with this you can hide the icon 😭
\n
\n<a href="https://massi-x.github.io/vibration_enable/privacy/">Have a look at the privacy policy.</a>
</string>
<string name="info_accessibility">Turn on this to bring back vibration even when battery saver is ON. No data is used or collected!</string>
<string name="accessibility_page">Open Settings</string>
<string name="support_me">My Apps</string>
<string name="hide_app">Hide icon</string>
<string name="goodbye">Goodbye my lover…</string>
<string name="activity_not_found">Activity not found! Open the settings manually.</string>
</resources>
21 changes: 21 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<resources>
<style name="Theme" parent="android:Theme.Material.Dialog.Alert"/>

<style name="Theme.VibrationFix">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>

<style name="Theme.Dialog">
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundTint">@color/background</item>
<item name="android:textColorPrimary">@color/text</item>
<item name="android:colorAccent">@color/buttons</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/xml/service_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service android:description="@string/info_accessibility"
xmlns:android="http://schemas.android.com/apk/res/android" />
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
}
Loading

0 comments on commit 1bcc59e

Please sign in to comment.