Skip to content

Commit

Permalink
feat(#1): add an arbitrary number of schedules per SIM card (#24)
Browse files Browse the repository at this point in the history
* Convert `SIM PIN` preference to a FAB button

* Add the `Add` FAB button

* Drop `Reset` scheduler option

* Bring in alarm card layout from `DeskClock` app for schedule items

* fix(ToolbarDecorator): detect layout direction & set relative padding during measurements

In the previous implementation we attempted to detect layout direction
& set relative padding during construction, which may not always be
ready (e.g., in split-screen), resulting in "LTR" padding whereas it's
actually "RTL".

* Update and remove unused translations

* Import translations

* Fix handling `single-schedule`s

1. When AlarmReceiver triggers the sync of all SIM subscriptions with
   their weekly repeat schedules, it overrides user's preference, i.e
   when the SIM card is expected to be disabled/enabled, but the user
   enabled/disabled it manually, so we want to keep the state within the
   allowed period. Currently, this breaks so-called "single-schedule"s,
   i.e., a schedule that doesn't have an opposite schedule that could
   invert the action.
   Fortunately, in the context of AlarmReceiver, we actually don't need
   to force override user's preference at all, because the alarm will
   always fire in the future, and at some point the
   Last{Act/Deact}-ivatedTime fields of the SIM card that we're
   checking to determine the expected state, will be behind the nearest
   schedule at the moment of synchronization.

2. When schedules of a particular SIM subscription are explicitly
   mutated by the user, we trigger the sync of all SIM subscriptions
   with their weekly repeat schedules. Again, we must override user's
   preference in order for the changes to take effect, but we need to do
   this only for the affected SIM subscription, which makes sense
   logically.
   p.s. The previous approach was literally a "left-over" from the
   "alpha" release and was already an overkill even before the
   "single-schedule" support was added, so it's also a tweak.

* Update README & images
  • Loading branch information
iusmac authored Aug 11, 2024
1 parent 7bf3233 commit 97d5aff
Show file tree
Hide file tree
Showing 131 changed files with 5,774 additions and 1,377 deletions.
3 changes: 2 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android_app {
static_libs: [
"SettingsLibBannerMessagePreference",
"SettingsLibCollapsingToolbarBaseActivity",
"SettingsLibMainSwitchPreference",
"SettingsLibLayoutPreference",
"SettingsLibSettingsTheme",
"SettingsLibTwoTargetPreference",
"androidx.annotation_annotation",
Expand All @@ -27,6 +27,7 @@ android_app {
"androidx.lifecycle_lifecycle-livedata",
"androidx.lifecycle_lifecycle-viewmodel",
"androidx.preference_preference",
"androidx.recyclerview_recyclerview",
"androidx.room_room-runtime",
"hilt_android",
],
Expand Down
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ If you're a normal user willing to give it a try, see [Installation](#installati
##### Screenshots
<p>
<img src="images/home-a13-dark.jpg" width="200" alt="Home A13 Dark Screenshot" />
<img src="images/scheduler-a14-light.jpg" width="200" alt="Scheduler A14 Light Screenshot" />
<img src="images/scheduler-a14-light.gif" width="200" alt="Scheduler A14 Light Screencast" />
<img src="images/home-a10-light.jpg" width="200" alt="Home A10 Light Screenshot" />
<img src="images/scheduler-a10-dark.jpg" width="200" alt="Scheduler A10 Dark Screenshot" />
<img src="images/scheduler-a10-dark.gif" width="200" alt="Scheduler A10 Dark Screencast" />
</p>

# Features
Expand All @@ -43,14 +43,6 @@ If you're a normal user willing to give it a try, see [Installation](#installati
feature (note that it may not work on some devices due to OEM limitations. Refer to
[FAQ](#faq) for troubleshooting)
- Add an arbitrary number of schedules per SIM card
> 🚧 **Work-in-Progress**
>
> This feature is already implement "under the hood", but needs UI overhaul. Currently, the UI
> only supports two schedules (`start` and `end`) that are treated as a single schedule sharing
> the same days of the week and the <em>Use schedule</em> switch.
>
> Subscribe to the iusmac/7SIM/issues/1 to be notified when this feature will be fully
> implemented.
- Automatically supply the PIN code provided by you to unlock the SIM card
- Automatically detect ongoing call and postpone SIM card deactivation
- Tinted SIM card icons
Expand Down
6 changes: 3 additions & 3 deletions SettingsLib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
!/CollapsingToolbarBaseActivity/
/CollapsingToolbarBaseActivity/*
!/CollapsingToolbarBaseActivity/build.gradle
!/MainSwitchPreference/
/MainSwitchPreference/*
!/MainSwitchPreference/build.gradle
!/LayoutPreference/
/LayoutPreference/*
!/LayoutPreference/build.gradle
!/SettingsTheme/
/SettingsTheme/*
!/SettingsTheme/build.gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ plugins {
id 'com.android.library'
}

def SettingsLibMainSwitchPreference = '../fwb/packages/SettingsLib/MainSwitchPreference'

android {
namespace 'com.android.settingslib.widget.mainswitch'
namespace 'com.android.settingslib.widget.preference.layout'

defaultConfig {
minSdk 28
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
Expand All @@ -21,15 +19,20 @@ android {
}
}

lint {
lintOptions {
checkReleaseBuilds false
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibMainSwitchPreference}/res"]
java.srcDirs = ["${SettingsLibMainSwitchPreference}/src"]
res.srcDirs = ['../fwb/packages/SettingsLib/LayoutPreference/res']
java.srcDirs = ['../fwb/packages/SettingsLib/LayoutPreference/src']
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare REPO_TAG='android-14.0.0_r31'
declare -a LIBS=(
'BannerMessagePreference'
'CollapsingToolbarBaseActivity'
'MainSwitchPreference'
'LayoutPreference'
'SettingsTheme'
'TwoTargetPreference'
'Utils'
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ buildscript {
// https://mvnrepository.com/artifact/androidx.preference/preference
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/preference/preference/
preference : 'androidx.preference:preference:1.2.1', // TODO: AOSP sources use 1.3.0-alpha01; upgrade when available in maven central
// https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/recyclerview/recyclerview/
recyclerview : 'androidx.recyclerview:recyclerview:1.3.0-alpha01',
room_compiler : "androidx.room:room-compiler:$room_version",
room_runtime : "androidx.room:room-runtime:$room_version",
// https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel
Expand Down Expand Up @@ -195,6 +198,7 @@ dependencies {
implementation libs.livedata
implementation libs.material
implementation libs.preference
implementation libs.recyclerview
implementation libs.viewmodel
implementation libs.hilt_android
kapt libs.hilt_compiler
Expand All @@ -204,7 +208,7 @@ dependencies {

implementation project(path: ':SettingsLib:BannerMessagePreference')
implementation project(path: ':SettingsLib:CollapsingToolbarBaseActivity')
implementation project(path: ':SettingsLib:MainSwitchPreference')
implementation project(path: ':SettingsLib:LayoutPreference')
implementation project(path: ':SettingsLib:SettingsTheme')
implementation project(path: ':SettingsLib:TwoTargetPreference')
}
Expand Down
Binary file added images/scheduler-a10-dark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/scheduler-a10-dark.jpg
Binary file not shown.
Binary file added images/scheduler-a14-light.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/scheduler-a14-light.jpg
Binary file not shown.
6 changes: 6 additions & 0 deletions res/color-night-v31/schedule_card_arrow_background_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="12" />
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="22"
android:alpha="0.86" />
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="17" />
</selector>
7 changes: 7 additions & 0 deletions res/color-night-v34/fab_add_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@android:color/system_accent1_100"
android:alpha="?android:attr/disabledAlpha" />
<item android:color="@android:color/system_accent1_100"/>
</selector>

6 changes: 6 additions & 0 deletions res/color-night/fab_add_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@android:color/black"
android:alpha="?android:attr/disabledAlpha" />
<item android:color="@android:color/black"/>
</selector>
6 changes: 6 additions & 0 deletions res/color-v31/fab_add_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@android:color/system_accent2_100"
android:alpha="?android:attr/disabledAlpha" />
<item android:color="@android:color/system_accent2_100"/>
</selector>
7 changes: 7 additions & 0 deletions res/color-v31/schedule_card_arrow_background_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="24"
android:alpha="0.12" />
</selector>
7 changes: 7 additions & 0 deletions res/color-v31/schedule_card_collapsed_background_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="92"
android:alpha="0.86" />
</selector>
7 changes: 7 additions & 0 deletions res/color-v31/schedule_card_day_unselected_stroke_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral2_600"
android:lStar="22"
android:alpha="0.22" />
</selector>
6 changes: 6 additions & 0 deletions res/color-v31/schedule_card_expanded_background_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/system_neutral1_600"
android:lStar="87" />
</selector>
7 changes: 7 additions & 0 deletions res/color-v34/fab_add_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@android:color/system_accent1_900"
android:alpha="?android:attr/disabledAlpha" />
<item android:color="@android:color/system_accent1_900"/>
</selector>

7 changes: 7 additions & 0 deletions res/color/day_of_week_text_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:color="@color/schedule_card_day_selected_text_color" />

<item android:color="?android:textColorPrimary" />
</selector>
4 changes: 4 additions & 0 deletions res/color/fab_add_background_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?android:attr/colorAccent"/>
</selector>

6 changes: 6 additions & 0 deletions res/color/fab_add_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@android:color/white"
android:alpha="?android:attr/disabledAlpha" />
<item android:color="@android:color/white"/>
</selector>
6 changes: 6 additions & 0 deletions res/color/fab_pin_background_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:color="@color/fab_pin_set_background_tint_color" />
<item android:color="@color/fab_pin_unset_background_tint_color" />
</selector>
18 changes: 18 additions & 0 deletions res/color/fab_pin_tint_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:state_enabled="true"
android:color="@color/fab_pin_set_tint_color" />
<item android:state_enabled="true"
android:color="@color/fab_pin_unset_tint_color" />

<item android:state_enabled="false"
android:state_checked="false"
android:color="@color/fab_pin_unset_tint_color"
android:alpha="?android:attr/disabledAlpha" />

<item android:state_enabled="false"
android:state_checked="true"
android:color="@color/fab_pin_set_tint_color"
android:alpha="?android:attr/disabledAlpha" />
</selector>
41 changes: 41 additions & 0 deletions res/drawable/day_of_week_toggle_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="8dp"
android:left="8dp"
android:right="8dp"
android:bottom="8dp">

<ripple
android:color="?android:attr/colorControlHighlight"
android:radius="16dp">

<item android:id="@android:id/mask">
<shape>
<solid android:color="@android:color/white" />
</shape>
</item>

<item>
<selector
android:enterFadeDuration="450"
android:exitFadeDuration="375"> <!-- Enter/exit fade duration taken from the ripple effect component -->

<item android:state_checked="true">
<shape android:shape="oval">
<size android:height="20dp" android:width="20dp" />
<solid android:color="@color/schedule_card_day_selected_background_color" />
</shape>
</item>

<item>
<shape android:shape="oval">
<size android:height="20dp" android:width="20dp" />
<stroke android:width="1dp" android:color="@color/schedule_card_day_unselected_stroke_color" />
</shape>
</item>
</selector>
</item>
</ripple>
</item>
</layer-list>
25 changes: 25 additions & 0 deletions res/drawable/ic_add_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 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
https://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="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
44 changes: 44 additions & 0 deletions res/drawable/ic_arrow_pointing_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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
android:top="8dp"
android:left="8dp"
android:right="8dp"
android:bottom="8dp">
<shape android:shape="oval">
<size android:height="24dp" android:width="24dp" />
<solid android:color="@color/schedule_card_arrow_background_color" />
</shape>
</item>
<item>
<vector
android:width="24dp"
android:height="24dp"
android:viewportWidth="48.0"
android:viewportHeight="48.0"
android:tint="?android:textColorPrimary">
<group
android:translateX="12"
android:translateY="13">
<path
android:fillColor="@android:color/white"
android:pathData="M5.41,7.59L4,9l8,8 8,-8 -1.41,-1.41L12,14.17" />
</group>
</vector>
</item>
</layer-list>
Loading

0 comments on commit 97d5aff

Please sign in to comment.