Skip to content

Commit

Permalink
Beta 0.9.4;Fixed updater
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Jul 8, 2018
1 parent bbb2df8 commit 173c980
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 32 deletions.
25 changes: 13 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,27 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"

// Support library
implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha3'
implementation 'androidx.exifinterface:exifinterface:1.0.0-alpha3'
implementation 'androidx.cardview:cardview:1.0.0-alpha3'
implementation 'androidx.preference:preference:1.0.0-alpha3'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0-alpha3'
implementation 'com.google.android.material:material:1.0.0-alpha3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha3'
implementation 'androidx.browser:browser:1.0.0-alpha3'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation "android.arch.work:work-runtime:1.0.0-alpha04"
implementation 'androidx.exifinterface:exifinterface:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation 'androidx.preference:preference:1.0.0-beta01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.browser:browser:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:11.8.0' // DO NOT DOWNGRADE, GOOGLE'S FAULT GH#415
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.devbrackets.android:exomedia:4.1.0'
implementation 'com.google.android.exoplayer:extension-okhttp:2.6.0'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'androidx.core:core-ktx:1.0.0-alpha3'
implementation 'androidx.core:core-ktx:1.0.0-beta01'

// Utils
implementation 'com.bugsnag:bugsnag-android:4.1.3'
implementation 'com.bugsnag:bugsnag-android:4.5.0'
implementation "org.ocpsoft.prettytime:prettytime:$versions.prettytime"
implementation 'com.jsibbold:zoomage:1.1.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class EndlessProgressAdapter<T : androidx.recyclerview.widget.RecyclerV
isLoading = true
}

fun addData(items: List<A>, shouldClearAdapter: Boolean) {
open fun addData(items: List<A>, shouldClearAdapter: Boolean) {
if (shouldClearAdapter || dataset.isEmpty()) {
dataset.apply {
clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class NetworkModule {
val httpLogging = HttpLoggingInterceptor()
httpLogging.level = HttpLoggingInterceptor.Level.BASIC
return OkHttpClient.Builder()
//.addNetworkInterceptor(CacheControlInterceptor(context))
.addInterceptor(ApiSignInterceptor(userManagerApi))
.addNetworkInterceptor(httpLogging)
//.cache(cache)
.protocols(listOf(Protocol.HTTP_1_1))
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class EntriesAdapter @Inject constructor(val userManagerApi: UserManagerApi, val
}
}

override fun addData(items: List<Entry>, shouldClearAdapter: Boolean) {
super.addData(items.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }, shouldClearAdapter)
}

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
if (holder is EntryViewHolder) {
holder.bindView(data[position])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.github.feelfreelinux.wykopmobilny.R
import io.github.feelfreelinux.wykopmobilny.models.dataclass.Author
import io.github.feelfreelinux.wykopmobilny.models.dataclass.Entry
import io.github.feelfreelinux.wykopmobilny.models.dataclass.EntryComment
import io.github.feelfreelinux.wykopmobilny.models.dataclass.Link
import io.github.feelfreelinux.wykopmobilny.ui.adapters.viewholders.*
import io.github.feelfreelinux.wykopmobilny.ui.fragments.entries.EntryActionListener
import io.github.feelfreelinux.wykopmobilny.ui.fragments.entrycomments.EntryCommentActionListener
Expand Down Expand Up @@ -36,7 +37,7 @@ class EntryAdapter @Inject constructor(val userManagerApi: UserManagerApi, val s
holder.bindView(entry!!)
}
is EntryCommentViewHolder -> {
val comment = entry!!.comments[position - 1]
val comment = entry!!.comments.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }[position - 1]
holder.bindView(comment, entry?.author, commentId ?: 0)
}
is BlockedViewHolder -> {
Expand All @@ -55,7 +56,7 @@ class EntryAdapter @Inject constructor(val userManagerApi: UserManagerApi, val s
}

override fun getItemCount(): Int {
entry?.comments?.let {
entry?.comments?.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }?.let {
return it.size + 1
}
return 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.feelfreelinux.wykopmobilny.ui.adapters

import androidx.recyclerview.widget.RecyclerView
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.github.feelfreelinux.wykopmobilny.base.adapter.EndlessProgressAdapter
import io.github.feelfreelinux.wykopmobilny.models.dataclass.Entry
import io.github.feelfreelinux.wykopmobilny.models.dataclass.EntryComment
import io.github.feelfreelinux.wykopmobilny.ui.adapters.viewholders.*
import io.github.feelfreelinux.wykopmobilny.ui.fragments.entrycomments.EntryCommentActionListener
Expand All @@ -16,14 +17,18 @@ class EntryCommentAdapter @Inject constructor(
val userManagerApi: UserManagerApi,
val settingsPreferencesApi: SettingsPreferencesApi,
val navigatorApi: NewNavigatorApi,
val linkHandlerApi: WykopLinkHandlerApi) : EndlessProgressAdapter<androidx.recyclerview.widget.RecyclerView.ViewHolder, EntryComment>() {
val linkHandlerApi: WykopLinkHandlerApi) : EndlessProgressAdapter<RecyclerView.ViewHolder, EntryComment>() {
// Required field, interacts with presenter. Otherwise will throw exception
lateinit var entryCommentActionListener : EntryCommentActionListener

override fun getViewType(position: Int): Int {
return EntryCommentViewHolder.getViewTypeForEntryComment(data[position])
}

override fun addData(items: List<EntryComment>, shouldClearAdapter: Boolean) {
super.addData(items.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }, shouldClearAdapter)
}

override fun constructViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder {
return when (viewType) {
EntryCommentViewHolder.TYPE_EMBED, EntryCommentViewHolder.TYPE_NORMAL ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class EntryLinksAdapter @Inject constructor(val userManagerApi: UserManagerApi,
}
}

override fun addData(items: List<EntryLink>, shouldClearAdapter: Boolean) {
super.addData(items.filterNot { settingsPreferencesApi.hideBlacklistedViews && if (it.entry != null) it.entry!!.isBlocked else it.link!!.isBlocked }, shouldClearAdapter)
}

override fun constructViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder {
return when (viewType) {
LinkViewHolder.TYPE_IMAGE, LinkViewHolder.TYPE_NOIMAGE ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class LinkCommentAdapter @Inject constructor(
}
}

override fun addData(items: List<LinkComment>, shouldClearAdapter: Boolean) {
super.addData(items.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }, shouldClearAdapter)
}

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
when (holder) {
is TopLinkCommentViewHolder -> holder.bindView(data[position], false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LinkDetailsAdapter @Inject constructor(val userManagerApi: UserManagerApi,
lateinit var linkCommentActionListener: LinkCommentActionListener
lateinit var linkHeaderActionListener: LinkHeaderActionListener
var link: Link? = null
val commentsList : List<LinkComment>? get() = link?.comments?.filterNot { it.isParentCollapsed }
val commentsList : List<LinkComment>? get() = link?.comments?.filterNot { it.isParentCollapsed || (it.isBlocked && settingsPreferencesApi.hideBlacklistedViews) }

override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
if (holder.itemViewType == LinkHeaderViewHolder.TYPE_HEADER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class LinksAdapter @Inject constructor(val userManagerApi: UserManagerApi, val s
}
}

override fun addData(items: List<Link>, shouldClearAdapter: Boolean) {
super.addData(items.filterNot { settingsPreferencesApi.hideBlacklistedViews && it.isBlocked }, shouldClearAdapter)
}

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
when (holder) {
is LinkViewHolder -> holder.bindView(data[position])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import kotlinx.android.synthetic.main.toolbar.*
import javax.inject.Inject
import android.net.Uri
import android.os.Handler
import com.github.javiersantos.appupdater.AppUpdater
import com.github.javiersantos.appupdater.enums.UpdateFrom
import com.google.android.material.internal.NavigationMenuView
import io.github.feelfreelinux.wykopmobilny.BuildConfig
import io.github.feelfreelinux.wykopmobilny.models.scraper.Blacklist
Expand Down Expand Up @@ -155,6 +157,15 @@ class MainNavigationActivity : BaseActivity(), MainNavigationView, com.google.an

(navigationView.getChildAt(0) as NavigationMenuView).isVerticalScrollBarEnabled = false
//Setup AppUpdater
AppUpdater(this)
.setUpdateFrom(UpdateFrom.GITHUB)
.setGitHubUserAndRepo("feelfreelinux", "WykopMobilny")
.setTitleOnUpdateAvailable(R.string.update_available)
.setContentOnUpdateAvailable(R.string.update_app)
.setButtonDismiss(R.string.cancel)
.setButtonDoNotShowAgain(R.string.do_not_show_again)
.setButtonUpdate(R.string.update)
.start()
//presenter.checkUpdates()
checkBlacklist()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*package io.github.feelfreelinux.wykopmobilny.ui.modules.notifications.notificationsservice
import androidx.work.Worker
import io.github.feelfreelinux.wykopmobilny.WykopApp
import io.github.feelfreelinux.wykopmobilny.api.ApiSignInterceptor
import io.github.feelfreelinux.wykopmobilny.api.UserTokenRefresher
import io.github.feelfreelinux.wykopmobilny.api.notifications.NotificationsRepository
import io.github.feelfreelinux.wykopmobilny.api.user.LoginRepository
import io.github.feelfreelinux.wykopmobilny.base.WykopSchedulers
import io.github.feelfreelinux.wykopmobilny.utils.api.CredentialsPreferences
import io.github.feelfreelinux.wykopmobilny.utils.usermanager.UserManager
import okhttp3.OkHttpClient
import okhttp3.Protocol
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.jackson.JacksonConverterFactory
import java.util.concurrent.TimeUnit
/**
* Dagger's AndroidInjector doesn't support Worker for now.
* Will replace this depedencies mess after it gets implemented.
*/
class WykopNotificationsWorker : Worker() {
val userManager by lazy {
UserManager(CredentialsPreferences(applicationContext))
}
val okHttpClient by lazy { OkHttpClient.Builder()
.addInterceptor(ApiSignInterceptor(userManager))
.protocols(listOf(Protocol.HTTP_1_1))
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build() }
val retrofit by lazy { Retrofit.Builder()
.client(okHttpClient)
.baseUrl(WykopApp.WYKOP_API_URL)
.addConverterFactory(JacksonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build() }
val notificationsRepository by lazy {
NotificationsRepository(retrofit, UserTokenRefresher(LoginRepository(retrofit, CredentialsPreferences(applicationContext)), userManager))
}
val presenter = WykopNotificationsJobPresenter(WykopSchedulers(), notificationsRepository, userManager)
override fun doWork(): Result {
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.preference.CheckBoxPreference
import androidx.preference.ListPreference
Expand All @@ -15,6 +16,9 @@ import dagger.android.support.HasSupportFragmentInjector
import io.github.feelfreelinux.wykopmobilny.R
import io.github.feelfreelinux.wykopmobilny.utils.preferences.SettingsPreferencesApi
import javax.inject.Inject
import android.os.Build



class SettingsAppearance : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener, HasSupportFragmentInjector {
@Inject
Expand All @@ -25,6 +29,7 @@ class SettingsAppearance : PreferenceFragmentCompat(), SharedPreferences.OnShare
return childFragmentInjector
}


override fun onAttach(context: Context) {
AndroidSupportInjection.inject(this)
super.onAttach(context)
Expand Down Expand Up @@ -74,11 +79,6 @@ class SettingsAppearance : PreferenceFragmentCompat(), SharedPreferences.OnShare
}
}

override fun onResume() {
super.onResume()
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
}

override fun onPause() {
super.onPause()
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import kotlinx.android.synthetic.main.input_toolbar.view.*
import android.os.Parcel
import android.widget.EditText






interface InputToolbarListener {
fun sendPhoto(photo : TypedInputStream, body : String, containsAdultContent: Boolean)
fun sendPhoto(photo : String?, body : String, containsAdultContent : Boolean)
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<style name="WykopAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:scrollbarThumbVertical">@drawable/scrollbar_gradient</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item name="preferenceTheme">@style/WykopPreferencesTheme</item>
<item name="textColorGrey">@color/textColorGrey</item>
<item name="textColorLight">@color/textColorLight</item>
<item name="textColorButtonToolbar">@color/textColorButtonToolbar</item>
Expand Down Expand Up @@ -550,6 +550,14 @@
<item name="textSizeHuge">@dimen/text_huge_size_huge</item>m>
</style>

<style name="WykopPreferencesTheme" parent="@style/PreferenceThemeOverlay.v14.Material">
<item name="preferenceFragmentListStyle">@style/NoMarginPreferences</item>
</style>

<style name="NoMarginPreferences">
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
</style>
<!-- SwipeBackLayout -->
<style name="SwipeBackLayout">
<item name="edge_size">50dip</item>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ allprojects {
project.ext {
versionMajor = 0
versionMinor = 9
versionPatch = 3
versionPatch = 4
versionBuild = 0
}
}
Expand Down

0 comments on commit 173c980

Please sign in to comment.