improved EditTextPreference appearance

WIP: user feedback screen
This commit is contained in:
Mariotaku Lee 2018-02-21 10:19:47 +08:00
parent deadd3a0a8
commit 315ac44363
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
14 changed files with 160 additions and 28 deletions

1
.gitignore vendored
View File

@ -37,4 +37,5 @@ Thumbs.db
# JRE error dumps # JRE error dumps
hs_err_*.log hs_err_*.log
# NDK related
.externalNativeBuild/ .externalNativeBuild/

View File

@ -35,7 +35,7 @@ allprojects {
subprojects { subprojects {
buildscript { buildscript {
ext { ext {
kotlinVersion = '1.2.10' kotlinVersion = '1.2.21'
pluginVersions = [ pluginVersions = [
AndroidSvgDrawable: '3.0.0', AndroidSvgDrawable: '3.0.0',
PlayServices : '3.1.1', PlayServices : '3.1.1',
@ -80,8 +80,8 @@ subprojects {
AbstractTask : '0.9.8', AbstractTask : '0.9.8',
Dagger : '2.11', Dagger : '2.11',
StethoBeanShellREPL : '0.3', StethoBeanShellREPL : '0.3',
ArchLifecycleExtensions: '1.0.0', ArchLifecycleExtensions: '1.1.0',
ArchPaging : '1.0.0-alpha4-1', ArchPaging : '1.0.0-alpha5',
ConstraintLayout : '1.1.0-beta4', ConstraintLayout : '1.1.0-beta4',
MessageBubbleView : '2.1', MessageBubbleView : '2.1',
] ]

View File

@ -65,6 +65,7 @@ public interface IntentConstants {
String INTENT_ACTION_SEND_DIRECT_MESSAGE = INTENT_PACKAGE_PREFIX + "SEND_DIRECT_MESSAGE"; String INTENT_ACTION_SEND_DIRECT_MESSAGE = INTENT_PACKAGE_PREFIX + "SEND_DIRECT_MESSAGE";
String INTENT_ACTION_DISCARD_DRAFT = INTENT_PACKAGE_PREFIX + "DISCARD_DRAFT"; String INTENT_ACTION_DISCARD_DRAFT = INTENT_PACKAGE_PREFIX + "DISCARD_DRAFT";
String INTENT_ACTION_SEND_DRAFT = INTENT_PACKAGE_PREFIX + "SEND_DRAFT"; String INTENT_ACTION_SEND_DRAFT = INTENT_PACKAGE_PREFIX + "SEND_DRAFT";
String INTENT_ACTION_USER_FEEDBACK = INTENT_PACKAGE_PREFIX + "USER_FEEDBACK";
String INTENT_ACTION_PEBBLE_NOTIFICATION = "com.getpebble.action.SEND_NOTIFICATION"; String INTENT_ACTION_PEBBLE_NOTIFICATION = "com.getpebble.action.SEND_NOTIFICATION";

View File

@ -601,6 +601,7 @@
android:theme="@style/Theme.Twidere.NoDisplay"/> android:theme="@style/Theme.Twidere.NoDisplay"/>
<activity <activity
android:name=".activity.presentation.ToggleRefreshActivity" android:name=".activity.presentation.ToggleRefreshActivity"
android:exported="false"
android:label="@string/action_refresh_launch_presentations" android:label="@string/action_refresh_launch_presentations"
android:theme="@style/Theme.Twidere.NoDisplay"> android:theme="@style/Theme.Twidere.NoDisplay">
<intent-filter> <intent-filter>
@ -608,6 +609,16 @@
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".activity.feedback.FeedbackActivity"
android:exported="false"
android:label="@string/title_user_feedback"
android:theme="@style/Theme.Twidere.Content">
<intent-filter>
<action android:name="org.mariotaku.twidere.USER_FEEDBACK"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<service <service
android:name=".service.LegacyTaskService" android:name=".service.LegacyTaskService"

View File

@ -0,0 +1,33 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.activity.feedback
import android.os.Bundle
import org.mariotaku.twidere.R
import org.mariotaku.twidere.activity.BaseActivity
class FeedbackActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_feedback)
}
}

View File

@ -5,9 +5,6 @@ import android.support.v7.widget.RecyclerView.ViewHolder
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import java.util.* import java.util.*
/**
* Created by mariotaku on 14/10/27.
*/
abstract class ArrayRecyclerAdapter<T, H : ViewHolder>( abstract class ArrayRecyclerAdapter<T, H : ViewHolder>(
context: Context, context: Context,
requestManager: RequestManager requestManager: RequestManager
@ -15,15 +12,13 @@ abstract class ArrayRecyclerAdapter<T, H : ViewHolder>(
protected val data = ArrayList<T>() protected val data = ArrayList<T>()
override fun onBindViewHolder(holder: H, position: Int) { override final fun onBindViewHolder(holder: H, position: Int) {
onBindViewHolder(holder, position, getItem(position)) onBindViewHolder(holder, position, getItem(position))
} }
abstract fun onBindViewHolder(holder: H, position: Int, item: T) abstract fun onBindViewHolder(holder: H, position: Int, item: T)
fun add(item: T) {
fun add(item: T?) {
if (item == null) return
data.add(item) data.add(item)
notifyDataSetChanged() notifyDataSetChanged()
} }

View File

@ -35,7 +35,6 @@ import android.view.ViewGroup
import com.google.android.exoplayer2.* import com.google.android.exoplayer2.*
import com.google.android.exoplayer2.extractor.ExtractorsFactory import com.google.android.exoplayer2.extractor.ExtractorsFactory
import com.google.android.exoplayer2.source.ExtractorMediaSource import com.google.android.exoplayer2.source.ExtractorMediaSource
import com.google.android.exoplayer2.source.LoopingMediaSource
import com.google.android.exoplayer2.source.TrackGroupArray import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
@ -332,17 +331,14 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
player.playWhenReady = !pausedByUser player.playWhenReady = !pausedByUser
playerHasError = false playerHasError = false
player.addListener(playerListener) player.addListener(playerListener)
player.repeatMode = if (isLoopEnabled) Player.REPEAT_MODE_ALL else Player.REPEAT_MODE_OFF
return@run player return@run player
} }
val uri = media?.getDownloadUri() ?: return val uri = media?.getDownloadUri() ?: return
val factory = AuthDelegatingDataSourceFactory(uri, account, dataSourceFactory) val factory = AuthDelegatingDataSourceFactory(uri, account, dataSourceFactory)
val uriSource = ExtractorMediaSource(uri, factory, extractorsFactory, null, null) val uriSource = ExtractorMediaSource(uri, factory, extractorsFactory, null, null)
if (isLoopEnabled) { playerView.player.prepare(uriSource)
playerView.player.prepare(LoopingMediaSource(uriSource))
} else {
playerView.player.prepare(uriSource)
}
updateVolume() updateVolume()
} }
@ -361,7 +357,7 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
if (bestVideoUrlAndType != null) { if (bestVideoUrlAndType != null) {
return Uri.parse(bestVideoUrlAndType.first) return Uri.parse(bestVideoUrlAndType.first)
} }
return arguments!!.getParcelable<Uri>(SubsampleImageViewerFragment.EXTRA_MEDIA_URI) return arguments!!.getParcelable(SubsampleImageViewerFragment.EXTRA_MEDIA_URI)
} }

View File

@ -21,8 +21,8 @@ import android.support.v7.preference.EditTextPreference
import android.support.v7.preference.PreferenceDialogFragmentCompat import android.support.v7.preference.PreferenceDialogFragmentCompat
import android.view.View import android.view.View
import android.widget.EditText import android.widget.EditText
import org.mariotaku.chameleon.Chameleon import org.mariotaku.chameleon.Chameleon
import org.mariotaku.chameleon.internal.ColorStateLists
import org.mariotaku.chameleon.view.ChameleonTextView import org.mariotaku.chameleon.view.ChameleonTextView
class ThemedEditTextPreferenceDialogFragmentCompat : ThemedPreferenceDialogFragmentCompat() { class ThemedEditTextPreferenceDialogFragmentCompat : ThemedPreferenceDialogFragmentCompat() {
@ -38,6 +38,7 @@ class ThemedEditTextPreferenceDialogFragmentCompat : ThemedPreferenceDialogFragm
val theme = Chameleon.getOverrideTheme(context, context) val theme = Chameleon.getOverrideTheme(context, context)
editText = view.findViewById(android.R.id.edit) editText = view.findViewById(android.R.id.edit)
val appearance = ChameleonTextView.Appearance.create(editText, context, null, theme) val appearance = ChameleonTextView.Appearance.create(editText, context, null, theme)
appearance.backgroundTintList = ColorStateLists.tintDefault(theme)
ChameleonTextView.Appearance.apply(editText, appearance) ChameleonTextView.Appearance.apply(editText, appearance)
return view return view
} }

View File

@ -31,7 +31,7 @@ interface Response<out Data> {
val extras: Bundle val extras: Bundle
fun hasData(): Boolean fun hasData(): Boolean = data != null
fun hasException(): Boolean fun hasException(): Boolean = exception != null
} }

View File

@ -31,14 +31,6 @@ data class SingleResponse<Data>(
constructor(exception: Exception) : this(null, exception) constructor(exception: Exception) : this(null, exception)
override fun hasData(): Boolean {
return data != null
}
override fun hasException(): Boolean {
return exception != null
}
companion object { companion object {
fun <T> getInstance(): SingleResponse<T> { fun <T> getInstance(): SingleResponse<T> {

View File

@ -0,0 +1,30 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.util
object Logcat {
fun get(filter: String?): String {
val builder = ProcessBuilder("logcat", "-d")
if (filter != null) {
builder.command("-s", filter)
}
return builder.start().inputStream.reader().readText()
}
}

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/element_spacing_normal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/element_spacing_normal"
android:orientation="vertical">
<org.mariotaku.twidere.view.FixedEditText
android:id="@+id/editTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_feedback_title"
android:singleLine="true"
app:backgroundTint="?colorControlStateful"/>
<org.mariotaku.twidere.view.FixedEditText
android:id="@+id/editContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/element_spacing_normal"
android:gravity="top"
android:hint="@string/hint_feedback_content"
android:minLines="3"
android:singleLine="false"
app:backgroundTint="?colorControlStateful"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View File

@ -1391,4 +1391,6 @@
<string name="users_blocked">Blocked these users.</string> <string name="users_blocked">Blocked these users.</string>
<string name="users_lists_with_name"><xliff:g id="name">%s</xliff:g>\'s lists</string> <string name="users_lists_with_name"><xliff:g id="name">%s</xliff:g>\'s lists</string>
<string name="hint_feedback_title">Title</string>
<string name="hint_feedback_content">Leave a comment</string>
</resources> </resources>

View File

@ -39,5 +39,11 @@
<Preference <Preference
android:fragment="org.mariotaku.twidere.fragment.NetworkDiagnosticsFragment" android:fragment="org.mariotaku.twidere.fragment.NetworkDiagnosticsFragment"
android:title="@string/network_diagnostics"/> android:title="@string/network_diagnostics"/>
<Preference
android:title="@string/title_user_feedback">
<intent
android:action="org.mariotaku.twidere.USER_FEEDBACK"
android:targetPackage="org.mariotaku.twidere"/>
</Preference>
</PreferenceScreen> </PreferenceScreen>