forked from CarbonDev/android_packages_apps_CarbonFibers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CFibers - Implement App circle sidebar [2/2]
Add whitelist app to include Add Trigger region control Change-Id: I47862e45b87d65a2b96ff6ecccc8beadba7a9440 Signed-off-by: MURA Stefano [STELIX PippoX3] <[email protected]>
- Loading branch information
Showing
4 changed files
with
224 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (C) 2014 The CarbonRom 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:key="interface_app_circle_bar_key" | ||
android:title="@string/category_app_circle_bar_title" | ||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"> | ||
|
||
<PreferenceCategory | ||
android:key="category_app_circle_bar" | ||
android:title="@string/category_app_circle_bar_title" > | ||
|
||
<com.carbon.fibers.preference.SystemSettingCheckBoxPreference | ||
android:key="enable_app_circle_bar" | ||
android:title="@string/app_circle_bar_title" | ||
android:summary="@string/app_circle_bar_summary" /> | ||
|
||
<com.carbon.fibers.chameleonos.AppMultiSelectListPreference | ||
android:key="app_circle_bar_included_apps" | ||
android:persistent="false" | ||
android:title="@string/app_circle_bar_included_apps_title" | ||
android:summary="@string/app_circle_bar_included_apps_summary" | ||
android:dependency="enable_app_circle_bar" /> | ||
</PreferenceCategory> | ||
|
||
<PreferenceCategory | ||
android:key="category_app_circle_bar_trigger" | ||
android:title="@string/trigger_category" > | ||
|
||
<com.carbon.fibers.chameleonos.SeekBarPreference | ||
android:key="trigger_width" | ||
android:persistent="false" | ||
android:title="@string/trigger_width_title" | ||
android:summary="@string/trigger_width_summary" | ||
android:max="64" | ||
settings:min="4" | ||
settings:unitsLeft="" | ||
settings:unitsRight="px" | ||
android:defaultValue="4" | ||
android:dependency="enable_app_circle_bar" /> | ||
|
||
<com.carbon.fibers.chameleonos.SeekBarPreference | ||
android:key="trigger_top" | ||
android:persistent="false" | ||
android:title="@string/trigger_top_title" | ||
android:summary="@string/trigger_top_summary" | ||
android:max="99" | ||
settings:min="0" | ||
settings:unitsLeft="" | ||
settings:unitsRight="%" | ||
android:defaultValue="0" | ||
android:dependency="enable_app_circle_bar" /> | ||
|
||
<com.carbon.fibers.chameleonos.SeekBarPreference | ||
android:key="trigger_bottom" | ||
android:persistent="false" | ||
android:title="@string/trigger_bottom_title" | ||
android:summary="@string/trigger_bottom_summary" | ||
android:max="100" | ||
settings:min="1" | ||
settings:unitsLeft="" | ||
settings:unitsRight="%" | ||
android:defaultValue="100" | ||
android:dependency="enable_app_circle_bar" /> | ||
</PreferenceCategory> | ||
</PreferenceScreen> |
129 changes: 129 additions & 0 deletions
129
src/com/carbon/fibers/fragments/ui/AppCircleSideBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (C) 2014 The CarbonRom 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. | ||
*/ | ||
|
||
package com.carbon.fibers.fragments.ui; | ||
|
||
import android.os.Bundle; | ||
import android.preference.ListPreference; | ||
import android.preference.Preference; | ||
import android.preference.PreferenceScreen; | ||
import android.provider.Settings; | ||
|
||
import android.text.TextUtils; | ||
import com.carbon.fibers.chameleonos.AppMultiSelectListPreference; | ||
import com.android.internal.util.omni.DeviceUtils; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.carbon.fibers.R; | ||
import com.carbon.fibers.chameleonos.SeekBarPreference; | ||
import com.carbon.fibers.preference.SettingsPreferenceFragment; | ||
|
||
public class AppCircleSideBar extends SettingsPreferenceFragment implements | ||
Preference.OnPreferenceChangeListener { | ||
private static final String TAG = "AppCircleSideBar"; | ||
private static final String KEY_TRIGGER_WIDTH = "trigger_width"; | ||
private static final String KEY_TRIGGER_TOP = "trigger_top"; | ||
private static final String KEY_TRIGGER_BOTTOM = "trigger_bottom"; | ||
private static final String PREF_INCLUDE_APP_CIRCLE_BAR_KEY = "app_circle_bar_included_apps"; | ||
private AppMultiSelectListPreference mIncludedAppCircleBar; | ||
private SeekBarPreference mTriggerWidthPref; | ||
private SeekBarPreference mTriggerTopPref; | ||
private SeekBarPreference mTriggerBottomPref; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
addPreferencesFromResource(R.xml.ui_app_circle); | ||
PreferenceScreen prefScreen = getPreferenceScreen(); | ||
|
||
mIncludedAppCircleBar = (AppMultiSelectListPreference) prefScreen.findPreference(PREF_INCLUDE_APP_CIRCLE_BAR_KEY); | ||
Set<String> includedApps = getIncludedApps(); | ||
if (includedApps != null) mIncludedAppCircleBar.setValues(includedApps); | ||
mIncludedAppCircleBar.setOnPreferenceChangeListener(this); | ||
mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH); | ||
mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_WIDTH, 10)); | ||
mTriggerWidthPref.setOnPreferenceChangeListener(this); | ||
mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP); | ||
mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_TOP, 0)); | ||
mTriggerTopPref.setOnPreferenceChangeListener(this); | ||
mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM); | ||
mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_HEIGHT, 100)); | ||
mTriggerBottomPref.setOnPreferenceChangeListener(this); | ||
} | ||
|
||
public boolean onPreferenceChange(Preference preference, Object objValue) { | ||
if (preference == mIncludedAppCircleBar) { | ||
storeIncludedApps((Set<String>) objValue); | ||
return true; | ||
} else if (preference == mTriggerWidthPref) { | ||
int width = ((Integer)objValue).intValue(); | ||
Settings.System.putInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_WIDTH, width); | ||
return true; | ||
} else if (preference == mTriggerTopPref) { | ||
int top = ((Integer)objValue).intValue(); | ||
Settings.System.putInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_TOP, top); | ||
return true; | ||
} else if (preference == mTriggerBottomPref) { | ||
int bottom = ((Integer)objValue).intValue(); | ||
Settings.System.putInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_TRIGGER_HEIGHT, bottom); | ||
return true; | ||
} | ||
return false; | ||
} | ||
private Set<String> getIncludedApps() { | ||
String included = Settings.System.getString(getActivity().getContentResolver(), | ||
Settings.System.WHITELIST_APP_CIRCLE_BAR); | ||
if (TextUtils.isEmpty(included)) { | ||
return null; | ||
} | ||
return new HashSet<String>(Arrays.asList(included.split("\\|"))); | ||
} | ||
|
||
private void storeIncludedApps(Set<String> values) { | ||
StringBuilder builder = new StringBuilder(); | ||
String delimiter = ""; | ||
for (String value : values) { | ||
builder.append(delimiter); | ||
builder.append(value); | ||
delimiter = "|"; | ||
} | ||
Settings.System.putString(getActivity().getContentResolver(), | ||
Settings.System.WHITELIST_APP_CIRCLE_BAR, builder.toString()); | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
Settings.System.putInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_SHOW_TRIGGER, 0); | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
Settings.System.putInt(getContentResolver(), | ||
Settings.System.APP_CIRCLE_BAR_SHOW_TRIGGER, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters