Skip to content

Commit

Permalink
merging with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Rabindra Khadka committed Aug 22, 2023
2 parents 29b7a1f + d587efb commit 57051b4
Show file tree
Hide file tree
Showing 47 changed files with 455 additions and 131 deletions.
60 changes: 36 additions & 24 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@ name: ci-dev.yml

on:
push:
branches: [ dev ]
branches:
- dev
workflow_dispatch:

jobs:
unit-test:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: '17.0.8'
distribution: 'temurin'
cache: gradle
- name: Unit tests
run: bash ./gradlew test --stacktrace
integration-test:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Run Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17.0.8'
distribution: 'temurin'
cache: gradle
- name: Unit tests
Expand All @@ -35,22 +41,28 @@ jobs:
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
# apk:
# name: Generate APK
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: set up JDK 11
# uses: actions/setup-java@v1
# with:
# java-version: '11'
# distribution: 'temurin'
# cache: gradle
# - name: Build debug APK
# run: bash ./gradlew assembleDebug --stacktrace
# - name: Upload APK
# uses: actions/upload-artifact@v3
# with:
# name: app
# path: app/build/outputs/apk/debug/app-debug.apk
apk:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Generate APK
runs-on: ubuntu-latest
needs: [ unit-test, integration-test ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17.0.8'
distribution: 'temurin'
cache: gradle
- name: Build debug APK
run: bash ./gradlew assembleRelease --stacktrace
- name: Upload APK to App Center
uses: wzieba/AppCenter-Github-Action@v1
with:
appName: Code-Crow-Corp/Mage-Android
token: ${{secrets.APP_CENTER_TOKEN}}
group: Testers
file: app/build/outputs/apk/release/app-release-unsigned.apk
notifyTesters: true
debug: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
.externalNativeBuild
.cxx
local.properties
app/google-services.json
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
google-services.json
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.MageApplication"
android:name=".MageApplication"
tools:targetApi="31">
tools:targetApi="33">
<activity
android:name=".ui.MainActivity"
android:exported="true"
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.codecrow.mage.data.datasource

import io.codecrow.mage.data.DataException
import io.codecrow.mage.data.Either
import io.codecrow.mage.remote.model.Channel
import io.codecrow.mage.remote.utils.Resource
import kotlinx.coroutines.flow.Flow

interface ChannelRemote {
fun getAllChannels(searchQuery: String, skip: Int, limit: Int): Flow<Resource<ArrayList<Channel>>>

fun getChannelByID(channelId: String) : Flow<Resource<Channel>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ class ChannelRemoteImpl @Inject constructor(
}
}

override fun getChannelByID(channelId: String): Flow<Resource<Channel>> {
return flow {
emit(Resource.loading())
emit(Resource.success(data = channelMapper.map(channelApi.getChannel(channelId))))
}.catch { e ->
emit(Resource.error(e))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface ChannelApi {
suspend fun deleteChannel(@Query("channelId") channelId: String): List<Channel>

@GET("channel")
suspend fun getChannel(@Query("channelId") channelId: String): Channel
suspend fun getChannel(@Query("channelId") channelId: String): ChannelResponseItem

@GET("channels/friend")
suspend fun getFriendChannel(@Query("title") title: String): Channel
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/java/io/codecrow/mage/model/Channel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.codecrow.mage.model
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
import io.codecrow.mage.remote.model.UserDetails

data class Channel(
@SerializedName("_id")
@Expose
var _id: String,

@SerializedName("title")
@Expose
var title: String,

@SerializedName("description")
@Expose
var description: String,

@SerializedName("thumbnail")
@Expose
var thumbnail: String,

@SerializedName("category")
@Expose
var category: List<String>,

@SerializedName("tags")
@Expose
var tags: List<String>,

@SerializedName("user")
@Expose
var user: String,

@SerializedName("memberCount")
@Expose
var memberCount: Int,

@SerializedName("channelType")
@Expose
var channelType: String,

@SerializedName("userDetails")
@Expose
var userDetails: UserDetails,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ constructor() :

override suspend fun map(input: ChannelResponseItem): Channel {
return Channel(
id = input.id.orEmpty(),
title = input.title.orEmpty(),
avatar = input.userDetails?.avatar.orEmpty(),
createdByUsername = input.userDetails?.username.orEmpty()
createdByUsername = input.userDetails?.username.orEmpty(),
memberCount = input.memberCount.toString()
)
}

suspend fun mapAllChannels(botItems : ArrayList<ChannelResponseItem>) : ArrayList<Channel>{
suspend fun mapAllChannels(botItems: ArrayList<ChannelResponseItem>): ArrayList<Channel> {
val allBots = ArrayList<Channel>()
Log.i("__TAG", GsonBuilder().setPrettyPrinting().create().toJson(botItems))
botItems.forEachIndexed { index, channelResponseItem ->
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/codecrow/mage/remote/model/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

data class Channel(
var id : String,
var title: String,
var createdByUsername: String,
var avatar: String,
var memberCount : String
)
17 changes: 17 additions & 0 deletions app/src/main/java/io/codecrow/mage/remote/model/UserDetails.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.codecrow.mage.remote.model
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

data class UserDetails(
@SerializedName("avatar")
@Expose
var avatar: String,

@SerializedName("displayName")
@Expose
var displayName: String,

@SerializedName("username")
@Expose
var username: String,
)
5 changes: 5 additions & 0 deletions app/src/main/java/io/codecrow/mage/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ class MainActivity : ComponentActivity() {
}
}

//
//composable("channel/{channelId}") { backStackEntry ->
// val channelId = backStackEntry.arguments?.getString("channelId")
// ChannelScreen(channelId)
//}
21 changes: 19 additions & 2 deletions app/src/main/java/io/codecrow/mage/ui/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,34 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import io.codecrow.mage.ui.browse.BrowseScreen
import io.codecrow.mage.ui.channel.ChannelScreen
import io.codecrow.mage.ui.channel.ChannelViewModel

@Composable
fun MainNavigation() {
val navController = rememberNavController()

NavHost(navController = navController, startDestination = "main") {
composable("main") { BrowseScreen(modifier = Modifier.padding(16.dp)) }
// TODO: Add more destinations
composable("main") {
BrowseScreen(
navController = navController,
modifier = Modifier.padding(16.dp)
)
}
composable("channel/{channelId}") { backStackEntry ->
val channelId = backStackEntry.arguments?.getString("channelId") ?: ""
val viewModel = hiltViewModel<ChannelViewModel>()
ChannelScreen(
navController = navController,
modifier = Modifier.padding(16.dp),
viewModel = viewModel,
channelID = channelId
)
}
}
}
Loading

0 comments on commit 57051b4

Please sign in to comment.