Skip to content

Commit

Permalink
prepare for stories
Browse files Browse the repository at this point in the history
  • Loading branch information
iTaysonLab committed Apr 17, 2020
1 parent 944cfce commit 078c77b
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.IBinder
import android.os.Looper
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import ua.itaysonlab.hfsdk.FeedCategory
import ua.itaysonlab.hfsdk.FeedItem
import ua.itaysonlab.hfsdk.IFeedInterface
import ua.itaysonlab.hfsdk.IFeedInterfaceCallback
Expand All @@ -32,7 +33,7 @@ object PluginConnector {
override fun onServiceConnected(componentName: ComponentName, iBinder: IBinder) {
Logger.log(TAG, "Connected to service ${componentName.packageName} / ${componentName.className}")
interfaces[componentName.packageName] = IFeedInterface.Stub.asInterface(iBinder)
interfaces[componentName.packageName]!!.getFeed(callbacks[componentName.packageName], 0, null)
interfaces[componentName.packageName]!!.getFeed(callbacks[componentName.packageName], 0, null, null)
}

override fun onServiceDisconnected(componentName: ComponentName) {
Expand Down Expand Up @@ -61,6 +62,10 @@ object PluginConnector {
Logger.log(TAG, "getFeedAsItLoads")

val stub = object: IFeedInterfaceCallback.Stub() {
override fun onCategoriesReceive(categories: MutableList<FeedCategory>?) {

}

override fun onFeedReceive(feed: MutableList<FeedItem>?) {
feed ?: return

Expand All @@ -81,7 +86,7 @@ object PluginConnector {
if (hasInitialized) {
index = 0
interfaces.forEach {
it.value?.getFeed(stub, page, null)
it.value?.getFeed(stub, page, null, null)
}
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ class HFElementPreview @JvmOverloads constructor(
}

private fun bindLayout() {
val not: View = layoutInflater.inflate(if (isCompact) {
R.layout.notification_compact
} else {
R.layout.notification_simple
}, null, false)
val not: View = layoutInflater.inflate(R.layout.feed_card_text, null, false)
view.previewer.addView(not)
bindPreview(not)
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/gradient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http:https://schemas.android.com/apk/res/android">
<gradient android:angle="270" android:startColor="@android:color/transparent" android:endColor="@android:color/black" />
</shape>
88 changes: 88 additions & 0 deletions app/src/main/res/layout/feed_card_story_large.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http:https://schemas.android.com/tools"
android:layout_marginStart="@dimen/rl_margin"
android:layout_marginBottom="8dp"
android:layout_marginEnd="@dimen/rl_margin"
app:cardBackgroundColor="@color/cardBg"
app:cardCornerRadius="8dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:minHeight="160dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/story_pic"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/backgrounds/scenic" />

<View
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/gradient"
android:backgroundTint="?android:windowBackground"
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/story_dimmer" />

<LinearLayout
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textAppearance="@style/TextAppearance.MaterialComponents.Overline"
android:id="@+id/story_source"
android:textSize="16sp"
tools:text="Story Source"
android:textColor="?android:textColorSecondary"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

<LinearLayout
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingBottom="12dp"
android:orientation="vertical"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/story_title"
android:textSize="24sp"
tools:text="Story Title"
android:textStyle="bold"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/story_desc"
android:textSize="16sp"
tools:text="Story Desc"
android:textColor="?android:textColorSecondary"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
56 changes: 20 additions & 36 deletions app/src/main/res/layout/feed_card_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,27 @@
android:layout_marginEnd="@dimen/rl_margin"
app:cardBackgroundColor="@color/cardBg"
app:cardCornerRadius="12dp">
<FrameLayout
<LinearLayout
android:id="@+id/iforeground"
android:paddingTop="@dimen/feed_card_vertical_padding"
android:paddingBottom="@dimen/feed_card_vertical_padding"
android:background="@color/cardBg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/notification_generic_content" />
<HorizontalScrollView
android:id="@+id/button_valley"
android:layout_marginTop="4dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ibackground"
android:padding="12dp"
android:background="@drawable/remove_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ibg_icon"
android:layout_marginStart="12dp"
android:layout_width="wrap_content"
android:src="@drawable/ic_delete_24"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/iforeground"
android:paddingTop="@dimen/feed_card_vertical_padding"
android:paddingBottom="@dimen/feed_card_vertical_padding"
android:background="@color/cardBg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/notification_generic_content" />
<HorizontalScrollView
android:id="@+id/button_valley"
android:layout_marginTop="4dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/button_valley_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</LinearLayout>
</FrameLayout>
android:id="@+id/button_valley_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
33 changes: 0 additions & 33 deletions app/src/main/res/layout/notification_compact.xml

This file was deleted.

109 changes: 0 additions & 109 deletions app/src/main/res/layout/notification_media.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<dimen name="dialog_rounding">8dp</dimen>
<dimen name="preview_height">140dp</dimen>

<dimen name="feed_card_horizontal_padding">18dp</dimen>
<dimen name="feed_card_horizontal_padding">12dp</dimen>
<dimen name="feed_card_vertical_padding">12dp</dimen>
</resources>

0 comments on commit 078c77b

Please sign in to comment.