Skip to content

Commit

Permalink
Fixed Dialog closing methods by checking the stored api length, Redes…
Browse files Browse the repository at this point in the history
…igned Home screen, and App logo, Added FAB for resetting the chat scroll, Updated Font styles, Code improvements
HarshPanchal18 committed Jan 22, 2024
1 parent b7fd465 commit 81ff176
Showing 36 changed files with 101 additions and 65 deletions.
15 changes: 1 addition & 14 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Photos/API_Input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Photos/Chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Photos/Home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Photos/Reasoning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Photos/Splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Photos/Summarize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ Insight Craft is an intuitive Android application that leverages Google's cuttin
| Splash screen | Home screen | Summarize with AI |
|---------------------------|---------------------------|---------------------------|
| ![](Photos/Splash.png) | ![](Photos/Home.png) | ![](Photos/Summarize.png) |
| Chat with AI | Photo Reasoning |
| ![](Photos/Chat.png) | ![](Photos/Reasoning.png) |
| Chat with AI | Photo Reasoning | API Input Dialog |
| ![](Photos/Chat.png) | ![](Photos/Reasoning.png) | ![](Photos/API_Input.png) |

## Features
- **Text Input Search:** Insight Craft allows users to input text for summarizing phrases and blogs using the powerful capabilities of the Gemini Pro AI model. This feature enables users to obtain concise and meaningful summaries of written content efficiently.
@@ -21,6 +21,7 @@ Insight Craft is integrated with Google's *Gemini Pro AI* model, which enables i

## Usage
Users can simply download the Insight Craft app from release and experience the seamless integration of *Gemini Pro AI* capabilities to enhance their text search, chat interactions, and photo reasoning experiences.
Users can update their API key by tapping on three circles from home screen.

## How to Contribute
Contributing is easy, and all skill levels are welcome! Here's how you can get started:
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ android {
minSdk = 27
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionName = "1.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions app/src/main/java/com/harsh/askgemini/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -20,12 +20,11 @@ import com.harsh.askgemini.ui.theme.AskGeminiTheme

class MainActivity : ComponentActivity() {

private val viewModel: SplashViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S) {
val viewModel: SplashViewModel by viewModels()
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { viewModel.isLoading.value }
}
45 changes: 34 additions & 11 deletions app/src/main/java/com/harsh/askgemini/feature/chat/ChatScreen.kt
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package com.harsh.askgemini.feature.chat
import android.Manifest
import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
@@ -23,25 +24,29 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowLeft
import androidx.compose.material.icons.filled.KeyboardDoubleArrowDown
import androidx.compose.material.icons.filled.Mic
import androidx.compose.material.icons.filled.Send
import androidx.compose.material.icons.outlined.BubbleChart
import androidx.compose.material.icons.outlined.ContentCopy
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedAssistChip
import androidx.compose.material3.FabPosition
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallFloatingActionButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
@@ -85,13 +90,32 @@ internal fun ChatRoute(
navController: NavHostController,
) {

BackHandler { navController.popBackStack() }
val chatUiState by chatViewModel.uiState.collectAsState()
val listState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
BackHandler { navController.popBackStack() }
val listState = rememberLazyListState()
val isScrollingUp by remember { mutableStateOf(listState.firstVisibleItemIndex != 0) }

Scaffold(
containerColor = MaterialTheme.colorScheme.primary.copy(0.40F),
floatingActionButton = {
AnimatedVisibility(visible = !isScrollingUp) {
SmallFloatingActionButton(
onClick = {
coroutineScope.launch {
listState.scrollToItem(0)
}
},
containerColor = Color.LightGray,
) {
Icon(
imageVector = Icons.Default.KeyboardDoubleArrowDown,
contentDescription = ""
)
}
}
},
floatingActionButtonPosition = FabPosition.Center,
bottomBar = {
MessageInput(
onSendMessage = { inputText ->
@@ -205,11 +229,10 @@ fun Bubble(
modifier = Modifier
.padding(all = 14.dp)
.clip(RoundedCornerShape(6.dp)),
style = TextStyle(
fontFamily = FontFamily.Serif,
fontWeight = FontWeight.SemiBold
),
lineHeight = 10.sp
style = TextStyle(fontFamily = FontFamily.Serif),
isTextSelectable = true,
lineHeight = 10.sp,
fontSize = MaterialTheme.typography.bodyLarge.fontSize
)

if (isModelMessage)
@@ -224,8 +247,8 @@ fun Bubble(
label = {
Text(
text = " Copy",
fontFamily = FontFamily(Font(R.font.next_time, FontWeight.Bold)),
)
fontFamily = FontFamily(Font(R.font.mavitya, FontWeight.ExtraBold)),
)
},
leadingIcon = {
Icon(
@@ -270,7 +293,7 @@ fun MessageInput(
placeholder = {
Text(
stringResource(R.string.chat_label),
fontFamily = FontFamily(Font(R.font.next_time, FontWeight.Bold)),
fontFamily = FontFamily(Font(R.font.mavitya, FontWeight.Bold)),
style = MaterialTheme.typography.titleLarge
)
},
@@ -360,7 +383,7 @@ fun TopAppBarOfChat(navController: NavHostController) {

Text(
text = "Chat with AI ",
fontFamily = FontFamily(Font(R.font.next_time, FontWeight.SemiBold)),
fontFamily = FontFamily(Font(R.font.mavitya, FontWeight.SemiBold)),
style = MaterialTheme.typography.titleLarge,
color = Color.DarkGray,
textAlign = TextAlign.Center
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ fun PhotoReasoningScreen(
placeholder = {
Text(
stringResource(R.string.reason_hint),
fontFamily = FontFamily(Font(R.font.next_time)),
fontFamily = FontFamily(Font(R.font.mavitya)),
style = MaterialTheme.typography.bodyLarge
)
},
@@ -233,7 +233,7 @@ fun PhotoReasoningScreen(
) {
Text(
text = "Add Image",
fontFamily = FontFamily(Font(R.font.next_time)),
fontFamily = FontFamily(Font(R.font.mavitya)),
style = MaterialTheme.typography.bodyLarge
)
}
@@ -249,7 +249,7 @@ fun PhotoReasoningScreen(
) {
Text(
text = "Clear",
fontFamily = FontFamily(Font(R.font.next_time)),
fontFamily = FontFamily(Font(R.font.mavitya)),
style = MaterialTheme.typography.bodyLarge
)
}
@@ -269,7 +269,7 @@ fun PhotoReasoningScreen(
) {
Text(
text = stringResource(id = R.string.action_go),
fontFamily = FontFamily(Font(R.font.next_time)),
fontFamily = FontFamily(Font(R.font.mavitya)),
style = MaterialTheme.typography.bodyLarge
)
}
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ fun SummarizedScreen(
placeholder = {
Text(
text = "What's cooking in your head?",
fontFamily = FontFamily(Font(R.font.next_time, FontWeight.Bold)),
fontFamily = FontFamily(Font(R.font.mavitya, FontWeight.Bold)),
style = MaterialTheme.typography.bodyLarge
)
},
@@ -172,7 +172,7 @@ fun SummarizedScreen(
label = {
Text(
text = suggestion,
fontFamily = FontFamily.Serif,
fontFamily = FontFamily(Font(R.font.mavitya)),
style = MaterialTheme.typography.bodyLarge
)
},
@@ -202,7 +202,8 @@ fun SummarizedScreen(
Text(
text = stringResource(id = R.string.action_go),
color = MaterialTheme.colorScheme.onSecondaryContainer,
fontFamily = FontFamily(Font(R.font.next_time, FontWeight.Bold)),
fontFamily = FontFamily(Font(R.font.mavitya)),
fontWeight = FontWeight.ExtraBold,
style = MaterialTheme.typography.bodyLarge
)

18 changes: 15 additions & 3 deletions app/src/main/java/com/harsh/askgemini/ui/MenuScreen.kt
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
@@ -23,22 +25,32 @@ fun MenuScreen(onItemClicked: (String) -> Unit = {}) {
routeId = "summarize",
titleResId = R.string.menu_summarize_title,
descriptionResId = R.string.menu_summarize_description,
backgroundColor = Color.Red
backgroundColor = Color(0xFFE03C39)
),
Screen(
routeId = "chat",
titleResId = R.string.menu_chat_title,
descriptionResId = R.string.menu_chat_description,
backgroundColor = Color.Yellow
backgroundColor = Color(0xFFFFC313)
),
Screen(
routeId = "reasoning",
titleResId = R.string.menu_reason_title,
descriptionResId = R.string.menu_reason_description,
backgroundColor = Color(0xFF68F51D)
backgroundColor = Color(0xFF4DC2D4)
)
)

val isApiValid = Cupboard.getApiKey().length == 39
val openDialog = remember { mutableStateOf(!isApiValid) }

if (openDialog.value)
ApiInputDialog(closeDialog = {
Cupboard.initPreference(context)
val newApiKey = Cupboard.getApiKey()
openDialog.value = newApiKey.length != 39
})

Column(
modifier = Modifier
.fillMaxHeight()
Loading

0 comments on commit 81ff176

Please sign in to comment.