List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override/*from w w w.j a v a 2s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LOG_TAG, "onCreate() : " + savedInstanceState); setContentView(R.layout.activity_jet_pack_elf); // App Invites mInvitesFragment = AppInvitesFragment.getInstance(this); // App Measurement mMeasurement = FirebaseAnalytics.getInstance(this); MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_rocket)); // [ANALYTICS SCREEN]: Rocket Sleigh AnalyticsManager.initializeAnalyticsTracker(this); AnalyticsManager.sendScreenView(R.string.analytics_screen_rocket); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ImmersiveModeHelper.setImmersiveSticky(getWindow()); ImmersiveModeHelper.installSystemUiVisibilityChangeListener(getWindow()); } mIntroVideo = (VideoView) findViewById(R.id.intro_view); mIntroControl = findViewById(R.id.intro_control_view); if (savedInstanceState == null) { String path = "android.resource://" + getPackageName() + "/" + R.raw.jp_background; mBackgroundPlayer = new MediaPlayer(); try { mBackgroundPlayer.setDataSource(this, Uri.parse(path)); mBackgroundPlayer.setLooping(true); mBackgroundPlayer.prepare(); mBackgroundPlayer.start(); } catch (IOException e) { e.printStackTrace(); } boolean nomovie = false; if (getIntent().getBooleanExtra("nomovie", false)) { nomovie = true; } else if (Build.MANUFACTURER.toUpperCase().contains("SAMSUNG")) { // nomovie = true; } if (!nomovie) { mIntroControl.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { endIntro(); } }); path = "android.resource://" + getPackageName() + "/" + R.raw.intro_wipe; mIntroVideo.setVideoURI(Uri.parse(path)); mIntroVideo.setOnCompletionListener(this); mIntroVideo.start(); mMoviePlaying = true; } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } } else { mIntroControl.setOnClickListener(null); mIntroControl.setVisibility(View.GONE); mIntroVideo.setVisibility(View.GONE); } mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // For hit indication. mHandler = new Handler(); // Get the main UI handler for posting update events DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); Log.d(LOG_TAG, "Width: " + dm.widthPixels + " Height: " + dm.heightPixels + " Density: " + dm.density); mScreenHeight = dm.heightPixels; mScreenWidth = dm.widthPixels; mSlotWidth = mScreenWidth / SLOTS_PER_SCREEN; // Setup the random number generator mRandom = new Random(); mRandom.setSeed(System.currentTimeMillis()); // This is ok. We are not looking for cryptographically secure random here! mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Setup the background/foreground mBackgroundLayout = (LinearLayout) findViewById(R.id.background_layout); mBackgroundScroll = (HorizontalScrollView) findViewById(R.id.background_scroll); mForegroundLayout = (LinearLayout) findViewById(R.id.foreground_layout); mForegroundScroll = (HorizontalScrollView) findViewById(R.id.foreground_scroll); mBackgrounds = new Bitmap[6]; mBackgrounds2 = new Bitmap[6]; mExitTransitions = new Bitmap[6]; mEntryTransitions = new Bitmap[6]; // Need to vertically scale background to fit the screen. Checkthe image size // compared to screen size and scale appropriately. We will also use the matrix to translate // as we move through the level. Bitmap bmp = BitmapFactory.decodeResource(getResources(), BACKGROUNDS[0]); Log.d(LOG_TAG, "Bitmap Width: " + bmp.getWidth() + " Height: " + bmp.getHeight() + " Screen Width: " + dm.widthPixels + " Height: " + dm.heightPixels); mScaleY = (float) dm.heightPixels / (float) bmp.getHeight(); mScaleX = (float) (dm.widthPixels * 2) / (float) bmp.getWidth(); // Ensure that a single bitmap is 2 screens worth of time. (Stock xxhdpi image is 3840x1080) if ((mScaleX != 1.0f) || (mScaleY != 1.0f)) { Bitmap tmp = Bitmap.createScaledBitmap(bmp, mScreenWidth * 2, mScreenHeight, false); if (tmp != bmp) { bmp.recycle(); bmp = tmp; } } BackgroundLoadTask.createTwoBitmaps(bmp, mBackgrounds, mBackgrounds2, 0); // Load the initial background view addNextImages(0); addNextImages(0); mWoodObstacles = new TreeMap<Integer, Bitmap>(); mWoodObstacleList = new ArrayList<Integer>(); mWoodObstacleIndex = 0; // We need the bitmaps, so we do pre-load here synchronously. initObstaclesAndPreLoad(WOOD_OBSTACLES, 3, mWoodObstacles, mWoodObstacleList); mCaveObstacles = new TreeMap<Integer, Bitmap>(); mCaveObstacleList = new ArrayList<Integer>(); mCaveObstacleIndex = 0; initObstacles(CAVE_OBSTACLES, 2, mCaveObstacleList); mFactoryObstacles = new TreeMap<Integer, Bitmap>(); mFactoryObstacleList = new ArrayList<Integer>(); mFactoryObstacleIndex = 0; initObstacles(FACTORY_OBSTACLES, 2, mFactoryObstacleList); // Setup the elf mElf = (ImageView) findViewById(R.id.elf_image); mThrust = (ImageView) findViewById(R.id.thrust_image); mElfLayout = (LinearLayout) findViewById(R.id.elf_container); loadElfImages(); updateElf(false); // Elf should be the same height relative to the height of the screen on any platform. Matrix scaleMatrix = new Matrix(); mElfScale = ((float) dm.heightPixels * 0.123f) / (float) mElfBitmap.getHeight(); // On a 1920x1080 xxhdpi screen, this makes the elf 133 pixels which is the height of the drawable. scaleMatrix.preScale(mElfScale, mElfScale); mElf.setImageMatrix(scaleMatrix); mThrust.setImageMatrix(scaleMatrix); mElfPosX = (dm.widthPixels * 15) / 100; // 15% Into the screen mElfPosY = (dm.heightPixels - ((float) mElfBitmap.getHeight() * mElfScale)) / 2; // About 1/2 way down. mElfVelX = (float) dm.widthPixels / 3000.0f; // We start at 3 seconds for a full screen to scroll. mGravityAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((1.2 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 1.2 seconds mThrustAccelY = (float) (2 * dm.heightPixels) / (float) Math.pow((0.7 * 1000.0), 2.0); // a = 2*d/t^2 Where d = height in pixels and t = 0.7 seconds // Setup the control view mControlView = findViewById(R.id.control_view); mGestureDetector = new GestureDetector(this, this); mGestureDetector.setIsLongpressEnabled(true); mGestureDetector.setOnDoubleTapListener(this); mScoreLabel = getString(R.string.score); mScoreText = (TextView) findViewById(R.id.score_text); mScoreText.setText("0"); mPlayPauseButton = (ImageView) findViewById(R.id.play_pause_button); mExit = (ImageView) findViewById(R.id.exit); // Is Tv? mIsTv = TvUtil.isTv(this); if (mIsTv) { mScoreText.setText(mScoreLabel + ": 0"); mPlayPauseButton.setVisibility(View.GONE); mExit.setVisibility(View.GONE); // move scoreLayout position to the Top-Right corner. View scoreLayout = findViewById(R.id.score_layout); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) scoreLayout.getLayoutParams(); params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); final int marginTop = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_top); final int marginLeft = getResources().getDimensionPixelOffset(R.dimen.overscan_margin_left); params.setMargins(marginLeft, marginTop, 0, 0); scoreLayout.setLayoutParams(params); scoreLayout.setBackground(null); scoreLayout.findViewById(R.id.score_text_seperator).setVisibility(View.GONE); } else { mPlayPauseButton.setEnabled(false); mPlayPauseButton.setOnClickListener(this); mExit.setOnClickListener(this); } mBigPlayButtonLayout = findViewById(R.id.big_play_button_layout); mBigPlayButtonLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // No interaction with the screen below this one. return true; } }); mBigPlayButton = (ImageButton) findViewById(R.id.big_play_button); mBigPlayButton.setOnClickListener(this); // For showing points when getting presents. mPlus100 = (ImageView) findViewById(R.id.plus_100); m100Anim = new AlphaAnimation(1.0f, 0.0f); m100Anim.setDuration(1000); m100Anim.setFillBefore(true); m100Anim.setFillAfter(true); mPlus500 = (ImageView) findViewById(R.id.plus_500); m500Anim = new AlphaAnimation(1.0f, 0.0f); m500Anim.setDuration(1000); m500Anim.setFillBefore(true); m500Anim.setFillAfter(true); // Get the obstacle layouts ready. No obstacles on the first screen of a level. // Prime with a screen full of obstacles. mObstacleLayout = (LinearLayout) findViewById(R.id.obstacles_layout); mObstacleScroll = (HorizontalScrollView) findViewById(R.id.obstacles_scroll); // Initialize the present bitmaps. These are used repeatedly so we keep them loaded. mGiftBoxes = new Bitmap[GIFT_BOXES.length]; for (int i = 0; i < GIFT_BOXES.length; i++) { mGiftBoxes[i] = BitmapFactory.decodeResource(getResources(), GIFT_BOXES[i]); } // Add starting obstacles. First screen has presents. Next 3 get obstacles. addFirstScreenPresents(); // addFinalPresentRun(); // This adds 2 screens of presents // addNextObstacles(0, 1); addNextObstacles(0, 3); // Setup the sound pool mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0); mSoundPool.setOnLoadCompleteListener(this); mCrashSound1 = mSoundPool.load(this, R.raw.jp_crash_1, 1); mCrashSound2 = mSoundPool.load(this, R.raw.jp_crash_2, 1); mCrashSound3 = mSoundPool.load(this, R.raw.jp_crash_3, 1); mGameOverSound = mSoundPool.load(this, R.raw.jp_game_over, 1); mJetThrustSound = mSoundPool.load(this, R.raw.jp_jet_thrust, 1); mLevelUpSound = mSoundPool.load(this, R.raw.jp_level_up, 1); mScoreBigSound = mSoundPool.load(this, R.raw.jp_score_big, 1); mScoreSmallSound = mSoundPool.load(this, R.raw.jp_score_small, 1); mJetThrustStream = 0; if (!mMoviePlaying) { doCountdown(); } }
From source file:com.flowzr.activity.BlotterFragment.java
private void showTransactionInfo(long id) { LayoutInflater layoutInflater = (LayoutInflater) this.getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); NodeInflater inflater = new NodeInflater(layoutInflater); TransactionInfoDialog transactionInfoView = new TransactionInfoDialog(this.getActivity(), db, inflater); transactionInfoView.show(this, id); }
From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java
public Bitmap getMarkerBitmap(String email, Boolean accurate, Boolean recent) { Log.e(TAG, "getMarkerBitmap"); // Add cache checking logic Bitmap markerImage = MainApplication.avatarCache.get(email + ":" + accurate + ":" + recent); if (markerImage != null) { Log.e(TAG, "Marker IN cache: " + email + ":" + accurate + ":" + recent); return markerImage; } else {/*from w w w . j a va 2 s . c om*/ Log.e(TAG, "Marker NOT in cache. Processing: " + email + ":" + accurate + ":" + recent); } Log.e(TAG, "AvatarLoader not in cache. Fetching it. Email: " + email); // Get avatars Bitmap userImage = Utils.getPhotoFromEmail(context, email); if (userImage == null) { userImage = BitmapFactory.decodeResource(getResources(), R.drawable.default_avatar); } else { userImage = Utils.getRoundedCornerBitmap(userImage, 50); } // Marker colors, etc. Log.e(TAG, "userImage size: " + userImage); View markerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.map_marker, null); aq = new AQuery(markerView); aq.id(R.id.user_image).image(userImage); Log.e(TAG, "aq in place"); if (email.equals(MainApplication.userAccount)) { aq.id(R.id.marker_frame).image(R.drawable.pointers_android_pointer_green); } else if (!recent || !accurate) { aq.id(R.id.marker_frame).image(R.drawable.pointers_android_pointer_orange); } Log.e(TAG, "Image set. Calling createDrawableFromView"); markerImage = createDrawableFromView(markerView); MainApplication.avatarCache.put(email + ":" + accurate + ":" + recent, markerImage); return markerImage; }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
private void updateButtonOpenLink() { final View btnOpenLink = menu.findViewById(R.id.BtnOpenLink); btnOpenLink.setOnClickListener(new OnClickListener() { @Override//w w w . j ava 2 s . co m public void onClick(final View view) { if (listener != null) { final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr); switch (setting.getData()) { case SettingBrowserChoice.BROWSER_CHOICE_UNKNOWN: final LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Dialog)); final View popupView = inflater.inflate(R.layout.browser_choice_popup, null); final CheckBox checkBox = (CheckBox) popupView.findViewById(R.id.CheckBoxDontShowAgain); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { popupView.findViewById(R.id.Hint).setVisibility(View.VISIBLE); } }); final String items[] = new String[3]; items[0] = context.getString(R.string.TxtBuiltInMobilized); items[1] = context.getString(R.string.TxtBuiltInOriginal); items[2] = context.getString(R.string.TxtExternalOriginal); builder.setTitle(R.string.TxtChooseBrowser); builder.setView(popupView); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { switch (which) { case 0: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED); } dialog.dismiss(); break; case 1: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL); } dialog.dismiss(); break; case 2: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL); } dialog.dismiss(); break; default: break; } } }); builder.setNegativeButton(context.getString(R.string.TxtCancel), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); builder.show(); break; case SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); break; case SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } break; case SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } break; default: break; } } } }); }
From source file:com.bigpigs.fragments.SearchFragment.java
private Bitmap getMarkerBitmapFromView(@DrawableRes int resId) { View customMarkerView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.custom_marker, null); ImageView markerImageView = (ImageView) customMarkerView.findViewById(R.id.marker_icon); markerImageView.setImageResource(resId); customMarkerView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); customMarkerView.layout(0, 0, customMarkerView.getMeasuredWidth(), customMarkerView.getMeasuredHeight()); customMarkerView.buildDrawingCache(); Bitmap returnedBitmap = Bitmap.createBitmap(customMarkerView.getMeasuredWidth(), customMarkerView.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(returnedBitmap); canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC_IN); Drawable drawable = customMarkerView.getBackground(); if (drawable != null) drawable.draw(canvas);//from w w w. j a va 2 s . co m customMarkerView.draw(canvas); return returnedBitmap; }
From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java
@Override public void initializeWidget() { T.UI();//from ww w .j ava 2s . c o m if (!isEnabled()) { LinearLayout advancedOrderContainer = (LinearLayout) findViewById(R.id.advanced_order_container); advancedOrderContainer.setVisibility(View.GONE); TextView advancedOrderLocked = (TextView) findViewById(R.id.advanced_order_locked); advancedOrderLocked.setVisibility(View.VISIBLE); advancedOrderLocked.setText(AdvancedOrderWidget.valueString(mActivity, mWidgetMap)); return; } mCachedDownloader = CachedDownloader.getInstance(mActivity.getMainService()); mLayoutInFlater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mAdvancedOrderDictionary = new HashMap<String, Map<String, AdvancedOrderItem>>(); try { mAdvancedOrder = new AdvancedOrderTO(mWidgetMap); for (AdvancedOrderCategory category : mAdvancedOrder.categories) { Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>(); for (AdvancedOrderItem item : category.items) { items.put(item.id, item); } mAdvancedOrderDictionary.put(category.id, items); } } catch (IncompleteMessageException e) { L.bug(e); return; } mResultDictionary = new HashMap<String, Map<String, AdvancedOrderItem>>(); @SuppressWarnings("unchecked") Map<String, Object> result = (Map<String, Object>) mWidgetMap.get("value"); if (result != null) { try { AdvancedOrderWidgetResult r = new AdvancedOrderWidgetResult(result); for (AdvancedOrderCategory category : r.categories) { Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>(); for (AdvancedOrderItem item : category.items) { items.put(item.id, item); } mResultDictionary.put(category.id, items); } } catch (IncompleteMessageException e) { L.bug(e); // Should never happen } } else { for (AdvancedOrderCategory category : mAdvancedOrder.categories) { Map<String, AdvancedOrderItem> items = new HashMap<String, AdvancedOrderItem>(); for (AdvancedOrderItem item : category.items) { if (item.value > 0) { items.put(item.id, item); } if (items.size() > 0) { mResultDictionary.put(category.id, items); } } } } renderListData(); if (mFontAwesomeTypeFace == null) { mFontAwesomeTypeFace = new FontAwesome().getTypeface(mActivity); } mBasketBtn = (TextView) findViewById(R.id.basket); mBasketBtn.setText(R.string.fa_shopping_cart); mBasketBtn.setTypeface(mFontAwesomeTypeFace); if (numberOfItemsInBasket() > 0) { mBasketBtn.setEnabled(true); mBasketBtn.setTextColor(mTextColor); } else { mBasketBtn.setEnabled(false); mBasketBtn.setTextColor(ContextCompat.getColor(mActivity, R.color.mc_divider_gray)); } mBasketBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { renderBasketListData(); showAdvancedOrderBasket(); } }); mListView = (ListView) findViewById(R.id.list_view); mListView.setAdapter(mListAdapter); mListView.setScrollContainer(false); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mListAdapter.onItemClick(parent, view, position, id); } }); mActivity.getMainService().postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { UIUtils.setListViewHeightBasedOnItems(mListView); } }); mBroadcastReceiver = getBroadcastReceiver(); final IntentFilter filter = getIntentFilter(); mActivity.registerReceiver(mBroadcastReceiver, filter); }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
private String getExtraData(Notification notification, String existing_text) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "I am running extra data"); }/*from w w w.j av a2 s . co m*/ RemoteViews views = notification.contentView; if (views == null) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "ContentView was empty, returning a blank string"); } return ""; } LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); try { ViewGroup localView = (ViewGroup) inflater.inflate(views.getLayoutId(), null); views.reapply(getApplicationContext(), localView); return dumpViewGroup(0, localView, existing_text); } catch (android.content.res.Resources.NotFoundException e) { return ""; } catch (RemoteViews.ActionException e) { return ""; } }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java
public AnyKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //creating the KeyDrawableStateProvider, as it suppose to be backward compatible int keyTypeFunctionAttrId = R.attr.key_type_function; int keyActionAttrId = R.attr.key_type_action; int keyActionTypeDoneAttrId = R.attr.action_done; int keyActionTypeSearchAttrId = R.attr.action_search; int keyActionTypeGoAttrId = R.attr.action_go; LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // int previewLayout = 0; mPreviewKeyTextSize = -1;/*from www .j a v a 2s . c o m*/ mPreviewLabelTextSize = -1; mPreviewKeyBackground = null; mPreviewKeyTextColor = 0xFFF; final int[] padding = new int[] { 0, 0, 0, 0 }; KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(context.getApplicationContext()); final int keyboardThemeStyleResId = getKeyboardStyleResId(theme); Log.d(TAG, "Will use keyboard theme " + theme.getName() + " id " + theme.getId() + " res " + keyboardThemeStyleResId); //creating a mapping from the remote Attribute IDs to my local attribute ID. //this is required in order to backward support any build-system (which may cause the attribute IDs to change) final SparseIntArray attributeIdMap = new SparseIntArray(R.styleable.AnyKeyboardViewTheme.length + R.styleable.AnyKeyboardViewIconsTheme.length + ACTION_KEY_TYPES.length + KEY_TYPES.length); final int[] remoteKeyboardThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable( R.styleable.AnyKeyboardViewTheme, context, theme.getPackageContext(), attributeIdMap); final int[] remoteKeyboardIconsThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable( R.styleable.AnyKeyboardViewIconsTheme, context, theme.getPackageContext(), attributeIdMap); HashSet<Integer> doneLocalAttributeIds = new HashSet<Integer>(); TypedArray a = theme.getPackageContext().obtainStyledAttributes(keyboardThemeStyleResId, remoteKeyboardThemeStyleable); final int n = a.getIndexCount(); for (int i = 0; i < n; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = attributeIdMap.get(remoteKeyboardThemeStyleable[remoteIndex]); if (setValueFromTheme(a, padding, localAttrId, remoteIndex)) { doneLocalAttributeIds.add(localAttrId); if (localAttrId == R.attr.keyBackground) { //keyTypeFunctionAttrId and keyActionAttrId are remote final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable(KEY_TYPES, context, theme.getPackageContext(), attributeIdMap); keyTypeFunctionAttrId = keyStateAttributes[0]; keyActionAttrId = keyStateAttributes[1]; } } } a.recycle(); // taking icons int iconSetStyleRes = theme.getIconsThemeResId(); Log.d(TAG, "Will use keyboard icons theme " + theme.getName() + " id " + theme.getId() + " res " + iconSetStyleRes); if (iconSetStyleRes != 0) { a = theme.getPackageContext().obtainStyledAttributes(iconSetStyleRes, remoteKeyboardIconsThemeStyleable); final int iconsCount = a.getIndexCount(); for (int i = 0; i < iconsCount; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = attributeIdMap.get(remoteKeyboardIconsThemeStyleable[remoteIndex]); if (setKeyIconValueFromTheme(theme, a, localAttrId, remoteIndex)) { doneLocalAttributeIds.add(localAttrId); if (localAttrId == R.attr.iconKeyAction) { //keyActionTypeDoneAttrId and keyActionTypeSearchAttrId and keyActionTypeGoAttrId are remote final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable( ACTION_KEY_TYPES, context, theme.getPackageContext(), attributeIdMap); keyActionTypeDoneAttrId = keyStateAttributes[0]; keyActionTypeSearchAttrId = keyStateAttributes[1]; keyActionTypeGoAttrId = keyStateAttributes[2]; } } } a.recycle(); } // filling what's missing KeyboardTheme fallbackTheme = KeyboardThemeFactory.getFallbackTheme(context.getApplicationContext()); final int keyboardFallbackThemeStyleResId = getKeyboardStyleResId(fallbackTheme); Log.d(TAG, "Will use keyboard fallback theme " + fallbackTheme.getName() + " id " + fallbackTheme.getId() + " res " + keyboardFallbackThemeStyleResId); a = fallbackTheme.getPackageContext().obtainStyledAttributes(keyboardFallbackThemeStyleResId, R.styleable.AnyKeyboardViewTheme); final int fallbackCount = a.getIndexCount(); for (int i = 0; i < fallbackCount; i++) { final int index = a.getIndex(i); final int attrId = R.styleable.AnyKeyboardViewTheme[index]; if (doneLocalAttributeIds.contains(attrId)) continue; Log.d(TAG, "Falling back theme res ID " + index); setValueFromTheme(a, padding, attrId, index); } a.recycle(); // taking missing icons int fallbackIconSetStyleId = fallbackTheme.getIconsThemeResId(); Log.d(TAG, "Will use keyboard fallback icons theme " + fallbackTheme.getName() + " id " + fallbackTheme.getId() + " res " + fallbackIconSetStyleId); a = fallbackTheme.getPackageContext().obtainStyledAttributes(fallbackIconSetStyleId, R.styleable.AnyKeyboardViewIconsTheme); final int fallbackIconsCount = a.getIndexCount(); for (int i = 0; i < fallbackIconsCount; i++) { final int index = a.getIndex(i); final int attrId = R.styleable.AnyKeyboardViewIconsTheme[index]; if (doneLocalAttributeIds.contains(attrId)) continue; Log.d(TAG, "Falling back icon res ID " + index); setKeyIconValueFromTheme(fallbackTheme, a, attrId, index); } a.recycle(); //creating the key-drawable state provider, as we suppose to have the entire data now mDrawableStatesProvider = new KeyDrawableStateProvider(keyTypeFunctionAttrId, keyActionAttrId, keyActionTypeDoneAttrId, keyActionTypeSearchAttrId, keyActionTypeGoAttrId); // settings. // don't forget that there are TWO paddings, the theme's and the // background image's padding! Drawable keyboardBabground = super.getBackground(); if (keyboardBabground != null) { Rect backgroundPadding = new Rect(); keyboardBabground.getPadding(backgroundPadding); padding[0] += backgroundPadding.left; padding[1] += backgroundPadding.top; padding[2] += backgroundPadding.right; padding[3] += backgroundPadding.bottom; } super.setPadding(padding[0], padding[1], padding[2], padding[3]); final Resources res = getResources(); mKeyboardDimens.setKeyboardMaxWidth(res.getDisplayMetrics().widthPixels - padding[0] - padding[2]); mPreviewPopup = new PopupWindow(context); if (mPreviewKeyTextSize > 0) { if (mPreviewLabelTextSize <= 0) mPreviewLabelTextSize = mPreviewKeyTextSize; mPreviewLayut = inflatePreviewWindowLayout(inflate); mPreviewText = (TextView) mPreviewLayut.findViewById(R.id.key_preview_text); mPreviewText.setTextColor(mPreviewKeyTextColor); mPreviewText.setTypeface(mKeyTextStyle); mPreviewIcon = (ImageView) mPreviewLayut.findViewById(R.id.key_preview_icon); mPreviewPopup.setBackgroundDrawable(mPreviewKeyBackground); mPreviewPopup.setContentView(mPreviewLayut); mShowPreview = mPreviewLayut != null; } else { mPreviewLayut = null; mPreviewText = null; mShowPreview = false; } mPreviewPopup.setTouchable(false); mPreviewPopup .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.KeyPreviewAnimation); mDelayBeforePreview = 0; mDelayAfterPreview = 10; mMiniKeyboardParent = this; mMiniKeyboardPopup = new PopupWindow(context.getApplicationContext()); mMiniKeyboardPopup.setBackgroundDrawable(null); mMiniKeyboardPopup .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.MiniKeyboardAnimation); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setTextSize(mKeyTextSize); mPaint.setTextAlign(Align.CENTER); mPaint.setAlpha(255); mKeyBackgroundPadding = new Rect(0, 0, 0, 0); mKeyBackground.getPadding(mKeyBackgroundPadding); reloadSwipeThresholdsSettings(res); mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance); AskOnGestureListener listener = new AskGestureEventsListener(this); mGestureDetector = AnyApplication.getDeviceSpecific().createGestureDetector(getContext(), listener); mGestureDetector.setIsLongpressEnabled(false); MultiTouchSupportLevel multiTouchSupportLevel = AnyApplication.getDeviceSpecific() .getMultiTouchSupportLevel(getContext()); mHasDistinctMultitouch = multiTouchSupportLevel == MultiTouchSupportLevel.Distinct; mKeyRepeatInterval = 50; AnyApplication.getConfig().addChangedListener(this); }
From source file:com.cypress.cysmart.RDKEmulatorView.RemoteControlEmulatorFragment.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mParentView = inflater.inflate(R.layout.rgb_view_landscape, null); ViewGroup rootViewG = (ViewGroup) getView(); // Remove all the existing views from the root view. try {/*from w w w. j a va2 s. c o m*/ assert rootViewG != null; rootViewG.removeAllViews(); rootViewG.addView(mParentView); } catch (Exception e) { e.printStackTrace(); } } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mParentView = inflater.inflate(R.layout.rgb_view_portrait, null); ViewGroup rootViewG = (ViewGroup) getView(); // Remove all the existing views from the root view. try { assert rootViewG != null; rootViewG.removeAllViews(); rootViewG.addView(mParentView); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private String getExtraBigData(Notification notification, String existing_text) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "I am running extra big data"); }//from w ww . ja v a2s . com RemoteViews views = null; try { views = notification.bigContentView; } catch (NoSuchFieldError e) { return getExtraData(notification, existing_text); } if (views == null) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "bigContentView was empty, running normal"); } return getExtraData(notification, existing_text); } LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); try { ViewGroup localView = (ViewGroup) inflater.inflate(views.getLayoutId(), null); views.reapply(getApplicationContext(), localView); return dumpViewGroup(0, localView, existing_text); } catch (android.content.res.Resources.NotFoundException e) { return ""; } }