kandi background
Explore Kits

CameraButton | Instagram-like button for taking photos or recording videos | User Interface library

 by   hluhovskyi Java Version: 2.0.1 License: Apache-2.0

 by   hluhovskyi Java Version: 2.0.1 License: Apache-2.0

Download this library from

kandi X-RAY | CameraButton Summary

CameraButton is a Java library typically used in User Interface applications. CameraButton has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. However CameraButton has 2 bugs. You can download it from GitHub, Maven.
Instagram-like button for taking photos or recording videos.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • CameraButton has a low active ecosystem.
  • It has 121 star(s) with 30 fork(s). There are 8 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 3 open issues and 5 have been closed. On average issues are closed in 23 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of CameraButton is 2.0.1
CameraButton Support
Best in #User Interface
Average in #User Interface
CameraButton Support
Best in #User Interface
Average in #User Interface

quality kandi Quality

  • CameraButton has 2 bugs (0 blocker, 0 critical, 1 major, 1 minor) and 23 code smells.
CameraButton Quality
Best in #User Interface
Average in #User Interface
CameraButton Quality
Best in #User Interface
Average in #User Interface

securitySecurity

  • CameraButton has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • CameraButton code analysis shows 0 unresolved vulnerabilities.
  • There are 3 security hotspots that need review.
CameraButton Security
Best in #User Interface
Average in #User Interface
CameraButton Security
Best in #User Interface
Average in #User Interface

license License

  • CameraButton is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
CameraButton License
Best in #User Interface
Average in #User Interface
CameraButton License
Best in #User Interface
Average in #User Interface

buildReuse

  • CameraButton releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • It has 3345 lines of code, 339 functions and 72 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
CameraButton Reuse
Best in #User Interface
Average in #User Interface
CameraButton Reuse
Best in #User Interface
Average in #User Interface
Top functions reviewed by kandi - BETA

kandi has reviewed CameraButton and discovered the below as its top functions. This is intended to give you an instant insight into CameraButton implemented functionality, and help decide if they suit your requirements.

  • Initializes the center button .
  • Initializes the buttons .
  • Get a bitmap from a drawable .
  • Get a color value from a typed array .
  • Subscribe the observer to the observer .
  • Checks that the main thread is on the main thread .
  • Interpolate arc width
  • Check duration .
  • Get the flash switch .
  • Creates and returns an observable view of state change events on a button .

CameraButton Key Features

Instagram-like button for taking photos or recording videos

Getting started

copy iconCopydownload iconDownload
 compile 'com.hluhovskyi.camerabutton:camerabutton:2.0.1'
 compile 'com.hluhovskyi.camerabutton:camerabutton-rxjava2:2.0.1'
 compile 'com.hluhovskyi.camerabutton:camerabutton-rxjava2-kotlin:2.0.1'

How to use?

copy iconCopydownload iconDownload
 <com.hluhovskyi.camerabutton.CameraButton
     android:id="@+id/camera_button"
     android:layout_width="@dimen/cb_layout_width_default"
     android:layout_height="@dimen/cb_layout_height_default" />

RxJava and Kotlin

copy iconCopydownload iconDownload

 RxCameraButton.stateChanges(button)
     .filter(state -> state == CameraButton.State.START_COLLAPSING)
     .subscribe(state -> hideButtons());
     
 RxCameraButton.tapEvents(button)
     .subscribe(event -> takePhoto());

Customization

copy iconCopydownload iconDownload
 <color name="my_color_1">#000000</color>
 <color name="my_color_2">#ffffff</color>

 <array name="my_progress_colors">
     <item>@color/my_color_1</item>
     <item>@color/my_color_2</item>
 </array>
 
 ...
 
 <com.hluhovskyi.camerabutton.CameraButton
     ...
     app:cb_progress_arc_colors="@color/my_progress_colors"/>  

License

copy iconCopydownload iconDownload
Copyright (C) 2018 Artem Hluhovskyi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

how to get permission result in kotlin

copy iconCopydownload iconDownload
private val requestPermission =
    registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
        // do something
    }
cameraButton.setOnClickListener {
        
        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.CAMERA
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            // Pass any permission you want while launching
            requestPermission.launch(Manifest.permission.CAMERA)
        }
    }
implementation 'androidx.fragment:fragment-ktx:1.2.0' // or later
implementation 'androidx.activity:activity-ktx:1.3.0' // or later
-----------------------
private val requestPermission =
    registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
        // do something
    }
cameraButton.setOnClickListener {
        
        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.CAMERA
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            // Pass any permission you want while launching
            requestPermission.launch(Manifest.permission.CAMERA)
        }
    }
implementation 'androidx.fragment:fragment-ktx:1.2.0' // or later
implementation 'androidx.activity:activity-ktx:1.3.0' // or later
-----------------------
private val requestPermission =
    registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
        // do something
    }
cameraButton.setOnClickListener {
        
        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.CAMERA
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            // Pass any permission you want while launching
            requestPermission.launch(Manifest.permission.CAMERA)
        }
    }
implementation 'androidx.fragment:fragment-ktx:1.2.0' // or later
implementation 'androidx.activity:activity-ktx:1.3.0' // or later
-----------------------
 fun Fragment.requestPermissions(request: ActivityResultLauncher<Array<String>>, permissions: Array<String>) = request.launch(permissions)

 fun Fragment.isAllPermissionsGranted(permissions: Array<String>) = permissions.all {
     ContextCompat.checkSelfPermission(requireContext(), it) == PackageManager.PERMISSION_GRANTED
 }
 class FirstFragment : Fragment() {
     companion object {
         private val PERMISSIONS = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION)
     }

     private lateinit var binding: FragmentFirstBinding
     private lateinit var permissionsRequest: ActivityResultLauncher<Array<String>>

     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
         binding = DataBindingUtil.inflate(inflater, R.layout.fragment_first, container, false)
         permissionsRequest = getPermissionsRequest()

         binding.grantButton.setOnClickListener {
             requestPermissions(permissionsRequest, PERMISSIONS)     //extension function
         }

         return binding.root
     }

     private fun getPermissionsRequest() = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
         if (isAllPermissionsGranted(PERMISSIONS)) {             //extension function
             //do your stuff
         } else {
             //do your stuff
         }
     }
 }
-----------------------
 fun Fragment.requestPermissions(request: ActivityResultLauncher<Array<String>>, permissions: Array<String>) = request.launch(permissions)

 fun Fragment.isAllPermissionsGranted(permissions: Array<String>) = permissions.all {
     ContextCompat.checkSelfPermission(requireContext(), it) == PackageManager.PERMISSION_GRANTED
 }
 class FirstFragment : Fragment() {
     companion object {
         private val PERMISSIONS = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION)
     }

     private lateinit var binding: FragmentFirstBinding
     private lateinit var permissionsRequest: ActivityResultLauncher<Array<String>>

     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
         binding = DataBindingUtil.inflate(inflater, R.layout.fragment_first, container, false)
         permissionsRequest = getPermissionsRequest()

         binding.grantButton.setOnClickListener {
             requestPermissions(permissionsRequest, PERMISSIONS)     //extension function
         }

         return binding.root
     }

     private fun getPermissionsRequest() = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
         if (isAllPermissionsGranted(PERMISSIONS)) {             //extension function
             //do your stuff
         } else {
             //do your stuff
         }
     }
 }

Path for picked file is throwing null check error in flutter

copy iconCopydownload iconDownload
class ProfilePictureCard extends StatefulWidget {
  final bool? isSetProfilePage;
  final bool? isEditable;
  final Function(File file) handleUpdate;
  final String? imageUrl;
  ProfilePictureCard({
    Key? key,
    this.isSetProfilePage = false,
    this.isEditable = false,
    this.handleUpdate,
    this.imageUrl,
  })
if (result != null) {
    widget.handleUpdate(result);
}
 class _EditProfilePage extends State<EditProfilePage {
    File? imageFile;

    @override
    Widget build(BuildContext context){
       ...other widgets
       ProfilePictureCard(
          isEditable: true, // because of this line the camera button is visible
          handleUpdate: _handleUpdate,
          imageUrl: 'https://picsum.photos/id/237/200/300', // previous profile picture, will be replaced with selected image
       )
    }
    
    _handleUpdate(File file){
       print(file.path);
       setState(() {
         imageFile = file;
       });
    }
}
-----------------------
class ProfilePictureCard extends StatefulWidget {
  final bool? isSetProfilePage;
  final bool? isEditable;
  final Function(File file) handleUpdate;
  final String? imageUrl;
  ProfilePictureCard({
    Key? key,
    this.isSetProfilePage = false,
    this.isEditable = false,
    this.handleUpdate,
    this.imageUrl,
  })
if (result != null) {
    widget.handleUpdate(result);
}
 class _EditProfilePage extends State<EditProfilePage {
    File? imageFile;

    @override
    Widget build(BuildContext context){
       ...other widgets
       ProfilePictureCard(
          isEditable: true, // because of this line the camera button is visible
          handleUpdate: _handleUpdate,
          imageUrl: 'https://picsum.photos/id/237/200/300', // previous profile picture, will be replaced with selected image
       )
    }
    
    _handleUpdate(File file){
       print(file.path);
       setState(() {
         imageFile = file;
       });
    }
}
-----------------------
class ProfilePictureCard extends StatefulWidget {
  final bool? isSetProfilePage;
  final bool? isEditable;
  final Function(File file) handleUpdate;
  final String? imageUrl;
  ProfilePictureCard({
    Key? key,
    this.isSetProfilePage = false,
    this.isEditable = false,
    this.handleUpdate,
    this.imageUrl,
  })
if (result != null) {
    widget.handleUpdate(result);
}
 class _EditProfilePage extends State<EditProfilePage {
    File? imageFile;

    @override
    Widget build(BuildContext context){
       ...other widgets
       ProfilePictureCard(
          isEditable: true, // because of this line the camera button is visible
          handleUpdate: _handleUpdate,
          imageUrl: 'https://picsum.photos/id/237/200/300', // previous profile picture, will be replaced with selected image
       )
    }
    
    _handleUpdate(File file){
       print(file.path);
       setState(() {
         imageFile = file;
       });
    }
}

React Native functional components - Navigate between different screens, each on a separate .js file

copy iconCopydownload iconDownload
function HomeScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: 'white' }}>
    <Button buttonStyle={styles.cameraButton} titleStyle={styles.buttonText}
    onPress={() => navigation.navigate('Email')}
    title="Email pics"
    />
    </View>
  );
}

How to save load data with pickle and the re use the anchor data in another script

copy iconCopydownload iconDownload
import pyautogui as pg
import pickle
import time 

anchors = []

pos1 = pg.position()
anchors.append(pos1)
print('Move mouse to a new location')
time.sleep(3)
pos2 = pg.position()
anchors.append(pos2)

with open('savefile.txt','wb') as fp:
     pickle.dump(anchors,fp)
 
print('anchors = ' , anchors)

anc1 = [] 
# append the anchors list to the list anc1, which results in a list of lists 
with open('savefile.txt','rb') as openfile:
    try:
      anc1.append(pickle.load(openfile))
    except:
      print('File read error')
print("anc1 = ", anc1)# anc1 is a list whose first and only element is the original anchors list
t1,t2 =anc1[0] # note that we use anc1[0] instead of anc1
print('t1 =', t1)
print('t2 =', t2)

# load the anchors list into anc2
with open('savefile.txt','rb') as openfile:
    try:
      anc2 = pickle.load(openfile)
    except:
      print('File read error')
print("anc2 = ", anc2)
t3,t4 = anc2
print('t3 = ',t3)
print('t4 =', t4)

anc3 = [] 
# extend list anc3 with the elements of the original anchors list
with open('savefile.txt','rb') as openfile:
    try:
      anc3.extend(pickle.load(openfile))
    except:
      print('File read error')
print("anc3 = ", anc3)
t5,t6 =anc3
print('t5 =', t5)
print('t6 =', t6)
anchors =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                  
anc1 =  [[Point(x=510, y=741), Point(x=1571, y=210)]]                                                                   
t1 = Point(x=510, y=741)                                                                                                
t2 = Point(x=1571, y=210)                                                                                               
anc2 =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                     
t3 =  Point(x=510, y=741)                                                                                               
t4 = Point(x=1571, y=210)                                                                                               
anc3 =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                     
t5 = Point(x=510, y=741)                                                                                                
t6 = Point(x=1571, y=210)    
-----------------------
import pyautogui as pg
import pickle
import time 

anchors = []

pos1 = pg.position()
anchors.append(pos1)
print('Move mouse to a new location')
time.sleep(3)
pos2 = pg.position()
anchors.append(pos2)

with open('savefile.txt','wb') as fp:
     pickle.dump(anchors,fp)
 
print('anchors = ' , anchors)

anc1 = [] 
# append the anchors list to the list anc1, which results in a list of lists 
with open('savefile.txt','rb') as openfile:
    try:
      anc1.append(pickle.load(openfile))
    except:
      print('File read error')
print("anc1 = ", anc1)# anc1 is a list whose first and only element is the original anchors list
t1,t2 =anc1[0] # note that we use anc1[0] instead of anc1
print('t1 =', t1)
print('t2 =', t2)

# load the anchors list into anc2
with open('savefile.txt','rb') as openfile:
    try:
      anc2 = pickle.load(openfile)
    except:
      print('File read error')
print("anc2 = ", anc2)
t3,t4 = anc2
print('t3 = ',t3)
print('t4 =', t4)

anc3 = [] 
# extend list anc3 with the elements of the original anchors list
with open('savefile.txt','rb') as openfile:
    try:
      anc3.extend(pickle.load(openfile))
    except:
      print('File read error')
print("anc3 = ", anc3)
t5,t6 =anc3
print('t5 =', t5)
print('t6 =', t6)
anchors =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                  
anc1 =  [[Point(x=510, y=741), Point(x=1571, y=210)]]                                                                   
t1 = Point(x=510, y=741)                                                                                                
t2 = Point(x=1571, y=210)                                                                                               
anc2 =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                     
t3 =  Point(x=510, y=741)                                                                                               
t4 = Point(x=1571, y=210)                                                                                               
anc3 =  [Point(x=510, y=741), Point(x=1571, y=210)]                                                                     
t5 = Point(x=510, y=741)                                                                                                
t6 = Point(x=1571, y=210)    

AlertDIalog Remove unnecessary space

copy iconCopydownload iconDownload
    <style name="CustomDialog" parent="@style/Theme.AppCompat.Dialog">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:windowNoTitle">true</item>
    </style>
<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="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:padding="16dp">

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Camera"
        android:textOn="Camera"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Lidar"
        android:textOn="Lidar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/three"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Sonar"
        android:textOn="Sonar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
private void showDialogHere() {
        
        AlertDialog.Builder obstacleDialogBuilder = new AlertDialog.Builder(this, R.style.CustomDialog);
        obstacleDialogBuilder.setMessage(null);

        LayoutInflater inflaterObstacle = this.getLayoutInflater();
        View obstacleDialogView = inflaterObstacle.inflate(R.layout.my_dialog, null);
        obstacleDialogBuilder.setView(obstacleDialogView);

        AlertDialog obstacleAlertDialog = obstacleDialogBuilder.create();
        obstacleAlertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        Window window = obstacleAlertDialog.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();

        params.gravity = Gravity.TOP | Gravity.RIGHT;
        params.x = 100;   //x position
        params.y = 100;   //y position

        obstacleAlertDialog.show();
    }
-----------------------
    <style name="CustomDialog" parent="@style/Theme.AppCompat.Dialog">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:windowNoTitle">true</item>
    </style>
<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="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:padding="16dp">

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Camera"
        android:textOn="Camera"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Lidar"
        android:textOn="Lidar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/three"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Sonar"
        android:textOn="Sonar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
private void showDialogHere() {
        
        AlertDialog.Builder obstacleDialogBuilder = new AlertDialog.Builder(this, R.style.CustomDialog);
        obstacleDialogBuilder.setMessage(null);

        LayoutInflater inflaterObstacle = this.getLayoutInflater();
        View obstacleDialogView = inflaterObstacle.inflate(R.layout.my_dialog, null);
        obstacleDialogBuilder.setView(obstacleDialogView);

        AlertDialog obstacleAlertDialog = obstacleDialogBuilder.create();
        obstacleAlertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        Window window = obstacleAlertDialog.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();

        params.gravity = Gravity.TOP | Gravity.RIGHT;
        params.x = 100;   //x position
        params.y = 100;   //y position

        obstacleAlertDialog.show();
    }
-----------------------
    <style name="CustomDialog" parent="@style/Theme.AppCompat.Dialog">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:windowNoTitle">true</item>
    </style>
<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="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:padding="16dp">

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Camera"
        android:textOn="Camera"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Lidar"
        android:textOn="Lidar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatToggleButton
        android:id="@+id/three"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="#43212121"
        android:checked="true"
        android:textOff="Sonar"
        android:textOn="Sonar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@id/two"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
private void showDialogHere() {
        
        AlertDialog.Builder obstacleDialogBuilder = new AlertDialog.Builder(this, R.style.CustomDialog);
        obstacleDialogBuilder.setMessage(null);

        LayoutInflater inflaterObstacle = this.getLayoutInflater();
        View obstacleDialogView = inflaterObstacle.inflate(R.layout.my_dialog, null);
        obstacleDialogBuilder.setView(obstacleDialogView);

        AlertDialog obstacleAlertDialog = obstacleDialogBuilder.create();
        obstacleAlertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        Window window = obstacleAlertDialog.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();

        params.gravity = Gravity.TOP | Gravity.RIGHT;
        params.x = 100;   //x position
        params.y = 100;   //y position

        obstacleAlertDialog.show();
    }

How to make background black of react native camera?

copy iconCopydownload iconDownload
...
<View
style={{
  flex: 0,
  flexDirection: 'row',
  justifyContent: 'center',
  backgroundColor: "#000000", //-----------------Here?
}}>
<TouchableOpacity
  style={styles.capture}
  onPress={(_) => {
    switch (flashMode) {
      case RNCamera.Constants.FlashMode.off:
        setFlashMode(RNCamera.Constants.FlashMode.auto);
...

Android Studio - IllegalStateException While Using Retrofit

copy iconCopydownload iconDownload
Caused by: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)
    for method IService.UploadRoom
@POST("api/rooms")
Call<UploadRoomResponse> UploadRoom(@Header("Authorization") String token, UploadRoomRequest uploadRoomRequest);
-----------------------
Caused by: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)
    for method IService.UploadRoom
@POST("api/rooms")
Call<UploadRoomResponse> UploadRoom(@Header("Authorization") String token, UploadRoomRequest uploadRoomRequest);

react native - how state works with buttons

copy iconCopydownload iconDownload
ShowButton = () => {
let prevState = this.state.showCamera;
this.setState({showCamera: !prevState}); //It will toggle the value
}
-----------------------
       <Button
              onPress={this.state.showCamera ? this.hideCamera : this.showCamera}
              title={this.state.showCamera 
                ? "click me to hide the camera!"
                : "click me to open the camera!"}
              color="#841584"
       />
-----------------------
class CameraButton extends Component {
  constructor(props) {
    super(props);

    this.state = {
      showCamera: false
    };
  }

  showCamera = () => this.setState({ showCamera: true });
  hideCamera = () => this.setState({ showCamera: false });

  render() {
    return (
      <View style={styles.container}>
        <Button
          onPress={this.state.showCamera ? this.hideCamera : this.showCamera}
          title={this.state.showCamera ? "Hide Camera!" : "Show Camera"}
          color="#841584"
        />
        {this.state.showCamera && <DeviceCamera />}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "#F5FCFF"
  },
  instructions: {
    textAlign: "center",
    color: "#333333",
    marginBottom: 5
  }
});

export default CameraButton;

Is there a way to have a button render my camera component in React Native?

copy iconCopydownload iconDownload
class CameraButton extends Component {
  showCamera = () => this.setState({ showCamera: true });

  render() {
    return (
      <View style={styles.container}>
        <Text> Button to Open Camera </Text>
        <Button
          onPress={this.showCamera}
          title="click me to open the camera!"
          color="#841584"
        />
        {this.state.showCamera && <DeviceCamera />}
      </View>
    );
  }
}

Reading value from QML in C++

copy iconCopydownload iconDownload
Rectangle {
        id: buttonPaneShadow
        width: bottomColumn.width + 16
        height: parent.height
        anchors.top: parent.top
        anchors.right: parent.right
        color: "white"

        property int recordint:0 //move to here

        Column {
            anchors {
                right: parent.right
                top: parent.top
                margins: 8
            }

            id: buttonsColumn
            anchors.rightMargin: 20
            anchors.topMargin: 20
            spacing: 12

            CameraButton {
                id: startbutton
                text: "Record"
                visible: camera.videoRecorder.recorderStatus == CameraRecorder.LoadedStatus
                onClicked:
                {
                    recordint=recordint+1
                    camera.videoRecorder.record()
                    console.log(recordint)

                }
            }
    }
}

Community Discussions

Trending Discussions on CameraButton
  • how to get permission result in kotlin
  • Path for picked file is throwing null check error in flutter
  • React Native functional components - Navigate between different screens, each on a separate .js file
  • How to save load data with pickle and the re use the anchor data in another script
  • Flutter CameraPreview widget shows black color instead of camera view while using Camera 0.8.0 on Flutter Stable channel
  • AlertDIalog Remove unnecessary space
  • How to make background black of react native camera?
  • How to convert an Android Studio project to an Appcelerator Titanium Module
  • Android Studio - IllegalStateException While Using Retrofit
  • react native - how state works with buttons
Trending Discussions on CameraButton

QUESTION

how to get permission result in kotlin

Asked 2022-Mar-14 at 15:57

I am trying to use a camera on my android. the user will be prompt for the permission of the camera. previously I used startActivityForResult and onRequestPermissionRequest for them. recently I found out that they are deprecated, so I'm trying out with registerForActivity. I managed to change to startActivity but I'm stuck at the permission request. I am wondering do I have to create another permissionlauncher or can I do the permission inside my resultlauncher.

    companion object{
        private const val CAMERA_PERMISSION_CODE = 1
        private const val CAMERA_REQUEST_CODE = 2 
    }
val checkpermission = Manifest.permission.CAMERA

        var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){ result ->
                if (result.resultCode == Activity.RESULT_OK) {
                    val data: Intent? = result.data
                    val DP: Bitmap = data!!.extras!!.get("data") as Bitmap
                    val image = findViewById<ImageView>(R.id.imageButtonVerifyPhoto)
                    image.setImageBitmap(DP)
                }

            }

        val permissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()){
                isGranted ->
            if(isGranted){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                resultLauncher.launch((intent))
                Toast.makeText(this,"Permission is tested", Toast.LENGTH_SHORT).show()
            }else{
                Toast.makeText(this,"Permission is denied",Toast.LENGTH_SHORT).show()
            }

        }
        var cameraButton = findViewById<Button>(R.id.buttonRetakePhoto) // can change later

        cameraButton.setOnClickListener {
            if(ContextCompat.checkSelfPermission(
                    this,
                    checkpermission
                ) == PackageManager.PERMISSION_GRANTED
            ){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                resultLauncher.launch(intent)

            }else{
                permissionLauncher.launch(checkpermission)
            }
        }

    }

below is my previous code for the onRequestPermission

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        if(requestCode == CAMERA_REQUEST_CODE){
            if(grantResults.isNotEmpty()&& grantResults[0] == PackageManager.PERMISSION_GRANTED){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                startActivityForResult(intent, CAMERA_REQUEST_CODE)
            }else{
                Toast.makeText(this,"Permission is denied",Toast.LENGTH_SHORT).show()
            }
        }
    }

ANSWER

Answered 2022-Mar-14 at 10:27

Requesting runtime permissions is just a little more simplified

private val requestPermission =
    registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
        // do something
    }

Now we can call this to get any type of permission you want

cameraButton.setOnClickListener {
        
        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.CAMERA
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            // Pass any permission you want while launching
            requestPermission.launch(Manifest.permission.CAMERA)
        }
    }

Make sure to add in build.gradle

implementation 'androidx.fragment:fragment-ktx:1.2.0' // or later
implementation 'androidx.activity:activity-ktx:1.3.0' // or later

If you want to understand how all this works check here

Source https://stackoverflow.com/questions/71465812

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install CameraButton

Add library as dependency to your build.gradle. No need to include all dependencies, choose just one which covers your needs. Please, feel free to open issues you are stuck with. PRs are also welcome :).

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare User Interface Libraries with Highest Quality
Compare User Interface Libraries with Highest Security
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.