From 315ac443632abd5e7eb47b6f79cd0dfe178a4f38 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 21 Feb 2018 10:19:47 +0800 Subject: [PATCH] improved EditTextPreference appearance WIP: user feedback screen --- .gitignore | 1 + build.gradle | 6 +- .../twidere/constant/IntentConstants.java | 1 + twidere/src/main/AndroidManifest.xml | 11 ++++ .../activity/feedback/FeedbackActivity.kt | 33 ++++++++++ .../twidere/adapter/ArrayRecyclerAdapter.kt | 9 +-- .../fragment/media/ExoPlayerPageFragment.kt | 10 +-- ...dEditTextPreferenceDialogFragmentCompat.kt | 3 +- .../org/mariotaku/twidere/model/Response.kt | 4 +- .../mariotaku/twidere/model/SingleResponse.kt | 8 --- .../org/mariotaku/twidere/util/Logcat.kt | 30 +++++++++ .../src/main/res/layout/activity_feedback.xml | 64 +++++++++++++++++++ twidere/src/main/res/values/strings.xml | 2 + .../src/main/res/xml/preferences_other.xml | 6 ++ 14 files changed, 160 insertions(+), 28 deletions(-) create mode 100644 twidere/src/main/kotlin/org/mariotaku/twidere/activity/feedback/FeedbackActivity.kt create mode 100644 twidere/src/main/kotlin/org/mariotaku/twidere/util/Logcat.kt create mode 100644 twidere/src/main/res/layout/activity_feedback.xml diff --git a/.gitignore b/.gitignore index 86eb59537..651d6524b 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ Thumbs.db # JRE error dumps hs_err_*.log +# NDK related .externalNativeBuild/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3b2af0521..e2b03a4b1 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ allprojects { subprojects { buildscript { ext { - kotlinVersion = '1.2.10' + kotlinVersion = '1.2.21' pluginVersions = [ AndroidSvgDrawable: '3.0.0', PlayServices : '3.1.1', @@ -80,8 +80,8 @@ subprojects { AbstractTask : '0.9.8', Dagger : '2.11', StethoBeanShellREPL : '0.3', - ArchLifecycleExtensions: '1.0.0', - ArchPaging : '1.0.0-alpha4-1', + ArchLifecycleExtensions: '1.1.0', + ArchPaging : '1.0.0-alpha5', ConstraintLayout : '1.1.0-beta4', MessageBubbleView : '2.1', ] diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/IntentConstants.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/IntentConstants.java index 412d7ae6e..8c4bdbdf9 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/IntentConstants.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/constant/IntentConstants.java @@ -65,6 +65,7 @@ public interface IntentConstants { 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_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"; diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml index 9aa100661..24a4b2921 100644 --- a/twidere/src/main/AndroidManifest.xml +++ b/twidere/src/main/AndroidManifest.xml @@ -601,6 +601,7 @@ android:theme="@style/Theme.Twidere.NoDisplay"/> @@ -608,6 +609,16 @@ + + + + + + + * + * 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 . + */ + +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) + } + +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ArrayRecyclerAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ArrayRecyclerAdapter.kt index a8c76f52d..b6044222e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ArrayRecyclerAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ArrayRecyclerAdapter.kt @@ -5,9 +5,6 @@ import android.support.v7.widget.RecyclerView.ViewHolder import com.bumptech.glide.RequestManager import java.util.* -/** - * Created by mariotaku on 14/10/27. - */ abstract class ArrayRecyclerAdapter( context: Context, requestManager: RequestManager @@ -15,15 +12,13 @@ abstract class ArrayRecyclerAdapter( protected val data = ArrayList() - override fun onBindViewHolder(holder: H, position: Int) { + override final fun onBindViewHolder(holder: H, position: Int) { onBindViewHolder(holder, position, getItem(position)) } abstract fun onBindViewHolder(holder: H, position: Int, item: T) - - fun add(item: T?) { - if (item == null) return + fun add(item: T) { data.add(item) notifyDataSetChanged() } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt index eec6a712c..6e5a80ba3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt @@ -35,7 +35,6 @@ import android.view.ViewGroup import com.google.android.exoplayer2.* import com.google.android.exoplayer2.extractor.ExtractorsFactory 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.trackselection.AdaptiveTrackSelection import com.google.android.exoplayer2.trackselection.DefaultTrackSelector @@ -332,17 +331,14 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment(SubsampleImageViewerFragment.EXTRA_MEDIA_URI) + return arguments!!.getParcelable(SubsampleImageViewerFragment.EXTRA_MEDIA_URI) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/preference/ThemedEditTextPreferenceDialogFragmentCompat.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/preference/ThemedEditTextPreferenceDialogFragmentCompat.kt index 1e67a465a..46e893289 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/preference/ThemedEditTextPreferenceDialogFragmentCompat.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/preference/ThemedEditTextPreferenceDialogFragmentCompat.kt @@ -21,8 +21,8 @@ import android.support.v7.preference.EditTextPreference import android.support.v7.preference.PreferenceDialogFragmentCompat import android.view.View import android.widget.EditText - import org.mariotaku.chameleon.Chameleon +import org.mariotaku.chameleon.internal.ColorStateLists import org.mariotaku.chameleon.view.ChameleonTextView class ThemedEditTextPreferenceDialogFragmentCompat : ThemedPreferenceDialogFragmentCompat() { @@ -38,6 +38,7 @@ class ThemedEditTextPreferenceDialogFragmentCompat : ThemedPreferenceDialogFragm val theme = Chameleon.getOverrideTheme(context, context) editText = view.findViewById(android.R.id.edit) val appearance = ChameleonTextView.Appearance.create(editText, context, null, theme) + appearance.backgroundTintList = ColorStateLists.tintDefault(theme) ChameleonTextView.Appearance.apply(editText, appearance) return view } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/Response.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/Response.kt index cfe3921cc..c71958f64 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/Response.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/Response.kt @@ -31,7 +31,7 @@ interface Response { val extras: Bundle - fun hasData(): Boolean + fun hasData(): Boolean = data != null - fun hasException(): Boolean + fun hasException(): Boolean = exception != null } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/SingleResponse.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/SingleResponse.kt index eb8423b0a..28e83bcfc 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/SingleResponse.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/SingleResponse.kt @@ -31,14 +31,6 @@ data class SingleResponse( constructor(exception: Exception) : this(null, exception) - override fun hasData(): Boolean { - return data != null - } - - override fun hasException(): Boolean { - return exception != null - } - companion object { fun getInstance(): SingleResponse { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/Logcat.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/Logcat.kt new file mode 100644 index 000000000..04364ea4f --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/Logcat.kt @@ -0,0 +1,30 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2018 Mariotaku Lee + * + * 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 . + */ + +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() + } +} \ No newline at end of file diff --git a/twidere/src/main/res/layout/activity_feedback.xml b/twidere/src/main/res/layout/activity_feedback.xml new file mode 100644 index 000000000..c596a03b2 --- /dev/null +++ b/twidere/src/main/res/layout/activity_feedback.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index bdb33c8ba..bf53055eb 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -1391,4 +1391,6 @@ Blocked these users. %s\'s lists + Title + Leave a comment diff --git a/twidere/src/main/res/xml/preferences_other.xml b/twidere/src/main/res/xml/preferences_other.xml index d4b254bc9..1c610f94d 100644 --- a/twidere/src/main/res/xml/preferences_other.xml +++ b/twidere/src/main/res/xml/preferences_other.xml @@ -39,5 +39,11 @@ + + + \ No newline at end of file