-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Android): Rounded Corners support for RTCSurfaceView
- Loading branch information
Showing
5 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
android/src/main/java/io/agora/rtc/ng/react/RoundedFrameLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.agora.rtc.ng.react; | ||
|
||
import android.view.SurfaceView; | ||
import android.widget.FrameLayout; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.module.annotations.ReactModule; | ||
import com.facebook.react.uimanager.ThemedReactContext; | ||
import com.facebook.react.uimanager.annotations.ReactProp; | ||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Path; | ||
import android.util.AttributeSet; | ||
|
||
public class RoundedFrameLayout extends FrameLayout { | ||
private float cornerRadius = 18; | ||
|
||
public RoundedFrameLayout(Context context) { | ||
super(context); | ||
} | ||
|
||
public RoundedFrameLayout(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public RoundedFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
@Override | ||
protected void dispatchDraw(Canvas canvas) { | ||
Path path = new Path(); | ||
float[] radii = {cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius, cornerRadius}; | ||
path.addRoundRect(0, 0, getWidth(), getHeight(), radii, Path.Direction.CW); | ||
canvas.clipPath(path); | ||
super.dispatchDraw(canvas); | ||
} | ||
|
||
public void setCornerRadius(float radius) { | ||
cornerRadius = radius; | ||
invalidate(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters