Skip to content

Commit

Permalink
Merge pull request #35 from umbum/develop
Browse files Browse the repository at this point in the history
release 1.0.1
  • Loading branch information
umbum authored Aug 22, 2019
2 parents 6d82993 + 509f65a commit dc6e96c
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 63 deletions.
15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.tistory.umbum.github_issue_widget_app"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionName '1.0.1' // X.Y.Z; X = Major, Y = minor, Z = Patch level
versionCode 2
buildConfigString "CLIENT_SECRET", (buildProperties.secrets['github_client_secret'] | buildProperties.notThere['github_client_secret']).string
buildConfigString "CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string
buildConfigString "REDIRECT_URI", (buildProperties.secrets['redirect_uri'] | buildProperties.notThere['redirect_uri']).string
Expand Down Expand Up @@ -53,7 +53,7 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
Expand All @@ -66,10 +66,9 @@ dependencies {
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.android.support:customtabs:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
kapt "com.android.databinding:compiler:$android_plugin_version"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxjava:2.2.10"
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ import retrofit2.Response

class AccessTokenRepository(private val context: Context) {
var accessToken: String?
get() = context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)
.getString("accessToken", null)
set(accessToken) {
accessToken ?: throw NullPointerException()
get() = sharedPref.getString("accessToken", null)
set(accessToken) = sharedPref.edit().putString("accessToken", accessToken).apply()

context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)
.edit()
.putString("accessToken", accessToken)
.apply()
}
private val sharedPref = context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)

fun updateAccessToken(code: String): LiveData<String?> {
val accessTokenLiveData = MutableLiveData<String?>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ import android.util.Log
import com.tistory.umbum.github_issue_widget_app.ALL_ISSUES_TEXT

class UserSelectedRepository(private val context: Context) {
val TAG = this::class.java.simpleName
val keyPrefix = "selected_repo_for_id"
private val TAG = this::class.java.simpleName
private val keyPrefix = "selected_repo_for_id"
private val sharedPref = context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)

fun getSelectedRepoPath(id: Int) : String = context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)
fun getSelectedRepoPath(id: Int) : String = sharedPref
.getString("${keyPrefix}${id}", ALL_ISSUES_TEXT)!!

fun setSelectedRepoPath(id: Int, repoPath: String) {
context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)
.edit()
sharedPref.edit()
.putString("${keyPrefix}${id}", repoPath)
.apply()
Log.d(TAG, "[save] ${keyPrefix}${id} : ${repoPath}")
}

fun removeSelectedRepoPath(id: Int) {
context.applicationContext
.getSharedPreferences("SETTINGS", Context.MODE_PRIVATE)
.edit()
sharedPref.edit()
.remove("${keyPrefix}${id}")
.apply()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.tistory.umbum.github_issue_widget_app.data.model

data class AccessTokenResponse(val accessToken: String,
val tokenType: String,
val scope: String)
import com.google.gson.annotations.SerializedName

data class AccessTokenResponse(@SerializedName("access_token") val accessToken: String,
@SerializedName("token_type") val tokenType: String,
@SerializedName("scope") val scope: String)
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.tistory.umbum.github_issue_widget_app.data.model

data class IssueItem(val id: Int,
val title: String,
val htmlUrl: String,
val labels: List<LabelItem>,
val repository: RepoItem
)
import com.google.gson.annotations.SerializedName

data class LabelItem(val name: String,
val color: String)
data class IssueItem(@SerializedName("id") val id: Int,
@SerializedName("title") val title: String,
@SerializedName("html_url") val htmlUrl: String,
@SerializedName("labels") val labels: List<LabelItem>,
@SerializedName("repository") val repository: RepoItem)

data class RepoItem(val id: Int,
val name: String,
val fullName: String,
val private: Boolean,
val openIssuesCount: Int)
data class LabelItem(@SerializedName("name") val name: String,
@SerializedName("color") val color: String)

data class RepoItem(@SerializedName("id") val id: Int,
@SerializedName("name") val name: String,
@SerializedName("full_name") val fullName: String,
@SerializedName("private") val private: Boolean,
@SerializedName("open_issues_count") val openIssuesCount: Int)
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.tistory.umbum.github_issue_widget_app.data.remote.api

import com.google.gson.FieldNamingPolicy
import com.google.gson.GsonBuilder
import com.google.gson.JsonArray
import com.tistory.umbum.github_issue_widget_app.data.model.IssueItem
import com.tistory.umbum.github_issue_widget_app.data.model.RepoItem
Expand All @@ -15,12 +13,9 @@ import retrofit2.http.Path
const val GITHUB_API_URL = "https://api.github.com/"

object GithubApiClient {
private val gson = GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()
val client = Retrofit.Builder()
.baseUrl(GITHUB_API_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(Service::class.java)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.tistory.umbum.github_issue_widget_app.data.remote.api

import com.google.gson.FieldNamingPolicy
import com.google.gson.GsonBuilder
import com.tistory.umbum.github_issue_widget_app.data.model.AccessTokenResponse
import retrofit2.Call
import retrofit2.Retrofit
Expand All @@ -15,12 +13,9 @@ import retrofit2.http.POST
const val GITHUB_URL = "https://github.com/"

object GithubClient {
private val gson = GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()
val client = Retrofit.Builder()
.baseUrl(GITHUB_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(Service::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import android.view.View
import android.view.ViewGroup
import com.tistory.umbum.github_issue_widget_app.R
import com.tistory.umbum.github_issue_widget_app.data.local.preferences.UserSelectedRepository
import com.tistory.umbum.github_issue_widget_app.databinding.RepoItemBinding
import com.tistory.umbum.github_issue_widget_app.data.model.RepoItem
import com.tistory.umbum.github_issue_widget_app.databinding.RepoItemBinding
import com.tistory.umbum.github_issue_widget_app.ui.widget.IssueWidget


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.tistory.umbum.github_issue_widget_app.ALL_ISSUES_TEXT
import com.tistory.umbum.github_issue_widget_app.R
import com.tistory.umbum.github_issue_widget_app.data.local.preferences.AccessTokenRepository
import com.tistory.umbum.github_issue_widget_app.data.local.preferences.UserSelectedRepository
import com.tistory.umbum.github_issue_widget_app.data.remote.api.GithubApiClient
import com.tistory.umbum.github_issue_widget_app.data.model.IssueItem
import com.tistory.umbum.github_issue_widget_app.data.remote.api.GithubApiClient
import retrofit2.Call


Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.40'
ext.kotlin_version = '1.3.41'
ext.retrofit_version = '2.5.0'
ext.android_plugin_version = '3.1.0'
ext.android_gradle_plugin_version = '3.5.0'
ext.lifecycle_version = '1.1.1'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "com.android.tools.build:gradle:$android_gradle_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.novoda:gradle-build-properties-plugin:0.4.1'

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 comments on commit dc6e96c

Please sign in to comment.