Skip to content

Commit

Permalink
Merge pull request #64 from uhooi/release/1.3.0
Browse files Browse the repository at this point in the history
Release/1.3.0
  • Loading branch information
uhooi authored Oct 5, 2020
2 parents 17ad185 + 266cd6c commit 0a46f37
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
java-version: 1.8

# Gradleのキャッシュ復元
- uses: actions/cache@v1
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/opened-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v1
- uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
Expand All @@ -22,8 +23,9 @@ jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v1
- uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
Expand Down
18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.theuhooi.uhooipicbook"
minSdkVersion 26
targetSdkVersion 29
versionCode 3
versionName "1.2.0"
versionCode 4
versionName "1.3.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -55,14 +55,16 @@ android {
}

dependencies {
implementation 'io.coil-kt:coil:0.9.5'
def coil_version = '0.13.0'
implementation "io.coil-kt:coil:$coil_version"
implementation "io.coil-kt:coil-base:$coil_version"

// Firebase
implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'
implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.1'
implementation 'com.google.firebase:firebase-firestore-ktx:21.6.0'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.google.firebase:firebase-perf:19.0.8'
implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.2'
implementation 'com.google.firebase:firebase-firestore-ktx:21.7.0'
implementation 'com.google.firebase:firebase-messaging:20.3.0'
implementation 'com.google.firebase:firebase-perf:19.0.9'

implementation 'androidx.recyclerview:recyclerview:1.1.0'

Expand All @@ -77,7 +79,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'

implementation 'com.google.android.material:material:1.2.1'
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,14 @@
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_notification" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
package com.theuhooi.uhooipicbook.modules.monsterdetail

import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.app.ShareCompat
import androidx.core.content.FileProvider
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs
import coil.ImageLoader
import coil.api.load
import coil.request.Disposable
import coil.request.ImageRequest
import com.theuhooi.uhooipicbook.R
import kotlinx.android.synthetic.main.fragment_monster_detail.view.*
import java.io.File
import java.io.FileOutputStream

class MonsterDetailFragment : Fragment() {

// region Stored Instance Properties

private val args: MonsterDetailFragmentArgs by navArgs()

private var disposable: Disposable? = null

// endregion

// region View Life-Cycle Methods

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
setHasOptionsMenu(true)
return inflater.inflate(R.layout.fragment_monster_detail, container, false)
}

Expand All @@ -32,8 +50,64 @@ class MonsterDetailFragment : Fragment() {

view.icon_imageview.load(this.args.monster.iconUrlString)
view.name_textview.text = this.args.monster.name
// TODO: 文字列の加工を終わらせた状態で渡す
view.description_textview.text = this.args.monster.description.replace("\\n", "\n")
view.description_textview.text = unescapeNewline(this.args.monster.description)
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)

inflater.inflate(R.menu.menu_share, menu)
val shareMenuItem = menu.findItem(R.id.share_menu_item)
shareMenuItem.setOnMenuItemClickListener {
shareMonster()
true
}
}

override fun onDestroyOptionsMenu() {
super.onDestroyOptionsMenu()

this.disposable?.dispose()
}

// endregion

// region Other Private Methods

private fun shareMonster() {
val monster = this.args.monster
val context = requireContext()
val request = ImageRequest.Builder(context)
.data(monster.iconUrlString)
.target { drawable ->
ShareCompat.IntentBuilder
.from(requireActivity())
.setText(monster.name + "\n" + unescapeNewline(monster.description) + "\n#UhooiPicBook")
.setStream(createTempPngFileUri(context, drawable))
.setType("image/png")
.setChooserTitle(R.string.share_menu_item_title)
.startChooser()
}
.build()
this.disposable = ImageLoader(context).enqueue(request)
}

private fun createTempPngFileUri(context: Context, drawable: Drawable): Uri? {
val cacheFile = File(context.externalCacheDir, "share_temp.png")
createPngFile(drawable, cacheFile)
return FileProvider.getUriForFile(context, context.packageName + ".fileprovider", cacheFile)
}

private fun createPngFile(drawable: Drawable, file: File) {
FileOutputStream(file).use { outputStream ->
val bitmap = (drawable as BitmapDrawable).bitmap
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
outputStream.flush()
}
}

private fun unescapeNewline(text: String): String {
return text.replace("\\n", "\n")
}

// endregion
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_baseline_share_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/menu/menu_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/share_menu_item"
android:icon="@drawable/ic_baseline_share_24"
android:title="@string/share_menu_item_title"
app:showAsAction="always" />
</menu>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<string name="app_name">UhooiPicBook</string>
<string name="icon_description">Icon</string>

<string name="share_menu_item_title">共有</string>

<string name="info_notification_channel_id">info</string>
<string name="info_notification_channel_name">お知らせ</string>
<string name="info_notification_channel_description">お知らせ</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-cache-path
name="cache"
path="." />
</paths>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"

// Firebase
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
classpath 'com.google.firebase:perf-plugin:1.3.1'

Expand Down
Binary file modified docs/screenshots/monsterDetail-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/monsterDetail-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a46f37

Please sign in to comment.