mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-25 15:16:01 +00:00
fix copying API token
This commit is contained in:
parent
4454c70d34
commit
1c4313f254
2 changed files with 10 additions and 10 deletions
|
|
@ -95,15 +95,6 @@
|
|||
android:shouldDisableView="false"
|
||||
android:summary="@string/SP_APIToken_summary"
|
||||
android:layout="@layout/preference_child_summary"/>
|
||||
|
||||
<Preference
|
||||
android:key="SP_user_qr_code"
|
||||
android:title="@string/SP_user_qr_code"
|
||||
android:selectable="true"
|
||||
android:persistent="false"
|
||||
android:shouldDisableView="false"
|
||||
android:summary="@string/SP_user_qr_code"
|
||||
android:layout="@layout/preference_child_summary"/>
|
||||
</PreferenceScreen>
|
||||
|
||||
<Preference
|
||||
|
|
|
|||
|
|
@ -8,9 +8,14 @@ import android.widget.Toast
|
|||
import androidx.preference.Preference
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.api.HostConfig
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class APIPreferenceFragment: BasePreferencesFragment() {
|
||||
@Inject
|
||||
lateinit var hostConfig: HostConfig
|
||||
|
||||
private val apiPreferences: List<String>
|
||||
get() = Arrays.asList(getString(R.string.SP_APIToken), getString(R.string.SP_userID))
|
||||
|
||||
|
|
@ -22,7 +27,11 @@ class APIPreferenceFragment: BasePreferencesFragment() {
|
|||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
val clipMan = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, preference.summary)
|
||||
if (preference.key == getString(R.string.SP_APIToken)) {
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, hostConfig.apiKey)
|
||||
} else {
|
||||
clipMan?.primaryClip = ClipData.newPlainText(preference.key, preference.summary)
|
||||
}
|
||||
Toast.makeText(activity, "Copied " + preference.key + " to clipboard.", Toast.LENGTH_SHORT).show()
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue