Skip to content

Commit

Permalink
Fix powered by preference
Browse files Browse the repository at this point in the history
  • Loading branch information
arcao committed Nov 10, 2019
1 parent 3bfe28e commit 6d4a306
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object AppConstants {
val USERS_GUIDE_URI = Uri.parse("https://geocaching4locus.eu/users-guide/")!!
val WEBSITE_URI = Uri.parse("https://geocaching4locus.eu/")!!
val FACEBOOK_URI = Uri.parse("https://www.facebook.com/Geocaching4Locus")!!
val GEOCACHING_LIVE_URI = Uri.parse("http://www.geocaching.com/live")!!
val GEOCACHING_URI = Uri.parse("http://geocaching.com/")!!
val POWER_SAVE_INFO_URI = Uri.parse("https://geocaching4locus.eu/redirect/power-save-issue")!!

// Saved in Base64 because Google Play doesn't allow donation via Paypal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object PrefConstants {
const val ABOUT_FACEBOOK = "about_facebook"
const val ABOUT_FEEDBACK = "about_feedback"
const val ABOUT_DONATE_PAYPAL = "about_donate_paypal"
const val ACCOUNT_GEOCACHING_LIVE = "account_geocaching_live"
const val ACCOUNT_POWERED_BY = "account_powered_by"

const val RESTRICTION__RENEW_FULL_GEOCACHE_LIMIT = "renew_full_geocache_limit"
const val RESTRICTION__CURRENT_FULL_GEOCACHE_LIMIT = "current_full_geocache_limit"
Expand Down Expand Up @@ -106,4 +106,4 @@ object PrefConstants {
)

val SHORT_CONTAINER_TYPE_NAMES = arrayOf("?", "M", "S", "R", "L", "H", "O")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.arcao.geocaching4locus.base.fragment.AbstractDialogFragment
import com.arcao.geocaching4locus.base.fragment.AbstractPreferenceFragment
import com.arcao.geocaching4locus.base.util.showWebPage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import org.koin.android.ext.android.get
import org.koin.android.ext.android.inject
Expand All @@ -30,7 +30,7 @@ class AboutPreferenceFragment : AbstractPreferenceFragment(), CoroutineScope {
private val dispatcherProvider by inject<CoroutinesDispatcherProvider>()
private val feedbackHelper by inject<FeedbackHelper>()

private val job = Job()
private val job = SupervisorJob()

override val coroutineContext: CoroutineContext
get() = job + dispatcherProvider.main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.preference.Preference
import com.arcao.geocaching4locus.R
import com.arcao.geocaching4locus.authentication.util.requestSignOn
import com.arcao.geocaching4locus.base.constants.AppConstants
import com.arcao.geocaching4locus.base.constants.PrefConstants.ACCOUNT_GEOCACHING_LIVE
import com.arcao.geocaching4locus.base.constants.PrefConstants.ACCOUNT_POWERED_BY
import com.arcao.geocaching4locus.base.fragment.AbstractPreferenceFragment
import com.arcao.geocaching4locus.base.util.getText
import com.arcao.geocaching4locus.base.util.showWebPage
Expand Down Expand Up @@ -43,8 +43,8 @@ class AccountsPreferenceFragment : AbstractPreferenceFragment() {
}
}

preference<Preference>(ACCOUNT_GEOCACHING_LIVE).setOnPreferenceClickListener {
requireActivity().showWebPage(AppConstants.GEOCACHING_LIVE_URI)
preference<Preference>(ACCOUNT_POWERED_BY).setOnPreferenceClickListener {
requireActivity().showWebPage(AppConstants.GEOCACHING_URI)
true
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.arcao.geocaching4locus.settings.widget

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.res.TypedArrayUtils
import androidx.core.view.doOnLayout
import androidx.core.view.updateLayoutParams
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import androidx.preference.R

class PoweredByPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = TypedArrayUtils.getAttr(
context,
R.attr.preferenceStyle,
android.R.attr.preferenceStyle
)
) : Preference(context, attrs, defStyleAttr) {
init {
widgetLayoutResource = com.arcao.geocaching4locus.R.layout.preference_powered_by_widget
}

override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)

(holder.findViewById(android.R.id.icon) as? ImageView)?.let { imageView ->
imageView.maxWidth = Integer.MAX_VALUE
imageView.maxHeight = Integer.MAX_VALUE
}

(holder.findViewById(android.R.id.summary) as? TextView)?.let { textView ->
textView.maxHeight = Integer.MAX_VALUE
}

holder.findViewById(android.R.id.title)?.let { view ->
view.doOnLayout {
holder.findViewById(android.R.id.widget_frame)?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = view.height
}
}
}
}
}

This file was deleted.

Binary file modified app/src/main/res/drawable-hdpi/ic_authorized_developer.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 app/src/main/res/drawable-mdpi/ic_authorized_developer.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 app/src/main/res/drawable-xhdpi/ic_authorized_developer.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 app/src/main/res/drawable-xxhdpi/ic_authorized_developer.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 app/src/main/res/drawable-xxxhdpi/ic_authorized_developer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/src/main/res/layout/preference_powered_by_widget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="16dp"
android:contentDescription="@null"
android:src="@drawable/ic_authorized_developer" />
</FrameLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
<item name="windowFixedWidthMajor">320dp</item>
</style>

<style name="AppTheme.Settings"/>
<style name="AppTheme.Settings">
<item name="preferenceStyle">@style/PreferenceThemeOverlay</item>
</style>

<style name="TextAppearance.AppCompat.Medium.Primary">
<item name="android:textColor">?android:attr/textColorPrimary</item>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/xml/preference_category_accounts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<Preference
app:iconSpaceReserved="false"
app:key="account" />
<com.arcao.geocaching4locus.settings.widget.UnlimitedIconSizePreference
app:icon="@drawable/ic_authorized_developer"
app:key="account_geocaching_live"
<com.arcao.geocaching4locus.settings.widget.PoweredByPreference
app:iconSpaceReserved="false"
app:key="account_powered_by"
app:summary="@string/pref_account_powered_by_summary"
app:title="@string/pref_account_powered_by" />
</androidx.preference.PreferenceScreen>

0 comments on commit 6d4a306

Please sign in to comment.