private void collectName(@NonNull Display display, @NonNull JSONObject container) throws JSONException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { container.put("name", display.getName()); } }
@TargetApi(JELLY_BEAN_MR1) public DisplayAssert hasName(String name) { isNotNull(); String actualName = actual.getName(); assertThat(actualName) // .overridingErrorMessage("Expected name <%s> but was <%s>", name, actualName) // .isEqualTo(name); return this; }
@Test public void changedStateShouldApplyToOtherInstancesOfSameDisplay() throws Exception { shadow.setName("another name"); shadow.setWidth(1024); shadow.setHeight(600); display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY); assertEquals(1024, display.getWidth()); assertEquals(600, display.getHeight()); assertEquals("another name", display.getName()); }
@Test public void shouldProvideWeirdDisplayInformation() { shadow.setName("foo"); shadow.setFlags(123); assertEquals("foo", display.getName()); assertEquals(123, display.getFlags()); display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY); assertEquals(123, display.getFlags()); }
@TargetApi(JELLY_BEAN_MR1) public DisplayAssert hasName(String name) { isNotNull(); String actualName = actual.getName(); assertThat(actualName) // .overridingErrorMessage("Expected name <%s> but was <%s>", name, actualName) // .isEqualTo(name); return this; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final View v; if (convertView == null) { v = ((Activity) mContext).getLayoutInflater().inflate( R.layout.presentation_list_item, null); } else { v = convertView; } final Display display = getItem(position); final int displayId = display.getDisplayId(); CheckBox cb = (CheckBox)v.findViewById(R.id.checkbox_presentation); cb.setTag(display); cb.setOnCheckedChangeListener(PresentationActivity.this); cb.setChecked(mActivePresentations.indexOfKey(displayId) >= 0 || mSavedPresentationContents.indexOfKey(displayId) >= 0); TextView tv = (TextView)v.findViewById(R.id.display_id); tv.setText(v.getContext().getResources().getString( R.string.presentation_display_id_text, displayId, display.getName())); Button b = (Button)v.findViewById(R.id.info); b.setTag(display); b.setOnClickListener(PresentationActivity.this); return v; }
R.string.presentation_display_id_text, displayId, display.getName()));
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the content view to the custom layout setContentView(R.layout.display); // Get the Views mLayout = (LinearLayout) findViewById(R.id.display_layout); mText = (TextView) findViewById(R.id.display_text); /* * Show the name of the display this presentation was embedded in. */ TextView smallText = (TextView) findViewById(R.id.display_smalltext); final String name = getDisplay().getName(); smallText.setText(getResources().getString(R.string.display_name, name)); }
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get the resources for the context of the presentation. // Notice that we are getting the resources from the context of the presentation. Resources r = getContext().getResources(); // Inflate the layout. setContentView(R.layout.presentation_content); final Display display = getDisplay(); final int displayId = display.getDisplayId(); final int photo = mContents.photo; // Show a caption to describe what's going on. TextView text = (TextView)findViewById(R.id.text); text.setText(r.getString(R.string.presentation_photo_text, photo, displayId, display.getName())); // Show a n image for visual interest. ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(r.getDrawable(PHOTOS[photo])); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // Set the background to a random gradient. Point p = new Point(); getDisplay().getSize(p); drawable.setGradientRadius(Math.max(p.x, p.y) / 2); drawable.setColors(mContents.colors); findViewById(android.R.id.content).setBackground(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get the resources for the context of the presentation. // Notice that we are getting the resources from the context of the presentation. Resources r = getContext().getResources(); // Inflate the layout. setContentView(R.layout.presentation_content); final Display display = getDisplay(); final int displayId = display.getDisplayId(); final int photo = mContents.photo; // Show a caption to describe what's going on. TextView text = (TextView)findViewById(R.id.text); text.setText(r.getString(R.string.presentation_photo_text, photo, displayId, display.getName())); // Show a n image for visual interest. ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(r.getDrawable(PHOTOS[photo])); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // Set the background to a random gradient. Point p = new Point(); getDisplay().getSize(p); drawable.setGradientRadius(Math.max(p.x, p.y) / 2); drawable.setColors(mContents.colors); findViewById(android.R.id.content).setBackground(drawable); } }
private void updateContents() { // Show either the content in the main activity or the content in the presentation // along with some descriptive text about what is happening. if (mPresentation != null) { mInfoTextView.setText(getResources().getString( R.string.presentation_with_media_router_now_playing_remotely, mPresentation.getDisplay().getName())); mSurfaceView.setVisibility(View.INVISIBLE); mSurfaceView.onPause(); if (mPaused) { mPresentation.getSurfaceView().onPause(); } else { mPresentation.getSurfaceView().onResume(); } } else { mInfoTextView.setText(getResources().getString( R.string.presentation_with_media_router_now_playing_locally, getWindowManager().getDefaultDisplay().getName())); mSurfaceView.setVisibility(View.VISIBLE); if (mPaused) { mSurfaceView.onPause(); } else { mSurfaceView.onResume(); } } }
private void updateContents() { // Show either the content in the main activity or the content in the presentation // along with some descriptive text about what is happening. if (mPresentation != null) { mInfoTextView.setText(getResources().getString( R.string.presentation_with_media_router_now_playing_remotely, mPresentation.getDisplay().getName())); mSurfaceView.setVisibility(View.INVISIBLE); mSurfaceView.onPause(); if (mPaused) { mPresentation.getSurfaceView().onPause(); } else { mPresentation.getSurfaceView().onResume(); } } else { mInfoTextView.setText(getResources().getString( R.string.presentation_with_media_router_now_playing_locally, getWindowManager().getDefaultDisplay().getName())); mSurfaceView.setVisibility(View.VISIBLE); if (mPaused) { mSurfaceView.onPause(); } else { mSurfaceView.onResume(); } } }