diff --git a/twidere/build.gradle b/twidere/build.gradle index c02d4ad23..a70aebd44 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -91,7 +91,6 @@ dependencies { kapt 'com.hannesdorfmann.parcelableplease:processor:1.0.2' kapt 'com.google.dagger:dagger-compiler:2.8' kapt 'com.github.mariotaku.ObjectCursor:processor:0.9.12' - kapt 'nz.bradcampbell:paperparcel-compiler:2.0.0-beta2' compile project(':twidere.component.common') compile project(':twidere.component.nyan') @@ -179,7 +178,6 @@ dependencies { compile 'nl.komponents.kovenant:kovenant-android:3.3.0' compile 'nl.komponents.kovenant:kovenant-functional:3.3.0' compile 'nl.komponents.kovenant:kovenant-combine:3.3.0' - compile 'nz.bradcampbell:paperparcel:2.0.0-beta2' } task svgToDrawable(type: SvgDrawableTask) { diff --git a/twidere/src/google/kotlin/org/mariotaku/twidere/activity/GooglePlayInAppPurchaseActivity.kt b/twidere/src/google/kotlin/org/mariotaku/twidere/activity/GooglePlayInAppPurchaseActivity.kt index 39e4913a5..c24aee931 100644 --- a/twidere/src/google/kotlin/org/mariotaku/twidere/activity/GooglePlayInAppPurchaseActivity.kt +++ b/twidere/src/google/kotlin/org/mariotaku/twidere/activity/GooglePlayInAppPurchaseActivity.kt @@ -15,6 +15,7 @@ import nl.komponents.kovenant.ui.successUi import org.mariotaku.twidere.Constants import org.mariotaku.twidere.activity.premium.AbsExtraFeaturePurchaseActivity import org.mariotaku.twidere.fragment.ProgressDialogFragment +import org.mariotaku.twidere.model.premium.PurchaseResult import org.mariotaku.twidere.util.premium.GooglePlayExtraFeaturesService import java.lang.ref.WeakReference @@ -82,7 +83,10 @@ class GooglePlayInAppPurchaseActivity : AbsExtraFeaturePurchaseActivity(), } private fun handlePurchased(sku: SkuDetails, transaction: TransactionDetails) { - val result = PurchaseResult(requestingFeature, sku.priceValue, sku.currency) + val result = PurchaseResult() + result.feature = requestingFeature + result.price = sku.priceValue + result.currency = sku.currency finishWithResult(result) } diff --git a/twidere/src/main/AndroidManifest.xml b/twidere/src/main/AndroidManifest.xml index 428c6b3dc..0d3fdeb74 100644 --- a/twidere/src/main/AndroidManifest.xml +++ b/twidere/src/main/AndroidManifest.xml @@ -297,7 +297,7 @@ CREATOR = new Creator() { + public PurchaseResult createFromParcel(Parcel source) { + PurchaseResult target = new PurchaseResult(); + PurchaseResultParcelablePlease.readFromParcel(target, source); + return target; + } + + public PurchaseResult[] newArray(int size) { + return new PurchaseResult[size]; + } + }; +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/model/tab/TabConfiguration.java b/twidere/src/main/java/org/mariotaku/twidere/model/tab/TabConfiguration.java index 23e37d9aa..0c7c86b07 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/model/tab/TabConfiguration.java +++ b/twidere/src/main/java/org/mariotaku/twidere/model/tab/TabConfiguration.java @@ -132,6 +132,8 @@ public abstract class TabConfiguration { private final String key; private StringHolder title; @Nullable + private StringHolder summary; + @Nullable private StringHolder headerTitle; private int position; private boolean mutable; @@ -155,16 +157,35 @@ public abstract class TabConfiguration { this.title = title; } + @Nullable + public StringHolder getSummary() { + return summary; + } + + public void setSummary(@Nullable StringHolder summary) { + this.summary = summary; + } + public ExtraConfiguration title(StringHolder title) { setTitle(title); return this; } + public ExtraConfiguration summary(StringHolder summary) { + setSummary(summary); + return this; + } + public ExtraConfiguration title(@StringRes int titleRes) { setTitle(StringHolder.resource(titleRes)); return this; } + public ExtraConfiguration summary(@StringRes int summaryRes) { + setSummary(StringHolder.resource(summaryRes)); + return this; + } + @Nullable public StringHolder getHeaderTitle() { return headerTitle; diff --git a/twidere/src/main/java/org/mariotaku/twidere/model/tab/impl/InteractionsTabConfiguration.java b/twidere/src/main/java/org/mariotaku/twidere/model/tab/impl/InteractionsTabConfiguration.java index 10b5e6347..dc0a39ab7 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/model/tab/impl/InteractionsTabConfiguration.java +++ b/twidere/src/main/java/org/mariotaku/twidere/model/tab/impl/InteractionsTabConfiguration.java @@ -119,14 +119,19 @@ public class InteractionsTabConfiguration extends TabConfiguration { final View view = getView(); final CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox); final TextView titleView = (TextView) view.findViewById(android.R.id.title); + final TextView summaryView = (TextView) view.findViewById(android.R.id.summary); view.setEnabled(hasOfficial); titleView.setEnabled(hasOfficial); + summaryView.setEnabled(hasOfficial); checkBox.setEnabled(hasOfficial); if (hasOfficial) { checkBox.setChecked(valueBackup); + summaryView.setVisibility(View.GONE); } else { valueBackup = checkBox.isChecked(); checkBox.setChecked(true); + summaryView.setText(R.string.summary_interactions_not_available); + summaryView.setVisibility(View.VISIBLE); } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java b/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java deleted file mode 100644 index ef04e0440..000000000 --- a/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Twidere - Twitter client for Android - * - * Copyright (C) 2012-2014 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.preference; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.support.annotation.NonNull; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceViewHolder; -import android.support.v7.widget.RecyclerView; -import android.util.AttributeSet; - -import org.mariotaku.twidere.R; -import org.mariotaku.twidere.adapter.DummyItemAdapter; -import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable; -import org.mariotaku.twidere.view.holder.StatusViewHolder; -import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder; - -import static org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME; - -public class CardPreviewPreference extends Preference implements OnSharedPreferenceChangeListener { - - private StatusViewHolder mHolder; - private DummyItemAdapter mAdapter; - - public CardPreviewPreference(final Context context) { - this(context, null); - } - - public CardPreviewPreference(final Context context, final AttributeSet attrs) { - this(context, attrs, 0); - } - - public CardPreviewPreference(final Context context, final AttributeSet attrs, final int defStyle) { - super(context, attrs, defStyle); - final SharedPreferences preferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, - Context.MODE_PRIVATE); - setLayoutResource(R.layout.layout_preferences_card_preview_compact); - preferences.registerOnSharedPreferenceChangeListener(this); - mAdapter = new DummyItemAdapter(context); - } - - @Override - public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) { - mAdapter.updateOptions(); - mHolder = null; - notifyChanged(); - } - - @Override - public void onBindViewHolder(PreferenceViewHolder holder) { - if (mHolder == null) { - mHolder = new StatusViewHolder(mAdapter, holder.itemView); - } - mHolder.setupViewOptions(); - mHolder.displaySampleStatus(); - mHolder.setStatusClickListener(new IStatusViewHolder.SimpleStatusClickListener() { - @Override - public void onItemActionClick(@NonNull RecyclerView.ViewHolder holder, int id, int position) { - if (id == R.id.favorite) { - ((StatusViewHolder) holder).playLikeAnimation(new LikeAnimationDrawable.OnLikedListener() { - @Override - public boolean onLiked() { - return false; - } - }); - } - } - }); - super.onBindViewHolder(holder); - } - -} diff --git a/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.kt b/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.kt new file mode 100644 index 000000000..b9c99ca73 --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/preference/CardPreviewPreference.kt @@ -0,0 +1,76 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2014 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.preference + +import android.content.Context +import android.content.SharedPreferences +import android.content.SharedPreferences.OnSharedPreferenceChangeListener +import android.support.v7.preference.Preference +import android.support.v7.preference.PreferenceViewHolder +import android.support.v7.widget.RecyclerView +import android.util.AttributeSet +import org.mariotaku.twidere.R +import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME +import org.mariotaku.twidere.adapter.DummyItemAdapter +import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable +import org.mariotaku.twidere.view.holder.StatusViewHolder +import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder + +class CardPreviewPreference( + context: Context, + attrs: AttributeSet? = null +) : Preference(context, attrs), OnSharedPreferenceChangeListener { + + private var holder: StatusViewHolder? = null + private val adapter: DummyItemAdapter = DummyItemAdapter(context) + + init { + val preferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, + Context.MODE_PRIVATE) + layoutResource = R.layout.layout_preferences_card_preview_compact + preferences.registerOnSharedPreferenceChangeListener(this) + } + + override fun onSharedPreferenceChanged(preferences: SharedPreferences, key: String) { + adapter.updateOptions() + holder = null + notifyChanged() + } + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + if (this.holder == null) { + this.holder = StatusViewHolder(adapter, holder.itemView).apply { + setStatusClickListener(object : IStatusViewHolder.StatusClickListener { + override fun onItemActionClick(holder: RecyclerView.ViewHolder, id: Int, position: Int) { + if (id == R.id.favorite) { + (holder as StatusViewHolder).playLikeAnimation(LikeAnimationDrawable.OnLikedListener { false }) + } + } + }) + } + } + this.holder?.let { + it.setupViewOptions() + it.displaySampleStatus() + } + super.onBindViewHolder(holder) + } + +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java index 1c04434ca..ff5a34568 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java @@ -169,7 +169,12 @@ public class ThemeUtils implements Constants { } public static Drawable getSelectableItemBackgroundDrawable(final Context context) { - final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.selectableItemBackground}); + return getDrawableFromThemeAttribute(context, android.R.attr.selectableItemBackground); + } + + + public static Drawable getDrawableFromThemeAttribute(final Context context, int attr) { + final TypedArray a = context.obtainStyledAttributes(new int[]{attr}); try { return a.getDrawable(0); } finally { diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ShortTimeView.java b/twidere/src/main/java/org/mariotaku/twidere/view/ShortTimeView.java index 63f7e42d3..f37482d7e 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/ShortTimeView.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/ShortTimeView.java @@ -23,15 +23,12 @@ import android.content.Context; import android.os.Handler; import android.os.SystemClock; import android.support.v7.widget.AppCompatTextView; -import android.text.format.DateUtils; import android.util.AttributeSet; import org.mariotaku.twidere.Constants; -import org.mariotaku.twidere.R; import java.lang.ref.WeakReference; -import static android.text.format.DateUtils.getRelativeTimeSpanString; import static org.mariotaku.twidere.util.Utils.formatSameDayTime; public class ShortTimeView extends AppCompatTextView implements Constants { @@ -83,10 +80,10 @@ public class ShortTimeView extends AppCompatTextView implements Constants { } else { final long current = System.currentTimeMillis(); if (Math.abs(current - mTime) > 60 * 1000) { - setText(getRelativeTimeSpanString(mTime, System.currentTimeMillis(), - DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)); +// setText(getRelativeTimeSpanString(mTime, System.currentTimeMillis(), +// DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)); } else { - setText(R.string.just_now); +// setText(R.string.just_now); } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt index 03868edbf..f840da85f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt @@ -94,7 +94,8 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallb import org.mariotaku.twidere.view.HomeDrawerLayout import org.mariotaku.twidere.view.TabPagerIndicator -class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, SupportFragmentCallback, OnLongClickListener, DrawerLayout.DrawerListener { +class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, SupportFragmentCallback, + OnLongClickListener, DrawerLayout.DrawerListener { private val accountUpdatedListener = AccountUpdatedListener(this) @@ -338,7 +339,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp drawerToggle = ActionBarDrawerToggle(this, homeMenu, R.string.open_accounts_dashboard, R.string.close_accounts_dashboard) homeContent.setOnFitSystemWindowsListener(this) - pagerAdapter = SupportTabsAdapter(this, supportFragmentManager, mainTabs, tabColumns) + pagerAdapter = SupportTabsAdapter(this, supportFragmentManager, mainTabs) mainPager.adapter = pagerAdapter mainTabs.setViewPager(mainPager) mainTabs.setOnPageChangeListener(this) @@ -533,7 +534,6 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp } override fun onDestroy() { - stopService(Intent(this, StreamingService::class.java)) // Delete unused items in databases. @@ -795,12 +795,14 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp val hasNoTab = pagerAdapter.count == 0 emptyTabHint.visibility = if (hasNoTab) View.VISIBLE else View.GONE mainPager.visibility = if (hasNoTab) View.GONE else View.VISIBLE - if (pagerAdapter.getPageWidth(0) < 1) { + if (resources.getBoolean(R.bool.home_tab_has_multiple_columns)) { mainPager.pageMargin = resources.getDimensionPixelOffset(R.dimen.home_page_margin) - mainPager.setPageMarginDrawable(R.color.home_page_margin_color) + mainPager.setPageMarginDrawable(ThemeUtils.getDrawableFromThemeAttribute(this, R.attr.dividerVertical)) + pagerAdapter.pageWidth = resources.getDimension(R.dimen.preferred_tab_column_width) / resources.displayMetrics.widthPixels } else { mainPager.pageMargin = 0 mainPager.setPageMarginDrawable(null) + pagerAdapter.pageWidth = 1f } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/LinkHandlerActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/LinkHandlerActivity.kt index 236e4fb6c..cb667caba 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/LinkHandlerActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/LinkHandlerActivity.kt @@ -34,6 +34,7 @@ import android.text.TextUtils import android.view.KeyEvent import android.view.MenuItem import android.view.Window +import kotlinx.android.synthetic.main.activity_link_handler.* import org.mariotaku.kpreferences.get import org.mariotaku.ktextension.convert import org.mariotaku.ktextension.set @@ -65,7 +66,8 @@ import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallb import org.mariotaku.twidere.util.Utils.LINK_ID_FILTERS_IMPORT_BLOCKS import org.mariotaku.twidere.util.Utils.matchLinkId -class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IControlBarActivity, SupportFragmentCallback { +class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IControlBarActivity, + SupportFragmentCallback { private lateinit var multiSelectHandler: MultiSelectEventHandler private lateinit var controlBarShowHideHelper: ControlBarShowHideHelper @@ -74,17 +76,15 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro private var subtitle: CharSequence? = null private var hideOffsetNotSupported: Boolean = false - override val currentVisibleFragment: Fragment? - get() { - return supportFragmentManager.findFragmentById(android.R.id.content) - } + get() = supportFragmentManager.findFragmentByTag("content_fragment") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) multiSelectHandler = MultiSelectEventHandler(this) controlBarShowHideHelper = ControlBarShowHideHelper(this) multiSelectHandler.dispatchOnCreate() + val uri = intent.data val linkId = matchLinkId(uri) intent.setExtrasClassLoader(classLoader) @@ -107,17 +107,26 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro return } + val contentFragmentId: Int + if (fragment is IToolBarSupportFragment) { if (!fragment.setupWindow(this)) { supportRequestWindowFeature(Window.FEATURE_NO_TITLE) supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY) } + contentFragmentId = android.R.id.content + } else { + setContentView(R.layout.activity_link_handler) + toolbar?.let { toolbar -> + setSupportActionBar(toolbar) + } + contentFragmentId = R.id.contentFragment } setupActionBarOption() Utils.logOpenNotificationFromUri(this, uri) val ft = supportFragmentManager.beginTransaction() - ft.replace(android.R.id.content, fragment) + ft.replace(contentFragmentId, fragment, "content_fragment") ft.commit() setTitle(linkId, uri) finishOnly = java.lang.Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt index b7c30ff15..8736d063c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt @@ -2,11 +2,9 @@ package org.mariotaku.twidere.activity.premium import android.content.Context import android.content.Intent -import android.os.Parcel -import android.os.Parcelable import org.mariotaku.twidere.activity.BaseActivity import org.mariotaku.twidere.constant.IntentConstants -import paperparcel.PaperParcel +import org.mariotaku.twidere.model.premium.PurchaseResult /** * Created by mariotaku on 2017/1/8. @@ -25,19 +23,6 @@ abstract class AbsExtraFeaturePurchaseActivity : BaseActivity() { finish() } - @PaperParcel - data class PurchaseResult(val feature: String, val price: Double, val currency: String) : Parcelable { - companion object { - @JvmField val CREATOR = PaperParcelAbsExtraFeaturePurchaseActivity_PurchaseResult.CREATOR - } - - override fun describeContents() = 0 - - override fun writeToParcel(dest: Parcel, flags: Int) { - PaperParcelAbsExtraFeaturePurchaseActivity_PurchaseResult.writeToParcel(this, dest, flags) - } - } - companion object { const val RESULT_SERVICE_UNAVAILABLE = 1 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt index da691c8da..ebe543cd7 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt @@ -361,6 +361,8 @@ class ParcelableActivitiesAdapter( fun onStatusClick(holder: IStatusViewHolder, position: Int) + fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) + } internal class StubViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { @@ -417,29 +419,28 @@ class ParcelableActivitiesAdapter( override fun onStatusClick(holder: IStatusViewHolder, position: Int) { val adapter = adapterRef.get() ?: return - if (adapter.activityAdapterListener != null) { - adapter.activityAdapterListener!!.onStatusClick(holder, position) - } + adapter.activityAdapterListener?.onStatusClick(holder, position) + } + + + override fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) { + val adapter = adapterRef.get() ?: return + adapter.activityAdapterListener?.onQuotedStatusClick(holder, position) } override fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) { val adapter = adapterRef.get() ?: return - if (adapter.activityAdapterListener != null) { - adapter.activityAdapterListener!!.onMediaClick(holder, view, media, statusPosition) - } + adapter.activityAdapterListener?.onMediaClick(holder, view, media, statusPosition) } override fun onActivityClick(holder: ActivityTitleSummaryViewHolder, position: Int) { val adapter = adapterRef.get() ?: return - if (adapter.activityAdapterListener == null) return - adapter.activityAdapterListener!!.onActivityClick(holder, position) + adapter.activityAdapterListener?.onActivityClick(holder, position) } override fun onItemMenuClick(holder: RecyclerView.ViewHolder, menuView: View, position: Int) { val adapter = adapterRef.get() ?: return - if (adapter.activityAdapterListener != null) { - adapter.activityAdapterListener!!.onStatusMenuClick(holder as StatusViewHolder, menuView, position) - } + adapter.activityAdapterListener?.onStatusMenuClick(holder as StatusViewHolder, menuView, position) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SupportTabsAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SupportTabsAdapter.kt index 302c8a721..88bd2ea77 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SupportTabsAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SupportTabsAdapter.kt @@ -41,8 +41,7 @@ import java.util.* class SupportTabsAdapter @JvmOverloads constructor( private val context: Context, fm: FragmentManager, - private val indicator: PagerIndicator? = null, - private val columns: Int = 1 + private val indicator: PagerIndicator? = null ) : SupportFixedFragmentStatePagerAdapter(fm), TabProvider, TabListener { private val tab = ArrayList() @@ -92,7 +91,7 @@ class SupportTabsAdapter @JvmOverloads constructor( } override fun getPageWidth(position: Int): Float { - return 1.0f / columns + return pageWidth } override fun getItem(position: Int): Fragment { @@ -153,4 +152,6 @@ class SupportTabsAdapter @JvmOverloads constructor( private val EXTRA_ADAPTER_POSITION = "adapter_position" } + + var pageWidth: Float = 1f } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/ContentCardClickListener.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/ContentCardClickListener.kt index 0017de5fd..fa142141f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/ContentCardClickListener.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/ContentCardClickListener.kt @@ -26,7 +26,7 @@ import android.view.View * Created by mariotaku on 14/12/3. */ interface ContentCardClickListener { - fun onItemActionClick(holder: ViewHolder, id: Int, position: Int) + fun onItemActionClick(holder: ViewHolder, id: Int, position: Int) {} - fun onItemMenuClick(holder: ViewHolder, menuView: View, position: Int) + fun onItemMenuClick(holder: ViewHolder, menuView: View, position: Int) {} } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/IGapSupportedAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/IGapSupportedAdapter.kt index b6be59a30..2c885d003 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/IGapSupportedAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/iface/IGapSupportedAdapter.kt @@ -37,13 +37,12 @@ interface IGapSupportedAdapter { interface GapClickListener { - fun onGapClick(holder: GapViewHolder, position: Int) + fun onGapClick(holder: GapViewHolder, position: Int) {} } companion object { - - val ITEM_VIEW_TYPE_GAP = 1 + const val ITEM_VIEW_TYPE_GAP = 1 } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/ParcelableStatusExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/ParcelableStatusExtensions.kt index f496a7cf8..fa4fab3dc 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/ParcelableStatusExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/ParcelableStatusExtensions.kt @@ -6,4 +6,5 @@ import org.mariotaku.twidere.model.ParcelableStatus * Created by mariotaku on 2017/1/7. */ val ParcelableStatus.media_type: Int - get() = media?.firstOrNull()?.type ?: 0 \ No newline at end of file + get() = media?.firstOrNull()?.type ?: 0 + diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt index 84abc7884..9c3ce2431 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt @@ -358,6 +358,11 @@ abstract class AbsActivitiesFragment protected constructor() : IntentUtils.openStatus(context, status, null) } + override fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) { + val status = getActivityStatus(position) ?: return + IntentUtils.openStatus(context, status.account_key, status.quoted_id) + } + private fun getActivityStatus(position: Int): ParcelableStatus? { return adapter.getActivity(position)?.getActivityStatus() } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt index 487ff4da8..08f5502f3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt @@ -399,7 +399,13 @@ abstract class AbsStatusesFragment protected constructor() : } override fun onStatusClick(holder: IStatusViewHolder, position: Int) { - IntentUtils.openStatus(activity, adapter.getStatus(position)!!, null) + val status = adapter.getStatus(position) ?: return + IntentUtils.openStatus(activity, status, null) + } + + override fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) { + val status = adapter.getStatus(position) ?: return + IntentUtils.openStatus(activity, status.account_key, status.quoted_id) } override fun onStatusLongClick(holder: IStatusViewHolder, position: Int): Boolean { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt index 1e8612881..85885ad27 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt @@ -45,7 +45,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) val activity = activity - pagerAdapter = SupportTabsAdapter(activity, childFragmentManager, null, 1) + pagerAdapter = SupportTabsAdapter(activity, childFragmentManager, null) viewPager.adapter = pagerAdapter viewPager.offscreenPageLimit = 2 viewPager.addOnPageChangeListener(this) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ItemsListFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ItemsListFragment.kt index 911c9e215..42d59d40c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ItemsListFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ItemsListFragment.kt @@ -46,12 +46,17 @@ class ItemsListFragment : AbsContentListRecyclerViewFragment(context) { + class StatusActivitySummaryLoader( + context: Context, + private val accountKey: UserKey, + private val statusId: String + ) : AsyncTaskLoader(context) { override fun loadInBackground(): StatusActivity? { val context = context - val details = AccountUtils.getAccountDetails(AccountManager.get(context), mAccountKey, true) ?: return null + val details = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?: return null if (AccountType.TWITTER != details.type) { return null } - val twitter = MicroBlogAPIFactory.getInstance(context, mAccountKey) ?: return null + val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?: return null val paging = Paging() paging.setCount(10) - val activitySummary = StatusActivity(mStatusId, emptyList()) + val activitySummary = StatusActivity(statusId, emptyList()) val retweeters = ArrayList() try { - for (status in twitter.getRetweets(mStatusId, paging)) { - val user = ParcelableUserUtils.fromUser(status.user, mAccountKey) + for (status in twitter.getRetweets(statusId, paging)) { + val user = ParcelableUserUtils.fromUser(status.user, accountKey) if (!DataStoreUtils.isFilteringUser(context, user.key.toString())) { retweeters.add(user) } } activitySummary.retweeters = retweeters val countValues = ContentValues() - val status = twitter.showStatus(mStatusId) + val status = twitter.showStatus(statusId) activitySummary.favoriteCount = status.favoriteCount activitySummary.retweetCount = status.retweetCount activitySummary.replyCount = status.replyCount @@ -2093,7 +2102,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks= statusAdapter.itemCount || childPos < 0) return false val itemType = statusAdapter.getItemType(childPos) when (itemType) { - StatusAdapter.ITEM_IDX_REPLY_LOAD_MORE, StatusAdapter.ITEM_IDX_REPLY_ERROR, StatusAdapter.ITEM_IDX_SPACE -> return false + StatusAdapter.ITEM_IDX_REPLY_LOAD_MORE, StatusAdapter.ITEM_IDX_REPLY_ERROR, + StatusAdapter.ITEM_IDX_SPACE -> return false } return true } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt index 5eeb478be..d92765bb8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt @@ -315,7 +315,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener, followContainer.follow.compoundDrawablePadding = Math.round(followContainer.follow.textSize * 0.25f) followingYouIndicator.visibility = if (userRelationship.followed_by) View.VISIBLE else View.GONE - val resolver = context.contentResolver + val resolver = context.applicationContext.contentResolver task { resolver.insert(CachedUsers.CONTENT_URI, ParcelableUserValuesCreator.create(user)) resolver.insert(CachedRelationships.CONTENT_URI, ParcelableRelationshipValuesCreator.create(userRelationship)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserMediaTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserMediaTimelineFragment.kt index c7b333336..e56b3dfc5 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserMediaTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserMediaTimelineFragment.kt @@ -137,7 +137,13 @@ class UserMediaTimelineFragment : AbsContentRecyclerViewFragment, itemView: View) favoriteButton.setOnClickListener(eventListener) mediaLabel.setOnClickListener(eventListener) + + quotedView.setOnClickListener(eventListener) } @@ -577,6 +579,9 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) holder.itemContent -> { listener.onStatusClick(holder, position) } + holder.quotedView -> { + listener.onQuotedStatusClick(holder, position) + } holder.itemMenu -> { listener.onItemMenuClick(holder, v, position) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/iface/IStatusViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/iface/IStatusViewHolder.kt index 6c4228c17..a6e8c304f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/iface/IStatusViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/iface/IStatusViewHolder.kt @@ -19,10 +19,8 @@ package org.mariotaku.twidere.view.holder.iface -import android.support.v7.widget.RecyclerView import android.view.View import android.widget.ImageView - import org.mariotaku.twidere.adapter.iface.ContentCardClickListener import org.mariotaku.twidere.adapter.iface.IGapSupportedAdapter import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable @@ -30,7 +28,6 @@ import org.mariotaku.twidere.model.ParcelableMedia import org.mariotaku.twidere.model.ParcelableStatus import org.mariotaku.twidere.model.UserKey import org.mariotaku.twidere.view.CardMediaContainer -import org.mariotaku.twidere.view.holder.GapViewHolder /** * Created by mariotaku on 15/10/26. @@ -55,42 +52,15 @@ interface IStatusViewHolder : CardMediaContainer.OnMediaClickListener { interface StatusClickListener : ContentCardClickListener, IGapSupportedAdapter.GapClickListener { - fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) + fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) {} - fun onStatusClick(holder: IStatusViewHolder, position: Int) + fun onStatusClick(holder: IStatusViewHolder, position: Int) {} - fun onStatusLongClick(holder: IStatusViewHolder, position: Int): Boolean + fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) {} - fun onUserProfileClick(holder: IStatusViewHolder, position: Int) + fun onStatusLongClick(holder: IStatusViewHolder, position: Int): Boolean = false + + fun onUserProfileClick(holder: IStatusViewHolder, position: Int) {} } - abstract class SimpleStatusClickListener : StatusClickListener { - override fun onMediaClick(holder: IStatusViewHolder, view: View, media: ParcelableMedia, statusPosition: Int) { - - } - - override fun onStatusClick(holder: IStatusViewHolder, position: Int) { - - } - - override fun onStatusLongClick(holder: IStatusViewHolder, position: Int): Boolean { - return false - } - - override fun onGapClick(holder: GapViewHolder, position: Int) { - - } - - override fun onUserProfileClick(holder: IStatusViewHolder, position: Int) { - - } - - override fun onItemActionClick(holder: RecyclerView.ViewHolder, id: Int, position: Int) { - - } - - override fun onItemMenuClick(holder: RecyclerView.ViewHolder, menuView: View, position: Int) { - - } - } } diff --git a/twidere/src/main/res/layout-w600dp/activity_link_handler.xml b/twidere/src/main/res/layout-w600dp/activity_link_handler.xml new file mode 100644 index 000000000..4fde6b528 --- /dev/null +++ b/twidere/src/main/res/layout-w600dp/activity_link_handler.xml @@ -0,0 +1,34 @@ + + + + + + + + + + \ No newline at end of file diff --git a/twidere/src/main/res/layout/activity_link_handler.xml b/twidere/src/main/res/layout/activity_link_handler.xml new file mode 100644 index 000000000..9c5ee07d4 --- /dev/null +++ b/twidere/src/main/res/layout/activity_link_handler.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/twidere/src/main/res/layout/layout_extra_config_checkbox.xml b/twidere/src/main/res/layout/layout_extra_config_checkbox.xml index a1fe50a6d..fdf6e197e 100644 --- a/twidere/src/main/res/layout/layout_extra_config_checkbox.xml +++ b/twidere/src/main/res/layout/layout_extra_config_checkbox.xml @@ -30,17 +30,35 @@ android:orientation="horizontal" tools:ignore="Overdraw"> - + android:minHeight="48dp" + android:orientation="vertical"> + + + + + + android:visibility="gone" + tools:visibility="visible"/> \ No newline at end of file diff --git a/twidere/src/main/res/layout/list_item_status.xml b/twidere/src/main/res/layout/list_item_status.xml index d5040bd3f..63778733e 100644 --- a/twidere/src/main/res/layout/list_item_status.xml +++ b/twidere/src/main/res/layout/list_item_status.xml @@ -223,6 +223,8 @@ android:layout_height="wrap_content" android:layout_below="@+id/mediaPreview" android:layout_marginTop="@dimen/element_spacing_small" + android:background="?selectableItemBackground" + android:clickable="true" android:paddingBottom="@dimen/element_spacing_small" android:paddingEnd="@dimen/element_spacing_small" android:paddingLeft="@dimen/element_spacing_normal" diff --git a/twidere/src/main/res/values-land/bools.xml b/twidere/src/main/res/values-land/bools.xml index 71902be94..7027f7a8c 100644 --- a/twidere/src/main/res/values-land/bools.xml +++ b/twidere/src/main/res/values-land/bools.xml @@ -2,6 +2,5 @@ true - true \ No newline at end of file diff --git a/twidere/src/main/res/values-notnight/themes_daynight.xml b/twidere/src/main/res/values-notnight/themes_daynight.xml index d7cdaeb84..938c5580a 100644 --- a/twidere/src/main/res/values-notnight/themes_daynight.xml +++ b/twidere/src/main/res/values-notnight/themes_daynight.xml @@ -5,7 +5,7 @@ + + + \ No newline at end of file diff --git a/twidere/src/main/res/values-w820dp/dimens.xml b/twidere/src/main/res/values-w820dp/dimens.xml index 58e25d3c7..0cc34c2eb 100644 --- a/twidere/src/main/res/values-w820dp/dimens.xml +++ b/twidere/src/main/res/values-w820dp/dimens.xml @@ -22,4 +22,5 @@ (such as screen margins) for screens with more than 820dp of available width. This would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> 64dp + @dimen/settings_panel_width_entries diff --git a/twidere/src/main/res/values/bools.xml b/twidere/src/main/res/values/bools.xml index 437dda85e..26cfa20fb 100644 --- a/twidere/src/main/res/values/bools.xml +++ b/twidere/src/main/res/values/bools.xml @@ -3,7 +3,9 @@ false false - false false + + false + \ No newline at end of file diff --git a/twidere/src/main/res/values/dimens.xml b/twidere/src/main/res/values/dimens.xml index 3ccbce39a..184bb8c11 100644 --- a/twidere/src/main/res/values/dimens.xml +++ b/twidere/src/main/res/values/dimens.xml @@ -10,6 +10,8 @@ 42dp 36dp + + 2dp 4dp 6dp @@ -24,6 +26,10 @@ -12dp -16dp -24dp + + + 420dp + 56dp 42dp 48dp diff --git a/twidere/src/main/res/values/dimens_system.xml b/twidere/src/main/res/values/dimens_system.xml new file mode 100644 index 000000000..93b4e411d --- /dev/null +++ b/twidere/src/main/res/values/dimens_system.xml @@ -0,0 +1,16 @@ + + + + + 100% + + 100% + + 80% + + 100% + \ 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 19656a528..6ca1aec31 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -903,4 +903,5 @@ Invalid subscription URL Subscription + Only available with official keys \ No newline at end of file diff --git a/twidere/src/main/res/values/themes.xml b/twidere/src/main/res/values/themes.xml index a21404714..dcd7e33f5 100644 --- a/twidere/src/main/res/values/themes.xml +++ b/twidere/src/main/res/values/themes.xml @@ -11,10 +11,9 @@ @style/Theme.Twidere.Light.Dialog - - + - - +