#StackBounty: #android #android-studio #protocol-buffers #android-studio-4.2 How to make the .proto definition files visible in Android…

Bounty: 50

When using protobuf definitions in my gradle projects, protoc works as expected. Everything builds as it is supposed to do. However, when working in the Android view (I mean View->Project->Android), the definition file doesn’t show up. On the contrary, it is visible from View->Project->Project. There I can find the my protobuf definition files as expected in e.g. app/src/main/proto.

Sources are defined in my build.gradle like this:

android {
    sourceSets {
        main {
            proto {
                srcDir '../src/main/proto'
            }
        }
    }
}

What do I have to do to make the proto source files visible in the Android view?


Get this bounty!!!

#StackBounty: #android #android-studio #3d #arcore #sceneform Draw Renderable Shape on 3D Model using Sceneform Android

Bounty: 50

I am using SceneForm Android SDK to render 3D Model in Android APP.

To display the 3D Model I am using this code below which also supports Rotating and Zooming feature in 3D Model

 private fun renderLocalObject(position: Int) {

    ModelRenderable.builder()
            .setSource(appCompatActivity, Uri.parse(models.get(position)))
            .setRegistryId(models.get(position))
            .build()
            .thenAccept { modelRenderable: ModelRenderable ->
                addNodeToScene(modelRenderable)
            }
            .exceptionally { throwable: Throwable? ->
                var message: String?
                message = if (throwable is CompletionException) {
                    Logger.DebugLog("ERROR LOADING 3D", throwable.message)
                    "Internet is not working"
                } else {
                    Logger.DebugLog("ERROR LOADING 3D", "FAILED TO LOAD")
                    "Can't load Model"

                }
                null
            }
}

private fun addNodeToScene(model: ModelRenderable) {

    if (sceneView != null) {

        val transformationSystem = makeTransformationSystem()
        val dragTransformableNode = DragTransformableNode(5f, transformationSystem)
        dragTransformableNode.renderable = model
        sceneView!!.scene.addChild(dragTransformableNode)
        dragTransformableNode.select()


        sceneView!!.getScene()
                .addOnPeekTouchListener { hitTestResult: HitTestResult?, motionEvent: MotionEvent? ->
                    transformationSystem.onTouch(
                            hitTestResult,
                            motionEvent
                    )

                    when (motionEvent?.action) {
                        MotionEvent.ACTION_UP ->
                            if (hitTestResult != null) {
                                addDot(hitTestResult)
                            }

                    }


                }
    }
}

I want to draw a sphere renderable shape directly over the 3d model, but the Node is not getting stuck model.

Below is the required output

Expected Output

Below is the final output of my code

Final Output

This is my code for adding node

  private fun addDot(hitTestResult: HitTestResult){
    val color = Color(.8f, 0f, 0f)
    MaterialFactory.makeOpaqueWithColor(appCompatActivity, color)
            .thenAccept { material->
                // The sphere is in local coordinate space, so make the center 0,0,0
                val sphere = ShapeFactory.makeSphere(0.05f, Vector3.zero(),
                        material)
                val indicatorModel = Node()
                indicatorModel.setParent(hitTestResult.node)
                indicatorModel.worldPosition = hitTestResult.point
              //  indicatorModel.localPosition = Vector3(0f, 0f, -1f)
                indicatorModel.renderable = sphere
               // sceneView!!.getScene().addChild(indicatorModel)


            }
}

Is there any way to draw shape directly over the 3d model.


Get this bounty!!!

#StackBounty: #android #android-studio #android-layout #android-animation #android-motionlayout Reset or make continuous Motion Layout …

Bounty: 100

I am building a counter-based android application using motion layout. I have built this scene using motion layout where you can slide the bead and it’ll add +1 to the counter. The initial scene of moving the bead from one place to another on swipe works great but now I don’t know how to make the bead start from the initial position it was on and then swipe it to the final position which will then add another +1 to the counter.

I want the process to be continuous as if you’re counting on real beads. The code below so far works great. I need help to make the counting process to continue and how to know when that the bead has reached its final position to add +1.

counter_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/tasbeeh_fragment_scene"
    tools:context=".ui.tasbeeh.TasbeehFragment">

    <ImageView
        android:id="@+id/tasbihStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tasbeeh_start"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/singeBead"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginStart="114dp"
        android:layout_marginTop="71dp"
        android:src="@drawable/singe_bead"
        app:layout_constraintStart_toStartOf="@+id/tasbihStart"
        app:layout_constraintTop_toTopOf="@+id/tasbihStart" />

    <ImageView
        android:id="@+id/tasbihFinal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tasbeeh_final"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.motion.widget.MotionLayout>

counter_fragment_scene

<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <ConstraintSet android:id="@+id/start">
        <Constraint android:id="@+id/singeBead"
            android:layout_width="45dp"
            android:layout_height="45dp"
            android:layout_marginStart="114dp"
            android:layout_marginTop="72dp"
            app:layout_constraintStart_toStartOf="@+id/tasbihStart"
            app:layout_constraintTop_toTopOf="@+id/tasbihStart"/>
        <Constraint
            android:id="@+id/tasbihStart"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
             />
    </ConstraintSet>

    <ConstraintSet android:id="@+id/end">
        <Constraint android:id="@+id/singeBead"
            android:layout_width="45dp"
            android:layout_height="45dp"
            android:layout_marginStart="231dp"
            android:layout_marginTop="27dp"
            app:layout_constraintStart_toStartOf="@+id/tasbihStart"
            app:layout_constraintTop_toTopOf="@+id/tasbihStart"
            android:layout_marginLeft="232dp" />
        <Constraint
            android:layout_height="wrap_content"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_width="wrap_content"
            android:id="@+id/imageView6"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
             />
        <Constraint
            android:id="@+id/tasbihStart"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
             />
    </ConstraintSet>

    <Transition
        app:constraintSetStart="@+id/start"
        app:constraintSetEnd="@id/end">
        <OnSwipe
            app:dragDirection="dragRight"
            app:touchAnchorId="@+id/singeBead"/>
    </Transition>
</MotionScene>

Output:
https://drive.google.com/file/d/1XR2nE5XZNB7pQHB5nXd7GIBwhRCPQIxs/view?usp=sharing

Expected Output:
https://drive.google.com/file/d/1XmcdupU-2Js-rfI_J7Uv_VqvH4Hi6mTk/view?usp=sharing


Get this bounty!!!

#StackBounty: #git #android-studio How can I compare two commit in different branches with Git in Android Studio 4.1?

Bounty: 50

I use Git in Android Studio 4.1. There are two commit in different branches.

The first commit is named "TestC 47" located in "TestC" branch, the second commit is named "Dell_Merge 25" located in "master" branch.

I hope to know what are different between "TestC 47" commit and "Dell_Merge 25" commit, how can I do?

Image 1
enter image description here

Image 2

enter image description here


Get this bounty!!!

#StackBounty: #android #android-studio #package-managers #android-package-managers Android studio is making used import statement as un…

Bounty: 50

I have just starting working my android studio project in another pc with same android studio version and it automatically makes used import statement as unused in the code and mark evey code related to particular import statement red. How can i fix this issue , its very annoying. but when i run the project ,it works fine without any error.

I have tried all those tricks including deleting .ide ,.gradle and even restarting with invalidate cash ,restard and disabling automatic import as well.

In the below screenshot , android studio just grayout all import statment i am using below and mark all those classes and its related method red in the code. how can i fix this issue

screenshot


Get this bounty!!!

#StackBounty: #android #android-studio #android-layout Draw partial circle as progress bar in android studio

Bounty: 50

SUMMARY :

Use picture 1 for reference.

I need to keep the grey part under the green part, so that when green decreases, grey becomes visible. But I also want the uncovered part (just grey to not be there). Resulting in a 2/3rd overlapping circle.


I am trying to create 2/3rd circle (with rounded corners) as a progress bar in android studio. I am not able to do it.
I was hoping to get your help.

Current circle: (PICTURE 1)

enter image description here

Circle I need :

enter image description here

Shape:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="ring" android:innerRadiusRatio="2.5" android:useLevel="false"
            android:thicknessRatio="12">
            <solid android:color="#DDD"/>
     </shape>
    </item>
    <item>
        <shape android:shape="ring" android:innerRadiusRatio="2.5" android:useLevel="true"
            android:thicknessRatio="12">
            <solid android:color="@color/colorAccent"/>
        </shape>
    </item>
</layer-list>

Layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    tools:context=".MainActivity">

    <ProgressBar
        android:id="@+id/timerProgressBar"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintDimensionRatio="1:1"
        android:indeterminateOnly="false"
        android:progressDrawable="@drawable/circle"
        android:rotation="-90"
        app:layout_constraintBottom_toTopOf="@+id/guidelineBottom"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guidelineTop"
        android:progress="10"/>

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guidelineBottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.5" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guidelineTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.1" />

 
</androidx.constraintlayout.widget.ConstraintLayout>


Get this bounty!!!

#StackBounty: #android-studio #kotlin #android-jetpack Why does LiveData only effect main layout and doesn't LiveData effect child …

Bounty: 50

FragmentHome load layout_home.xml, and layout_home.xml displays a recyclerview and a button named btnMain

recyclerview include the item layout layout_voice_item.xml, it displays a button named btnChild

I use displayCheckBox : LiveData<Boolean> to control whether both btnMain and btnChild are shown or not with the code android:visibility="@{!aHomeViewModel.displayCheckBox? View.VISIBLE: View.GONE}".

I find btnMain can be shown or not when I change the value of displayCheckBox, but btnChild keep to show, why?

FragmentHome.kt

class FragmentHome : Fragment() {

    private lateinit var binding: LayoutHomeBinding

    private val mHomeViewModel by lazy {
        getViewModel {
            HomeViewModel(provideRepository(mContext))
        }
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = DataBindingUtil.inflate(
            inflater, R.layout.layout_home, container, false
        )
        binding.lifecycleOwner = this.viewLifecycleOwner
        binding.aHomeViewModel=mHomeViewModel

        val adapter = VoiceAdapters(mHomeViewModel)
        binding.mvoiceList.adapter=adapter
        mHomeViewModel.listVoiceBySort.observe(viewLifecycleOwner){
          adapter.submitList(it)
        }
        ...
        return binding.root
    }
}

HomeViewModel.kt

class HomeViewModel(private val mDBVoiceRepository: DBVoiceRepository) : ViewModel() {

    private val _displayCheckBox = MutableLiveData<Boolean>(true)
    val displayCheckBox : LiveData<Boolean> = _displayCheckBox

    fun setCheckBox(isDisplay:Boolean){
        _displayCheckBox.value = isDisplay
    }

    ...
}

VoiceAdapters.kt

class VoiceAdapters (private val aHomeViewModel: HomeViewModel):
        ListAdapter<MVoice, VoiceAdapters.VoiceViewHolder>(MVoiceDiffCallback()) {
    ...
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VoiceViewHolder {
        return VoiceViewHolder(
            LayoutVoiceItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        )
    }

    override fun onBindViewHolder(holder: VoiceViewHolder, position: Int) {
        val aMVoice = getItem(position)
        holder.bind(aHomeViewModel, aMVoice)
    }

    inner class VoiceViewHolder (private val binding: LayoutVoiceItemBinding):
          RecyclerView.ViewHolder(binding.root) {

        fun bind(mHomeViewModel: HomeViewModel, aMVoice: MVoice) {
            binding.aHomeViewModel = mHomeViewModel
            binding.executePendingBindings()
        }

    }

    ...
}
class MVoiceDiffCallback : DiffUtil.ItemCallback<MVoice>() {
    ...
}

layout_home.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
        <import type="android.view.View" />

        <variable name="aHomeViewModel"
            type="info.dodata.voicerecorder.viewcontrol.HomeViewModel" />
    </data>

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/mvoice_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            tools:listitem="@layout/layout_voice_item"            
        />

      <Button
            android:id="@+id/btnMain"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"         
            android:visibility="@{!aHomeViewModel.displayCheckBox? View.VISIBLE: View.GONE}"            
        />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

layout_voice_item.xml

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
    <import type="android.view.View" />
    <variable name="aHomeViewModel"
        type="info.dodata.voicerecorder.viewcontrol.HomeViewModel" />
</data>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/btnChild"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="@{!aHomeViewModel.displayCheckBox? View.VISIBLE: View.GONE}"        
    />

</LinearLayout>
</layout>


Get this bounty!!!