├── .gitignore ├── .idea ├── .gitignore ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── api ├── .gitignore ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── example │ │ └── api │ │ ├── ConduitClient.kt │ │ ├── MyClass.kt │ │ ├── model │ │ ├── entity │ │ │ ├── Article.kt │ │ │ ├── ArticleRequestEntity.kt │ │ │ ├── Author.kt │ │ │ ├── AuthorX.kt │ │ │ ├── Comment.kt │ │ │ ├── Error.kt │ │ │ ├── Errors.kt │ │ │ ├── Profile.kt │ │ │ ├── Tags.kt │ │ │ ├── UpdateUserProfileEntity.kt │ │ │ ├── User.kt │ │ │ ├── UserCred.kt │ │ │ └── UserLoginInfo.kt │ │ ├── requests │ │ │ ├── CreateArticleRequest.kt │ │ │ ├── LoginRequest.kt │ │ │ ├── UpdateProfileRequest.kt │ │ │ └── UserRequests.kt │ │ └── response │ │ │ ├── ArticleResponse.kt │ │ │ ├── ArticlesResponse.kt │ │ │ ├── CommentResponse.kt │ │ │ ├── CommentsResponse.kt │ │ │ ├── ProfileResponse.kt │ │ │ └── UserResponse.kt │ │ └── service │ │ └── ConduitApi.kt │ └── test │ └── java │ └── ConduitApiTest.kt ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── blogoapp │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── blogoapp │ │ │ ├── AppHomeActivity.kt │ │ │ ├── AuthenticationActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── adopter │ │ │ └── GlobleFeedAdopter.kt │ │ │ ├── data │ │ │ ├── ArticleRepo.kt │ │ │ ├── UserAuthRepo.kt │ │ │ └── UserSharedpreferences.kt │ │ │ ├── extensions │ │ │ ├── ImageView.kt │ │ │ └── TextView.kt │ │ │ └── ui │ │ │ ├── ActivityViewModel.kt │ │ │ ├── article │ │ │ ├── ArticleFragment.kt │ │ │ └── ArticleViewModel.kt │ │ │ ├── auth │ │ │ ├── LoginFragment.kt │ │ │ ├── LoginViewModel.kt │ │ │ ├── SignupFragment.kt │ │ │ └── SignupViewModel.kt │ │ │ ├── bottomsheet │ │ │ ├── PostArticleBS.kt │ │ │ └── UpdateUserInfo.kt │ │ │ ├── personalfeed │ │ │ ├── PersonalFeedFragment.kt │ │ │ └── PersonalFeedViewModel.kt │ │ │ └── profile │ │ │ ├── ProfileFragment.kt │ │ │ └── ProfileViewModel.kt │ └── res │ │ ├── anim │ │ ├── item_animation_fall_down.xml │ │ └── layout_animation.xml │ │ ├── drawable-v24 │ │ ├── bottom_sheet_background.xml │ │ ├── bottom_sheet_view_background.xml │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── app_icon.png │ │ ├── article_list_item_background.xml │ │ ├── green_circuler_background.xml │ │ ├── ic_baseline_add.xml │ │ ├── ic_dashboard_black_24dp.xml │ │ ├── ic_edit_icon.xml │ │ ├── ic_home_black_24dp.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_login.xml │ │ ├── ic_menu_article.xml │ │ ├── ic_menu_personalfeed.xml │ │ ├── ic_menu_profile.xml │ │ ├── ic_notifications_black_24dp.xml │ │ ├── ic_profile_img.xml │ │ ├── ic_signup.xml │ │ ├── profile_sublayout.xml │ │ ├── profileimg.jpg │ │ └── side_nav_bar.xml │ │ ├── font │ │ ├── product_sans.xml │ │ ├── product_sans_bold.ttf │ │ ├── product_sans_bold_italic.ttf │ │ ├── product_sans_italic.ttf │ │ └── product_sans_regular.ttf │ │ ├── layout │ │ ├── activity_app_home.xml │ │ ├── activity_authentication.xml │ │ ├── activity_main.xml │ │ ├── app_bar_main.xml │ │ ├── content_main.xml │ │ ├── fragment_article.xml │ │ ├── fragment_personalfeed.xml │ │ ├── fragment_profile.xml │ │ ├── fragment_update_user_info.xml │ │ ├── globle_feed_list_item_article.xml │ │ ├── login_fragment.xml │ │ ├── nav_header_main.xml │ │ ├── post_article_b_fragment.xml │ │ └── signup_fragment.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── app_home.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher_foreground.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher_foreground.png │ │ ├── navigation │ │ ├── mobile_navigation.xml │ │ └── navigation_auth.xml │ │ ├── values-night │ │ └── themes.xml │ │ ├── values-v28 │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── example │ └── blogoapp │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Blogo App -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 119 | 120 | 122 | 123 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://cloud.githubusercontent.com/assets/556934/25672246/9a20e960-2fe7-11e7-99d3-23652878a2c2.png) 2 | 3 | > ### Android/Kotlin codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the [RealWorld](https://github.com/gothinkster/realworld) spec and API. 4 | 5 | This codebase was created to demonstrate a fully fledged fullstack application built 6 | with **Kotlin** including CRUD operations, authentication, routing, pagination, and more. 7 | 8 | See how a Medium.com clone (called Conduit) is built using Kotlin in Android to connect 9 | to any other backend from https://realworld.io/. 10 | 11 | For more information on how to this works with other backends, head over to 12 | the [RealWorld](https://github.com/gothinkster/realworld) repo. 13 | 14 | I've gone to great lengths to adhere to the latest community styleguides & 15 | best practices but had to adapt between the RealWorld specification 16 | and general mobile layout of Medium.com. 17 | 18 | ### Development 19 | This project has been developed with [Android Studio](https://developer.android.com/studio/) 20 | 21 | ### Concepts 22 | This RealWorld app tries to show the following Android concepts: 23 | * 100% Kotlin Codebase 24 | * MVVM (Model View ViewModel) Architecture 25 | * LiveData 26 | * Kotlin Coroutines 27 | * Jetpack Navigation Architecture 28 | 29 | ### Architecture 30 | The project follows the general MVVM structure without any specifics. 31 | 32 | There are two _modules_ in the project 33 | 34 | * `app` - The UI of the app. The main project that forms the APK 35 | * `api` - The REST API consumption library. Pure JVM library not Android-specific 36 | 37 | ### Other Backends 38 | Obviously, this RealWorld app is a frontend app. But it can connect to all backends implementing the [RealWorld](https://github.com/gothinkster/realworld) spec and API. To test you own backend implementation just change the URL in the settings dialog. 39 | 40 | ## Testing 41 | This project has been manually tested against 42 | * Emulator 43 | * Pixel 2 Android SDK 23 44 | * Devices 45 | * Samsung S8 Android 8.0.0 46 | 47 | ### Automated tests 48 | The project contains an example e2e test to illustrate an end-to-end test case. 49 | 50 | ## License & Credits 51 | Credits have to go out to [Thinkster](https://thinkster.io/) with their awesome [RealWorld](https://github.com/gothinkster/realworld) 52 | 53 | This project is licensed under the MIT license. 54 | 55 | ## Disclaimer 56 | This source and the whole package comes without warranty. It may or may not harm your computer or cell phone. Please use with care. Any damage cannot be related back to the author. The source has been tested on a virtual environment and scanned for viruses and has passed all tests. 57 | -------------------------------------------------------------------------------- /api/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /api/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'kotlin' 4 | id 'kotlin-kapt' 5 | } 6 | 7 | java { 8 | sourceCompatibility = JavaVersion.VERSION_11 9 | targetCompatibility = JavaVersion.VERSION_11 10 | } 11 | 12 | dependencies { 13 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 14 | 15 | //Retrofit 16 | api "com.squareup.retrofit2:retrofit:$retrofit_version" 17 | //It is connecter between moshi and retrofitBuilder 18 | implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version" 19 | //Moshi json converter 20 | implementation "com.squareup.moshi:moshi-kotlin:$moshi_version" 21 | 22 | //kapt codegen make coding faster and add some auto gentated code 23 | kapt("com.squareup.moshi:moshi-kotlin-codegen:1.11.0") 24 | 25 | //Test 26 | testImplementation 'junit:junit:4.13.2' 27 | 28 | //Coroutines in kotlin 29 | 30 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' 31 | 32 | //multidex dependency 33 | implementation 'com.android.support:multidex:1.0.3' 34 | 35 | //OKHTTP dependency 36 | testImplementation("com.squareup.okhttp3:mockwebserver:4.9.0") 37 | 38 | 39 | } -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/ConduitClient.kt: -------------------------------------------------------------------------------- 1 | package com.example.api 2 | 3 | import com.example.api.service.ConduitApi 4 | import okhttp3.Interceptor 5 | import okhttp3.OkHttpClient 6 | import retrofit2.Retrofit 7 | import retrofit2.converter.moshi.MoshiConverterFactory 8 | import java.util.concurrent.TimeUnit 9 | 10 | object ConduitClient { 11 | 12 | var authToken:String?=null 13 | 14 | private val authInterceptor = Interceptor { chain -> 15 | var req = chain.request() 16 | authToken?.let { 17 | req = req.newBuilder() 18 | .header("Authorization", "Token $it") 19 | .build() 20 | print("Token"+ authToken) 21 | } 22 | chain.proceed(req) 23 | } 24 | 25 | 26 | val okHttpBuilder = OkHttpClient.Builder() 27 | .readTimeout(10,TimeUnit.SECONDS) 28 | .connectTimeout(6,TimeUnit.SECONDS) 29 | 30 | 31 | val retrofitBuilder=Retrofit.Builder() 32 | .baseUrl("https://conduit.productionready.io/api/") 33 | .addConverterFactory(MoshiConverterFactory.create()) 34 | 35 | 36 | val api=retrofitBuilder 37 | .client(okHttpBuilder.build()) 38 | .build() 39 | .create(ConduitApi::class.java) 40 | 41 | val authApi=retrofitBuilder 42 | .client(okHttpBuilder.addInterceptor(authInterceptor).build()) 43 | .build() 44 | .create(ConduitApi::class.java) 45 | 46 | 47 | } -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/MyClass.kt: -------------------------------------------------------------------------------- 1 | package com.example.api 2 | 3 | class MyClass { 4 | } -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Article.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Article( 9 | @Json(name = "author") 10 | val author: Profile, 11 | @Json(name = "body") 12 | val body: String, 13 | @Json(name = "createdAt") 14 | val createdAt: String, 15 | @Json(name = "description") 16 | val description: String, 17 | @Json(name = "favorited") 18 | val favorited: Boolean, 19 | @Json(name = "favoritesCount") 20 | val favoritesCount: Int, 21 | @Json(name = "slug") 22 | val slug: String, 23 | @Json(name = "tagList") 24 | val tagList: List, 25 | @Json(name = "title") 26 | val title: String, 27 | @Json(name = "updatedAt") 28 | val updatedAt: String 29 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/ArticleRequestEntity.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class ArticleRequestEntity( 9 | @Json(name = "body") 10 | val body: String, 11 | @Json(name = "description") 12 | val description: String, 13 | @Json(name = "tagList") 14 | val tagList: List, 15 | @Json(name = "title") 16 | val title: String 17 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Author.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Author( 9 | @Json(name = "bio") 10 | val bio: String, 11 | @Json(name = "following") 12 | val following: Boolean, 13 | @Json(name = "image") 14 | val image: String, 15 | @Json(name = "username") 16 | val username: String 17 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/AuthorX.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class AuthorX( 9 | @Json(name = "bio") 10 | val bio: String, 11 | @Json(name = "following") 12 | val following: Boolean, 13 | @Json(name = "image") 14 | val image: String, 15 | @Json(name = "username") 16 | val username: String 17 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Comment.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.example.api.model.entity.Author 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class Comment( 10 | @Json(name = "author") 11 | val author: Author, 12 | @Json(name = "body") 13 | val body: String, 14 | @Json(name = "createdAt") 15 | val createdAt: String, 16 | @Json(name = "id") 17 | val id: Int, 18 | @Json(name = "updatedAt") 19 | val updatedAt: String 20 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Error.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Error( 9 | @Json(name = "errors") 10 | val errors: Errors 11 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Errors.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Errors( 9 | @Json(name = "body") 10 | val body: List 11 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Profile.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Profile( 9 | @Json(name = "bio") 10 | val bio: String?, 11 | @Json(name = "following") 12 | val following: Boolean, 13 | @Json(name = "image") 14 | val image: String, 15 | @Json(name = "username") 16 | val username: String 17 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/Tags.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class Tags( 9 | @Json(name = "tags") 10 | val tags: List 11 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/UpdateUserProfileEntity.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class UpdateUserProfileEntity( 9 | @Json(name = "bio") 10 | val bio: String, 11 | @Json(name = "email") 12 | val email: String, 13 | @Json(name = "image") 14 | val image: String, 15 | @Json(name = "password") 16 | val password: String, 17 | @Json(name = "username") 18 | val username: String 19 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/User.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class User( 9 | @Json(name = "bio") 10 | val bio: String?, 11 | @Json(name = "email") 12 | val email: String, 13 | @Json(name = "image") 14 | val image: String?, 15 | @Json(name = "token") 16 | val token: String, 17 | @Json(name = "username") 18 | val username: String 19 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/UserCred.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class UserCred( 9 | @Json(name = "email") 10 | val email: String, 11 | @Json(name = "password") 12 | val password: String, 13 | @Json(name = "username") 14 | val username: String 15 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/entity/UserLoginInfo.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.entity 2 | 3 | 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonClass 6 | 7 | @JsonClass(generateAdapter = true) 8 | data class UserLoginInfo( 9 | @Json(name = "email") 10 | val email: String, 11 | @Json(name = "password") 12 | val password: String 13 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/requests/CreateArticleRequest.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.requests 2 | 3 | 4 | import com.example.api.model.entity.ArticleRequestEntity 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class CreateArticleRequest( 10 | @Json(name = "article") 11 | val articleRequestEntity: ArticleRequestEntity 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/requests/LoginRequest.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.requests 2 | 3 | 4 | import com.example.api.model.entity.UserLoginInfo 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class LoginRequest( 10 | @Json(name = "user") 11 | val userLoginInfo: UserLoginInfo 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/requests/UpdateProfileRequest.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.requests 2 | 3 | 4 | import com.example.api.model.entity.UpdateUserProfileEntity 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class UpdateProfileRequest( 10 | @Json(name = "user") 11 | val updateUserProfileEntity: UpdateUserProfileEntity 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/requests/UserRequests.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.requests 2 | 3 | 4 | import com.example.api.model.entity.UserCred 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class UserRequests( 10 | @Json(name = "user") 11 | val user: UserCred 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/ArticleResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.Article 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class ArticleResponse( 10 | @Json(name = "article") 11 | val article: Article 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/ArticlesResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.Article 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class ArticlesResponse( 10 | @Json(name = "articles") 11 | val articles: List
, 12 | @Json(name = "articlesCount") 13 | val articlesCount: Int 14 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/CommentResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.Comment 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class CommentResponse( 10 | @Json(name = "comment") 11 | val comment: Comment 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/CommentsResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.Comment 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class CommentsResponse( 10 | @Json(name = "comments") 11 | val comments: List 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/ProfileResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.Profile 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class ProfileResponse( 10 | @Json(name = "profile") 11 | val profile: Profile 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/model/response/UserResponse.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.model.response 2 | 3 | 4 | import com.example.api.model.entity.User 5 | import com.squareup.moshi.Json 6 | import com.squareup.moshi.JsonClass 7 | 8 | @JsonClass(generateAdapter = true) 9 | data class UserResponse( 10 | @Json(name = "user") 11 | val user: User 12 | ) -------------------------------------------------------------------------------- /api/src/main/java/com/example/api/service/ConduitApi.kt: -------------------------------------------------------------------------------- 1 | package com.example.api.service 2 | 3 | import com.example.api.model.entity.Article 4 | import com.example.api.model.requests.CreateArticleRequest 5 | import com.example.api.model.requests.LoginRequest 6 | import com.example.api.model.requests.UpdateProfileRequest 7 | import com.example.api.model.requests.UserRequests 8 | import com.example.api.model.response.ArticleResponse 9 | import com.example.api.model.response.ArticlesResponse 10 | import com.example.api.model.response.ProfileResponse 11 | import com.example.api.model.response.UserResponse 12 | import retrofit2.Response 13 | import retrofit2.http.* 14 | 15 | interface ConduitApi { 16 | 17 | 18 | 19 | // add new user in database 20 | @POST("users") 21 | suspend fun addUser( 22 | @Body userRequests: UserRequests 23 | ):Response 24 | 25 | 26 | // add new user in database 27 | @POST("articles") 28 | suspend fun createArticles( 29 | @Body createArticleRequest: CreateArticleRequest 30 | ):Response 31 | 32 | 33 | // login user in database 34 | @POST("users/login") 35 | suspend fun loginUser( 36 | @Body userCreds: LoginRequest 37 | ): Response 38 | 39 | // get articles 40 | @GET("articles") 41 | suspend fun getArticles( 42 | @Query("author")author:String?=null, 43 | @Query("tag")tag:List?=null, 44 | @Query("favorited")favorited:String?=null 45 | ):Response 46 | 47 | 48 | @GET("articles/feed") 49 | suspend fun getFeedArticles(): Response 50 | 51 | //get Profile 52 | @GET("profiles/{username}") 53 | suspend fun getProfile( 54 | @Path("username") username:String 55 | ):Response 56 | 57 | //get current user 58 | @GET("user") 59 | suspend fun getCurrentUser():Response 60 | 61 | //update Profile 62 | 63 | @PUT("user") 64 | suspend fun updateProfile( 65 | @Body updateProfileRequest: UpdateProfileRequest 66 | ):Response 67 | 68 | } -------------------------------------------------------------------------------- /api/src/test/java/ConduitApiTest.kt: -------------------------------------------------------------------------------- 1 | import com.example.api.ConduitClient 2 | import com.example.api.model.entity.ArticleRequestEntity 3 | import com.example.api.model.entity.UpdateUserProfileEntity 4 | import com.example.api.model.entity.UserCred 5 | import com.example.api.model.requests.CreateArticleRequest 6 | import com.example.api.model.requests.UpdateProfileRequest 7 | import com.example.api.model.requests.UserRequests 8 | import kotlinx.coroutines.runBlocking 9 | import org.junit.Assert.assertEquals 10 | import org.junit.Assert.assertNotNull 11 | import org.junit.Test 12 | import java.util.* 13 | 14 | class ConduitApiTest { 15 | 16 | val conduitClient=ConduitClient 17 | @Test 18 | fun getArticle(){ 19 | runBlocking { 20 | val articles=conduitClient.api.getArticles() 21 | assertNotNull(articles.body()?.articles) 22 | } 23 | 24 | } 25 | @Test 26 | fun `get Article by author`(){ 27 | runBlocking { 28 | val articles=conduitClient.api.getArticles(author = "444") 29 | assertNotNull(articles.body()?.articles) 30 | } 31 | 32 | } 33 | @Test 34 | fun `get Article by tag`(){ 35 | runBlocking { 36 | val articles=conduitClient.api.getArticles(tag = Arrays.asList("js","dragon")) 37 | assertNotNull(articles.body()?.articles) 38 | } 39 | 40 | } 41 | @Test 42 | fun `get Article by favorite`(){ 43 | runBlocking { 44 | val articles=conduitClient.api.getArticles(favorited = "444") 45 | assertNotNull(articles.body()?.articles) 46 | } 47 | 48 | } 49 | 50 | @Test 51 | fun `Create new user`(){ 52 | val userCred=UserCred(email = "testmail332@test.com", 53 | password = "Tu999999999", 54 | username = "Marhwiojrioew") 55 | runBlocking { 56 | val user=conduitClient.api.addUser(UserRequests(userCred)) 57 | assertEquals(userCred.username,user.body()?.user?.username) 58 | } 59 | } 60 | 61 | @Test 62 | fun `Create Article`(){ 63 | val createArticleRequest=CreateArticleRequest(ArticleRequestEntity( 64 | body = "This is test article by jathalal", 65 | title = "Jatalal Test Article", 66 | 67 | description = "This article is for testing api from jathalal", 68 | tagList = listOf("jatha","fun","test") 69 | )) 70 | ConduitClient.authToken="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTQ5Nzg3LCJ1c2VybmFtZSI6ImphdGhhIiwiZXhwIjoxNjIxMjAxNjIwfQ.7jAsGGPaa3bkbqQ6awMhP3v__L3BHSO9uc83hszqdhw" 71 | runBlocking { 72 | print(conduitClient.authToken) 73 | val article=ConduitClient.authApi.createArticles(createArticleRequest) 74 | assertEquals(article.body()?.article?.body,createArticleRequest.articleRequestEntity.body) 75 | 76 | } 77 | } 78 | 79 | @Test 80 | fun `get profile`(){ 81 | ConduitClient.authToken="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTQ5Nzg3LCJ1c2VybmFtZSI6ImphdGhhIiwiZXhwIjoxNjIxMjAxNjIwfQ.7jAsGGPaa3bkbqQ6awMhP3v__L3BHSO9uc83hszqdhw" 82 | 83 | runBlocking { 84 | print(conduitClient.authToken) 85 | val article=ConduitClient.authApi.getProfile("jatha") 86 | assertEquals(article.body()?.profile?.username,"jatha") 87 | 88 | 89 | } 90 | } 91 | 92 | @Test 93 | fun `update profile`(){ 94 | ConduitClient.authToken="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTQ5Nzg3LCJ1c2VybmFtZSI6ImphdGhhIiwiZXhwIjoxNjIxMjAxNjIwfQ.7jAsGGPaa3bkbqQ6awMhP3v__L3BHSO9uc83hszqdhw" 95 | val updateProfileReques=UpdateProfileRequest(UpdateUserProfileEntity(bio = "Hello jatha", 96 | email = "jatha123@gmail.com", 97 | image = "https://static-koimoi.akamaized.net/wp-content/new-galleries/2020/10/dilip-joshi-turns-into-jethalal-of-taarak-mehta-ka-ooltah-chashmah-irl-this-picture-is-the-proof001.jpg?format=webp&compress=true&quality=80&w=720&dpr=1.0", 98 | username ="jathalal" , 99 | password ="jatha1245" )) 100 | runBlocking { 101 | print(conduitClient.authToken) 102 | val article=ConduitClient.authApi.updateProfile(updateProfileReques) 103 | assertEquals(article.body()?.user?.username,"jathalal") 104 | 105 | 106 | } 107 | } 108 | 109 | 110 | // @Test 111 | // fun `Login user`(){ 112 | // val userCred=UserLoginRequest("jatha","jatha123@gmail.com") 113 | // runBlocking { 114 | // val user=conduitClient.api.loginRequest(LoginRequest(userCred)) 115 | // assertEquals(userCred.userLoginRequest.email,user.body()?.user?.email) 116 | // } 117 | // } 118 | 119 | } -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | id 'kotlin-kapt' 5 | } 6 | 7 | android { 8 | compileSdkVersion 30 9 | buildToolsVersion "30.0.3" 10 | 11 | defaultConfig { 12 | applicationId "com.example.blogoapp" 13 | minSdkVersion 21 14 | targetSdkVersion 30 15 | versionCode 1 16 | versionName "1.0" 17 | multiDexEnabled true 18 | 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_11 31 | targetCompatibility JavaVersion.VERSION_11 32 | } 33 | kotlinOptions { 34 | jvmTarget = '1.8' 35 | } 36 | // buildFeatures { 37 | // viewBinding true 38 | // } 39 | } 40 | 41 | dependencies { 42 | 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 44 | implementation 'androidx.core:core-ktx:1.3.1' 45 | implementation 'androidx.appcompat:appcompat:1.2.0' 46 | implementation 'com.google.android.material:material:1.2.1' 47 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' 48 | implementation project(path: ':api') 49 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' 50 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' 51 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' 52 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' 53 | implementation 'androidx.vectordrawable:vectordrawable:1.1.0' 54 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 55 | testImplementation 'junit:junit:4.+' 56 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 57 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 58 | //Retrofit 59 | api "com.squareup.retrofit2:retrofit:$retrofit_version" 60 | //It is connecter between moshi and retrofitBuilder 61 | implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version" 62 | //Moshi json converter 63 | implementation "com.squareup.moshi:moshi-kotlin:$moshi_version" 64 | 65 | //kapt codegen make coding faster and add some auto generated code 66 | kapt("com.squareup.moshi:moshi-kotlin-codegen:1.11.0") 67 | 68 | // Coroutines in kotlin 69 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' 70 | 71 | //Timber 72 | implementation 'com.jakewharton.timber:timber:4.7.1' 73 | 74 | //multidex dependency 75 | implementation 'com.android.support:multidex:1.0.3' 76 | // 77 | // //Circular imageView Dependency 78 | // implementation 'de.hdodenhof:circleimageview:3.1.0' 79 | //Glide 80 | implementation 'com.github.bumptech.glide:glide:4.12.0' 81 | kapt 'com.github.bumptech.glide:compiler:4.12.0' 82 | 83 | // Loading animation library 84 | implementation 'com.github.yash786agg:AnimatedLoadingIndicator:v1.3' 85 | 86 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/blogoapp/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.blogoapp", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/AppHomeActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.view.Menu 6 | import android.view.MenuItem 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import com.google.android.material.floatingactionbutton.FloatingActionButton 10 | import com.google.android.material.snackbar.Snackbar 11 | import com.google.android.material.navigation.NavigationView 12 | import androidx.navigation.findNavController 13 | import androidx.navigation.ui.AppBarConfiguration 14 | import androidx.navigation.ui.navigateUp 15 | import androidx.navigation.ui.setupActionBarWithNavController 16 | import androidx.navigation.ui.setupWithNavController 17 | import androidx.drawerlayout.widget.DrawerLayout 18 | import androidx.appcompat.app.AppCompatActivity 19 | import androidx.appcompat.widget.Toolbar 20 | import androidx.core.content.edit 21 | import androidx.lifecycle.ViewModelProvider 22 | import com.example.api.ConduitClient 23 | import com.example.blogoapp.R 24 | import com.example.blogoapp.data.UserSharedpreferences 25 | import com.example.blogoapp.extensions.loadImage 26 | import com.example.blogoapp.ui.ActivityViewModel 27 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 28 | 29 | class AppHomeActivity : AppCompatActivity() { 30 | 31 | private lateinit var appBarConfiguration: AppBarConfiguration 32 | private lateinit var activityViewModel:ActivityViewModel 33 | 34 | override fun onCreate(savedInstanceState: Bundle?) { 35 | super.onCreate(savedInstanceState) 36 | setContentView(R.layout.activity_app_home) 37 | val toolbar: Toolbar = findViewById(R.id.toolbar) 38 | setSupportActionBar(toolbar) 39 | activityViewModel= ViewModelProvider(this).get(ActivityViewModel::class.java) 40 | ConduitClient.authToken=UserSharedpreferences(this).token 41 | activityViewModel.getCurrentUserInfo() 42 | 43 | 44 | 45 | 46 | val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) 47 | val navView: NavigationView = findViewById(R.id.nav_view) 48 | val navController = findNavController(R.id.nav_host_fragment) 49 | // Passing each menu ID as a set of Ids because each 50 | // menu should be considered as top level destinations. 51 | activityViewModel.userRes.observe({lifecycle}) { 52 | val hView = navView.getHeaderView(0) 53 | if (!it.user.image?.isEmpty()!!) { 54 | hView.findViewById(R.id.imageView) 55 | .loadImage( 56 | it.user.image!!, 57 | true 58 | ) 59 | } 60 | if (!it.user.username.isEmpty()){ 61 | hView.findViewById(R.id.userName_nav) 62 | .setText( 63 | it.user.username, 64 | ) 65 | } 66 | if (!it.user.email.isEmpty()){ 67 | hView.findViewById(R.id.email_nav) 68 | .setText( 69 | it.user.email, 70 | ) 71 | } 72 | } 73 | //Todo: Set real user image 74 | appBarConfiguration = AppBarConfiguration(setOf( 75 | R.id.nav_article, R.id.nav_personalfeed, R.id.nav_profile), drawerLayout) 76 | setupActionBarWithNavController(navController, appBarConfiguration) 77 | navView.setupWithNavController(navController) 78 | } 79 | 80 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 81 | when(item.itemId){ 82 | R.id.logout ->{ 83 | activityViewModel.logout(this).let { 84 | if(it){ 85 | val intent= Intent(this@AppHomeActivity,AuthenticationActivity::class.java) 86 | startActivity(intent) 87 | finish() 88 | } 89 | 90 | } 91 | } 92 | 93 | } 94 | return false 95 | 96 | } 97 | 98 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 99 | // Inflate the menu; this adds items to the action bar if it is present. 100 | menuInflater.inflate(R.menu.app_home, menu) 101 | 102 | return true 103 | } 104 | 105 | override fun onSupportNavigateUp(): Boolean { 106 | val navController = findNavController(R.id.nav_host_fragment) 107 | return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() 108 | } 109 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/AuthenticationActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.widget.Toast 6 | import androidx.lifecycle.ViewModelProvider 7 | import androidx.navigation.NavController 8 | import androidx.navigation.Navigation 9 | import com.example.api.model.entity.User 10 | import com.example.blogoapp.data.UserSharedpreferences 11 | import com.example.blogoapp.ui.auth.SignupViewModel 12 | import com.google.android.material.tabs.TabLayout 13 | 14 | class AuthenticationActivity : AppCompatActivity() { 15 | public lateinit var navController:NavController 16 | public lateinit var tabLayout: TabLayout 17 | private lateinit var viewModel: SignupViewModel 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | setContentView(R.layout.activity_authentication) 21 | viewModel= ViewModelProvider(this).get(SignupViewModel::class.java) 22 | 23 | tabLayout=findViewById(R.id.tabLayout) 24 | navController=Navigation.findNavController(findViewById(R.id.authFragmentNavHost)); 25 | tabLayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener{ 26 | override fun onTabSelected(tab: TabLayout.Tab?) { 27 | when (tab?.position){ 28 | 0->{ 29 | navController.navigate(R.id.gotoLoginFragment) 30 | } 31 | 32 | 1->{ 33 | navController.navigate(R.id.gotoSignupFragment) 34 | } 35 | 36 | } 37 | } 38 | 39 | override fun onTabUnselected(tab: TabLayout.Tab?) { 40 | 41 | } 42 | 43 | override fun onTabReselected(tab: TabLayout.Tab?) { 44 | 45 | } 46 | 47 | }) 48 | val tab=tabLayout.getTabAt(0) 49 | viewModel.userResponse?.observe({lifecycle}){ 50 | when(it){ 51 | is User ->{ 52 | tab?.select() 53 | Toast.makeText(this,"tab swithcing in android",Toast.LENGTH_LONG).show() 54 | UserSharedpreferences(this).token=it.token 55 | 56 | } 57 | } 58 | } 59 | 60 | 61 | 62 | 63 | } 64 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp 2 | 3 | import android.content.Intent 4 | import androidx.appcompat.app.AppCompatActivity 5 | import android.os.Bundle 6 | import android.os.Handler 7 | import com.example.blogoapp.data.UserSharedpreferences 8 | 9 | class MainActivity : AppCompatActivity() { 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | setContentView(R.layout.activity_main) 13 | Handler().postDelayed({ 14 | if (UserSharedpreferences(this).token== null){ 15 | val intent = Intent(this@MainActivity,AuthenticationActivity::class.java) 16 | startActivity(intent) 17 | finish() 18 | }else{ 19 | val intent = Intent(this@MainActivity,AppHomeActivity::class.java) 20 | startActivity(intent) 21 | finish() 22 | } 23 | },2000) 24 | 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/adopter/GlobleFeedAdopter.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.adopter 2 | 3 | import android.graphics.Color 4 | import android.graphics.drawable.ColorDrawable 5 | import android.os.Build 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import android.widget.ImageView 10 | import android.widget.TextView 11 | import androidx.annotation.RequiresApi 12 | import androidx.recyclerview.widget.DiffUtil 13 | import androidx.recyclerview.widget.ListAdapter 14 | import androidx.recyclerview.widget.RecyclerView 15 | import com.example.api.model.entity.Article 16 | import com.example.api.model.entity.Author 17 | import com.example.blogoapp.R 18 | import com.example.blogoapp.extensions.loadImage 19 | import java.util.zip.Inflater 20 | 21 | class GlobleFeedAdopter:ListAdapter( 22 | object :DiffUtil.ItemCallback
(){ 23 | override fun areItemsTheSame(oldItem: Article, newItem: Article): Boolean { 24 | return oldItem==newItem 25 | } 26 | 27 | override fun areContentsTheSame(oldItem: Article, newItem: Article): Boolean { 28 | return oldItem.toString()==oldItem.toString() 29 | } 30 | 31 | } 32 | ) { 33 | 34 | 35 | inner class ArticleViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){ 36 | 37 | val tvAuthor:TextView=itemView.findViewById(R.id.tvAuthorName) 38 | val tvArticleTitle: TextView=itemView.findViewById(R.id.tvArticleTitle) 39 | val tvArticleDescription: TextView=itemView.findViewById(R.id.tvArticleDescription) 40 | val tvDate: TextView=itemView.findViewById(R.id.tvDate) 41 | val imgAvtar: ImageView=itemView.findViewById(R.id.imgAvtar) 42 | } 43 | 44 | @RequiresApi(Build.VERSION_CODES.M) 45 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ArticleViewHolder { 46 | val inflater = LayoutInflater.from(parent.context) 47 | val view = inflater.inflate(R.layout.globle_feed_list_item_article, parent, false) 48 | val root=ArticleViewHolder( 49 | view 50 | ) 51 | 52 | return root 53 | } 54 | 55 | override fun onBindViewHolder(holder: ArticleViewHolder, position: Int) { 56 | val article=getItem(position) 57 | 58 | 59 | holder.tvAuthor.text=article.author.username 60 | holder.tvDate.text="25 Dec, 2021" 61 | holder.tvArticleTitle.text=article.title 62 | holder.tvArticleDescription.text=article.description 63 | holder.imgAvtar.loadImage(article.author.image,true) 64 | 65 | 66 | } 67 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/data/ArticleRepo.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.data 2 | 3 | import com.example.api.ConduitClient 4 | import com.example.api.model.requests.UserRequests 5 | 6 | object ArticleRepo { 7 | 8 | val api=ConduitClient.api 9 | 10 | suspend fun getGlobleFeedArticle()=api.getArticles() 11 | 12 | 13 | 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/data/UserAuthRepo.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.data 2 | 3 | import android.util.Log 4 | import com.example.api.ConduitClient 5 | import com.example.api.model.entity.User 6 | import com.example.api.model.requests.LoginRequest 7 | import com.example.api.model.entity.UserLoginInfo 8 | import com.example.api.model.requests.UserRequests 9 | import com.example.api.model.response.ArticlesResponse 10 | 11 | object UserAuthRepo { 12 | val userApi=ConduitClient.api 13 | val authApi=ConduitClient.authApi 14 | suspend fun userSignup(userRequests: UserRequests): User? { 15 | val response=userApi.addUser(userRequests) 16 | ConduitClient.authToken=response.body()?.user?.token 17 | return response.body()?.user 18 | } 19 | suspend fun userLogin(email:String,password:String):User?{ 20 | val response=userApi.loginUser(LoginRequest( 21 | UserLoginInfo(email,password) 22 | )) 23 | ConduitClient.authToken=response.body()?.user?.token 24 | return response.body()?.user 25 | } 26 | 27 | suspend fun feedArticle():ArticlesResponse?{ 28 | Log.e("My Token","Token "+ConduitClient.authToken) 29 | val response= authApi.getFeedArticles() 30 | 31 | return response.body() 32 | } 33 | 34 | suspend fun getUserProfile(userName:String)= authApi.getProfile(username = userName) 35 | suspend fun getCurrentUser()= authApi.getCurrentUser() 36 | 37 | 38 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/data/UserSharedpreferences.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.data 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import androidx.core.content.edit 6 | 7 | class UserSharedpreferences(context: Context) { 8 | val PREFERENCE_NAME = "USER_DETAIL_SHAREDPREFERANCE" 9 | val PREFS_KEY_TOKEN = "PREFS_KEY_TOKEN" 10 | val sharedPreferences: SharedPreferences = 11 | context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) 12 | var token: String? = null 13 | get() = sharedPreferences.getString(PREFS_KEY_TOKEN, null) 14 | set(value) { 15 | field = value 16 | sharedPreferences.edit { 17 | putString(PREFS_KEY_TOKEN, field) 18 | } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/extensions/ImageView.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.extensions 2 | 3 | import android.widget.ImageView 4 | import com.bumptech.glide.Glide 5 | 6 | fun ImageView.loadImage(url:String,crop:Boolean=false){ 7 | if (crop) 8 | Glide.with(this).load(url).circleCrop().into(this) 9 | else 10 | Glide.with(this).load(url).into(this) 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/extensions/TextView.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.extensions 2 | 3 | import android.widget.TextView 4 | 5 | fun TextView.loadText(){ 6 | 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/ActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui 2 | 3 | import android.content.Context 4 | import androidx.core.content.edit 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.MutableLiveData 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.viewModelScope 9 | import com.example.api.model.response.UserResponse 10 | import com.example.blogoapp.data.UserAuthRepo 11 | import com.example.blogoapp.data.UserSharedpreferences 12 | import kotlinx.coroutines.launch 13 | 14 | class ActivityViewModel:ViewModel() { 15 | private val _userRes= MutableLiveData() 16 | val userRes: LiveData =_userRes 17 | 18 | fun logout(context: Context):Boolean{ 19 | UserSharedpreferences(context).sharedPreferences.edit { 20 | remove("PREFS_KEY_TOKEN") 21 | }.let { 22 | return true 23 | } 24 | } 25 | 26 | fun getCurrentUserInfo(){ 27 | viewModelScope.launch { 28 | UserAuthRepo.getCurrentUser().let { 29 | _userRes.postValue(it.body()) 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/article/ArticleFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.article 2 | 3 | import android.app.Dialog 4 | import android.graphics.Color 5 | import android.graphics.drawable.ColorDrawable 6 | import android.os.Bundle 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import androidx.navigation.fragment.findNavController 10 | import android.view.ViewGroup 11 | import android.view.Window 12 | import android.widget.TextView 13 | import android.widget.Toast 14 | import androidx.core.content.ContextCompat 15 | import androidx.fragment.app.Fragment 16 | import androidx.lifecycle.Observer 17 | import androidx.lifecycle.ViewModelProvider 18 | import androidx.recyclerview.widget.LinearLayoutManager 19 | import androidx.recyclerview.widget.RecyclerView 20 | import com.example.blogoapp.R 21 | import com.example.blogoapp.adopter.GlobleFeedAdopter 22 | import com.google.android.material.floatingactionbutton.FloatingActionButton 23 | 24 | class ArticleFragment : Fragment() { 25 | private lateinit var fab:FloatingActionButton 26 | private lateinit var feedRecyclerView: RecyclerView 27 | private lateinit var globleFeedAdopter: GlobleFeedAdopter 28 | private lateinit var articleViewModel: ArticleViewModel 29 | 30 | override fun onCreateView( 31 | inflater: LayoutInflater, 32 | container: ViewGroup?, 33 | savedInstanceState: Bundle? 34 | ): View? { 35 | articleViewModel = 36 | ViewModelProvider(requireActivity()).get(ArticleViewModel::class.java) 37 | val root = inflater.inflate(R.layout.fragment_article, container, false) 38 | feedRecyclerView = root.findViewById(R.id.feedRecylerView) 39 | 40 | globleFeedAdopter=GlobleFeedAdopter() 41 | feedRecyclerView.layoutManager=LinearLayoutManager(context) 42 | feedRecyclerView.adapter=globleFeedAdopter 43 | 44 | return root 45 | } 46 | 47 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 48 | super.onViewCreated(view, savedInstanceState) 49 | 50 | fab=view.findViewById(R.id.fab) 51 | 52 | 53 | val progressDialog = Dialog(requireContext()) 54 | progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) 55 | progressDialog.setContentView(R.layout.custom_dialog_progress) 56 | 57 | /* Custom setting to change TextView text,Color and Text Size according to your Preference*/ 58 | 59 | val progressTv = progressDialog.findViewById(R.id.progress_tv) as TextView 60 | progressTv.text = resources.getString(R.string.loading) 61 | progressTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) 62 | progressTv.textSize = 19F 63 | 64 | progressDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 65 | progressDialog.setCancelable(false) 66 | progressDialog.show() 67 | 68 | 69 | 70 | articleViewModel.fetchGlobaleFeedArticle() 71 | articleViewModel.feed.observe({ lifecycle }) { 72 | globleFeedAdopter.submitList(it).let { 73 | // globleFeedAdopter.notifyItemChanged(0) Todo: Refrace the recyclerView 74 | progressDialog.dismiss() 75 | } 76 | 77 | } 78 | 79 | fab.setOnClickListener { 80 | findNavController().navigate(R.id.postArticleBS) 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/article/ArticleViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.article 2 | 3 | import android.util.Log 4 | import android.widget.Toast 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.MutableLiveData 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.viewModelScope 9 | import com.example.api.ConduitClient 10 | import com.example.api.model.entity.Article 11 | import com.example.api.model.entity.ArticleRequestEntity 12 | import com.example.api.model.requests.CreateArticleRequest 13 | import com.example.api.model.response.ArticleResponse 14 | import com.example.blogoapp.data.ArticleRepo 15 | import kotlinx.coroutines.launch 16 | import timber.log.Timber 17 | 18 | public class ArticleViewModel : ViewModel() { 19 | 20 | private val _feed=MutableLiveData>() 21 | val feed:LiveData> = _feed 22 | 23 | private val _text = MutableLiveData().apply { 24 | value = "This is home Fragment" 25 | } 26 | 27 | fun fetchGlobaleFeedArticle(){ 28 | viewModelScope.launch { 29 | ArticleRepo.getGlobleFeedArticle().body().let { 30 | _feed.postValue(it?.articles) 31 | Log.e("Article: ",it?.articlesCount.toString()) 32 | } 33 | } 34 | } 35 | val text: LiveData = _text 36 | 37 | private val _articleResponse=MutableLiveData() 38 | val articleResponse: LiveData =_articleResponse 39 | 40 | fun PostArticles(title: String,body: String,description:String,tagList:List){ 41 | viewModelScope.launch { 42 | val createArticleRequest= CreateArticleRequest( 43 | ArticleRequestEntity( 44 | title = title, 45 | body = body, 46 | description = description, 47 | tagList = tagList, 48 | ) 49 | ) 50 | ConduitClient.authApi.createArticles(createArticleRequest).let { 51 | _articleResponse.postValue(it.body()) 52 | } 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/auth/LoginFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.auth 2 | 3 | import android.content.Intent 4 | import androidx.lifecycle.ViewModelProvider 5 | import android.os.Bundle 6 | import androidx.fragment.app.Fragment 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.widget.Button 11 | import android.widget.EditText 12 | import android.widget.TextView 13 | import android.widget.Toast 14 | import com.example.api.model.entity.User 15 | import com.example.blogoapp.AppHomeActivity 16 | import com.example.blogoapp.R 17 | import com.example.blogoapp.data.UserSharedpreferences 18 | 19 | class LoginFragment : Fragment() { 20 | 21 | private lateinit var tvNoAccount: TextView 22 | private lateinit var edEmailId: EditText 23 | private lateinit var edPassword: EditText 24 | private lateinit var signInBtn: Button 25 | 26 | companion object { 27 | fun newInstance() = LoginFragment() 28 | } 29 | 30 | private lateinit var viewModel: LoginViewModel 31 | 32 | override fun onCreateView( 33 | inflater: LayoutInflater, container: ViewGroup?, 34 | savedInstanceState: Bundle? 35 | ): View? { 36 | return inflater.inflate(R.layout.login_fragment, container, false) 37 | 38 | 39 | } 40 | 41 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 42 | super.onViewCreated(view, savedInstanceState) 43 | 44 | tvNoAccount = view.findViewById(R.id.tvNoAccount) 45 | edEmailId = view.findViewById(R.id.edEmailId) 46 | edPassword = view.findViewById(R.id.edPassword) 47 | signInBtn = view.findViewById(R.id.signInBtn) 48 | 49 | 50 | } 51 | 52 | 53 | override fun onActivityCreated(savedInstanceState: Bundle?) { 54 | super.onActivityCreated(savedInstanceState) 55 | viewModel = ViewModelProvider(this).get(LoginViewModel::class.java) 56 | 57 | signInBtn.setOnClickListener { 58 | viewModel.userLoginRequest( 59 | edEmailId.text.toString().trim(), 60 | edPassword.text.toString().trim() 61 | ) 62 | } 63 | 64 | viewModel.userInfo.observe({lifecycle}){ 65 | when(it){ 66 | is User ->{ 67 | Toast.makeText(requireContext(),"Logged in",Toast.LENGTH_LONG).show() 68 | UserSharedpreferences(requireContext()).token=it.token 69 | val intent =Intent(activity,AppHomeActivity::class.java) 70 | startActivity(intent) 71 | activity?.finish() 72 | 73 | } 74 | else ->{ 75 | Toast.makeText(requireContext(),"Login request is fail",Toast.LENGTH_LONG).show() 76 | 77 | } 78 | } 79 | } 80 | 81 | 82 | } 83 | 84 | 85 | 86 | 87 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/auth/LoginViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.auth 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.example.api.model.entity.User 8 | import com.example.blogoapp.data.UserAuthRepo 9 | import com.example.blogoapp.data.UserSharedpreferences 10 | import kotlinx.coroutines.launch 11 | 12 | class LoginViewModel : ViewModel() { 13 | private val _userInfo=MutableLiveData() 14 | val userInfo:LiveData = _userInfo 15 | fun userLoginRequest(email: String, password:String){ 16 | viewModelScope.launch{ 17 | UserAuthRepo.userLogin(email,password)?.let { 18 | _userInfo.postValue(it) 19 | 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/auth/SignupFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.auth 2 | 3 | import android.os.Bundle 4 | import androidx.fragment.app.Fragment 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.Button 9 | import android.widget.EditText 10 | import android.widget.TextView 11 | import androidx.fragment.app.activityViewModels 12 | import androidx.navigation.fragment.findNavController 13 | import com.example.api.model.entity.UserCred 14 | import com.example.api.model.requests.UserRequests 15 | import com.example.blogoapp.R 16 | 17 | class SignupFragment : Fragment() { 18 | 19 | private lateinit var edUserName:EditText 20 | private lateinit var edEmailId:EditText 21 | private lateinit var edPassword:EditText 22 | private lateinit var signupBtn:Button 23 | private lateinit var tvAlreadyAccount:TextView 24 | companion object { 25 | fun newInstance() = SignupFragment() 26 | } 27 | val viewModel: SignupViewModel by activityViewModels() 28 | 29 | override fun onCreateView( 30 | inflater: LayoutInflater, container: ViewGroup?, 31 | savedInstanceState: Bundle? 32 | ): View? { 33 | val root=inflater.inflate(R.layout.signup_fragment, container, false) 34 | 35 | return root 36 | } 37 | 38 | override fun onViewCreated(root: View, savedInstanceState: Bundle?) { 39 | super.onViewCreated(root, savedInstanceState) 40 | edEmailId=root.findViewById(R.id.edEmailId) 41 | edPassword=root.findViewById(R.id.edPassword) 42 | edUserName=root.findViewById(R.id.edUserName) 43 | signupBtn=root.findViewById(R.id.signUpBtn) 44 | tvAlreadyAccount=root.findViewById(R.id.tvAlreadyAccount) 45 | } 46 | 47 | override fun onActivityCreated(savedInstanceState: Bundle?) { 48 | super.onActivityCreated(savedInstanceState) 49 | 50 | signupBtn.setOnClickListener { 51 | if (validationCheck()) { 52 | viewModel.addUser( 53 | UserRequests( 54 | UserCred( 55 | email = edEmailId.text.toString(), 56 | password = edPassword.text.toString(), 57 | username = edUserName.text.toString() 58 | ) 59 | ) 60 | ) 61 | } 62 | 63 | } 64 | tvAlreadyAccount.setOnClickListener { 65 | findNavController().navigate(R.id.gotoLoginFragment) 66 | // val tab=AuthenticationActivity().tabLayout.getTabAt(0) 67 | // tab?.select() 68 | } 69 | 70 | // viewModel.userResponse?.observe({lifecycle}){ 71 | // 72 | // when(it){ 73 | // is User->{ 74 | // Toast.makeText(context, "User ${it}", Toast.LENGTH_LONG).show() 75 | // Toast.makeText(context, "User ${it}", Toast.LENGTH_LONG).show() 76 | //// val intent= Intent(activity,AppHomeActivity::class.java) 77 | //// startActivity(intent) 78 | //// activity?.finish() 79 | // findNavController().navigate(R.id.gotoLoginFragment) 80 | // 81 | // } 82 | // else->{ 83 | // Toast.makeText(context, "User ${it}", Toast.LENGTH_LONG).show() 84 | // } 85 | // } 86 | // 87 | // 88 | // } 89 | 90 | 91 | } 92 | 93 | fun validationCheck():Boolean{ 94 | if (edEmailId.text.isEmpty()) 95 | return false; 96 | else if (edPassword.text.isEmpty()) 97 | return false; 98 | else if (edUserName.text.isEmpty()) 99 | return false; 100 | else 101 | return true 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/auth/SignupViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.auth 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.example.api.model.entity.User 8 | import com.example.api.model.requests.UserRequests 9 | import com.example.blogoapp.data.UserAuthRepo 10 | import kotlinx.coroutines.launch 11 | 12 | class SignupViewModel : ViewModel() { 13 | private val _userResponse=MutableLiveData() 14 | val userResponse:LiveData? =_userResponse 15 | 16 | fun addUser(userRequests: UserRequests){ 17 | viewModelScope.launch { 18 | val user: Unit =UserAuthRepo.userSignup(userRequests).let { 19 | _userResponse.postValue(it) 20 | 21 | 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/bottomsheet/PostArticleBS.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.bottomsheet 2 | 3 | import androidx.lifecycle.ViewModelProvider 4 | import android.os.Bundle 5 | import androidx.fragment.app.Fragment 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import android.widget.Button 10 | import android.widget.EditText 11 | import android.widget.Toast 12 | import androidx.navigation.fragment.findNavController 13 | import com.example.api.ConduitClient 14 | import com.example.api.model.response.ArticleResponse 15 | import com.example.blogoapp.R 16 | import com.example.blogoapp.data.UserSharedpreferences 17 | import com.example.blogoapp.ui.article.ArticleViewModel 18 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 19 | import com.google.android.material.floatingactionbutton.FloatingActionButton 20 | 21 | class PostArticleBS : BottomSheetDialogFragment() { 22 | companion object { 23 | fun newInstance() = PostArticleBS() 24 | } 25 | 26 | private lateinit var updateBtn:Button 27 | private lateinit var edTitle:EditText 28 | private lateinit var edShortDescription:EditText 29 | private lateinit var edArticleId:EditText 30 | private lateinit var viewModel: ArticleViewModel 31 | 32 | override fun onCreateView( 33 | inflater: LayoutInflater, container: ViewGroup?, 34 | savedInstanceState: Bundle? 35 | ): View? { 36 | return inflater.inflate(R.layout.post_article_b_fragment, container, false) 37 | } 38 | 39 | override fun onCreate(savedInstanceState: Bundle?) { 40 | super.onCreate(savedInstanceState) 41 | setStyle(BottomSheetDialogFragment.STYLE_NORMAL, R.style.MyBottomSheetDialogTheme) 42 | } 43 | 44 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 45 | super.onViewCreated(view, savedInstanceState) 46 | updateBtn=view.findViewById(R.id.updateBtn) 47 | edTitle=view.findViewById(R.id.edTitle) 48 | edShortDescription=view.findViewById(R.id.edShortDescription) 49 | edArticleId=view.findViewById(R.id.edArticleId) 50 | updateBtn.background=resources.getDrawable(R.drawable.green_circuler_background) 51 | ConduitClient.authToken=UserSharedpreferences(requireContext()).token 52 | } 53 | override fun onActivityCreated(savedInstanceState: Bundle?) { 54 | super.onActivityCreated(savedInstanceState) 55 | viewModel = ViewModelProvider(requireActivity()).get(ArticleViewModel::class.java) 56 | 57 | updateBtn.setOnClickListener { 58 | if (checkValidation()){ 59 | viewModel.PostArticles( 60 | body =edArticleId.text.toString(), 61 | title = edTitle.text.toString(), 62 | description = edShortDescription.text.toString(), 63 | tagList = listOf("BlogoApp") 64 | ).let { 65 | Toast.makeText(requireContext(),"Please Wait...",Toast.LENGTH_LONG).show() 66 | 67 | } 68 | } 69 | } 70 | 71 | viewModel.articleResponse.observe({lifecycle}){ 72 | when(it){ 73 | is ArticleResponse->{ 74 | Toast.makeText(requireContext(),"Article is successful",Toast.LENGTH_LONG).show() 75 | viewModel.fetchGlobaleFeedArticle() 76 | dismiss() 77 | } 78 | else->{ 79 | Toast.makeText(requireContext(),"Sorry Some Technical Issue",Toast.LENGTH_LONG).show() 80 | dismiss() 81 | } 82 | } 83 | } 84 | } 85 | 86 | fun checkValidation():Boolean{ 87 | if (edTitle.text.isEmpty()) 88 | return false 89 | else if (edShortDescription.text.isEmpty()) 90 | return false 91 | else return !edArticleId.text.isEmpty() 92 | } 93 | 94 | 95 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/bottomsheet/UpdateUserInfo.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.bottomsheet 2 | 3 | import android.app.Dialog 4 | import android.graphics.Color 5 | import android.graphics.drawable.ColorDrawable 6 | import androidx.lifecycle.ViewModelProvider 7 | import android.os.Bundle 8 | import androidx.fragment.app.Fragment 9 | import android.view.LayoutInflater 10 | import android.view.View 11 | import android.view.ViewGroup 12 | import android.view.Window 13 | import android.widget.Button 14 | import android.widget.EditText 15 | import android.widget.TextView 16 | import android.widget.Toast 17 | import androidx.core.content.ContextCompat 18 | import androidx.navigation.fragment.findNavController 19 | import com.example.api.ConduitClient 20 | import com.example.api.model.response.ArticleResponse 21 | import com.example.api.model.response.UserResponse 22 | import com.example.blogoapp.R 23 | import com.example.blogoapp.data.UserSharedpreferences 24 | import com.example.blogoapp.ui.profile.ProfileViewModel 25 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 26 | import com.google.android.material.floatingactionbutton.FloatingActionButton 27 | 28 | class UpdateUserInfo : BottomSheetDialogFragment() { 29 | companion object { 30 | fun newInstance() = PostArticleBS() 31 | } 32 | private lateinit var edUserName:EditText 33 | private lateinit var edEmailId:EditText 34 | private lateinit var edBioId:EditText 35 | private lateinit var edImageId:EditText 36 | private lateinit var edPassword:EditText 37 | private lateinit var updateBtn:Button 38 | private lateinit var viewModel: ProfileViewModel 39 | 40 | override fun onCreateView( 41 | inflater: LayoutInflater, container: ViewGroup?, 42 | savedInstanceState: Bundle? 43 | ): View? { 44 | return inflater.inflate(R.layout.fragment_update_user_info, container, false) 45 | } 46 | 47 | override fun onCreate(savedInstanceState: Bundle?) { 48 | super.onCreate(savedInstanceState) 49 | setStyle(BottomSheetDialogFragment.STYLE_NORMAL, R.style.MyBottomSheetDialogTheme) 50 | } 51 | 52 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 53 | super.onViewCreated(view, savedInstanceState) 54 | updateBtn=view.findViewById(R.id.updateBtn) 55 | edUserName=view.findViewById(R.id.edUserName) 56 | edEmailId=view.findViewById(R.id.edEmailId) 57 | edBioId=view.findViewById(R.id.edBioId) 58 | edImageId=view.findViewById(R.id.edImageId) 59 | edPassword=view.findViewById(R.id.edPassword) 60 | updateBtn.background=resources.getDrawable(R.drawable.green_circuler_background) 61 | ConduitClient.authToken=UserSharedpreferences(requireContext()).token 62 | 63 | } 64 | override fun onActivityCreated(savedInstanceState: Bundle?) { 65 | super.onActivityCreated(savedInstanceState) 66 | viewModel = ViewModelProvider(this).get(ProfileViewModel::class.java) 67 | viewModel.getCurrentUserInfo() 68 | 69 | 70 | val progressDialog = Dialog(requireContext()) 71 | progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) 72 | progressDialog.setContentView(R.layout.custom_dialog_progress) 73 | 74 | /* Custom setting to change TextView text,Color and Text Size according to your Preference*/ 75 | 76 | val progressTv = progressDialog.findViewById(R.id.progress_tv) as TextView 77 | progressTv.text = resources.getString(R.string.loading) 78 | progressTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) 79 | progressTv.textSize = 19F 80 | 81 | progressDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 82 | progressDialog.setCancelable(false) 83 | progressDialog.show() 84 | 85 | 86 | 87 | 88 | viewModel.userRes.observe({lifecycle}){ 89 | when(it){ 90 | is UserResponse->{ 91 | edBioId.setText(it.user.bio ?:" ") 92 | edUserName.setText(it.user.username ?: " ") 93 | edEmailId.setText(it.user.email ?:" ") 94 | edImageId.setText(it.user.image ?: " ") 95 | progressDialog.dismiss() 96 | } 97 | else->{ 98 | Toast.makeText(requireContext(),"Error in server", Toast.LENGTH_LONG).show() 99 | progressDialog.dismiss() 100 | } 101 | } 102 | } 103 | updateBtn.setOnClickListener { 104 | if (checkValidation()){ 105 | viewModel.PostArticles( 106 | bio = edBioId.text.takeIf { it.isNotBlank() }.toString(), 107 | userName = edUserName.text.takeIf { it.isNotBlank() }.toString(), 108 | image = edImageId.text.toString(), 109 | email = edEmailId.text.takeIf { it.isNotBlank() }.toString(), 110 | password = edPassword.text.takeIf { it.isNotBlank() }.toString() 111 | ).let { 112 | Toast.makeText(requireContext(),"Please Wait...", Toast.LENGTH_LONG).show() 113 | 114 | } 115 | } 116 | } 117 | 118 | viewModel.userResponse.observe({lifecycle}){ 119 | when(it){ 120 | is UserResponse ->{ 121 | Toast.makeText(requireContext(),"Article is successful", Toast.LENGTH_LONG).show() 122 | viewModel.getCurrentUserInfo() 123 | dismiss() 124 | } 125 | else->{ 126 | Toast.makeText(requireContext(),"Sorry Some Technical Issue", Toast.LENGTH_LONG).show() 127 | dismiss() 128 | } 129 | } 130 | } 131 | } 132 | 133 | fun checkValidation():Boolean{ 134 | if (edUserName.text.isEmpty()) 135 | return false 136 | else if (edEmailId.text.isEmpty()) 137 | return false 138 | else return !edPassword.text.isEmpty() 139 | } 140 | 141 | 142 | } 143 | 144 | 145 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/personalfeed/PersonalFeedFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.personalfeed 2 | 3 | import android.app.Dialog 4 | import android.graphics.Color 5 | import android.graphics.drawable.ColorDrawable 6 | import android.os.Bundle 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.view.Window 11 | import android.widget.TextView 12 | import androidx.core.content.ContextCompat 13 | import androidx.fragment.app.Fragment 14 | import androidx.lifecycle.Observer 15 | import androidx.lifecycle.ViewModelProvider 16 | import androidx.navigation.fragment.findNavController 17 | import androidx.recyclerview.widget.LinearLayoutManager 18 | import androidx.recyclerview.widget.RecyclerView 19 | import com.example.api.ConduitClient 20 | import com.example.blogoapp.R 21 | import com.example.blogoapp.adopter.GlobleFeedAdopter 22 | import com.example.blogoapp.data.UserSharedpreferences 23 | import com.example.blogoapp.ui.article.ArticleViewModel 24 | import com.google.android.material.floatingactionbutton.FloatingActionButton 25 | 26 | class PersonalFeedFragment : Fragment() { 27 | private lateinit var feedRecyclerView: RecyclerView 28 | private lateinit var fab: FloatingActionButton 29 | private lateinit var globleFeedAdopter: GlobleFeedAdopter 30 | 31 | private lateinit var personalFeedViewModel: PersonalFeedViewModel 32 | 33 | override fun onCreateView( 34 | inflater: LayoutInflater, 35 | container: ViewGroup?, 36 | savedInstanceState: Bundle? 37 | ): View? { 38 | personalFeedViewModel = 39 | ViewModelProvider(this).get(PersonalFeedViewModel::class.java) 40 | val root = inflater.inflate(R.layout.fragment_personalfeed, container, false) 41 | feedRecyclerView = root.findViewById(R.id.feedRecylerView) 42 | fab = root.findViewById(R.id.fab) 43 | 44 | globleFeedAdopter=GlobleFeedAdopter() 45 | feedRecyclerView.layoutManager= LinearLayoutManager(context) 46 | feedRecyclerView.adapter=globleFeedAdopter 47 | return root 48 | } 49 | 50 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 51 | super.onViewCreated(view, savedInstanceState) 52 | 53 | 54 | val progressDialog = Dialog(requireContext()) 55 | progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) 56 | progressDialog.setContentView(R.layout.custom_dialog_progress) 57 | 58 | /* Custom setting to change TextView text,Color and Text Size according to your Preference*/ 59 | 60 | val progressTv = progressDialog.findViewById(R.id.progress_tv) as TextView 61 | progressTv.text = resources.getString(R.string.loading) 62 | progressTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) 63 | progressTv.textSize = 19F 64 | 65 | progressDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 66 | progressDialog.setCancelable(false) 67 | progressDialog.show() 68 | 69 | 70 | 71 | fab.setOnClickListener { 72 | findNavController().navigate(R.id.postArticleBS) 73 | } 74 | 75 | 76 | 77 | ConduitClient.authToken= UserSharedpreferences(requireContext()).token 78 | personalFeedViewModel.personalFeed() 79 | personalFeedViewModel.articleResponse.observe({ lifecycle }) { 80 | globleFeedAdopter.submitList(it).let { 81 | progressDialog.dismiss() 82 | } 83 | } 84 | } 85 | 86 | override fun onActivityCreated(savedInstanceState: Bundle?) { 87 | super.onActivityCreated(savedInstanceState) 88 | } 89 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/personalfeed/PersonalFeedViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.personalfeed 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.MutableLiveData 7 | import androidx.lifecycle.ViewModel 8 | import androidx.lifecycle.viewModelScope 9 | import com.example.api.ConduitClient 10 | import com.example.api.model.entity.Article 11 | import com.example.api.model.response.ArticleResponse 12 | import com.example.api.model.response.ArticlesResponse 13 | import com.example.blogoapp.data.UserAuthRepo 14 | import com.example.blogoapp.data.UserSharedpreferences 15 | import kotlinx.coroutines.launch 16 | 17 | class PersonalFeedViewModel : ViewModel() { 18 | 19 | private val _articleResponse = MutableLiveData>() 20 | val articleResponse: LiveData> = _articleResponse 21 | 22 | fun personalFeed(){ 23 | viewModelScope.launch { 24 | UserAuthRepo.feedArticle().let { 25 | _articleResponse.postValue(it?.articles) 26 | } 27 | } 28 | } 29 | 30 | 31 | 32 | 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/profile/ProfileFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.profile 2 | 3 | import android.app.Dialog 4 | import android.graphics.Color 5 | import android.graphics.drawable.ColorDrawable 6 | import android.os.Bundle 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.view.Window 11 | import android.widget.ImageView 12 | import android.widget.TextView 13 | import androidx.core.content.ContextCompat 14 | import androidx.fragment.app.Fragment 15 | import androidx.lifecycle.Observer 16 | import androidx.lifecycle.ViewModelProvider 17 | import androidx.navigation.fragment.findNavController 18 | import com.bumptech.glide.Glide 19 | import com.example.api.ConduitClient 20 | import com.example.blogoapp.R 21 | import com.example.blogoapp.data.UserSharedpreferences 22 | import com.google.android.material.floatingactionbutton.FloatingActionButton 23 | 24 | class ProfileFragment : Fragment() { 25 | 26 | private lateinit var profileViewModel: ProfileViewModel 27 | private lateinit var fab:FloatingActionButton 28 | private lateinit var userName:TextView 29 | private lateinit var editBtn:ImageView 30 | private lateinit var userBio:TextView 31 | private lateinit var profileUserName:TextView 32 | private lateinit var tvbio:TextView 33 | private lateinit var emailId:TextView 34 | private lateinit var profileImage:ImageView 35 | override fun onCreateView( 36 | inflater: LayoutInflater, 37 | container: ViewGroup?, 38 | savedInstanceState: Bundle? 39 | ): View? { 40 | profileViewModel = 41 | ViewModelProvider(this).get(ProfileViewModel::class.java) 42 | val root = inflater.inflate(R.layout.fragment_profile, container, false) 43 | 44 | return root 45 | } 46 | 47 | 48 | 49 | 50 | 51 | 52 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 53 | super.onViewCreated(view, savedInstanceState) 54 | fab=view.findViewById(R.id.fab) 55 | userName=view.findViewById(R.id.userName) 56 | editBtn=view.findViewById(R.id.editBtn) 57 | userBio=view.findViewById(R.id.userBio) 58 | profileUserName=view.findViewById(R.id.profileUserName) 59 | tvbio=view.findViewById(R.id.tvbio) 60 | emailId=view.findViewById(R.id.emailId) 61 | profileImage=view.findViewById(R.id.profileImage) 62 | ConduitClient.authToken=UserSharedpreferences(requireContext()).token 63 | 64 | } 65 | override fun onActivityCreated(savedInstanceState: Bundle?) { 66 | super.onActivityCreated(savedInstanceState) 67 | 68 | 69 | 70 | val progressDialog = Dialog(requireContext()) 71 | progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) 72 | progressDialog.setContentView(R.layout.custom_dialog_progress) 73 | 74 | /* Custom setting to change TextView text,Color and Text Size according to your Preference*/ 75 | 76 | val progressTv = progressDialog.findViewById(R.id.progress_tv) as TextView 77 | progressTv.text = resources.getString(R.string.loading) 78 | progressTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) 79 | progressTv.textSize = 19F 80 | 81 | progressDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 82 | progressDialog.setCancelable(false) 83 | progressDialog.show() 84 | 85 | 86 | 87 | fab.setOnClickListener { 88 | findNavController().navigate(R.id.updateUserInfo) 89 | } 90 | editBtn.setOnClickListener { 91 | findNavController().navigate(R.id.updateUserInfo) 92 | } 93 | profileViewModel.getCurrentUserInfo() 94 | profileViewModel.userRes.observe({lifecycle}){ 95 | progressDialog.dismiss() 96 | userName.text=it.user.username 97 | profileUserName.text=it.user.username 98 | userBio.text=it.user.bio 99 | tvbio.text=it.user.bio 100 | emailId.text=it.user.email 101 | if(!it.user.image?.isEmpty()!!){ 102 | Glide.with(this).load(it.user.image).circleCrop().into(profileImage) 103 | } 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/blogoapp/ui/profile/ProfileViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.blogoapp.ui.profile 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import androidx.lifecycle.viewModelScope 7 | import com.example.api.ConduitClient 8 | import com.example.api.model.entity.ArticleRequestEntity 9 | import com.example.api.model.entity.UpdateUserProfileEntity 10 | import com.example.api.model.requests.CreateArticleRequest 11 | import com.example.api.model.requests.UpdateProfileRequest 12 | import com.example.api.model.response.ArticleResponse 13 | import com.example.api.model.response.ProfileResponse 14 | import com.example.api.model.response.UserResponse 15 | import com.example.blogoapp.data.UserAuthRepo 16 | import kotlinx.coroutines.launch 17 | 18 | class ProfileViewModel : ViewModel() { 19 | 20 | 21 | private val _userResponse=MutableLiveData() 22 | val userResponse: LiveData =_userResponse 23 | private val _profileResponse=MutableLiveData() 24 | val profileResponse: LiveData =_profileResponse 25 | private val _userRes=MutableLiveData() 26 | val userRes: LiveData =_userRes 27 | 28 | fun PostArticles(userName: String,email: String,bio:String,image:String,password:String){ 29 | viewModelScope.launch { 30 | val updateProfileRequest= UpdateProfileRequest( 31 | UpdateUserProfileEntity( 32 | username = userName, 33 | email = email, 34 | bio = bio, 35 | image = image, 36 | password = password, 37 | 38 | ) 39 | ) 40 | ConduitClient.authApi.updateProfile(updateProfileRequest).let { 41 | _userResponse.postValue(it.body()) 42 | } 43 | } 44 | } 45 | 46 | fun getProfileInfo(userName:String){ 47 | viewModelScope.launch { 48 | UserAuthRepo.getUserProfile(userName).let { 49 | _profileResponse.postValue(it.body()) 50 | } 51 | } 52 | } 53 | 54 | fun getCurrentUserInfo(){ 55 | viewModelScope.launch { 56 | UserAuthRepo.getCurrentUser().let { 57 | _userRes.postValue(it.body()) 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/item_animation_fall_down.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 15 | 16 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/anim/layout_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/bottom_sheet_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/bottom_sheet_view_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/drawable/app_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/article_list_item_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/green_circuler_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_add.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dashboard_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_edit_icon.xml: -------------------------------------------------------------------------------- 1 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_login.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_article.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 33 | 36 | 39 | 42 | 45 | 48 | 51 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_personalfeed.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_profile.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_profile_img.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_signup.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/profile_sublayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/profileimg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/drawable/profileimg.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/font/product_sans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/font/product_sans_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/font/product_sans_bold.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/product_sans_bold_italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/font/product_sans_bold_italic.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/product_sans_italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/font/product_sans_italic.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/product_sans_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/font/product_sans_regular.ttf -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_authentication.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 22 | 23 | 24 | 29 | 30 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_article.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 23 | 24 | 25 | 26 | 27 | 28 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_personalfeed.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_profile.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 20 | 21 | 33 | 34 | 35 | 52 | 53 | 62 | 63 | 80 | 81 | 82 | 83 | 91 | 92 | 93 | 94 | 95 | 104 | 105 | 121 | 122 | 123 | 138 | 139 | 140 | 141 | 150 | 151 | 167 | 168 | 169 | 184 | 185 | 186 | 187 | 188 | 197 | 198 | 214 | 215 | 216 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 254 | 255 | 256 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_update_user_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 15 | 16 | 22 | 23 | 32 | 33 | 45 | 46 | 58 | 59 | 72 | 73 | 85 | 86 | 87 | 98 | 99 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /app/src/main/res/layout/globle_feed_list_item_article.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 20 | 25 | 31 | 32 | 33 | 34 | 40 | 49 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 79 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/login_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 22 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 22 | 23 | 30 | 31 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/post_article_b_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 15 | 16 | 22 | 23 | 32 | 33 | 45 | 46 | 58 | 59 | 72 | 73 | 74 | 75 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/signup_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 23 | 24 | 25 | 36 | 37 | 50 | 51 | 64 | 65 | 77 | 78 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/menu/app_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marvel999/Conduit-Android-kotlin/3709e521a897317d8cd90d1e89745aeeee2d9722/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/navigation/mobile_navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 16 | 23 | 24 | 29 | 30 | 35 | 40 | 45 | 46 | 47 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/navigation/navigation_auth.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 18 | 19 | 25 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-v28/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #5CB85C 4 | #818a91 5 | #595E61 6 | #347834 7 | #bbb 8 | #F8F8F8 9 | #000000 10 | #365CB85C 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 176dp 7 | 16dp 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:drawable/ic_menu_camera 3 | @android:drawable/ic_menu_gallery 4 | @android:drawable/ic_menu_slideshow 5 | @android:drawable/ic_menu_manage 6 | @android:drawable/ic_menu_share 7 | @android:drawable/ic_menu_send 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ConduIt App 3 | AppHomeActivity 4 | Open navigation drawer 5 | Close navigation drawer 6 | Android Studio 7 | android.studio@android.com 8 | Navigation header 9 | 10 | 11 | Login/Logout 12 | 13 | Article 14 | Personal Article 15 | Profile 16 | Need an account? 17 | Have an account? 18 | 19 | Hello blank fragment 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 22 | 23 | 29 | 30 | 31 | 35 | 40 | 41 |