Cherish: Custom logo customizations [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
neobuddy89
2019-04-05 15:31:02 +05:30
committed by Hưng Phan
parent 4895413ffe
commit bc1ce679eb
7 changed files with 709 additions and 3 deletions

417
res/drawable/ic_logo.xml Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1198,4 +1198,120 @@
<item>4</item> <item>4</item>
<item>5</item> <item>5</item>
</string-array> </string-array>
<!-- Status bar logo position -->
<string-array name="status_bar_logo_position_entries" translatable="false">
<item>@string/status_bar_logo_position_left</item>
<item>@string/status_bar_logo_position_right</item>
</string-array>
<string-array name="status_bar_logo_position_values" translatable="false">
<item>0</item>
<item>1</item>
</string-array>
<!-- Status bar logo style -->
<string-array name="status_bar_logo_style_entries" translatable="false">
<item>@string/status_bar_logo_style_cherish</item>
<item>@string/status_bar_logo_style_android</item>
<item>@string/status_bar_logo_style_apple</item>
<item>@string/status_bar_logo_style_beats</item>
<item>@string/status_bar_logo_style_biohazard</item>
<item>@string/status_bar_logo_style_blackberry</item>
<item>@string/status_bar_logo_style_blogger</item>
<item>@string/status_bar_logo_style_bomb</item>
<item>@string/status_bar_logo_style_brain</item>
<item>@string/status_bar_logo_style_cake</item>
<item>@string/status_bar_logo_style_cannabis</item>
<item>@string/status_bar_logo_style_death_star</item>
<item>@string/status_bar_logo_style_emoticon</item>
<item>@string/status_bar_logo_style_emoticon_cool</item>
<item>@string/status_bar_logo_style_emoticon_dead</item>
<item>@string/status_bar_logo_style_emoticon_devil</item>
<item>@string/status_bar_logo_style_emoticon_happy</item>
<item>@string/status_bar_logo_style_emoticon_neutral</item>
<item>@string/status_bar_logo_style_emoticon_poop</item>
<item>@string/status_bar_logo_style_emoticon_sad</item>
<item>@string/status_bar_logo_style_emoticon_tongue</item>
<item>@string/status_bar_logo_style_fire</item>
<item>@string/status_bar_logo_style_flask</item>
<item>@string/status_bar_logo_style_gender_female</item>
<item>@string/status_bar_logo_style_gender_male</item>
<item>@string/status_bar_logo_style_gender_male_female</item>
<item>@string/status_bar_logo_style_ghost</item>
<item>@string/status_bar_logo_style_google</item>
<item>@string/status_bar_logo_style_guitar_acoustic</item>
<item>@string/status_bar_logo_style_guitar_electric</item>
<item>@string/status_bar_logo_style_heart</item>
<item>@string/status_bar_logo_style_human_female</item>
<item>@string/status_bar_logo_style_human_male</item>
<item>@string/status_bar_logo_style_human_male_female</item>
<item>@string/status_bar_logo_style_incognito</item>
<item>@string/status_bar_logo_style_ios</item>
<item>@string/status_bar_logo_style_linux</item>
<item>@string/status_bar_logo_style_lock</item>
<item>@string/status_bar_logo_style_music_note</item>
<item>@string/status_bar_logo_style_ninja</item>
<item>@string/status_bar_logo_style_pac_man</item>
<item>@string/status_bar_logo_style_peace</item>
<item>@string/status_bar_logo_style_robot</item>
<item>@string/status_bar_logo_style_skull</item>
<item>@string/status_bar_logo_style_smoking</item>
<item>@string/status_bar_logo_style_wallet</item>
<item>@string/status_bar_logo_style_windows</item>
<item>@string/status_bar_logo_style_xbox</item>
<item>@string/status_bar_logo_style_xbox_controller</item>
<item>@string/status_bar_logo_style_yin_yang</item>
</string-array>
<string-array name="status_bar_logo_style_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
<item>20</item>
<item>21</item>
<item>22</item>
<item>23</item>
<item>24</item>
<item>25</item>
<item>26</item>
<item>27</item>
<item>28</item>
<item>29</item>
<item>30</item>
<item>31</item>
<item>32</item>
<item>33</item>
<item>34</item>
<item>35</item>
<item>36</item>
<item>37</item>
<item>38</item>
<item>39</item>
<item>40</item>
<item>41</item>
<item>42</item>
<item>43</item>
<item>44</item>
<item>45</item>
<item>46</item>
<item>47</item>
<item>48</item>
<item>49</item>
</string-array>
</resources> </resources>

View File

@@ -1067,4 +1067,64 @@
<string name="qs_media_player_title">QS Media player</string> <string name="qs_media_player_title">QS Media player</string>
<string name="qs_media_player_summary_on">Show media player in QS.\nRequires a SystemUI restart</string> <string name="qs_media_player_summary_on">Show media player in QS.\nRequires a SystemUI restart</string>
<string name="qs_media_player_summary_off">Show media player as a notification.\nRequires a SystemUI restart</string> <string name="qs_media_player_summary_off">Show media player as a notification.\nRequires a SystemUI restart</string>
<!-- Statusbar logo -->
<string name="status_bar_logo_title">Logo</string>
<string name="status_bar_logo_summary">Show a custom logo in the status bar</string>
<string name="status_bar_logo_color">Logo color</string>
<string name="status_bar_logo_position">Logo position</string>
<string name="status_bar_logo_position_summary">%1$s</string>
<string name="status_bar_logo_position_right">Right</string>
<string name="status_bar_logo_position_left">Left</string>
<string name="status_bar_logo_style">Logo style</string>
<string name="status_bar_logo_style_cherish">Cherish</string>
<string name="status_bar_logo_style_android">Android</string>
<string name="status_bar_logo_style_apple">Apple</string>
<string name="status_bar_logo_style_beats">Beats</string>
<string name="status_bar_logo_style_biohazard">Biohazard</string>
<string name="status_bar_logo_style_blackberry">Blackberry</string>
<string name="status_bar_logo_style_blogger">Blogger</string>
<string name="status_bar_logo_style_bomb">Bomb</string>
<string name="status_bar_logo_style_brain">Brain</string>
<string name="status_bar_logo_style_cake">Cake</string>
<string name="status_bar_logo_style_cannabis">Cannabis</string>
<string name="status_bar_logo_style_death_star">Death Star</string>
<string name="status_bar_logo_style_emoticon">Emoji</string>
<string name="status_bar_logo_style_emoticon_cool">Emoji (Cool)</string>
<string name="status_bar_logo_style_emoticon_dead">Emoji (Dead)</string>
<string name="status_bar_logo_style_emoticon_devil">Emoji (Devil)</string>
<string name="status_bar_logo_style_emoticon_happy">Emoji (Happy)</string>
<string name="status_bar_logo_style_emoticon_neutral">Emoji (Neutral)</string>
<string name="status_bar_logo_style_emoticon_poop">Emoji (Poop)</string>
<string name="status_bar_logo_style_emoticon_sad">Emoji (Sad)</string>
<string name="status_bar_logo_style_emoticon_tongue">Emoji (Tongue)</string>
<string name="status_bar_logo_style_fire">Fire</string>
<string name="status_bar_logo_style_flask">Flask</string>
<string name="status_bar_logo_style_gender_male">Gender (Male)</string>
<string name="status_bar_logo_style_gender_female">Gender (Female)</string>
<string name="status_bar_logo_style_gender_male_female">Gender (Male &amp; Female)</string>
<string name="status_bar_logo_style_ghost">Ghost</string>
<string name="status_bar_logo_style_google">Google</string>
<string name="status_bar_logo_style_guitar_acoustic">Guitar (Acoustic)</string>
<string name="status_bar_logo_style_guitar_electric">Guitar (Electric)</string>
<string name="status_bar_logo_style_heart">Heart</string>
<string name="status_bar_logo_style_human_male">Human (Male)</string>
<string name="status_bar_logo_style_human_female">Human (Female)</string>
<string name="status_bar_logo_style_human_male_female">Human (Male &amp; Female)</string>
<string name="status_bar_logo_style_incognito">Incognito</string>
<string name="status_bar_logo_style_ios">iOS</string>
<string name="status_bar_logo_style_linux">Linux</string>
<string name="status_bar_logo_style_lock">Lock</string>
<string name="status_bar_logo_style_music_note">Music Note</string>
<string name="status_bar_logo_style_ninja">Ninja</string>
<string name="status_bar_logo_style_pac_man">Pac-Man</string>
<string name="status_bar_logo_style_peace">Peace</string>
<string name="status_bar_logo_style_robot">Robot</string>
<string name="status_bar_logo_style_skull">Skull</string>
<string name="status_bar_logo_style_smoking">Smoking</string>
<string name="status_bar_logo_style_wallet">Wallet</string>
<string name="status_bar_logo_style_windows">Windows</string>
<string name="status_bar_logo_style_xbox">XBOX</string>
<string name="status_bar_logo_style_xbox_controller">XBOX Controller</string>
<string name="status_bar_logo_style_yin_yang">Yin-Yang</string>
</resources> </resources>

View File

@@ -124,5 +124,13 @@
android:title="@string/carrier_label_settings_title" android:title="@string/carrier_label_settings_title"
android:summary="@string/carrier_label_settings_summary" android:summary="@string/carrier_label_settings_summary"
android:fragment="com.cherish.settings.fragments.CustomCarrierLabel" /> android:fragment="com.cherish.settings.fragments.CustomCarrierLabel" />
<com.cherish.settings.preferences.SystemSettingMasterSwitchPreference
android:key="status_bar_logo"
android:icon="@drawable/ic_logo"
android:fragment="com.cherish.settings.fragments.StatusbarLogo"
android:title="@string/status_bar_logo_title"
android:summary="@string/status_bar_logo_summary"
android:defaultValue="false" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 Havoc-OS
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"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/status_bar_logo_title" >
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="status_bar_logo_position"
android:title="@string/status_bar_logo_position"
android:entries="@array/status_bar_logo_position_entries"
android:entryValues="@array/status_bar_logo_position_values"
android:defaultValue="0" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="status_bar_logo_style"
android:title="@string/status_bar_logo_style"
android:entries="@array/status_bar_logo_style_entries"
android:entryValues="@array/status_bar_logo_style_values"
android:defaultValue="0" />
</PreferenceScreen>

View File

@@ -40,6 +40,10 @@ import java.util.Collections;
public class StatusBarSettings extends SettingsPreferenceFragment implements public class StatusBarSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { OnPreferenceChangeListener {
private static final String STATUS_BAR_LOGO = "status_bar_logo";
private SystemSettingMasterSwitchPreference mStatusBarLogo;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@@ -49,11 +53,22 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
ContentResolver resolver = getActivity().getContentResolver(); ContentResolver resolver = getActivity().getContentResolver();
PreferenceScreen prefSet = getPreferenceScreen(); PreferenceScreen prefSet = getPreferenceScreen();
mStatusBarLogo = (SystemSettingMasterSwitchPreference) findPreference(STATUS_BAR_LOGO);
mStatusBarLogo.setChecked((Settings.System.getInt(getActivity().getContentResolver(),
Settings.System.STATUS_BAR_LOGO, 0) == 1));
mStatusBarLogo.setOnPreferenceChangeListener(this);
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object objValue) { public boolean onPreferenceChange(Preference preference, Object objValue) {
if (preference == mStatusBarLogo) {
boolean value = (Boolean) objValue;
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.STATUS_BAR_LOGO, value ? 1 : 0);
return true;
}
return false; return false;
} }
@@ -63,4 +78,3 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
} }
} }

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2020 TenX-OS
*
* 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.cherish.settings.fragments;
import android.content.Context;
import android.content.ContentResolver;
import android.os.Bundle;
import android.provider.Settings;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
public class StatusbarLogo extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
addPreferencesFromResource(R.xml.statusbar_logo);
}
@Override
public void onResume() {
super.onResume();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return false;
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
}
}