List of usage examples for android.util TypedValue TypedValue
TypedValue
From source file:com.geecko.QuickLyric.fragment.SettingsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;/*from www . j av a2s. c om*/ final MainActivity activity = ((MainActivity) this.getActivity()); View fragmentView = getView(); TypedValue typedValue = new TypedValue(); view.getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true); if (fragmentView != null) fragmentView.setBackgroundColor(typedValue.data); DrawerAdapter drawerAdapter = ((DrawerAdapter) ((ListView) activity.findViewById(R.id.drawer_list)) .getAdapter()); if (drawerAdapter.getSelectedItem() != 2) { drawerAdapter.setSelectedItem(2); drawerAdapter.notifyDataSetChanged(); } this.isActiveFragment = true; }
From source file:com.dtd.thevyshka.Utils.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w.ja v a 2 s . co m*/ */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mTabCount); textView.setGravity(Gravity.CENTER); textView.setTextSize(12);//TODO adapting to all textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding / 2, padding, padding / 2, padding); return textView; }
From source file:com.bhatworks.android.slidingtab.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w . ja v a 2s. co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); if (mTabColor != null) { textView.setTextColor(mTabColor); } return textView; }
From source file:com.consumer.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from www . ja v a 2 s . co m */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { Resources res = context.getResources(); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); //textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTextSize(TAB_VIEW_TEXT_SIZE_SP); //textView.setTypeface(Typeface.DEFAULT_BOLD); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f); textView.setLayoutParams(param); int unSelColorBg = R.color.TabPager; textView.setTextColor(context.getResources().getColor(unSelColorBg)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); //textView.setPadding(padding,padding, padding, padding); textView.setPadding(5, 17, 5, 22); return textView; }
From source file:com.consumer.widget.SlidingTabLayoutSpend.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w . j a va 2 s.c o m*/ */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { Resources res = context.getResources(); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); //textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTextSize(TAB_VIEW_TEXT_SIZE_SP); //textView.setTypeface(Typeface.DEFAULT_BOLD); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f); textView.setLayoutParams(param); // int unSelColorBg= R.color.TabPager; int unSelColorBg = R.color.White; textView.setTextColor(context.getResources().getColor(unSelColorBg)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); //textView.setPadding(padding,padding, padding, padding); textView.setPadding(28, 15, 28, 15); return textView; }
From source file:ch.berta.fabio.fabprogress.FabProgress.java
private int fetchAccentColor() { final TypedValue value = new TypedValue(); getContext().getTheme().resolveAttribute(R.attr.colorAccent, value, true); return value.data; }
From source file:com.dotcom.jamaat.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w .java2 s .c o m */ protected TextView createDefaultTabView(Context context) { // TextView textView = new TextView(context); // textView.setGravity(Gravity.CENTER); // textView.setTextSize(context.getResources().getDimension(R.dimen.dimen_9_sp)); // textView.setTypeface(Typeface.DEFAULT); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Regular.ttf"); textView.setTypeface(font); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(false); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(10, padding, 10, padding); return textView; /*// WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); //*/ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // // If we're running on Honeycomb or newer, then we can use the Theme's // // selectableItemBackground to ensure that the View has a pressed state // TypedValue outValue = new TypedValue(); // getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, // outValue, true); // textView.setBackgroundResource(outValue.resourceId); // } // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style // // textView.setAllCaps(true); // } // // int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); // textView.setPadding(0,20,0,20); // // return textView; }
From source file:com.geecko.QuickLyric.broadcastReceiver.MusicBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { /** Google Play Music //bool streaming long position //long albumId String album //bool currentSongLoaded String track //long ListPosition long ListSize //long id bool playing //long duration int previewPlayType //bool supportsRating int domain //bool albumArtFromService String artist //int rating bool local //bool preparing bool inErrorState */// ww w . j a v a2s . com Bundle extras = intent.getExtras(); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); boolean lengthFilter = sharedPref.getBoolean("pref_filter_20min", true); if (extras != null) try { extras.getInt("state"); } catch (BadParcelableException e) { return; } if (extras == null || extras.getInt("state") > 1 //Tracks longer than 20min are presumably not songs || (lengthFilter && (extras.get("duration") instanceof Long && extras.getLong("duration") > 1200000) || (extras.get("duration") instanceof Double && extras.getDouble("duration") > 1200000) || (extras.get("duration") instanceof Integer && extras.getInt("duration") > 1200)) || (lengthFilter && (extras.get("secs") instanceof Long && extras.getLong("secs") > 1200000) || (extras.get("secs") instanceof Double && extras.getDouble("secs") > 1200000) || (extras.get("secs") instanceof Integer && extras.getInt("secs") > 1200)) || (extras.containsKey("com.maxmpz.audioplayer.source") && Build.VERSION.SDK_INT >= 19)) return; String artist = extras.getString("artist"); String track = extras.getString("track"); long position = extras.containsKey("position") && extras.get("position") instanceof Long ? extras.getLong("position") : -1; if (extras.get("position") instanceof Double) position = Double.valueOf(extras.getDouble("position")).longValue(); boolean isPlaying = extras.getBoolean(extras.containsKey("playstate") ? "playstate" : "playing", true); if (intent.getAction().equals("com.amazon.mp3.metachanged")) { artist = extras.getString("com.amazon.mp3.artist"); track = extras.getString("com.amazon.mp3.track"); } else if (intent.getAction().equals("com.spotify.music.metadatachanged")) isPlaying = spotifyPlaying; else if (intent.getAction().equals("com.spotify.music.playbackstatechanged")) spotifyPlaying = isPlaying; if ((artist == null || "".equals(artist)) //Could be problematic || (track == null || "".equals(track) || track.startsWith("DTNS"))) // Ignore one of my favorite podcasts return; SharedPreferences current = context.getSharedPreferences("current_music", Context.MODE_PRIVATE); String currentArtist = current.getString("artist", ""); String currentTrack = current.getString("track", ""); SharedPreferences.Editor editor = current.edit(); editor.putString("artist", artist); editor.putString("track", track); if (!(artist.equals(currentArtist) && track.equals(currentTrack) && position == -1)) editor.putLong("position", position); editor.putBoolean("playing", isPlaying); if (isPlaying) { long currentTime = System.currentTimeMillis(); editor.putLong("startTime", currentTime); } editor.apply(); autoUpdate = autoUpdate || sharedPref.getBoolean("pref_auto_refresh", false); int notificationPref = Integer.valueOf(sharedPref.getString("pref_notifications", "0")); if (autoUpdate && App.isActivityVisible()) { Intent internalIntent = new Intent("Broadcast"); internalIntent.putExtra("artist", artist).putExtra("track", track); LyricsViewFragment.sendIntent(context, internalIntent); forceAutoUpdate(false); } boolean inDatabase = DatabaseHelper.getInstance(context) .presenceCheck(new String[] { artist, track, artist, track }); if (notificationPref != 0 && isPlaying && (inDatabase || OnlineAccessVerifier.check(context))) { Intent activityIntent = new Intent("com.geecko.QuickLyric.getLyrics").putExtra("TAGS", new String[] { artist, track }); Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE").putExtra("artist", artist) .putExtra("track", track); PendingIntent openAppPending = PendingIntent.getActivity(context, 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent wearablePending = PendingIntent.getBroadcast(context, 8, wearableIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Action wearableAction = new NotificationCompat.Action.Builder(R.drawable.ic_watch, context.getString(R.string.wearable_prompt), wearablePending).build(); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context); NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context); int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red, R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark }; int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); TypedValue primaryColorValue = new TypedValue(); context.setTheme(themes[themeNum]); context.getTheme().resolveAttribute(R.attr.colorPrimary, primaryColorValue, true); notifBuilder.setSmallIcon(R.drawable.ic_notif).setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setColor(primaryColorValue.data).setGroupSummary(true); wearableNotifBuilder.setSmallIcon(R.drawable.ic_notif) .setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending) .setVisibility(-1) // Notification.VISIBILITY_SECRET .setGroup("Lyrics_Notification").setOngoing(false).setColor(primaryColorValue.data) .setGroupSummary(false) .extend(new NotificationCompat.WearableExtender().addAction(wearableAction)); if (notificationPref == 2) { notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN wearableNotifBuilder.setPriority(-2); } else notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW Notification notif = notifBuilder.build(); Notification wearableNotif = wearableNotifBuilder.build(); if (notificationPref == 2) notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; else notif.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManagerCompat.from(context).notify(0, notif); try { context.getPackageManager().getPackageInfo("com.google.android.wearable.app", PackageManager.GET_META_DATA); NotificationManagerCompat.from(context).notify(8, wearableNotif); } catch (PackageManager.NameNotFoundException ignored) { } } else if (track.equals(current.getString("track", ""))) NotificationManagerCompat.from(context).cancel(0); }
From source file:com.homework.group.videoplayer.ui.widgets.slidingTab.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w .jav a2 s . co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextAppearance(context, R.style.SlidingTextViewStyle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); // textView.setBackgroundResource(R.color.theme_color); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.doomy.library.DiscreteSeekBar.java
public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFocusable(true);/*from w w w.j a v a2 s.c o m*/ setWillNotDraw(false); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); float density = context.getResources().getDisplayMetrics().density; mTrackHeight = (int) (1 * density); mScrubberHeight = (int) (4 * density); int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP); //Extra pixels for a touch area of 48dp int touchBounds = (int) (density * 32); mAddedTouchBounds = (touchBounds - thumbSize) / 2; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, R.attr.discreteSeekBarStyle, defStyle); int max = 100; int min = 0; int value = 0; mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl); mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick); int indexMax = R.styleable.DiscreteSeekBar_dsb_max; int indexMin = R.styleable.DiscreteSeekBar_dsb_min; int indexValue = R.styleable.DiscreteSeekBar_dsb_value; final TypedValue out = new TypedValue(); //Not sure why, but we wanted to be able to use dimensions here... if (a.getValue(indexMax, out)) { if (out.type == TypedValue.TYPE_DIMENSION) { max = a.getDimensionPixelSize(indexMax, max); } else { max = a.getInteger(indexMax, max); } } if (a.getValue(indexMin, out)) { if (out.type == TypedValue.TYPE_DIMENSION) { min = a.getDimensionPixelSize(indexMin, min); } else { min = a.getInteger(indexMin, min); } } if (a.getValue(indexValue, out)) { if (out.type == TypedValue.TYPE_DIMENSION) { value = a.getDimensionPixelSize(indexValue, value); } else { value = a.getInteger(indexValue, value); } } mMin = min; mMax = Math.max(min + 1, max); mValue = Math.max(min, Math.min(max, value)); updateKeyboardRange(); mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter); ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor); ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor); ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor); boolean editMode = isInEditMode(); if (editMode && rippleColor == null) { rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY }); } if (editMode && trackColor == null) { trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY }); } if (editMode && progressColor == null) { progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { 0xff009688 }); } mRipple = SeekBarCompat.getRipple(rippleColor); if (isLollipopOrGreater) { SeekBarCompat.setBackground(this, mRipple); } else { mRipple.setCallback(this); } TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor); mTrack = shapeDrawable; mTrack.setCallback(this); shapeDrawable = new TrackRectDrawable(progressColor); mScrubber = shapeDrawable; mScrubber.setCallback(this); ThumbDrawable thumbDrawable = new ThumbDrawable(progressColor, thumbSize); mThumb = thumbDrawable; mThumb.setCallback(this); mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight()); if (!editMode) { mIndicator = new PopupIndicator(context, attrs, defStyle, convertValueToMessage(mMax)); mIndicator.setListener(mFloaterListener); } a.recycle(); setNumericTransformer(new DefaultNumericTransformer()); }