Java Code Examples for android.view.WindowInsets#isRound()

The following examples show how to use android.view.WindowInsets#isRound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PixelWatchFace.java    From PixelWatchFace with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
  super.onApplyWindowInsets(insets);
  Log.d("onApplyWindowInsets",
      "onApplyWindowInsets: " + (insets.isRound() ? "round" : "square"));

  // Load resources that have alternate values for round watches.
  Resources resources = PixelWatchFace.this.getResources();
  mIsRound = insets.isRound();
  mChinSize = insets.getSystemWindowInsetBottom();

  float timeTextSize = resources.getDimension(mIsRound
      ? R.dimen.digital_time_text_size_round : R.dimen.digital_time_text_size);
  float dateTextSize = resources.getDimension(mIsRound
      ? R.dimen.digital_date_text_size_round : R.dimen.digital_date_text_size);

  mTimePaint.setTextSize(timeTextSize);
  mInfoPaint.setTextSize(dateTextSize);


}
 
Example 2
Source File: HeadingListView.java    From WearPreferenceActivity with Apache License 2.0 6 votes vote down vote up
@Override public WindowInsets onApplyWindowInsets(final WindowInsets insets) {
    if(insets.isRound()) {
        heading.setGravity(Gravity.CENTER_HORIZONTAL);

        // Adjust paddings for round devices
        if(!hasAdjustedPadding) {
            final int padding = heading.getPaddingTop();
            heading.setPadding(padding, 2 * padding, padding, padding);
            list.setPadding(padding, 0, padding, 0);
            hasAdjustedPadding = true;
        }
    } else {
        heading.setGravity(Gravity.START);
    }
    return super.onApplyWindowInsets(insets);
}
 
Example 3
Source File: EarthWatchFaceService.java    From earth with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    if (insets.isRound()) {
        inset = -2;
        setWatchFaceStyle(new WatchFaceStyle.Builder(EarthWatchFaceService.this)
                .setHotwordIndicatorGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)
                .setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT)
                .setShowSystemUiTime(true)
                .setShowUnreadCountIndicator(true)
                .setStatusBarGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP)
                .setViewProtectionMode(WatchFaceStyle.PROTECT_HOTWORD_INDICATOR
                        | WatchFaceStyle.PROTECT_STATUS_BAR)
                .build());
    } else {
        inset = getResources().getDimensionPixelOffset(R.dimen.padding_square);
        setWatchFaceStyle(new WatchFaceStyle.Builder(EarthWatchFaceService.this)
                .setHotwordIndicatorGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)
                .setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT)
                .setShowSystemUiTime(true)
                .setShowUnreadCountIndicator(true)
                .setStatusBarGravity(Gravity.END | Gravity.TOP)
                .setViewProtectionMode(WatchFaceStyle.PROTECT_HOTWORD_INDICATOR
                        | WatchFaceStyle.PROTECT_STATUS_BAR)
                .build());
    }
}
 
Example 4
Source File: BinaryWatchFaceService.java    From WearBinaryWatchFace with Apache License 2.0 6 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = BinaryWatchFaceService.this.getResources();

    if(!insets.isRound()) {
        dotYExtraOffset = getResources().getDimension(R.dimen.digital_y_square_extra_offset);
    }

    dotWidth  = getResources().getDimension(R.dimen.circle_width);
    dotMargin = getResources().getDimension(R.dimen.circle_margin);
    clockYOffset = getResources().getDimension(R.dimen.digital_y_offset);

    textPaint.setTextSize(resources.getDimension(R.dimen.text_size));
}
 
Example 5
Source File: LayoutFaceService.java    From io18watchface with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    int gravity = !insets.isRound() ? (Gravity.START | Gravity.TOP) :  Gravity.CENTER;
    setWatchFaceStyle(new WatchFaceStyle.Builder(LayoutFaceService.this)
            .setStatusBarGravity(gravity)
            .setAccentColor(0xff526cfe)
            .build());

    // Load the display spec - we'll need this later for measuring layoutRoot
    Point displaySize = new Point();
    ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getSize(displaySize);

    if (layoutRoot instanceof LinearLayout) {
        int height = (int) (displaySize.y * 0.28);
        int width = (int) (height * 0.62);
        for (LottieAnimationView digitView : digitViews) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) digitView.getLayoutParams();
            params.width = width;
            params.height = height;
        }
        //noinspection SuspiciousNameCombination
        layoutRoot.findViewById(R.id.logo).setLayoutParams(new LinearLayout.LayoutParams(height, height));
    }
    
    // Recompute the MeasureSpec fields - these determine the actual size of the layout
    int specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
    int specH = View.MeasureSpec.makeMeasureSpec(displaySize.y, View.MeasureSpec.EXACTLY);

    // Update the layout
    layoutRoot.measure(specW, specH);
    layoutRoot.layout(0, 0, layoutRoot.getMeasuredWidth(), layoutRoot.getMeasuredHeight());
}
 
Example 6
Source File: SunsetsWatchFace.java    From american-sunsets-watch-face with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);
    mIsRound = insets.isRound();
    if(mIsRound) {
        mTimePaint.setTextSize(getResources().getDimension(R.dimen.font_size_time_round));
    }else{
        mTimePaint.setTextSize(getResources().getDimension(R.dimen.font_size_time_square));
    }
}
 
Example 7
Source File: CustomWatchFaceService.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    mYOffset = getResources().getDimension( R.dimen.y_offset );

    if( insets.isRound() ) {
        mXOffset = getResources().getDimension( R.dimen.x_offset_round );
    } else {
        mXOffset = getResources().getDimension( R.dimen.x_offset_square );
    }
}
 
Example 8
Source File: MyTapFace.java    From wearable with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyTapFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    mTextPaint.setTextSize(textSize);
}
 
Example 9
Source File: MyTapFace.java    From wearable with Apache License 2.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyTapFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    mTextPaint.setTextSize(textSize);
}
 
Example 10
Source File: BaseWatchFace.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
    super.onLayout(shape, screenBounds, screenInsets);
    layoutView.onApplyWindowInsets(screenInsets);
    bIsRound = screenInsets.isRound();
}
 
Example 11
Source File: BatmanWatchFaceService.java    From wearable with Apache License 2.0 4 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = BatmanWatchFaceService.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    //time size
    float textSize = resources.getDimension(isRound
    //        ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
            ? R.dimen.date_text_size_round : R.dimen.date_text_size);
    //date size.
    float datetextSize = resources.getDimension(isRound
            ? R.dimen.date_text_size_round : R.dimen.date_text_size);

    mTextPaint_date.setTextSize(datetextSize);
    mTextPaint_time.setTextSize(textSize);
    //setup where everything goes.

    Rect bounds = new Rect();

    String text = "13:40:45";  //sample time
    mTextPaint_time.getTextBounds(text, 0, text.length(), bounds );
    time_height = bounds.height();

    time_width = bounds.width();

    text = "13:40";  //sample date ambient
    mTextPaint_time.getTextBounds(text, 0, text.length(), bounds );
    time_width_amb = bounds.width();
    time_height_amb = bounds.height();

    text = "02/27 Mon";  //sample date
    mTextPaint_date.getTextBounds(text, 0, text.length(), bounds );
    date_height = bounds.height();
    date_width = bounds.width();



}
 
Example 12
Source File: BatmanWatchFaceService.java    From wearable with Apache License 2.0 4 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = BatmanWatchFaceService.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    //time size
    float textSize = resources.getDimension(isRound
    //        ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
            ? R.dimen.date_text_size_round : R.dimen.date_text_size);
    //date size.
    float datetextSize = resources.getDimension(isRound
            ? R.dimen.date_text_size_round : R.dimen.date_text_size);

    mTextPaint_date.setTextSize(datetextSize);
    mTextPaint_time.setTextSize(textSize);
    //setup where everything goes.

    Rect bounds = new Rect();

    String text = "13:40:45";  //sample time
    mTextPaint_time.getTextBounds(text, 0, text.length(), bounds );
    time_height = bounds.height();

    time_width = bounds.width();

    text = "13:40";  //sample date ambient
    mTextPaint_time.getTextBounds(text, 0, text.length(), bounds );
    time_width_amb = bounds.width();
    time_height_amb = bounds.height();

    text = "02/27 Mon";  //sample date
    mTextPaint_date.getTextBounds(text, 0, text.length(), bounds );
    date_height = bounds.height();
    date_width = bounds.width();



}