Skip to content

Commit

Permalink
rova: parts: Introduce battery-friendly Pocket Judge
Browse files Browse the repository at this point in the history
* import from: https://github.com/iusmac/battery-friendly-pocketmode

Co-authored-by: maytinhdibo <iammaytinhdibo@gmail.com>
Signed-off-by: iusmac <iusico.maxim@libero.it>
  • Loading branch information
iusmac and maytinhdibo committed Oct 12, 2022
1 parent e2fc608 commit de14e48
Show file tree
Hide file tree
Showing 58 changed files with 1,104 additions and 2 deletions.
3 changes: 1 addition & 2 deletions overlay/frameworks/base/core/res/res/values/cr_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
-->
<resources>
<!-- Pocket Lock -->
<bool name="config_pocketModeSupported">true</bool>
<bool name="config_pocketUseLightSensor">true</bool>
<bool name="config_pocketModeSupported">false</bool>

<!-- Whether device supports sensor based doze customizations -->
<bool name="config_dozePulsePickup">true</bool>
Expand Down
30 changes: 30 additions & 0 deletions parts/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<uses-permission android:name="android.permission.INJECT_EVENTS"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<protected-broadcast android:name="org.lineageos.settings.smartcharging.BatteryMonitorReceiver" />

Expand Down Expand Up @@ -116,5 +117,34 @@
<action android:name="android.content.action.SEARCH_INDEXABLES_PROVIDER" />
</intent-filter>
</provider>

<service
android:name=".pocketjudge.PocketJudgeService"
android:exported="false">
</service>

<activity
android:name=".pocketjudge.PocketJudgeActivity"
android:exported="true"
android:label="@string/pocket_judge_title">
<intent-filter>
<action android:name="com.android.settings.action.IA_SETTINGS" />
</intent-filter>
<meta-data
android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.display" />
<meta-data
android:name="com.android.settings.summary"
android:resource="@string/pocket_judge_summary" />
</activity>

<receiver
android:name=".PhoneStateReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
4 changes: 4 additions & 0 deletions parts/proguard.flags
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
-keep class org.lineageos.settings.smartcharging.* {
*;
}

-keep class org.lineageos.settings.pocketjudge.* {
*;
}
25 changes: 25 additions & 0 deletions parts/res/drawable/ic_pocket.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 crDroid Android Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24.0dp"
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M22 12a10 10 0 0 1-10 10A10 10 0 0 1 2 12V4.5A2.5 2.5 0 0 1 4.5 2h15A2.5 2.5 0 0 1 22 4.5V12m-6.12-3.75L12 12.13 8.12 8.24a1.5 1.5 0 0 0-2.12 0 1.5 1.5 0 0 0 0 2.12l4.93 4.96c.57.58 1.54.58 2.13 0L18 10.37a1.5 1.5 0 0 0 0-2.12 1.5 1.5 0 0 0-2.12 0Z" />
</vector>
27 changes: 27 additions & 0 deletions parts/res/drawable/illustration_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/illustration_color"/>
<corners android:radius="28dp"/>
<size android:width="412dp"
android:height="300dp"/>
</shape>
</item>
</layer-list>
27 changes: 27 additions & 0 deletions parts/res/drawable/pocket_judge_phone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2022 iusmac <iusico.maxim@libero.it>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="185dp"
android:viewportWidth="100"
android:viewportHeight="185">
<path
android:pathData="M86.9,24.8H13c0,-1.8 0,-3.5 0.8,-5.2a7.5,7.5 0,0 1,7 -4.2h58.3c3.7,0 7.2,3 7.6,6.6v2.8Z"
android:fillColor="#8ab4f8"/>
<path
android:pathData="M90,92.5v69a10.9,10.9 0,0 1,-10.5 11.3H21a11,11 0,0 1,-11 -11V23.2a11,11 0,0 1,11 -11h58a11,11 0,0 1,11 11.3v69ZM13.1,24.8a1248615.75,1248615.75 0,0 0,0.3 138.7c0.9,3.8 4,6.1 7.8,6.1a276710.5,276710.5 0,0 0,59.6 -0.2c3.7,-0.9 6,-4 6,-7.8V22a7.8,7.8 0,0 0,-7.5 -6.7H20.9a7.5,7.5 0,0 0,-7 4.3,9.2 9.2,0 0,0 -0.8,5.2Z"
android:fillColor="#dadce0"/>
<path
android:pathData="M50,99.9a2.7,2.7 0,1 1,0 -5.4c2,0 3.4,2.3 2.3,4 -0.4,0.9 -1.3,1.4 -2.3,1.4m8,4V90.5H42v13.3H58m0,-16c1.4,0 2.7,1.2 2.7,2.7v13.3c0,1.6 -1.2,2.8 -2.7,2.8H42a2.7,2.7 0,0 1,-2.7 -2.7V90.5c0,-1.5 1.2,-2.7 2.7,-2.7h1.4v-2.7a6.7,6.7 0,1 1,13.4 0v2.7H58M50,81.2a4,4 0,0 0,-4 4v2.6h8v-2.7a4,4 0,0 0,-4 -4Z"
android:fillColor="#dadce0"/>
</vector>
34 changes: 34 additions & 0 deletions parts/res/layout/pocketjudge_illustration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2022 iusmac <iusico.maxim@libero.it>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="412dp"
android:layout_height="300dp"
android:layout_gravity="center"
android:gravity="center_vertical"
android:paddingHorizontal="16dp"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/illustration_background"
android:contentDescription="@null" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/pocket_judge_phone"
android:contentDescription="@null" />
</FrameLayout>
9 changes: 9 additions & 0 deletions parts/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@
<!-- Misc -->
<string name="not_now">"ليس الآن"</string>
<string name="next_update_time">التحديث التالي: في %1$s</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">إستشعار الجيب</string>
<string name="pocket_judge_summary">الغاء تفعيل الشاشة و أزرار الإدخال عندما يكون الجهاز في الجيب</string>
<string name="pocket_judge_notif_title">وضع الجيب قيد التشغيل</string>
<string name="pocket_judge_notif_msg">اضغط مع الاستمرار على زر الطاقة ﻹلغاء القفل</string>
<string name="pocket_judge_demo_title_cancel">لاستخدام هاتفك:</string>
<string name="pocket_judge_demo_tag_cancel">تحقق مما إذا كانت المنطقة الزرقاء في هاتفك خالية من أي عرقلة، وقم بتنظيف أي تراب أو غبار.</string>
<string name="pocket_judge_demo_tag_cancel2">اضغط مطولاً على زر الطاقة لفرض الخروج عن وضع الجيب.</string>
</resources>
7 changes: 7 additions & 0 deletions parts/res/values-az-rAZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@
<string name="dirac_preset_country">Kantri</string>
<string name="dirac_preset_dance">Rəqs</string>
<string name="dirac_preset_metal">Metal</string>

<!-- Pocket Judge -->
<string name="pocket_judge_notif_title">Cib rejimi açıqdır</string>
<string name="pocket_judge_notif_msg">Kilidi açmaq üçün güc düyməsinə basıb saxlayın</string>
<string name="pocket_judge_demo_title_cancel">Telefonunu istifadə et:</string>
<string name="pocket_judge_demo_tag_cancel">Telefonun mavi hissəsində hər hansı tozun olub olmadığını yoxlayın və əgər varsa onları təmizləyin.</string>
<string name="pocket_judge_demo_tag_cancel2">Cib rejimindən çıxmağa məcbur etmək üçün güc düyməsinə uzun basın.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-be-rBY/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@
<!-- Misc -->
<string name="not_now">"Не цяпер"</string>
<string name="next_update_time">Наступнае абнаўленне: а %1$s</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Рэжым "У кішэні"</string>
<string name="pocket_judge_summary">Блакаваць экран і кнопкі, калі прылада знаходзіцца ў кішэні</string>
<string name="pocket_judge_notif_title">Рэжым "У кішэні" уключаны</string>
<string name="pocket_judge_notif_msg">Націсніце і ўтрымлівайце кнопку сілкавання, каб разблакаваць</string>
<string name="pocket_judge_demo_title_cancel">Для выкарыстання тэлефона:</string>
<string name="pocket_judge_demo_tag_cancel">Праверце, ці не закрыта сіняя вобласць вашага тэлефона якімі-небудзь прадметамі, і ачысціце ад бруду або пылу.</string>
<string name="pocket_judge_demo_tag_cancel2">Доўгі націск кнопкі сілкавання для прымусовага выхаду з рэжыму \"У кішэні\".</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-bg-rBG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@

<!-- Misc -->
<string name="not_now">"Не сега"</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Разпознаване при носене</string>
<string name="pocket_judge_summary">Изключване на екрана и бутоните, когато устройството е в джоба</string>
<string name="pocket_judge_notif_title">Джобен режим е включен</string>
<string name="pocket_judge_notif_msg">Натиснете и задръжте бутона за изключване, за да отключите</string>
<string name="pocket_judge_demo_title_cancel">За да използвате телефона:</string>
<string name="pocket_judge_demo_tag_cancel">Проверете дали синята зона на телефона ви е чиста</string>
<string name="pocket_judge_demo_tag_cancel2">Натиснете и задръжте бутона за изключване за да премахнете \"джобният режим\"</string>
</resources>
3 changes: 3 additions & 0 deletions parts/res/values-bn-rBD/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@
<string name="smart_charging_reset_stats_title">ব্যাটারির পরিসংখ্যান রিসেট করুন</string>
<string name="smart_charging_reset_stats_summary">ব্যবহারকারীর নির্ধারিত চার্জিং সীমা পৌঁছানোর পরে ব্যাটারি পরিসংখ্যান পুনরায় চালু</string>
<string name="smart_charging_footer">স্মার্ট চার্জিং আপনাকে ব্যাটারির আয়ু বাড়ানোর জন্য সর্বোচ্চ চার্জিং লেভেল সেট করতে দেয়। সক্রিয় করা হলে, ব্যাটারি স্টপ ট্রিগার লেভেলে চার্জ করা বন্ধ করে এবং স্টার্ট ট্রিগার লেভেলে চার্জিং আবার শুরু করে। স্টপ ট্রিগার লেভেল সবসময় স্টার্ট ট্রিগার লেভেলের চেয়ে বড় হওয়া উচিত।.</string>
<string name="pocket_judge_demo_title_cancel">To use your phone:</string>
<string name="pocket_judge_demo_tag_cancel">Check if the blue area of your phone is clear of any obstructions, and clean off any dirt or dust.</string>
<string name="pocket_judge_demo_tag_cancel2">Long press the power button to force quit pocket mode.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@

<!-- Misc -->
<string name="not_now">"Ara no"</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Detecció de butxaca</string>
<string name="pocket_judge_summary">Bloqueja les entrades de pantalla i de botó quan el dispositiu es troba a la butxaca</string>
<string name="pocket_judge_notif_title">El mode butxaca està activat</string>
<string name="pocket_judge_notif_msg">Prem i mantén el botó d’encesa per desbloquejar</string>
<string name="pocket_judge_demo_title_cancel">Per a utilitzar el teu telèfon:</string>
<string name="pocket_judge_demo_tag_cancel">Comprova si l\'àrea blava del teu telèfon està lliure d\'obstruccions i neteja tota la pols i brutícia.</string>
<string name="pocket_judge_demo_tag_cancel2">Deixa premut el botó d\'encesa per a treure el mode butzaca de forma forçada.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@

<!-- Misc -->
<string name="not_now">"Teď ne"</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Detekce uložení vu00a0kapse</string>
<string name="pocket_judge_summary">Blokovat obrazovku au00a0hardwarová tlačítka, když je zařízení vu00a0kapse</string>
<string name="pocket_judge_notif_title">Režim vu00a0kapse je zapnutý</string>
<string name="pocket_judge_notif_msg">Stisknutím au00a0podržením tlačítka napájení zapnout obrazovku</string>
<string name="pocket_judge_demo_title_cancel">Pro použití telefonu:</string>
<string name="pocket_judge_demo_tag_cancel">Zkontrolujte, zda je modrá oblast zařízení bez jakýchkoliv překážek a\u00a0vyčistěte případné nečistoty nebo prach.</string>
<string name="pocket_judge_demo_tag_cancel2">Dlouhým stiskem tlačítka Napájení vynutíte ukončení režimu v\u00a0kapse.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@
<!-- Misc -->
<string name="not_now">"Später"</string>
<string name="next_update_time">Nächste Aktualisierung um %1$s Uhr</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Taschenerkennung</string>
<string name="pocket_judge_summary">Bildschirm- und Tasteneingaben blockieren, wenn das Gerät in der Tasche steckt</string>
<string name="pocket_judge_notif_title">Taschenmodus aktiviert</string>
<string name="pocket_judge_notif_msg">Zum Entsperren Ein-/Aus-Taste gedrückt halten</string>
<string name="pocket_judge_demo_title_cancel">Um das Gerät zu verwenden:</string>
<string name="pocket_judge_demo_tag_cancel">Vergewissere dich, dass die blau dargestellte Zone nicht blockiert ist und reinige sie gegebenenfalls.</string>
<string name="pocket_judge_demo_tag_cancel2">Ein-/Aus-Taste gedrückt halten, um den Taschenmodus zu beenden.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@

<!-- Misc -->
<string name="not_now">"Όχι τώρα"</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Ανίχνευση τσέπης</string>
<string name="pocket_judge_summary">Μπλοκάρισμα οθόνης και πλήκτρων όταν η συσκευή είναι στην τσέπη</string>
<string name="pocket_judge_notif_title">Η λειτουργία τσέπης είναι ενεργοποιημένη</string>
<string name="pocket_judge_notif_msg">Πατήστε παρατεταμένα το κουμπί λειτουργίας για ξεκλείδωμα</string>
<string name="pocket_judge_demo_title_cancel">Για να χρησιμοποιήσετε το τηλέφωνό σας:</string>
<string name="pocket_judge_demo_tag_cancel">Ελέγξτε εάν η μπλε περιοχή του τηλεφώνου σας είναι καθαρή από τυχόν εμπόδια, και καθαρίστε τη βρωμιά ή τη σκόνη.</string>
<string name="pocket_judge_demo_tag_cancel2">Πατήστε παρατεταμένα το κουμπί λειτουργίας για αναγκαστική έξοδο από τη λειτουργία τσέπης.</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@
<!-- Misc -->
<string name="not_now">"Ahora no"</string>
<string name="next_update_time">Próxima actualización a las %1$s</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Detección de bolsillo</string>
<string name="pocket_judge_summary">Bloquear pantalla y botones cuando el dispositivo esté en un bolsillo</string>
<string name="pocket_judge_notif_title">Modo bolsillo activado</string>
<string name="pocket_judge_notif_msg">Mantén pulsado el botón de encendido para desbloquear</string>
<string name="pocket_judge_demo_title_cancel">Para usar su teléfono:</string>
<string name="pocket_judge_demo_tag_cancel">Compruebe si la zona azul de su teléfono está libre de cualquier obstrucción, y limpie cualquier suciedad o polvo.</string>
<string name="pocket_judge_demo_tag_cancel2">Mantén pulsado el botón encendido para forzar el apagado del modo bolsillo.</string>
</resources>
4 changes: 4 additions & 0 deletions parts/res/values-es-rVE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
<!-- Misc -->
<string name="not_now">"Ahora no"</string>
<string name="next_update_time">Próxima actualización a las %1$s</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Detección de bolsillo</string>
<string name="pocket_judge_summary">Bloquear pantalla y botones cuando el dispositivo esté en un bolsillo</string>
</resources>
9 changes: 9 additions & 0 deletions parts/res/values-et-rEE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@

<!-- Misc -->
<string name="not_now">"Mitte kohe"</string>

<!-- Pocket Judge -->
<string name="pocket_judge_title">Taskutuvastus</string>
<string name="pocket_judge_summary">Blokeeri ekraan ja nupusisendid, kui seade on taskus</string>
<string name="pocket_judge_notif_title">Taskurežiim on sees</string>
<string name="pocket_judge_notif_msg">Avamiseks vajuta ja hoia all toitenuppu</string>
<string name="pocket_judge_demo_title_cancel">Telefoni kasutamiseks:</string>
<string name="pocket_judge_demo_tag_cancel">Kontrolli, et sinu telefoni sinine ala on takistustest vaba ning eemalda mistahes tolm või mustus.</string>
<string name="pocket_judge_demo_tag_cancel2">Taskurežiimist sundväljumiseks vajuta pikalt toitenuppu.</string>
</resources>
Loading

0 comments on commit de14e48

Please sign in to comment.