From daac4eba2e47d877402075f4b050e3e51c1c4957 Mon Sep 17 00:00:00 2001 From: Adamantcheese Date: Wed, 5 Jun 2019 20:04:51 -0700 Subject: [PATCH] Resolves #40 --- .../chan/core/manager/WatchManager.java | 4 ++++ .../chan/core/settings/ChanSettings.java | 2 ++ .../adamantcheese/chan/ui/adapter/DrawerAdapter.java | 12 ++++++++++-- .../chan/ui/controller/WatchSettingsController.java | 3 +++ Kuroba/app/src/main/res/layout/cell_pin.xml | 9 +++++---- Kuroba/app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/manager/WatchManager.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/manager/WatchManager.java index faf9c69732..65e81ea7a3 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/manager/WatchManager.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/manager/WatchManager.java @@ -578,6 +578,10 @@ public PinWatcher(Pin pin) { pageRequestManager.addListener(this); } + public int getReplyCount() { + return posts.size() - 1; + } + public List getUnviewedPosts() { if (posts.isEmpty()) { return posts; diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java index 51ceeea6d1..930431a4f7 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java @@ -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; @@ -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); diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/adapter/DrawerAdapter.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/adapter/DrawerAdapter.java index 675b2305ae..2168988198 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/adapter/DrawerAdapter.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/adapter/DrawerAdapter.java @@ -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; @@ -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( @@ -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 diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/WatchSettingsController.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/WatchSettingsController.java index 98254cb31b..a33a7a52e2 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/WatchSettingsController.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/controller/WatchSettingsController.java @@ -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)); diff --git a/Kuroba/app/src/main/res/layout/cell_pin.xml b/Kuroba/app/src/main/res/layout/cell_pin.xml index 9ed1ab15a1..60ed4265ce 100644 --- a/Kuroba/app/src/main/res/layout/cell_pin.xml +++ b/Kuroba/app/src/main/res/layout/cell_pin.xml @@ -24,16 +24,16 @@ along with this program. If not, see . 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" /> . "Could not remove site %1$s, error message: %2$s Comment body is empty. Something is wrong with this file. + Short bookmark info + Shorter information in the bookmark menu for unread and quoted posts