Skip to content

Commit b865549

Browse files
authored
Merge branch 'stage' into fix/ADFA-2095-nullpointer-homefragment
2 parents b22e78f + f6878b1 commit b865549

15 files changed

Lines changed: 163 additions & 58 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,7 @@ tests/test-home
128128
/sample-plugin/build/
129129
/keystore-generator-plugin/build/
130130
/keystore-generator-plugin/.kotlin/
131+
**/build
132+
133+
# Release files
134+
*.zim

app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,11 @@ abstract class BaseEditorActivity :
576576
}
577577

578578
feedbackButtonManager =
579-
FeedbackButtonManager(activity = this, feedbackFab = binding.fabFeedback)
579+
FeedbackButtonManager(
580+
activity = this,
581+
feedbackFab = binding.fabFeedback,
582+
getLogContent = ::getLogContent,
583+
)
580584
feedbackButtonManager?.setupDraggableFab()
581585

582586
setupMemUsageChart()
@@ -1280,17 +1284,25 @@ abstract class BaseEditorActivity :
12801284
}
12811285

12821286
private fun getLogContent(): String? {
1283-
if (bottomSheetViewModel.sheetBehaviorState == BottomSheetBehavior.STATE_COLLAPSED) {
1284-
return null
1287+
val pagerAdapter = binding.content.bottomSheet.pagerAdapter
1288+
1289+
val candidateTabs = buildList {
1290+
add(bottomSheetViewModel.currentTab)
1291+
add(BottomSheetViewModel.TAB_BUILD_OUTPUT)
1292+
add(BottomSheetViewModel.TAB_APPLICATION_LOGS)
1293+
add(BottomSheetViewModel.TAB_IDE_LOGS)
1294+
}.distinct()
1295+
1296+
candidateTabs.forEach { tabIndex ->
1297+
val fragment = pagerAdapter.getFragmentAtIndex<Fragment>(tabIndex)
1298+
if (fragment is ShareableOutputFragment) {
1299+
val shareable = fragment.getShareableContent().trim()
1300+
if (shareable.isNotEmpty()) {
1301+
return shareable
1302+
}
1303+
}
12851304
}
12861305

1287-
val fragment = this.binding.content.bottomSheet.pagerAdapter.getFragmentAtIndex<Fragment>(
1288-
bottomSheetViewModel.currentTab
1289-
)
1290-
1291-
return when (fragment) {
1292-
is ShareableOutputFragment -> fragment.getShareableContent()
1293-
else -> null
1294-
}
1306+
return null
12951307
}
12961308
}

app/src/main/java/com/itsaky/androidide/adapters/EditorBottomSheetTabAdapter.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,20 @@ class EditorBottomSheetTabAdapter(
107107
title = fragmentActivity.getString(R.string.debugger_title),
108108
fragmentClass = DebuggerFragment::class.java,
109109
itemId = TAB_DEBUGGER,
110-
tooltipTag = TooltipTag.PROJECT_DEBUGGER_OUTPUT,
111-
),
112-
)
113-
114-
if (isExperimentsEnabled()) {
115-
add(
116-
Tab(
117-
title = fragmentActivity.getString(R.string.title_agent),
118-
fragmentClass = AgentFragmentContainer::class.java,
119-
itemId = TAB_AGENT,
120-
tooltipTag = TooltipTag.PROJECT_AGENT,
121-
),
122-
)
123-
}
110+
tooltipTag = TooltipTag.PROJECT_DEBUGGER_OUTPUT,
111+
),
112+
)
113+
114+
if (isExperimentsEnabled()) {
115+
add(
116+
Tab(
117+
title = fragmentActivity.getString(R.string.title_agent),
118+
fragmentClass = AgentFragmentContainer::class.java,
119+
itemId = TAB_AGENT,
120+
tooltipTag = TooltipTag.PROJECT_AGENT,
121+
),
122+
)
123+
}
124124
}
125125

126126
private val tabs = MutableList(allTabs.size) { allTabs[it] }

app/src/main/java/com/itsaky/androidide/agent/fragments/AgentFragmentContainer.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.itsaky.androidide.agent.fragments
22

3+
import android.content.Context
34
import android.os.Bundle
45
import android.view.View
6+
import androidx.core.content.edit
57
import com.itsaky.androidide.databinding.FragmentAgentContainerBinding
68
import com.itsaky.androidide.fragments.EmptyStateFragment
79

10+
internal const val PREFS_NAME = "LlamaPrefs"
11+
private const val DISCLAIMER_SHOWN_KEY = "disclaimer_shown"
12+
813
class AgentFragmentContainer : EmptyStateFragment<FragmentAgentContainerBinding>(FragmentAgentContainerBinding::inflate) {
914
override fun onFragmentLongPressed() {
1015
}
@@ -16,5 +21,19 @@ class AgentFragmentContainer : EmptyStateFragment<FragmentAgentContainerBinding>
1621
super.onViewCreated(view, savedInstanceState)
1722
emptyStateViewModel.setEmptyMessage("No git actions yet")
1823
emptyStateViewModel.setEmpty(false)
24+
showDisclaimerDialogIfNeeded()
25+
}
26+
27+
private fun showDisclaimerDialogIfNeeded() {
28+
val prefs = requireActivity().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
29+
val disclaimerShown = prefs.getBoolean(DISCLAIMER_SHOWN_KEY, false)
30+
31+
if (!disclaimerShown) {
32+
DisclaimerDialogFragment().show(childFragmentManager, "DisclaimerDialogFragment")
33+
34+
prefs.edit {
35+
putBoolean(DISCLAIMER_SHOWN_KEY, true)
36+
}
37+
}
1938
}
2039
}

app/src/main/java/com/itsaky/androidide/agent/fragments/AiSettingsFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import java.util.Locale
3131

3232

3333
const val SAVED_MODEL_URI_KEY = "saved_model_uri"
34-
private const val PREFS_NAME = "LlamaPrefs"
3534

3635
class AiSettingsFragment : Fragment(R.layout.fragment_ai_settings) {
3736

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.itsaky.androidide.agent.fragments
2+
3+
import android.app.Dialog
4+
import android.os.Bundle
5+
import androidx.fragment.app.DialogFragment
6+
import com.google.android.material.dialog.MaterialAlertDialogBuilder
7+
import com.itsaky.androidide.resources.R
8+
9+
class DisclaimerDialogFragment : DialogFragment() {
10+
11+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
12+
return MaterialAlertDialogBuilder(requireContext())
13+
.setTitle(getString(R.string.ai_disclaimer))
14+
.setMessage(getString(R.string.ai_disclaimer_message))
15+
.setPositiveButton("OK", null)
16+
.create()
17+
}
18+
}

app/src/main/res/layout/fragment_ai_settings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
android:layout_height="wrap_content"
4545
android:layout_marginTop="16dp" />
4646

47+
<include
48+
android:id="@+id/disclaimer"
49+
layout="@layout/layout_ai_disclaimer" />
4750
</LinearLayout>
4851
</ScrollView>
4952
</LinearLayout>

app/src/main/res/layout/fragment_chat.xml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:layout_width="0dp"
3636
android:layout_height="0dp"
3737
android:clipToPadding="false"
38-
android:paddingBottom="4dp"
38+
android:paddingBottom="8dp"
3939
app:layout_constraintBottom_toTopOf="@id/input_bar_card"
4040
app:layout_constraintEnd_toEndOf="parent"
4141
app:layout_constraintStart_toStartOf="parent"
@@ -88,7 +88,7 @@
8888
android:id="@+id/input_bar_card"
8989
android:layout_width="0dp"
9090
android:layout_height="wrap_content"
91-
app:cardElevation="4dp"
91+
app:cardElevation="8dp"
9292
app:layout_constraintBottom_toTopOf="@id/keyboard_spacer"
9393
app:layout_constraintEnd_toEndOf="parent"
9494
app:layout_constraintStart_toStartOf="parent"
@@ -98,10 +98,10 @@
9898
android:layout_width="match_parent"
9999
android:layout_height="wrap_content"
100100
android:orientation="vertical"
101-
android:paddingStart="4dp"
102-
android:paddingTop="4dp"
103-
android:paddingEnd="4dp"
104-
android:paddingBottom="2dp">
101+
android:paddingStart="8dp"
102+
android:paddingTop="8dp"
103+
android:paddingEnd="8dp"
104+
android:paddingBottom="4dp">
105105

106106
<LinearLayout
107107
android:layout_width="match_parent"
@@ -114,7 +114,7 @@
114114
style="@style/Widget.Material3.Button.IconButton"
115115
android:layout_width="wrap_content"
116116
android:layout_height="wrap_content"
117-
android:contentDescription="Add Context File"
117+
android:contentDescription="@string/add_context_file"
118118
android:text="\@" />
119119

120120
<HorizontalScrollView
@@ -133,23 +133,31 @@
133133

134134
<com.google.android.material.textfield.TextInputLayout
135135
android:id="@+id/prompt_input_layout"
136-
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.Dense"
136+
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
137137
android:layout_width="match_parent"
138138
android:layout_height="wrap_content"
139-
android:layout_marginTop="2dp"
140-
android:hint="Type a message...">
139+
android:layout_marginTop="4dp"
140+
android:hint="@string/type_a_message_or_prompt">
141141

142142
<com.google.android.material.textfield.TextInputEditText
143143
android:id="@+id/prompt_input_edittext"
144144
android:layout_width="match_parent"
145145
android:layout_height="wrap_content"
146146
android:gravity="top"
147147
android:inputType="textMultiLine|textCapSentences"
148-
android:maxLines="6"
149-
android:minHeight="48dp"
148+
android:maxLines="8"
149+
android:minHeight="56dp"
150150
android:scrollbars="vertical" />
151151
</com.google.android.material.textfield.TextInputLayout>
152152

153+
<TextView
154+
android:layout_width="match_parent"
155+
android:layout_height="wrap_content"
156+
android:text="@string/experimental_ai_use_at_your_own_risk"
157+
android:textAppearance="?attr/textAppearanceCaption"
158+
android:gravity="center_horizontal"
159+
android:layout_marginTop="4dp"/>
160+
153161
<RelativeLayout
154162
android:layout_width="match_parent"
155163
android:layout_height="wrap_content"
@@ -172,7 +180,7 @@
172180
android:id="@+id/backend_status_icon"
173181
android:layout_width="18dp"
174182
android:layout_height="18dp"
175-
android:contentDescription="Current AI Backend"
183+
android:contentDescription="@string/current_ai_backend"
176184
android:src="@drawable/ic_ai"
177185
app:tint="?attr/colorOnSurfaceVariant" />
178186

@@ -202,7 +210,7 @@
202210
android:layout_height="wrap_content"
203211
android:layout_alignParentEnd="true"
204212
android:layout_centerVertical="true"
205-
android:contentDescription="Stop Generation"
213+
android:contentDescription="@string/stop_generation"
206214
android:visibility="gone"
207215
app:icon="@drawable/ic_stop"
208216
tools:visibility="visible" />
@@ -214,7 +222,7 @@
214222
android:layout_height="wrap_content"
215223
android:layout_alignParentEnd="true"
216224
android:layout_centerVertical="true"
217-
android:contentDescription="Send Message"
225+
android:contentDescription="@string/send_message"
218226
android:enabled="false"
219227
app:icon="@drawable/ic_send" />
220228
</RelativeLayout>
@@ -226,7 +234,7 @@
226234
android:layout_height="wrap_content"
227235
android:layout_centerVertical="true"
228236
android:layout_toStartOf="@id/btn_control_prompt"
229-
android:contentDescription="Upload Image"
237+
android:contentDescription="@string/upload_image"
230238
app:icon="@drawable/ic_add_photo" />
231239
</RelativeLayout>
232240
</LinearLayout>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/warning_text"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:gravity="center_vertical"
7+
android:padding="8dp"
8+
android:text="@string/experimental_ai_use_at_your_own_risk"
9+
android:textAppearance="?attr/textAppearanceCaption" />

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,4 @@
1818
<resources>
1919
<!-- Required by F-Droid-->
2020
<string name="app_name" translatable="false">Code on the Go</string>
21-
<string name="retry">Retry</string>
22-
<string name="open_ai_settings">Open AI Settings</string>
23-
<string name="new_chat">New Chat</string>
2421
</resources>

0 commit comments

Comments
 (0)