Skip to content

Commit

Permalink
Suspend Actions & Wakelock Blocker (2/3)
Browse files Browse the repository at this point in the history
Change-Id: I3167307df0adfb393f1cb4bd81496bc5c71a7535
Signed-off-by: Scott <scott@ubuntu>

Conflicts:
	AndroidManifest.xml

Conflicts:
	AndroidManifest.xml
	res/values/bs_strings.xml
  • Loading branch information
maxwen authored and Scott committed Nov 22, 2013
1 parent 78ce6da commit 2022015
Show file tree
Hide file tree
Showing 20 changed files with 645 additions and 0 deletions.
15 changes: 15 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -1715,6 +1715,21 @@

<activity android:name=".cyanogenmod.PerformanceSettings" />

<activity
android:name=".cyanogenmod.fragments.ScreenStateToggles"
android:label="@string/screen_state_toggles_title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".cyanogenmod.fragments.WakeLockBlocker"
android:label="@string/wakelock_blocker" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

<activity android:name=".notificationlight.NotificationLightSettings" />

<activity android:name=".notificationlight.BatteryLightSettings" />
Expand Down
Binary file added res/drawable-hdpi/ic_menu_save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_screen_state.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_wakelock_blocker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_menu_save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_wakelock_blocker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_menu_save.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_screen_state.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_wakelock_blocker.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions res/layout/wakelock_blocker.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingEnd="?android:attr/scrollbarSize"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">

<RelativeLayout
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">

<TextView android:id="@+id/wakelock_blocker_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:text="@string/wakelock_blocker_title"
android:fadingEdge="horizontal" />

<TextView android:id="@+id/wakelock_blocker_title_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/wakelock_blocker_title"
android:layout_alignStart="@id/wakelock_blocker_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/wakelock_blocker_summary"
android:maxLines="4" />

</RelativeLayout>

<LinearLayout android:id="@+android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical" >

<Switch
android:id="@+id/wakelock_blocker_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dip"/>
</LinearLayout>
</LinearLayout>

<TextView
android:id="@+id/wakelock_list_header"
android:text="@string/wakelock_list_header"
style="?android:attr/listSeparatorTextViewStyle" />

<ListView
android:id="@+id/wakelock_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
13 changes: 13 additions & 0 deletions res/layout/wakelock_item.xml
@@ -0,0 +1,13 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<CheckBox
android:id="@+id/wakelock_blocked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:focusable="false"/>

</LinearLayout>
Binary file added res/mipmap-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/mipmap-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/mipmap-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions res/values/bs_strings.xml
Expand Up @@ -448,4 +448,29 @@
<string name="wifi_setting_countrycode_error">There was a problem setting the region code.</string>
<!-- Wi-Fi settings diables message if Wifi is off-->
<string name="wifi_setting_countrycode_disabled">Enable Wi-Fi to change this option.</string>

<!-- Screen state service -->
<string name="screen_state_toggles_summary">@null</string>
<string name="screen_state_toggles_title">Suspend Actions</string>
<string name="screen_state_toggles_enable_title">Enable</string>
<string name="screen_state_toggles_enable_summary">Actions will be executed on screen off. On screen on the previous state will be restored.</string>
<string name="screen_state_toggles_mobile_title">Mobile networks</string>
<string name="screen_state_toggles_location_title">Location</string>
<string name="screen_state_toggles_twog">Switch to 2G</string>
<string name="screen_state_toggles_twog_summary">Network mode will be switched to 2G on screen off</string>
<string name="screen_state_toggles_gps">Disable GPS</string>
<string name="screen_state_toggles_gps_summary">GPS based location service will be disabled on screen off</string>
<string name="screen_state_toggles_mobile_data">Disable mobile data</string>
<string name="screen_state_toggles_mobile_data_summary">Mobile data will be disabled on screen off</string>

<!-- Wakelock blocker -->
<string name="wakelock_blocker_header_summary">@null</string>
<string name="wakelock_blocker">Wakelock Blocker</string>
<string name="wakelock_blocker_title">Enable</string>
<string name="wakelock_blocker_summary">Activate blocking for checked wakelocks</string>
<string name="wakelock_blocker_save">Save</string>
<string name="wakelock_list_header">Available Wakelocks</string>
<string name="wakelock_blocker_reload">Reload</string>
<string name="wakelock_blocker_warning_title">Proceed with Caution</string>
<string name="wakelock_blocker_warning">Blocking wakelocks have the potential to cause instability, crashes or data loss.</string>
</resources>
12 changes: 12 additions & 0 deletions res/xml/beanstalk_interface_settings.xml
Expand Up @@ -34,6 +34,18 @@
android:key="navbar_settings"
android:fragment="com.android.settings.beanstalk.NavigationSettings"
android:title="@string/navigation_settings_title" />

<PreferenceScreen
android:key="screen_state_service"
android:fragment="com.android.settings.cyanogenmod.fragments.ScreenStateToggles"
android:title="@string/screen_state_toggles_title"
android:summary="@string/screen_state_toggles_summary" />

<PreferenceScreen
android:key="wakelock_blocker"
android:fragment="com.android.settings.cyanogenmod.fragments.WakeLockBlocker"
android:title="@string/wakelock_blocker"
android:summary="@string/wakelock_blocker_header_summary" />

<PreferenceScreen
android:key="misc_settings"
Expand Down
56 changes: 56 additions & 0 deletions res/xml/prefs_screen_state_toggles.xml
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2012 The CyanogenMod 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.
-->

<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/screen_state_toggles_title">


<SwitchPreference
android:key="screen_state_toggles_enable_key"
android:title="@string/screen_state_toggles_enable_title"
android:summary="@string/screen_state_toggles_enable_summary"
android:defaultValue="false"/>

<PreferenceCategory
android:key="screen_state_toggles_mobile_key"
android:title="@string/screen_state_toggles_mobile_title">

<CheckBoxPreference
android:key="screen_state_toggles_twog"
android:title="@string/screen_state_toggles_twog"
android:summary="@string/screen_state_toggles_twog_summary"
android:defaultValue="false"/>

<CheckBoxPreference
android:key="screen_state_toggles_mobile_data"
android:title="@string/screen_state_toggles_mobile_data"
android:summary="@string/screen_state_toggles_mobile_data_summary"
android:defaultValue="false"/>
</PreferenceCategory>

<PreferenceCategory
android:key="screen_state_toggles_location_key"
android:title="@string/screen_state_toggles_location_title">

<CheckBoxPreference
android:key="screen_state_toggles_gps"
android:title="@string/screen_state_toggles_gps"
android:summary="@string/screen_state_toggles_gps_summary"
android:defaultValue="false"/>

</PreferenceCategory>
</PreferenceScreen>
11 changes: 11 additions & 0 deletions src/com/android/settings/CreateShortcut.java
Expand Up @@ -50,6 +50,17 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
finish();
}

private int getProperShortcutIcon(String className) {
String c = className.substring(className.lastIndexOf(".") + 1);

if (c.equals("ScreenStateToggles"))
return R.drawable.ic_screen_state;
else if (c.equals("WakeLockBlocker"))
return R.drawable.ic_wakelock_blocker;
else
return R.mipmap.ic_launcher;
}

@Override
protected boolean onEvaluateShowIcons() {
return false;
Expand Down

0 comments on commit 2022015

Please sign in to comment.