Skip to content

Commit

Permalink
Change all left/right to start/end (android#71)
Browse files Browse the repository at this point in the history
* Change all left/right to start/end

* add 'ltr' layoutDirection and replace math with kotlin math
  • Loading branch information
zhaonian authored and owahltinez committed Oct 16, 2019
1 parent 34b2e64 commit 1af984d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ class CameraFragment : Fragment() {
/** Volume down button receiver used to trigger shutter */
private val volumeDownReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val keyCode = intent.getIntExtra(KEY_EVENT_EXTRA, KeyEvent.KEYCODE_UNKNOWN)
when (keyCode) {
when (intent.getIntExtra(KEY_EVENT_EXTRA, KeyEvent.KEYCODE_UNKNOWN)) {
// When the volume down button is pressed, simulate a shutter button click
KeyEvent.KEYCODE_VOLUME_DOWN -> {
val shutter = container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.camera.core.PreviewConfig
import java.lang.IllegalArgumentException
import java.lang.ref.WeakReference
import java.util.Objects
import kotlin.math.roundToInt

/**
* Builder for [Preview] that takes in a [WeakReference] of the view finder and [PreviewConfig],
Expand Down Expand Up @@ -205,10 +206,10 @@ class AutoFitPreviewBuilder private constructor(
// Match longest sides together -- i.e. apply center-crop transformation
if (viewFinderDimens.width > viewFinderDimens.height) {
scaledHeight = viewFinderDimens.width
scaledWidth = Math.round(viewFinderDimens.width * bufferRatio)
scaledWidth = (viewFinderDimens.width * bufferRatio).roundToInt()
} else {
scaledHeight = viewFinderDimens.height
scaledWidth = Math.round(viewFinderDimens.height * bufferRatio)
scaledWidth = (viewFinderDimens.height * bufferRatio).roundToInt()
}

// Compute the relative scale value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/camera_ui_container"
android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -26,7 +27,7 @@
android:id="@id/camera_switch_button"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginRight="@dimen/margin_xlarge"
android:layout_marginEnd="@dimen/margin_xlarge"
android:layout_marginBottom="@dimen/margin_small"
android:padding="@dimen/spacing_small"
android:scaleType="fitXY"
Expand All @@ -40,7 +41,7 @@
android:id="@id/camera_capture_button"
android:layout_width="@dimen/round_button_large"
android:layout_height="@dimen/round_button_large"
android:layout_marginRight="@dimen/shutter_button_margin"
android:layout_marginEnd="@dimen/shutter_button_margin"
android:background="@drawable/ic_shutter"
android:contentDescription="@string/capture_button_alt"
android:scaleType="fitXY"
Expand All @@ -52,7 +53,7 @@
android:id="@id/photo_view_button"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginRight="@dimen/margin_xlarge"
android:layout_marginEnd="@dimen/margin_xlarge"
android:layout_marginTop="@dimen/margin_small"
android:padding="@dimen/spacing_large"
android:scaleType="fitXY"
Expand Down
5 changes: 3 additions & 2 deletions CameraXBasic/app/src/main/res/layout/camera_ui_container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/camera_ui_container"
android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -27,7 +28,7 @@
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_xlarge"
android:layout_marginLeft="@dimen/margin_small"
android:layout_marginStart="@dimen/margin_small"
android:padding="@dimen/spacing_small"
android:scaleType="fitCenter"
android:background="@android:color/transparent"
Expand All @@ -53,7 +54,7 @@
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_xlarge"
android:layout_marginRight="@dimen/margin_small"
android:layout_marginEnd="@dimen/margin_small"
android:padding="@dimen/spacing_large"
android:scaleType="fitCenter"
android:background="@drawable/ic_outer_circle"
Expand Down
12 changes: 7 additions & 5 deletions CameraXBasic/app/src/main/res/layout/fragment_gallery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layoutDirection="ltr">

<androidx.viewpager.widget.ViewPager
android:layout_width="match_parent"
Expand All @@ -35,7 +37,7 @@
android:contentDescription="@string/back_button_alt"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="@dimen/margin_xsmall"
android:layout_marginStart="@dimen/margin_xsmall"
android:layout_marginTop="@dimen/margin_small"
android:layout_width="@dimen/round_button_small"
android:layout_height="@dimen/round_button_small"
Expand All @@ -49,7 +51,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/margin_xlarge"
android:layout_marginEnd="@dimen/margin_xlarge"
android:layout_marginBottom="@dimen/margin_small"
android:layout_width="@dimen/round_button_small"
android:layout_height="@dimen/round_button_small"
Expand All @@ -63,7 +65,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="@dimen/margin_xlarge"
android:layout_marginStart="@dimen/margin_xlarge"
android:layout_marginBottom="@dimen/margin_small"
android:layout_width="@dimen/round_button_small"
android:layout_height="@dimen/round_button_small"
Expand Down

0 comments on commit 1af984d

Please sign in to comment.