use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.
the class QuickSettingsModel method onWifiSignalChanged.
// NetworkSignalChanged callback
@Override
public void onWifiSignalChanged(boolean enabled, int wifiSignalIconId, String wifiSignalContentDescription, String enabledDesc) {
// TODO: If view is in awaiting state, disable
Resources r = mContext.getResources();
boolean wifiConnected = enabled && (wifiSignalIconId > 0) && (enabledDesc != null);
boolean wifiNotConnected = (wifiSignalIconId > 0) && (enabledDesc == null);
mWifiState.enabled = enabled;
mWifiState.connected = wifiConnected;
if (wifiConnected) {
mWifiState.iconId = wifiSignalIconId;
mWifiState.label = removeDoubleQuotes(enabledDesc);
mWifiState.signalContentDescription = wifiSignalContentDescription;
} else if (wifiNotConnected) {
mWifiState.iconId = R.drawable.ic_qs_wifi_0;
mWifiState.label = r.getString(R.string.quick_settings_wifi_label);
mWifiState.signalContentDescription = r.getString(R.string.accessibility_no_wifi);
} else {
mWifiState.iconId = R.drawable.ic_qs_wifi_no_network;
mWifiState.label = r.getString(R.string.quick_settings_wifi_off_label);
mWifiState.signalContentDescription = r.getString(R.string.accessibility_wifi_off);
}
mWifiCallback.refreshView(mWifiTile, mWifiState);
}
use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.
the class QuickSettingsModel method onMobileDataSignalChanged.
// NetworkSignalChanged callback
@Override
public void onMobileDataSignalChanged(boolean enabled, int mobileSignalIconId, String signalContentDescription, int dataTypeIconId, String dataContentDescription, String enabledDesc) {
if (deviceHasMobileData()) {
// TODO: If view is in awaiting state, disable
Resources r = mContext.getResources();
mRSSIState.signalIconId = enabled && (mobileSignalIconId > 0) ? mobileSignalIconId : R.drawable.ic_qs_signal_no_signal;
mRSSIState.signalContentDescription = enabled && (mobileSignalIconId > 0) ? signalContentDescription : r.getString(R.string.accessibility_no_signal);
mRSSIState.dataTypeIconId = enabled && (dataTypeIconId > 0) && !mWifiState.enabled ? dataTypeIconId : 0;
mRSSIState.dataContentDescription = enabled && (dataTypeIconId > 0) && !mWifiState.enabled ? dataContentDescription : r.getString(R.string.accessibility_no_data);
mRSSIState.label = enabled ? removeTrailingPeriod(enabledDesc) : r.getString(R.string.quick_settings_rssi_emergency_only);
mRSSICallback.refreshView(mRSSITile, mRSSIState);
}
}
use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.
the class ScreenTimeoutButton method makeTimeoutToastString.
private String makeTimeoutToastString(Context context, int timeout) {
Resources res = context.getResources();
int resId;
/* ms -> seconds */
timeout /= 1000;
if (timeout >= 60 && timeout % 60 == 0) {
/* seconds -> minutes */
timeout /= 60;
if (timeout >= 60 && timeout % 60 == 0) {
/* minutes -> hours */
timeout /= 60;
resId = timeout == 1 ? com.android.internal.R.string.hour : com.android.internal.R.string.hours;
} else {
resId = timeout == 1 ? com.android.internal.R.string.minute : com.android.internal.R.string.minutes;
}
} else {
resId = timeout == 1 ? com.android.internal.R.string.second : com.android.internal.R.string.seconds;
}
return res.getString(R.string.powerwidget_screen_timeout_toast, timeout, res.getString(resId));
}
use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.
the class TabletTicker method makeWindow.
private ViewGroup makeWindow() {
final Resources res = mContext.getResources();
final FrameLayout view = new FrameLayout(mContext);
final int width = res.getDimensionPixelSize(R.dimen.notification_ticker_width);
int windowFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
if (CLICKABLE_TICKER) {
windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
} else {
windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
}
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, mLargeIconHeight, WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, windowFlags, PixelFormat.TRANSLUCENT);
lp.gravity = Gravity.BOTTOM | Gravity.END;
// lp.windowAnimations = com.android.internal.R.style.Animation_Toast;
mLayoutTransition = new LayoutTransition();
mLayoutTransition.addTransitionListener(this);
view.setLayoutTransition(mLayoutTransition);
lp.setTitle("NotificationTicker");
view.setLayoutParams(lp);
return view;
}
use of android.content.res.Resources in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method addStartingWindow.
/** {@inheritDoc} */
@Override
public View addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int windowFlags) {
if (!SHOW_STARTING_ANIMATIONS) {
return null;
}
if (packageName == null) {
return null;
}
WindowManager wm = null;
View view = null;
try {
Context context = mContext;
if (DEBUG_STARTING_WINDOW)
Slog.d(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
try {
context = context.createPackageContext(packageName, 0);
if (theme != context.getThemeResId()) {
context.setTheme(theme);
}
} catch (PackageManager.NameNotFoundException e) {
// Ignore
}
Window win = PolicyManager.makeNewWindow(context);
final TypedArray ta = win.getWindowStyle();
if (ta.getBoolean(com.android.internal.R.styleable.Window_windowDisablePreview, false) || ta.getBoolean(com.android.internal.R.styleable.Window_windowShowWallpaper, false)) {
return null;
}
Resources r = context.getResources();
win.setTitle(r.getText(labelRes, nonLocalizedLabel));
win.setType(WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
// Force the window flags: this is a fake window, so it is not really
// touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM
// flag because we do know that the next window will take input
// focus, so we want to get the IME window up on top of us right away.
win.setFlags(windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
if (!compatInfo.supportsScreen()) {
win.addFlags(WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW);
}
win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
final WindowManager.LayoutParams params = win.getAttributes();
params.token = appToken;
params.packageName = packageName;
params.windowAnimations = win.getWindowStyle().getResourceId(com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
params.setTitle("Starting " + packageName);
wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
view = win.getDecorView();
if (win.isFloating()) {
// earlier.)
return null;
}
if (DEBUG_STARTING_WINDOW)
Slog.d(TAG, "Adding starting window for " + packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null));
wm.addView(view, params);
// window manager... which we can tell by it having a parent.
return view.getParent() != null ? view : null;
} catch (WindowManager.BadTokenException e) {
// ignore
Log.w(TAG, appToken + " already running, starting window not displayed");
} catch (RuntimeException e) {
// don't crash if something else bad happens, for example a
// failure loading resources because we are loading from an app
// on external storage that has been unmounted.
Log.w(TAG, appToken + " failed creating starting window", e);
} finally {
if (view != null && view.getParent() == null) {
Log.w(TAG, "view not successfully added to wm, removing view");
wm.removeViewImmediate(view);
}
}
return null;
}
Aggregations