Skip to content

Commit

Permalink
CFibers - Implement App circle sidebar [2/2]
Browse files Browse the repository at this point in the history
Add whitelist app to include
Add Trigger region control

Change-Id: I47862e45b87d65a2b96ff6ecccc8beadba7a9440
Signed-off-by: MURA Stefano [STELIX PippoX3] <[email protected]>
  • Loading branch information
Squadzone authored and STELIX committed Oct 26, 2014
1 parent 1e3817d commit 1f3d44f
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 1 deletion.
14 changes: 14 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@
<string name="backlight_summary_enabled_with_timeout">Enabled for <xliff:g id="timeout">%s</xliff:g></string>
<string name="backlight_summary_enabled">Enabled</string>

<!-- App Circle SideBar -->
<string name="category_app_circle_bar_title">App launcher</string>
<string name="app_circle_bar_title">App circle bar</string>
<string name="app_circle_bar_summary">Show circle app launcher after touching right side of screen</string>
<string name="app_circle_bar_included_apps_title">Included apps</string>
<string name="app_circle_bar_included_apps_summary">Apps will show in app circle bar</string>
<string name="trigger_category">Trigger region</string>
<string name="trigger_width_title">Trigger width</string>
<string name="trigger_width_summary">Adjust the width of the trigger area</string>
<string name="trigger_top_title">Trigger position</string>
<string name="trigger_top_summary">Adjust the vertical postion of the trigger area</string>
<string name="trigger_bottom_title">Trigger height</string>
<string name="trigger_bottom_summary">Adjust the height of the trigger area</string>

<!-- Installer settings -->
<string name="installer_title">Persistence</string>
<string name="persist_options">Persistence</string>
Expand Down
78 changes: 78 additions & 0 deletions res/xml/ui_app_circle.xml
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 src/com/carbon/fibers/fragments/ui/AppCircleSideBar.java
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);
}
}
4 changes: 3 additions & 1 deletion src/com/carbon/fibers/fragments/ui/InterfaceSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public StatusBarAdapter(FragmentManager fm) {
frags[1] = new RecentsPanel();
frags[2] = new BatterySaverSettings();
frags[3] = new ProgressBar();
frags[4] = new AppCircleSideBar();
}

@Override
Expand All @@ -119,7 +120,8 @@ private String[] getTitles() {
getString(R.string.ui_general_category),
getString(R.string.ui_recents_category),
getString(R.string.battery_saver_title),
getString(R.string.progressbar_title)};
getString(R.string.progressbar_title),
getString(R.string.category_app_circle_bar_title)};
return titleString;
}
}

0 comments on commit 1f3d44f

Please sign in to comment.