Skip to content

Commit

Permalink
CidBean : Changes to toggle between CID and Jellybean
Browse files Browse the repository at this point in the history
Based on Robert Burns commit from 10.0

Patchset 2 : Remove unused imports
Patchset 3 : Format cleanup

Change-Id: I2827425681463d4ca077607cb6a043c28bf6f633
  • Loading branch information
Danesh committed Dec 10, 2012
1 parent 7536aa5 commit 0561b72
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 9 deletions.
9 changes: 6 additions & 3 deletions core/java/com/android/internal/app/PlatLogoActivity.java
Expand Up @@ -84,15 +84,16 @@ private View makeView() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

final boolean isCid = getIntent().hasExtra("is_cid");
mToast = Toast.makeText(this, "", Toast.LENGTH_LONG);
mToast.setView(makeView());

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

mContent = new ImageView(this);
mContent.setImageResource(com.android.internal.R.drawable.platlogo_alt);
mContent.setImageResource(isCid ? com.android.internal.R.drawable.cidlogo
: com.android.internal.R.drawable.platlogo_alt);
mContent.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

final int p = (int)(32 * metrics.density);
Expand All @@ -102,7 +103,8 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
mToast.show();
mContent.setImageResource(com.android.internal.R.drawable.platlogo);
mContent.setImageResource(isCid ? com.android.internal.R.drawable.cidlogo_alt
: com.android.internal.R.drawable.platlogo);
}
});

Expand All @@ -114,6 +116,7 @@ public boolean onLongClick(View v) {
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
.putExtra("is_cid", isCid)
.addCategory("com.android.internal.category.PLATLOGO"));
//.setClassName("com.android.systemui","com.android.systemui.BeanBag"));
} catch (ActivityNotFoundException ex) {
Expand Down
Binary file added core/res/res/drawable-nodpi/cidlogo.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 core/res/res/drawable-nodpi/cidlogo_alt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions core/res/res/values/symbols.xml
Expand Up @@ -974,6 +974,8 @@
<java-symbol type="drawable" name="picture_emergency" />
<java-symbol type="drawable" name="platlogo" />
<java-symbol type="drawable" name="platlogo_alt" />
<java-symbol type="drawable" name="cidlogo" />
<java-symbol type="drawable" name="cidlogo_alt" />
<java-symbol type="drawable" name="stat_notify_sync_error" />
<java-symbol type="drawable" name="stat_notify_wifi_in_range" />
<java-symbol type="drawable" name="stat_notify_rssi_in_range" />
Expand Down
12 changes: 12 additions & 0 deletions packages/SystemUI/AndroidManifest.xml
Expand Up @@ -217,8 +217,20 @@
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.service.dream"
android:resource="@xml/dream_info" />
</service>

<activity android:name=".BeanBagDreamSettings"
android:taskAffinity=""
android:excludeFromRecents="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

<activity android:name=".Somnambulator"
android:label="@string/start_dreams"
android:icon="@mipmap/ic_launcher_dreams"
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/SystemUI/res/drawable-nodpi/cidlogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/SystemUI/res/values/strings.xml
Expand Up @@ -457,6 +457,8 @@

<!-- Name of the Jelly Bean platlogo screensaver -->
<string name="jelly_bean_dream_name">BeanFlinger</string>
<string name="bean_dream_settings_cid_title">Use CID head</string>
<string name="bean_dream_settings_cid_summary">Use CID head instead of jellybean inside the dream</string>

<!-- Name of the launcher shortcut icon that allows dreams to be started immediately [CHAR LIMIT=20] -->
<string name="start_dreams">Daydream</string>
Expand Down
4 changes: 4 additions & 0 deletions packages/SystemUI/res/xml/dream_info.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.android.systemui/com.android.systemui.BeanBagDreamSettings"
/>
23 changes: 23 additions & 0 deletions packages/SystemUI/res/xml/dream_settings.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->

<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/jelly_bean_dream_name">
<CheckBoxPreference
android:key="beanbag_dream_cid"
android:title="@string/bean_dream_settings_cid_title"
android:summary="@string/bean_dream_settings_cid_summary"
android:defaultValue="false" />
</PreferenceScreen>
33 changes: 28 additions & 5 deletions packages/SystemUI/src/com/android/systemui/BeanBag.java
Expand Up @@ -137,6 +137,28 @@ static int pickInt(int[] array) {
0xFF333333,
};

static int CIDS[] = {
R.drawable.cid_angry,
R.drawable.cid_angry,
R.drawable.cid_angry,
R.drawable.cid_angry,
R.drawable.cid_normal,
R.drawable.cid_normal,
R.drawable.cid_confused,
};

static int CIDCOLORS[] = {
0xFF0099CC,
0xFF33B5E5,
0xFF669900,
0xFF99CC00,
0xFFCC0000,
0xFFFF8800,
0xFFFFBB33,
0xFF9933CC,
0xFFAA66CC,
};

public class Bean extends ImageView {
public static final float VMAX = 1000.0f;
public static final float VMIN = 100.0f;
Expand Down Expand Up @@ -167,7 +189,7 @@ public String toString() {
}

private void pickBean() {
int beanId = pickInt(BEANS);
int beanId = pickInt(mIsCid ? CIDS : BEANS);
if (randfrange(0,1) <= LUCKY) {
beanId = R.drawable.jandycane;
}
Expand All @@ -182,7 +204,7 @@ private void pickBean() {
this.setImageDrawable(bean);

Paint pt = new Paint();
final int color = pickInt(COLORS);
final int color = pickInt(mIsCid ? CIDCOLORS : COLORS);
ColorMatrix CM = new ColorMatrix();
float[] M = CM.getArray();
// we assume the color information is in the red channel
Expand Down Expand Up @@ -266,10 +288,11 @@ public boolean onTouchEvent(MotionEvent e) {
TimeAnimator mAnim;
private int boardWidth;
private int boardHeight;
private boolean mIsCid;

public Board(Context context, AttributeSet as) {
public Board(Context context, AttributeSet as, boolean isCid) {
super(context, as);

mIsCid = isCid;
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

setWillNotDraw(!DEBUG);
Expand Down Expand Up @@ -413,7 +436,7 @@ public void onStart() {
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
);
mBoard = new Board(this, null);
mBoard = new Board(this, null, getIntent().getBooleanExtra("is_cid", false));
setContentView(mBoard);
}

Expand Down
5 changes: 4 additions & 1 deletion packages/SystemUI/src/com/android/systemui/BeanBagDream.java
Expand Up @@ -16,6 +16,8 @@

package com.android.systemui;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.service.dreams.DreamService;

import com.android.systemui.BeanBag.Board;
Expand All @@ -29,7 +31,8 @@ public void onAttachedToWindow() {
super.onAttachedToWindow();
setInteractive(true);
setFullscreen(true);
mBoard = new Board(this, null);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
mBoard = new Board(this, null, prefs.getBoolean("beanbag_dream_cid", false));
setContentView(mBoard);
}

Expand Down
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2009 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.
*/

package com.android.systemui;

import android.os.Bundle;
import android.preference.PreferenceActivity;

import com.android.systemui.R;

public class BeanBagDreamSettings extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.dream_settings);
}
}

0 comments on commit 0561b72

Please sign in to comment.