Skip to content

Commit

Permalink
Resolves #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantcheese committed Jun 6, 2019
1 parent f59d6d9 commit daac4eb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ public PinWatcher(Pin pin) {
pageRequestManager.addListener(this);
}

public int getReplyCount() {
return posts.size() - 1;
}

public List<Post> getUnviewedPosts() {
if (posts.isEmpty()) {
return posts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public Long getTimeoutValue() {

public static final StringSetting postDefaultName;
public static final BooleanSetting postPinThread;
public static final BooleanSetting shortPinInfo;

public static final BooleanSetting developer;

Expand Down Expand Up @@ -218,6 +219,7 @@ public Long getTimeoutValue() {

postDefaultName = new StringSetting(p, "preference_default_name", "");
postPinThread = new BooleanSetting(p, "preference_pin_on_post", false);
shortPinInfo = new BooleanSetting(p, "preference_short_pin_info", true);

developer = new BooleanSetting(p, "preference_developer", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.ItemTouchHelper;
Expand Down Expand Up @@ -234,6 +235,12 @@ public void updateHighlighted(RecyclerView recyclerView) {
}

private void updatePinViewHolder(PinViewHolder holder, Pin pin) {
LinearLayout.LayoutParams newParams = new LinearLayout.LayoutParams(
holder.watchCountText.getLayoutParams().width,
holder.watchCountText.getLayoutParams().height,
ChanSettings.shortPinInfo.get() ? 1.5f : 2.5f);
holder.watchCountText.setLayoutParams(newParams);

CharSequence text = pin.loadable.title;
if (pin.archived) {
BitmapDrawable archivedIcon = new BitmapDrawable(
Expand All @@ -247,9 +254,10 @@ private void updatePinViewHolder(PinViewHolder holder, Pin pin) {
holder.image.setUrl(pin.thumbnailUrl, dp(40), dp(40));

if (ChanSettings.watchEnabled.get()) {
String count = PinHelper.getShortUnreadCount(pin.getNewPostCount());
String newCount = PinHelper.getShortUnreadCount(pin.getNewPostCount());
String totalCount = PinHelper.getShortUnreadCount(watchManager.getPinWatcher(pin).getReplyCount());
holder.watchCountText.setVisibility(View.VISIBLE);
holder.watchCountText.setText(count);
holder.watchCountText.setText(ChanSettings.shortPinInfo.get() ? newCount : totalCount + " / " + newCount);

if (!pin.watching) {
holder.watchCountText.setTextColor(0xff898989); // TODO material colors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public void onPreferenceChange(SettingView item) {
private void populatePreferences() {
SettingsGroup settings = new SettingsGroup(R.string.settings_group_watch);

settings.add(new BooleanSettingView(this, ChanSettings.shortPinInfo,
context.getString(R.string.setting_bookmark_short_info), context.getString(R.string.setting_bookmark_short_info_description)));

// settings.add(new BooleanSettingView(this, ChanSettings.watchCountdown, string(R.string.setting_watch_countdown), string(R.string.setting_watch_countdown_description)));
enableBackground = settings.add(new BooleanSettingView(this, ChanSettings.watchBackground, R.string.setting_watch_enable_background, R.string.setting_watch_enable_background_description));

Expand Down
9 changes: 5 additions & 4 deletions Kuroba/app/src/main/res/layout/cell_pin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:id="@+id/thumb"
android:layout_width="56dp"
android:layout_height="48dp"
android:paddingBottom="4dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="0dp"
android:paddingTop="4dp" />
android:paddingBottom="4dp" />

<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_weight="5"
android:ellipsize="end"
android:gravity="center_vertical"
android:paddingLeft="16dp"
Expand All @@ -44,8 +44,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

<TextView
android:id="@+id/watch_count"
android:layout_width="56dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:paddingRight="16dp"
Expand Down
2 changes: 2 additions & 0 deletions Kuroba/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,6 @@ Don't have a 4chan Pass?<br>
<string name="could_not_remove_site_error_message">"Could not remove site %1$s, error message: %2$s</string>
<string name="reply_comment_empty">Comment body is empty.</string>
<string name="image_reencode_format_error">Something is wrong with this file.</string>
<string name="setting_bookmark_short_info">Short bookmark info</string>
<string name="setting_bookmark_short_info_description">Shorter information in the bookmark menu for unread and quoted posts</string>
</resources>

0 comments on commit daac4eb

Please sign in to comment.