public Builder extend(Builder builder) { if (VERSION.SDK_INT >= 21) { Bundle carExtensions = new Bundle(); if (this.mLargeIcon != null) { carExtensions.putParcelable(EXTRA_LARGE_ICON, this.mLargeIcon); } if (this.mColor != 0) { carExtensions.putInt(EXTRA_COLOR, this.mColor); } if (this.mUnreadConversation != null) { carExtensions.putBundle(EXTRA_CONVERSATION, NotificationCompat.IMPL.getBundleForUnreadConversation(this.mUnreadConversation)); } builder.getExtras().putBundle(EXTRA_CAR_EXTENDER, carExtensions); } return builder; }
private void findAllFragmentsWithViews( android.app.FragmentManager fragmentManager, ArrayMap<View, android.app.Fragment> result) { int index = 0; while (true) { tempBundle.putInt(FRAGMENT_INDEX_KEY, index++); android.app.Fragment fragment = null; try { fragment = fragmentManager.getFragment(tempBundle, FRAGMENT_MANAGER_GET_FRAGMENT_KEY); } catch (Exception e) { // This generates log spam from FragmentManager anyway. } if (fragment == null) { break; } if (fragment.getView() != null) { result.put(fragment.getView(), fragment); if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { findAllFragmentsWithViews(fragment.getChildFragmentManager(), result); } } } }
public static void tintStatusBar(Window window, @ColorInt int statusBarColor, @FloatRange (from = 0.0d, to = 1.0d) float alpha) { if (VERSION.SDK_INT >= 19) { if (VERSION.SDK_INT >= 21) { window.clearFlags(67108864); window.addFlags(Integer.MIN_VALUE); window.setStatusBarColor(0); } else { window.addFlags(67108864); } ViewGroup decorView = (ViewGroup) window.getDecorView(); View rootView = ((ViewGroup) window.getDecorView().findViewById(16908290)).getChildAt (0); if (rootView != null) { ViewCompat.setFitsSystemWindows(rootView, true); } setStatusBar(decorView, statusBarColor, true); setTranslucentView(decorView, alpha); } }
public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(s)) { if (VERSION.SDK_INT >= 21) { MQConversationActivity.this.mSendTextBtn.setElevation(0.0f); } MQConversationActivity.this.mSendTextBtn.setImageResource(R.drawable .mq_ic_send_icon_grey); MQConversationActivity.this.mSendTextBtn.setBackgroundResource(R.drawable .mq_shape_send_back_normal); return; } MQConversationActivity.this.inputting(s.toString()); if (VERSION.SDK_INT >= 21) { MQConversationActivity.this.mSendTextBtn.setElevation((float) MQUtils.dip2px (MQConversationActivity.this, IPhotoView.DEFAULT_MAX_SCALE)); } MQConversationActivity.this.mSendTextBtn.setImageResource(R.drawable .mq_ic_send_icon_white); MQConversationActivity.this.mSendTextBtn.setBackgroundResource(R.drawable .mq_shape_send_back_pressed); }
private CalendarDay findAccessibilityFocus() { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child instanceof MonthView) { CalendarDay focus = ((MonthView) child).getAccessibilityFocus(); if (focus != null) { if (VERSION.SDK_INT != 17) { return focus; } ((MonthView) child).clearAccessibilityFocus(); return focus; } } } return null; }
public void attachToWindow() { if (getParent() == null) { this.mLp = new LayoutParams(); if (VERSION.SDK_INT >= 19) { this.mLp.type = 2005; } else { this.mLp.type = 2002; } this.mLp.format = 1; this.mLp.flags = 40; this.mLp.gravity = 8388659; this.mLp.width = -1; this.mLp.height = -2; this.mLp.x = 0; this.mLp.y = 0; this.mWindowManager.addView(this, this.mLp); } }
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { if (VERSION.SDK_INT >= 14) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(ACCESSIBILITY_EVENT_CLASS_NAME); CharSequence switchText = isChecked() ? this.mTextOn : this.mTextOff; if (!TextUtils.isEmpty(switchText)) { CharSequence oldText = info.getText(); if (TextUtils.isEmpty(oldText)) { info.setText(switchText); return; } StringBuilder newText = new StringBuilder(); newText.append(oldText).append(' ').append(switchText); info.setText(newText); } } }
/** * Generate a value suitable for use in {@link android.view.View#setId(int)}. * This value will not collide with ID values generated at build time by aapt for R.id. * * @return a generated ID value */ public static int generateViewId() { if (VERSION.SDK_INT >= 17) { return android.view.View.generateViewId(); } else { for (; ; ) { final int result = sNextGeneratedId.get(); // aapt-generated IDs have the high byte nonzero; clamp to the range under that. int newValue = result + 1; if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0. if (sNextGeneratedId.compareAndSet(result, newValue)) { return result; } } } }
public void onAnimationEnd(View view) { if (this.mVpa.mOldLayerType >= 0) { ViewCompat.setLayerType(view, this.mVpa.mOldLayerType, null); this.mVpa.mOldLayerType = -1; } if (VERSION.SDK_INT >= 16 || !this.mAnimEndCalled) { if (this.mVpa.mEndAction != null) { Runnable endAction = this.mVpa.mEndAction; this.mVpa.mEndAction = null; endAction.run(); } ViewPropertyAnimatorListener listenerTag = view.getTag(ViewPropertyAnimatorCompat.LISTENER_TAG_ID); ViewPropertyAnimatorListener listener = null; if (listenerTag instanceof ViewPropertyAnimatorListener) { listener = listenerTag; } if (listener != null) { listener.onAnimationEnd(view); } this.mAnimEndCalled = true; } }
public static synchronized String c(Context context) { String str; synchronized (f.class) { if (c != null) { str = c; } else { String string; try { string = Secure.getString(context.getContentResolver(), "android_id"); } catch (Throwable th) { b.a(th); string = null; } c = d.b(string + (VERSION.SDK_INT > 8 ? Build.SERIAL : null)); str = c; } } return str; }
private void initClasses() throws ClassNotFoundException, InstantiationException, IllegalAccessException { sPackageParserClass = Class.forName("android.content.pm.PackageParser"); sActivityClass = Class.forName("android.content.pm.PackageParser$Activity"); sServiceClass = Class.forName("android.content.pm.PackageParser$Service"); sProviderClass = Class.forName("android.content.pm.PackageParser$Provider"); sInstrumentationClass = Class.forName("android.content.pm.PackageParser$Instrumentation"); sPermissionClass = Class.forName("android.content.pm.PackageParser$Permission"); sPermissionGroupClass = Class.forName("android.content.pm.PackageParser$PermissionGroup"); try { sArraySetClass = Class.forName("android.util.ArraySet"); } catch (ClassNotFoundException e) { } if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { sPackageUserStateClass = Class.forName("android.content.pm.PackageUserState"); mDefaultPackageUserState = sPackageUserStateClass.newInstance(); mUserId = UserHandleCompat.getCallingUserId(); } }
public TransferControlView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); inflate(context, R.layout.transfer_controls_view, this); final Drawable background = ContextCompat.getDrawable(context, R.drawable.transfer_controls_background); if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { background.setColorFilter(0x66ffffff, Mode.MULTIPLY); } setLongClickable(false); ViewUtil.setBackground(this, background); setVisibility(GONE); this.progressWheel = ViewUtil.findById(this, R.id.progress_wheel); this.downloadDetails = ViewUtil.findById(this, R.id.download_details); this.contractedWidth = getResources().getDimensionPixelSize(R.dimen.transfer_controls_contracted_width); this.expandedWidth = getResources().getDimensionPixelSize(R.dimen.transfer_controls_expanded_width); }
private static int a(Context context) { int i = -1; if (VERSION.SDK_INT >= 11) { Object property = System.getProperty("http.proxyPort"); if (TextUtils.isEmpty(property)) { return i; } try { return Integer.parseInt(property); } catch (NumberFormatException e) { return i; } } else if (context == null) { return Proxy.getDefaultPort(); } else { i = Proxy.getPort(context); if (i < 0) { return Proxy.getDefaultPort(); } return i; } }
@Deprecated public static void onEvent(String str, Map<String, String> map) { if (VERSION.SDK_INT < 10) { ib.b(a, "Device SDK Version older than 10"); } else if (str == null) { ib.b(a, "String eventId passed to onEvent was null."); } else if (map == null) { ib.b(a, "Parameters Map passed to onEvent was null."); } else { try { fu.a().c(str, map); } catch (Throwable th) { ib.a(a, "", th); } } }
public static Bundle composeHaboCgiReportParams(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) { Bundle bundle = new Bundle(); bundle.putString(Constants.PARAM_PLATFORM, "1"); bundle.putString("result", str); bundle.putString("code", str2); bundle.putString("tmcost", str3); bundle.putString("rate", str4); bundle.putString("cmd", str5); bundle.putString("uin", str6); bundle.putString("appid", str7); bundle.putString("share_type", str8); bundle.putString("detail", str9); bundle.putString("os_ver", VERSION.RELEASE); bundle.putString("network", a.a(Global.getContext())); bundle.putString("apn", a.b(Global.getContext())); bundle.putString("model_name", Build.MODEL); bundle.putString("sdk_ver", Constants.SDK_VERSION); bundle.putString(ShareRequestParam.REQ_PARAM_PACKAGENAME, Global.getPackageName()); bundle.putString("app_ver", getAppVersionName(Global.getContext(), Global.getPackageName())); return bundle; }
@SuppressLint({"NewApi"}) public static Bitmap takeScreenShot(Activity pActivity) { View view = pActivity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); Rect frame = new Rect(); view.getWindowVisibleDisplayFrame(frame); int stautsHeight = frame.top; Point size = new Point(); Display display = pActivity.getWindowManager().getDefaultDisplay(); if (VERSION.SDK_INT < 13) { size.set(display.getWidth(), display.getHeight()); } else { pActivity.getWindowManager().getDefaultDisplay().getSize(size); } return Bitmap.createBitmap(bitmap, 0, stautsHeight, size.x, size.y - stautsHeight); }
public View createView(View parent, String name, @NonNull Context context, @NonNull AttributeSet attrs) { boolean isPre21; boolean inheritContext; if (VERSION.SDK_INT < 21) { isPre21 = true; } else { isPre21 = false; } if (this.mAppCompatViewInflater == null) { this.mAppCompatViewInflater = new AppCompatViewInflater(); } if (isPre21 && shouldInheritContext((ViewParent) parent)) { inheritContext = true; } else { inheritContext = false; } return this.mAppCompatViewInflater.createView(parent, name, context, attrs, inheritContext, isPre21, true, isPre21); }
@TargetApi(VERSION_CODES.JELLY_BEAN) private void compatPostOnAnimation(Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { postOnAnimation(runnable); } else { postDelayed(runnable, 1000/60); } }
@TargetApi(9) public boolean save(Editor editor) { if (VERSION.SDK_INT < 9) { return editor.commit(); } editor.apply(); return true; }
@Nullable public static Drawable getDrawableForDensity(@NonNull Resources res, @DrawableRes int id, int density, @Nullable Theme theme) throws NotFoundException { if (VERSION.SDK_INT >= 21) { return ResourcesCompatApi21.getDrawableForDensity(res, id, density, theme); } if (VERSION.SDK_INT >= 15) { return ResourcesCompatIcsMr1.getDrawableForDensity(res, id, density); } return res.getDrawable(id); }
public static void setVersionName(String str) { if (VERSION.SDK_INT < 10) { ib.b(a, "Device SDK Version older than 10"); } else if (str == null) { ib.b(a, "String versionName passed to setVersionName was null."); } else { je.a().a("VersionName", (Object) str); } }
private void startForegroundWithNotification(String content) { if (VERSION.SDK_INT >= VERSION_CODES.O) startForeground(FOREGROUND_SERVICE_NOTIFICATION_ID, new NotificationCompat.Builder(this, "sync") .setTicker(content) .setSmallIcon(R.drawable.icon) .setColor(getResources().getColor(R.color.light_black)) .setContentTitle(content) .setContentText(content) .setWhen(System.currentTimeMillis()) .setCategory(NotificationCompat.CATEGORY_SERVICE) .build()); }
public static String getSecurityPatchDateString() { if (VERSION.SDK_INT >= 23) { return VERSION.SECURITY_PATCH; } Matcher matcher = Pattern.compile(DATE_PATTERN).matcher(SystemUtils.getSystemProp(SECURITY_PATCH)); if (matcher.find()) { return matcher.group(); } return null; }
public void writeToParcel(Parcel dest, int flags) { if (VERSION.SDK_INT < 21) { dest.writeString(this.mMediaId); TextUtils.writeToParcel(this.mTitle, dest, flags); TextUtils.writeToParcel(this.mSubtitle, dest, flags); TextUtils.writeToParcel(this.mDescription, dest, flags); dest.writeParcelable(this.mIcon, flags); dest.writeParcelable(this.mIconUri, flags); dest.writeBundle(this.mExtras); dest.writeParcelable(this.mMediaUri, flags); return; } MediaDescriptionCompatApi21.writeToParcel(getMediaDescription(), dest, flags); }
public static void finishAffinity(Activity activity) { if (VERSION.SDK_INT >= 16) { ActivityCompatJB.finishAffinity(activity); } else { activity.finish(); } }
public static void setViewBackground(View view, Drawable drawable) { if (view != null) { if (VERSION.SDK_INT < 16) { view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } } }
private void initFooterSearchView(ArrayList<String> arrayList) { try { this.mFootSearchView.setList(this.mChannelHomeBean.searchWords); if (this.mPullView != null && ((ExpandableListView) this.mPullView.getRefreshableView()).getFooterViewsCount() >= 1 && VERSION.SDK_INT >= 14) { ((ExpandableListView) this.mPullView.getRefreshableView()).removeFooterView(this.mFootSearchView); } ((ExpandableListView) this.mPullView.getRefreshableView()).addFooterView(this.mFootSearchView); } catch (Exception e) { this.mFootSearchView.setVisibility(8); e.printStackTrace(); } }
public void setMetadata(MediaMetadataCompat metadata) { Bundle bundle = null; if (VERSION.SDK_INT >= 14 && metadata != null) { metadata = cloneMetadataIfNeeded(metadata); } synchronized (this.mLock) { this.mMetadata = metadata; } sendMetadata(metadata); if (!this.mIsActive) { return; } Object obj; if (VERSION.SDK_INT >= 19) { obj = this.mRccObj; if (metadata != null) { bundle = metadata.getBundle(); } MediaSessionCompatApi19.setMetadata(obj, bundle, this.mState == null ? 0 : this.mState.getActions()); } else if (VERSION.SDK_INT >= 14) { obj = this.mRccObj; if (metadata != null) { bundle = metadata.getBundle(); } MediaSessionCompatApi14.setMetadata(obj, bundle); } }
protected void onLayout(boolean changed, int l, int t, int r, int b) { if (VERSION.SDK_INT >= 11 && this.oriLeft != 0) { setLeft(this.oriLeft); setRight(this.oriRight); setTop(this.oriTop); setBottom(this.oriBottom); } }
@TargetApi(16) public void handleBeforeMeasure(int width, int height) { if (this.mIsTranslucentStatus && VERSION.SDK_INT >= 16 && this.mTargetRootView.getFitsSystemWindows()) { Rect rect = new Rect(); this.mTargetRootView.getWindowVisibleDisplayFrame(rect); height = rect.bottom - rect.top; } Log.d(TAG, "onMeasure, width: " + width + " height: " + height); if (height >= 0) { if (this.mOldHeight < 0) { this.mOldHeight = height; return; } int offset = this.mOldHeight - height; if (offset == 0) { Log.d(TAG, "" + offset + " == 0 break;"); } else if (Math.abs(offset) == this.mStatusBarHeight) { Log.w(TAG, String.format("offset just equal statusBar height %d", new Object[]{Integer.valueOf(offset)})); } else { this.mOldHeight = height; IPanelConflictLayout panel = getPanelLayout(this.mTargetRootView); if (panel == null) { Log.w(TAG, "can't find the valid panel conflict layout, give up!"); } else if (offset > 0) { panel.handleHide(); } else if (panel.isKeyboardShowing() && panel.isVisible()) { panel.handleShow(); } } } }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { SDK16.postOnAnimation(view, runnable); } else { view.postDelayed(runnable, 16); } }
public static void putBinder(Bundle bundle, String key, IBinder binder) { if (VERSION.SDK_INT >= 18) { BundleCompatJellybeanMR2.putBinder(bundle, key, binder); } else { BundleCompatDonut.putBinder(bundle, key, binder); } }
@Override protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) { final ExpandableListView lv; if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { lv = new InternalExpandableListViewSDK9(context, attrs); } else { lv = new InternalExpandableListView(context, attrs); } // Set it to this so it can be used in ListActivity/ListFragment lv.setId(android.R.id.list); return lv; }
@Override public void onDraw(Canvas canvas) { if (mBackground != null) { // Draw the background filling parts not covered by the illustration canvas.save(); canvas.translate(0, mIllustrationBounds.height()); // Scale the background so its size matches the foreground canvas.scale(mScale, mScale, 0, 0); if (VERSION.SDK_INT > VERSION_CODES.JELLY_BEAN_MR1 && shouldMirrorDrawable(mBackground, getLayoutDirection())) { // Flip the illustration for RTL layouts canvas.scale(-1, 1); canvas.translate(-mBackground.getBounds().width(), 0); } mBackground.draw(canvas); canvas.restore(); } if (mIllustration != null) { canvas.save(); if (VERSION.SDK_INT > VERSION_CODES.JELLY_BEAN_MR1 && shouldMirrorDrawable(mIllustration, getLayoutDirection())) { // Flip the illustration for RTL layouts canvas.scale(-1, 1); canvas.translate(-mIllustrationBounds.width(), 0); } // Draw the illustration mIllustration.draw(canvas); canvas.restore(); } super.onDraw(canvas); }
public final void run() { int i = 0; try { long currentTimeMillis = System.currentTimeMillis() / 1000; long s = a.s(); new StringBuilder(z[2]).append(currentTimeMillis).append(z[0]).append(s); z.b(); if (-1 == s || Math.abs(currentTimeMillis - s) > this.a) { List t = cn.jpush.android.util.a.t(this.b.getApplicationContext()); a.b(currentTimeMillis); int size = t != null ? t.size() : 0; while (i < size) { Intent intent = new Intent(); intent.setComponent((ComponentName) t.get(i)); if (VERSION.SDK_INT >= 12) { intent.setFlags(32); } this.b.startService(intent); i++; } return; } new StringBuilder(z[1]).append(currentTimeMillis - s); z.a(); } catch (SecurityException e) { z.d(z[4], z[3]); e.printStackTrace(); } }
static TextToSpeech construct(Context context, OnInitListener onInitListener, String engineName) { if (VERSION.SDK_INT >= 14) { return new TextToSpeech(context, onInitListener, engineName); } if (engineName == null) { return new TextToSpeech(context, onInitListener); } Log.w(TAG, "Can't specify tts engine on this device"); return new TextToSpeech(context, onInitListener); }
protected void onCreate(Bundle bundle) { super.onCreate(bundle); try { Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } try { String string = extras.getString("url"); if (i.b(string)) { Method method; super.requestWindowFeature(1); this.c = new Handler(getMainLooper()); Object string2 = extras.getString("cookie"); if (!TextUtils.isEmpty(string2)) { CookieSyncManager.createInstance(getApplicationContext()).sync(); CookieManager.getInstance().setCookie(string, string2); CookieSyncManager.getInstance().sync(); } View linearLayout = new LinearLayout(getApplicationContext()); LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); linearLayout.setOrientation(1); setContentView(linearLayout, layoutParams); this.a = new WebView(getApplicationContext()); layoutParams.weight = 1.0f; this.a.setVisibility(0); linearLayout.addView(this.a, layoutParams); WebSettings settings = this.a.getSettings(); settings.setUserAgentString(settings.getUserAgentString() + i.c(getApplicationContext())); settings.setRenderPriority(RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(TextSize.NORMAL); this.a.setVerticalScrollbarOverlay(true); this.a.setWebViewClient(new a()); this.a.loadUrl(string); if (VERSION.SDK_INT >= 7) { try { method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)}); } } catch (Exception e) { } } try { method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]); if (method != null) { method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"}); method.invoke(this.a, new Object[]{"accessibility"}); method.invoke(this.a, new Object[]{"accessibilityTraversal"}); return; } return; } catch (Exception e2) { return; } } finish(); } catch (Exception e3) { finish(); } } catch (Exception e4) { finish(); } }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { postOnAnimationJellyBean(view, runnable); } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); } }
public static Long getFreeSpaceSize(StatFs statFs) { long freeSpaceSize = 0; try { if (VERSION.SDK_INT >= 18) { freeSpaceSize = statFs.getFreeBlocksLong() * statFs.getBlockSizeLong(); } else { freeSpaceSize = ((long) statFs.getFreeBlocks()) * ((long) statFs.getBlockSize()); } } catch (Throwable e) { LOG.w(TAG, "getScreenHeightWidth failed(Throwable): " + e.getMessage()); } return Long.valueOf(freeSpaceSize); }