Skip to content

Commit 2ea9853

Browse files
committed
Merge branch 'wip' into develop
2 parents 68e62c8 + 4f122f2 commit 2ea9853

66 files changed

Lines changed: 1164 additions & 503 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/captures/
88
.externalNativeBuild
99
/gradle/
10+
*.apk

app/build.gradle

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ androidExtensions {
99

1010
android {
1111
compileSdkVersion 26
12-
buildToolsVersion "26.0.1"
12+
buildToolsVersion "26.0.2"
1313
defaultConfig {
1414
applicationId "jp.co.seesaa.geckour.picrossmaker"
1515
minSdkVersion 21
@@ -37,54 +37,73 @@ android {
3737
configurations.all {
3838
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
3939
}
40+
41+
lintOptions {
42+
disable 'ClickableViewAccessibility'
43+
}
4044
}
4145

4246
dependencies {
43-
def android_support_version = '26.0.0-alpha1'
44-
def orma_version = '4.2.3'
47+
def android_support_version = '26.1.0'
48+
def stetho_version = '1.5.0'
49+
def orma_version = '4.2.5'
4550
def rxLifecycle_version = '2.0.1'
46-
def coroutines_version = '0.13'
51+
def coroutines_version = '0.19.3'
52+
def retrofit_version = '2.3.0'
53+
def okhttp_version = '3.8.0'
4754

48-
compile fileTree(dir: 'libs', include: ['*.jar'])
55+
implementation fileTree(dir: 'libs', include: ['*.jar'])
4956
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
5057
exclude group: 'com.android.support', module: 'support-annotations'
5158
})
52-
testCompile 'junit:junit:4.12'
53-
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
59+
testImplementation 'junit:junit:4.12'
60+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
61+
62+
kapt 'com.android.databinding:compiler:3.0.1'
5463

55-
kapt 'com.android.databinding:compiler:2.3.1'
64+
implementation "com.android.support:appcompat-v7:$android_support_version"
65+
implementation "com.android.support:support-v4:$android_support_version"
66+
implementation "com.android.support:design:$android_support_version"
67+
implementation "com.android.support:recyclerview-v7:$android_support_version"
68+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
5669

57-
compile "com.android.support:appcompat-v7:$android_support_version"
58-
compile "com.android.support:support-v4:$android_support_version"
59-
compile "com.android.support:design:$android_support_version"
60-
compile "com.android.support:recyclerview-v7:$android_support_version"
61-
compile 'com.android.support.constraint:constraint-layout:1.0.2'
70+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
71+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
6272

63-
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
64-
compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
73+
implementation "com.facebook.stetho:stetho:$stetho_version"
74+
implementation "com.facebook.stetho:stetho-okhttp3:$stetho_version"
6575

66-
compile 'io.reactivex.rxjava2:rxjava:2.0.8'
67-
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
68-
compile 'io.reactivex.rxjava2:rxkotlin:2.0.0'
69-
compile "com.trello.rxlifecycle2:rxlifecycle:$rxLifecycle_version"
70-
compile "com.trello.rxlifecycle2:rxlifecycle-components:$rxLifecycle_version"
71-
compile "com.trello.rxlifecycle2:rxlifecycle-kotlin:$rxLifecycle_version"
76+
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
77+
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
78+
implementation 'io.reactivex.rxjava2:rxkotlin:2.0.0'
79+
implementation "com.trello.rxlifecycle2:rxlifecycle:$rxLifecycle_version"
80+
implementation "com.trello.rxlifecycle2:rxlifecycle-components:$rxLifecycle_version"
81+
implementation "com.trello.rxlifecycle2:rxlifecycle-kotlin:$rxLifecycle_version"
7282

73-
compile 'com.squareup.retrofit2:converter-moshi:2.2.0'
74-
compile 'com.google.code.gson:gson:2.8.0'
83+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
84+
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
85+
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
86+
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
87+
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
7588

76-
compile 'com.jakewharton.timber:timber:4.5.1'
89+
implementation 'com.google.code.gson:gson:2.8.2'
7790

78-
compile 'com.github.yamamotoj:pikkel:0.3.3'
91+
implementation 'com.jakewharton.timber:timber:4.5.1'
7992

80-
compile group: 'org.ow2.sat4j', name: 'org.ow2.sat4j.core', version: '2.3.5'
93+
implementation 'com.github.yamamotoj:pikkel:0.3.3'
94+
95+
implementation group: 'org.ow2.sat4j', name: 'org.ow2.sat4j.core', version: '2.3.5'
8196

8297
kapt "com.github.gfx.android.orma:orma-processor:$orma_version"
83-
compile "com.github.gfx.android.orma:orma:$orma_version"
98+
implementation "com.github.gfx.android.orma:orma:$orma_version"
8499
}
85100

86101
repositories {
87102
mavenCentral()
88103
maven { url "https://jitpack.io" }
89104
maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" }
105+
maven {
106+
url 'https://maven.google.com/'
107+
name 'Google'
108+
}
90109
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="jp.co.seesaa.geckour.picrossmaker">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
46

57
<application
68
android:name=".App"
79
android:allowBackup="true"
810
android:icon="@mipmap/ic_launcher"
11+
android:roundIcon="@mipmap/ic_launcher_round"
912
android:label="@string/app_name"
1013
android:supportsRtl="false"
1114
android:theme="@style/AppTheme">

app/src/main/ic_launcher-web.png

45.5 KB
Loading
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
package jp.co.seesaa.geckour.picrossmaker
22

33
import android.app.Application
4+
import com.facebook.stetho.Stetho
45
import com.google.gson.Gson
56
import com.google.gson.GsonBuilder
67
import jp.co.seesaa.geckour.picrossmaker.model.OrmaProvider
7-
import kotlinx.coroutines.experimental.CommonPool
8-
import kotlinx.coroutines.experimental.CoroutineScope
9-
import kotlinx.coroutines.experimental.Job
10-
import kotlinx.coroutines.experimental.android.UI
11-
import kotlinx.coroutines.experimental.launch
12-
import kotlin.coroutines.experimental.CoroutineContext
8+
import jp.co.seesaa.geckour.picrossmaker.util.OkHttpProvider
9+
import timber.log.Timber
1310

1411
class App : Application() {
1512

1613
companion object {
17-
val gson: Gson = GsonBuilder().apply {}.create()
14+
val gson: Gson = GsonBuilder().apply {
15+
serializeNulls()
16+
setLenient()
17+
}.create()
1818
}
1919

2020
override fun onCreate() {
2121
super.onCreate()
2222

23+
if (BuildConfig.DEBUG) {
24+
Timber.plant(Timber.DebugTree())
25+
Stetho.initializeWithDefaults(this)
26+
}
27+
2328
OrmaProvider.init(this)
29+
OkHttpProvider.init()
2430
}
25-
}
26-
27-
fun <T> async(context: CoroutineContext = CommonPool, block: suspend CoroutineScope.() -> T) =
28-
kotlinx.coroutines.experimental.async(context, block = block)
29-
30-
fun ui(managerList: ArrayList<Job>, onError: (Throwable) -> Unit = {}, block: suspend CoroutineScope.() -> Unit) =
31-
launch(UI) {
32-
try {
33-
block()
34-
} catch (e: Exception) {
35-
e.printStackTrace()
36-
onError(e)
37-
}
38-
}.apply {
39-
managerList.add(this)
40-
}
31+
}

app/src/main/java/jp/co/seesaa/geckour/picrossmaker/activity/MainActivity.kt

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,45 @@ package jp.co.seesaa.geckour.picrossmaker.activity
33
import android.content.DialogInterface
44
import android.databinding.DataBindingUtil
55
import android.os.Bundle
6+
import android.support.design.widget.AppBarLayout
67
import android.support.design.widget.NavigationView
7-
import android.support.v4.view.GravityCompat
88
import android.util.Size
9+
import android.view.Gravity
10+
import android.view.LayoutInflater
911
import android.view.Menu
1012
import android.view.MenuItem
13+
import android.widget.Toolbar
1114
import com.trello.rxlifecycle2.components.RxActivity
1215
import jp.co.seesaa.geckour.picrossmaker.fragment.ProblemsFragment
1316
import jp.co.seesaa.geckour.picrossmaker.R
1417
import jp.co.seesaa.geckour.picrossmaker.databinding.ActivityMainBinding
1518
import jp.co.seesaa.geckour.picrossmaker.fragment.DraftProblemsFragment
1619
import jp.co.seesaa.geckour.picrossmaker.fragment.EditorFragment
20+
import jp.co.seesaa.geckour.picrossmaker.fragment.SearchFragment
1721
import jp.co.seesaa.geckour.picrossmaker.util.MyAlertDialogFragment
18-
import jp.co.seesaa.geckour.picrossmaker.util.MyAlertDialogFragment.Companion.showSnackbar
22+
import jp.co.seesaa.geckour.picrossmaker.util.ViewUtil.showSnackbar
1923

2024
class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListener, EditorFragment.IListener, MyAlertDialogFragment.IListener {
2125

2226
lateinit var binding: ActivityMainBinding
27+
lateinit var toolbar: Toolbar
28+
val layoutListenerForClear by lazy { { (toolbar.layoutParams as AppBarLayout.LayoutParams).scrollFlags = 0 } }
29+
val layoutListenerForSet by lazy { {
30+
(toolbar.layoutParams as AppBarLayout.LayoutParams).scrollFlags =
31+
AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
32+
} }
2333

2434
override fun onCreate(savedInstanceState: Bundle?) {
2535
super.onCreate(savedInstanceState)
2636
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
27-
setActionBar(binding.appBarMain.toolbar)
37+
binding.appBarMain?.appBar?.apply {
38+
toolbar = (LayoutInflater.from(context).inflate(R.layout.toolbar_main, null) as Toolbar).apply {
39+
viewTreeObserver.addOnGlobalLayoutListener(layoutListenerForClear)
40+
}
41+
removeAllViews()
42+
addView(toolbar)
43+
setActionBar(toolbar)
44+
}
2845

2946
binding.navView.setNavigationItemSelectedListener(this)
3047

@@ -35,11 +52,9 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
3552
}
3653

3754
override fun onBackPressed() {
38-
val drawer = binding.drawerLayout
39-
if (drawer.isDrawerOpen(GravityCompat.START)) {
40-
drawer.closeDrawer(GravityCompat.START)
41-
} else {
42-
super.onBackPressed()
55+
binding.drawerLayout.apply {
56+
if (isDrawerOpen(Gravity.START)) closeDrawer(Gravity.START)
57+
else super.onBackPressed()
4358
}
4459
}
4560

@@ -56,12 +71,12 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
5671
when (id) {
5772
R.id.nav_problem -> {
5873
val fragment = ProblemsFragment.newInstance()
59-
fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(null).commit()
74+
fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(ProblemsFragment.TAG).commit()
6075
}
6176

6277
R.id.nav_draft -> {
6378
val fragment = DraftProblemsFragment.newInstance()
64-
fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(null).commit()
79+
fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(DraftProblemsFragment.TAG).commit()
6580
}
6681

6782
R.id.nav_editor -> {
@@ -75,27 +90,25 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
7590
fragment.show(fragmentManager, MyAlertDialogFragment.getTag(requestCode))
7691
}
7792

78-
R.id.nav_setting -> {
79-
80-
}
81-
82-
R.id.nav_share -> {
93+
R.id.nav_setting -> {}
8394

95+
R.id.nav_search -> {
96+
val fragment = SearchFragment.createInstance()
97+
fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(SearchFragment.tag).commit()
8498
}
8599
}
86100

87-
binding.drawerLayout.closeDrawer(GravityCompat.START)
101+
binding.drawerLayout.closeDrawer(Gravity.START)
88102
return true
89103
}
90104

91105
override fun onCanvasSizeError(size: Size) {
92-
showSnackbar(binding.appBarMain.contentMain.container, R.string.problem_fragment_error_invalid_size)
106+
binding.appBarMain?.contentMain?.container?.let { showSnackbar(it, R.string.problem_fragment_error_invalid_size) }
93107
}
94108

95109
override fun onResultAlertDialog(dialogInterface: DialogInterface, requestCode: MyAlertDialogFragment.RequestCode, resultCode: Int, result: Any?) {
96110
when (resultCode) {
97-
DialogInterface.BUTTON_POSITIVE ->
98-
onPositive(requestCode, result)
111+
DialogInterface.BUTTON_POSITIVE -> onPositive(requestCode, result)
99112
}
100113
dialogInterface.dismiss()
101114
}
@@ -105,12 +118,7 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
105118
MyAlertDialogFragment.RequestCode.DEFINE_SIZE -> {
106119
(result as? Size)?.let {
107120
val fragment = EditorFragment.newInstance(it, this@MainActivity)
108-
if (fragment != null) {
109-
fragmentManager.beginTransaction()
110-
.replace(R.id.container, fragment)
111-
.addToBackStack(null)
112-
.commit()
113-
}
121+
if (fragment != null) fragmentManager.beginTransaction().replace(R.id.container, fragment).addToBackStack(EditorFragment.TAG).commit()
114122
}
115123
}
116124
else -> {}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package jp.co.seesaa.geckour.picrossmaker.api
2+
3+
import io.reactivex.Single
4+
import jp.co.seesaa.geckour.picrossmaker.App.Companion.gson
5+
import jp.co.seesaa.geckour.picrossmaker.api.model.Problem
6+
import jp.co.seesaa.geckour.picrossmaker.api.model.Result
7+
import jp.co.seesaa.geckour.picrossmaker.api.service.ApiService
8+
import jp.co.seesaa.geckour.picrossmaker.util.OkHttpProvider
9+
import retrofit2.Retrofit
10+
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
11+
import retrofit2.converter.gson.GsonConverterFactory
12+
13+
class ApiClient {
14+
15+
companion object {
16+
private val baseUrl = "10.0.2.2:8080"//"172.16.21.15:8080"
17+
}
18+
19+
private val service = Retrofit.Builder().client(OkHttpProvider.client)
20+
.baseUrl("http://$baseUrl/")
21+
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
22+
.addConverterFactory(GsonConverterFactory.create(gson))
23+
.build()
24+
.create(ApiService::class.java)
25+
26+
fun registerProblem(problem: Problem): Single<Result<String>> = service.registerProblem(problem)
27+
28+
fun search(title: String?, genre: String?): Single<Result<Result.Data<Result.Data.Problems>>> = service.search(title, genre)
29+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package jp.co.seesaa.geckour.picrossmaker.api.model
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
data class Problem(
6+
val id: Long? = null,
7+
8+
val title: String,
9+
10+
val tags: List<String>,
11+
12+
@SerializedName("keys_horizontal")
13+
val keysHorizontal: List<List<Int>>,
14+
15+
@SerializedName("keys_vertical")
16+
val keysVertical: List<List<Int>>,
17+
18+
@SerializedName("created_at")
19+
val createdAt: Long = System.currentTimeMillis(),
20+
21+
@SerializedName("edited_at")
22+
val editedAt: Long = System.currentTimeMillis()
23+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package jp.co.seesaa.geckour.picrossmaker.api.model
2+
3+
data class Result<out T>(
4+
val success: Boolean,
5+
val message: T
6+
) {
7+
data class Data<out T>(
8+
val data: T
9+
) {
10+
data class Problems(
11+
val problems: List<Problem>
12+
)
13+
}
14+
}

0 commit comments

Comments
 (0)