Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/bvlion/ShareBookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bvlion committed Jun 20, 2021
2 parents baa7900 + c044e21 commit 9c3e3ed
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 53 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ dependencies {
implementation "joda-time:joda-time:2.10.6"
implementation "org.jsoup:jsoup:1.13.1"
implementation "com.airbnb.android:lottie:3.7.0"
implementation "com.ibm.icu:icu4j:64.2"

testImplementation 'junit:junit:4.13.1'
testImplementation 'androidx.test:core:1.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ interface ItemDao {
@Query("SELECT * FROM items WHERE parent_id = :parentId AND active = 1 ORDER BY `order`, upserted DESC")
suspend fun getItems(parentId: Long): List<Item>

@Query("SELECT * FROM items WHERE url IS NOT NULL AND active = 1 AND (name LIKE :textH OR name LIKE :textK OR name LIKE :textKH OR name LIKE :textHKH) ORDER BY upserted DESC")
suspend fun getSearchItems(textH: String, textK: String, textKH: String, textHKH: String): List<Item>
@Query("SELECT * FROM items WHERE url IS NOT NULL AND active = 1 AND (name LIKE :textH OR name LIKE :textK OR name LIKE :textKH) ORDER BY upserted DESC")
suspend fun getSearchItems(
textH: String,
textK: String,
textKH: String
): List<Item>

@Query("SELECT * FROM items WHERE url IS NULL AND id != :selfId AND active = 1 AND owner_type IN (0, 1) ORDER BY `order`")
suspend fun getFolderItems(selfId: Long): List<Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FaqActivity : BaseActivity(), FaqListAdapter.FaqClickListener {
override fun onInquiryClick() {
finish()
startActivity(Intent(this, InquiryActivity::class.java))
overridePendingTransition(R.anim.fade_in_top, android.R.anim.fade_out)
overridePendingTransition(android.R.anim.fade_in, R.anim.fade_in_top)
}

override fun finish() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.appcompat.widget.SearchView
import androidx.core.app.AppLaunchChecker
import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.FragmentContainerView
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
Expand Down Expand Up @@ -287,7 +288,7 @@ class HomeActivity : BaseActivity(), OnNavigationItemSelectedListener,
NotificationActivity::class.java
)
)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right)
overridePendingTransition(android.R.anim.fade_in, R.anim.slide_in_left)
}, 110)
}
R.id.menu_login -> {
Expand Down Expand Up @@ -330,7 +331,7 @@ class HomeActivity : BaseActivity(), OnNavigationItemSelectedListener,
analyticsUtils.logMenuTap("other")
Handler(Looper.getMainLooper()).postDelayed({
forceUpdateActivityResult.launch(Intent(this@HomeActivity, OtherActivity::class.java))
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right)
overridePendingTransition(android.R.anim.fade_in, R.anim.slide_in_left)
}, 110)
}
R.id.menu_app_rating -> {
Expand Down Expand Up @@ -360,14 +361,14 @@ class HomeActivity : BaseActivity(), OnNavigationItemSelectedListener,
SettingActivity::class.java
)
)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right)
overridePendingTransition(android.R.anim.fade_in, R.anim.slide_in_left)
}, 110)
}
R.id.menu_how_to_use -> {
analyticsUtils.logMenuTap("how to use")
Handler(Looper.getMainLooper()).postDelayed({
startActivity(UsageActivity.createIntent(this@HomeActivity))
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right)
overridePendingTransition(android.R.anim.fade_in, R.anim.slide_in_left)
}, 110)
}
}
Expand Down Expand Up @@ -484,6 +485,18 @@ class HomeActivity : BaseActivity(), OnNavigationItemSelectedListener,
View.GONE
}
}

binding.drawerLayout.addDrawerListener(object : DrawerLayout.DrawerListener {
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {}

override fun onDrawerOpened(drawerView: View) {}

override fun onDrawerClosed(drawerView: View) {}

override fun onDrawerStateChanged(newState: Int) {
closeSearch()
}
})
}

private fun errorSnackbar() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.widget.ImageView
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.bumptech.glide.Glide
import com.ibm.icu.text.Transliterator
import net.ambitious.android.sharebookmarks.data.local.item.Item
import net.ambitious.android.sharebookmarks.data.local.item.ItemDao
import net.ambitious.android.sharebookmarks.data.remote.etc.EtcApi
Expand Down Expand Up @@ -69,9 +68,6 @@ class HomeViewModel(

private val _breadcrumbsList = arrayListOf<Pair<Long, String>>()

private val transFH = Transliterator.getInstance("Fullwidth-Halfwidth")
private val transHK = Transliterator.getInstance("Hiragana-Katakana")

fun setInitialParentId(parentId: Long?) {
_parentId = parentId ?: 0L
}
Expand Down Expand Up @@ -278,9 +274,8 @@ class HomeViewModel(
} else {
itemDao.getSearchItems(
"%$text%",
"%${transHK.transliterate(text)}%",
"%${transFH.transliterate(text)}%",
"%${transFH.transliterate(transHK.transliterate(text))}%",
"%${OperationUtils.hiraganaToKatakana(text)}%",
"%${OperationUtils.kanaZenToHan(text)}%"
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class NotificationActivity : BaseActivity(), NotificationListAdapter.OnNotificat

override fun finish() {
super.finish()
overridePendingTransition(R.anim.slide_out_right, R.anim.slide_out_left)
overridePendingTransition(R.anim.slide_out_right, android.R.anim.fade_out)
}

override fun onRowClick(url: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class OtherActivity : BaseActivity() {

override fun finish() {
super.finish()
overridePendingTransition(R.anim.slide_out_right, R.anim.slide_out_left)
overridePendingTransition(R.anim.slide_out_right, android.R.anim.fade_out)
}

fun termsOfUseShow() = true.apply {
Expand All @@ -65,7 +65,12 @@ class OtherActivity : BaseActivity() {
setHomeAsUpIndicator(R.drawable.ic_clear_white)
}
supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.fade_in_top, android.R.anim.fade_out, android.R.anim.fade_in, R.anim.fade_out_bottom_fragment)
.setCustomAnimations(
android.R.anim.fade_in,
R.anim.fade_in_top,
android.R.anim.fade_in,
R.anim.fade_out_bottom_fragment
)
.replace(R.id.nav_host_fragment, DetailFragment.newInstance(true))
.addToBackStack(null)
.commit()
Expand All @@ -78,7 +83,12 @@ class OtherActivity : BaseActivity() {
setHomeAsUpIndicator(R.drawable.ic_clear_white)
}
supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.fade_in_top, android.R.anim.fade_out, android.R.anim.fade_in, R.anim.fade_out_bottom_fragment)
.setCustomAnimations(
android.R.anim.fade_in,
R.anim.fade_in_top,
android.R.anim.fade_in,
R.anim.fade_out_bottom_fragment
)
.replace(R.id.nav_host_fragment, DetailFragment.newInstance(false))
.addToBackStack(null)
.commit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OtherFragment : PreferenceFragmentCompat() {
preferenceScreen.findPreference<Preference>(QUESTIONS)?.setOnPreferenceClickListener {
analyticsUtils.logOtherTap("Other", "inquiry")
startActivity(Intent(context, FaqActivity::class.java))
activity?.overridePendingTransition(R.anim.fade_in_top, android.R.anim.fade_out)
activity?.overridePendingTransition(android.R.anim.fade_in, R.anim.fade_in_top)
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class SettingActivity : BaseActivity() {

override fun finish() {
super.finish()
overridePendingTransition(R.anim.slide_out_right, R.anim.slide_out_left)
overridePendingTransition(R.anim.slide_out_right, android.R.anim.fade_out)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UsageActivity : BaseActivity() {
if (fromDialog) {
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
} else {
overridePendingTransition(R.anim.slide_out_right, R.anim.slide_out_left)
overridePendingTransition(R.anim.slide_out_right, android.R.anim.fade_out)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,47 @@ object OperationUtils {
return contactList
}

fun hiraganaToKatakana(str: String) =
str.map {
if (it.code in 0x3041..0x3093) {
it + 0x60
} else {
it
}
}.joinToString("")

fun kanaZenToHan(str: String) =
hiraganaToKatakana(str)
.map {
if (it.code in ZEN[0].code..ZEN.last().code) {
HAN[it.code - ZEN[0].code]
} else {
it
}
}.joinToString("")

private val ZEN = listOf(
'', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', ''
)

private val HAN = listOf(
"", "", "", "", "",
"", "", "", "", "", "", "ガ", "", "ギ", "", "グ", "",
"ゲ", "", "ゴ", "", "ザ", "", "ジ", "", "ズ", "", "ゼ", "ソ",
"ゾ", "", "ダ", "", "ヂ", "", "", "ヅ", "", "デ", "", "ド",
"", "", "", "", "", "", "バ", "パ", "", "ビ", "ピ", "",
"ブ", "プ", "", "ベ", "ペ", "", "ボ", "ポ", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "ヴ", "", ""
)

private fun getUserImage(contentResolver: ContentResolver, contactId: Long) =
Contacts.openContactPhotoInputStream(
contentResolver,
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/res/anim/fade_in_top.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="20%p" android:toYDelta="0"
android:duration="@android:integer/config_mediumAnimTime"/>
<alpha
android:interpolator="@android:interpolator/accelerate_quad"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />
android:duration="@android:integer/config_shortAnimTime"/>
</set>
4 changes: 2 additions & 2 deletions app/src/main/res/anim/fade_out_bottom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="50%p"
android:duration="@android:integer/config_mediumAnimTime"/>
android:duration="@android:integer/config_shortAnimTime"/>
<alpha
android:interpolator="@android:interpolator/accelerate_quad"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@android:integer/config_longAnimTime" />
android:duration="@android:integer/config_shortAnimTime" />
</set>
4 changes: 2 additions & 2 deletions app/src/main/res/anim/fade_out_bottom_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="100%p"
android:duration="@android:integer/config_mediumAnimTime"/>
android:duration="@android:integer/config_shortAnimTime"/>
<alpha
android:interpolator="@android:interpolator/accelerate_quad"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@android:integer/config_longAnimTime" />
android:duration="@android:integer/config_shortAnimTime" />
</set>
4 changes: 2 additions & 2 deletions app/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_mediumAnimTime"/>
<translate android:fromXDelta="0" android:toXDelta="100%p"
android:duration="@android:integer/config_shortAnimTime"/>
</set>
5 changes: 0 additions & 5 deletions app/src/main/res/anim/slide_in_right.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/anim/slide_out_left.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/anim/slide_out_right.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="@android:integer/config_mediumAnimTime"/>
android:duration="@android:integer/config_shortAnimTime"/>
</set>
2 changes: 1 addition & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<string name="all_sync_dialog_title">全データ更新を行います</string>
<string name="all_sync_dialog_subject">この機能は緊急用です。\n管理者より案内がない場合は使用をお控えください。\n\n端末のデータを全て削除し、サーバーから全データを取得しますか?</string>
<string name="all_sync_dialog_exec">理解のうえで実行</string>
<string name="communication_error">読み込みに失敗しました。\n通信化環境をご確認ください。</string>
<string name="communication_error">読み込みに失敗しました。\nWi-Fi やモバイル通信の状況をご確認下さい。</string>

<!-- 使い方 -->
<string name="how_to_use_text_main_1">このアプリがあれば、いつも使っているレシピもお気に入りのサイトも画像付きで自由に保存してシェア(共有)できます!</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<string name="all_sync_dialog_title">Update all data</string>
<string name="all_sync_dialog_subject">This feature is for emergency use only.\nPlease refrain from using it unless you are informed by the administrator.\n\nDo you want to delete all data on the device and get all data from the server?</string>
<string name="all_sync_dialog_exec">Execute with understanding</string>
<string name="communication_error">Failed to load.\nPlease check your communication environment.</string>
<string name="communication_error">Failed to load.\nPlease check the status of your Wi-Fi and mobile communications.</string>

<!-- 使い方 -->
<string name="how_to_use_text_main_1">With this app, you\'re free to save and share both your regular recipes and your favorite sites, complete with images!</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class OperationUtilsUnitTest {
fun createThumbnailUrlTest() {
// favicon 取得 URL 生成
assertThat(
OperationUtils.createThumbnailUrl("https://bvlion-app.firebaseapp.com"),
`is`("${Const.GOOGLE_FAVICON_URL}bvlion-app.firebaseapp.com")
OperationUtils.createThumbnailUrl("https://bvlion-app.firebaseapp.com"),
`is`("${Const.GOOGLE_FAVICON_URL}bvlion-app.firebaseapp.com")
)

// null
Expand All @@ -54,8 +54,8 @@ class OperationUtilsUnitTest {
runBlocking {
// OGP 取得
assertThat(
OperationUtils.getOgpImage("https://www.ambitious-i.net", etcApi),
`is`("https://www.ambitious-i.net/img/main.jpg")
OperationUtils.getOgpImage("https://www.ambitious-i.net", etcApi),
`is`("https://www.ambitious-i.net/img/main.jpg")
)

// URL 形式でない
Expand Down
Loading

0 comments on commit 9c3e3ed

Please sign in to comment.