1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-02 18:30:53 +01:00

unlimited faved sticker works

This commit is contained in:
NekoInverter 2020-01-18 14:35:06 +08:00 committed by Riko Sakurauchi
parent 24453b0c83
commit fa55ecaff1
No known key found for this signature in database
GPG Key ID: 25AC0345B92902AF
4 changed files with 46 additions and 22 deletions

View File

@ -65,6 +65,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressWarnings("unchecked")
public class MediaDataController extends BaseController {
@ -289,7 +291,7 @@ public class MediaDataController extends BaseController {
getFileRefController().requestReference(parentObject, req);
}
});
maxCount = getMessagesController().maxFaveStickersCount;
maxCount = NekoConfig.unlimitedFavedStickers ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount;
} else {
maxCount = getMessagesController().maxRecentStickersCount;
}
@ -785,7 +787,7 @@ public class MediaDataController extends BaseController {
maxCount = getMessagesController().maxRecentGifsCount;
} else {
if (type == TYPE_FAVE) {
maxCount = getMessagesController().maxFaveStickersCount;
maxCount = NekoConfig.unlimitedFavedStickers ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount;
} else {
maxCount = getMessagesController().maxRecentStickersCount;
}

View File

@ -24,6 +24,7 @@ public class NekoConfig {
public static boolean hideProxySponsorChannel = false;
public static boolean saveCacheToPrivateDirectory = Build.VERSION.SDK_INT >= 24;
public static float stickerSize = 14.0f;
public static boolean unlimitedFavedStickers = true;
public static boolean showAddToSavedMessages = true;
public static boolean showReport = false;
@ -73,6 +74,7 @@ public class NekoConfig {
editor.putBoolean("newYearEve", newYearEve);
editor.putBoolean("fireworks", fireworks);
editor.putFloat("stickerSize", stickerSize);
editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers);
editor.commit();
} catch (Exception e) {
@ -111,6 +113,7 @@ public class NekoConfig {
newYearEve = preferences.getBoolean("newYearEve", false);
fireworks = preferences.getBoolean("fireworks", false);
stickerSize = preferences.getFloat("stickerSize", 14.0f);
unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false);
configLoaded = true;
}
}
@ -299,6 +302,14 @@ public class NekoConfig {
editor.commit();
}
public static void toggleUnlimitedFavedStickers() {
unlimitedFavedStickers = !unlimitedFavedStickers;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers);
editor.commit();
}
public static void setStickerSize(float size) {
stickerSize = size;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);

View File

@ -61,10 +61,6 @@ public class NekoSettingsActivity extends BaseFragment {
private int rowCount;
private int sensitiveRow;
private int disableFilteringRow;
private int sensitive2Row;
private int connectionRow;
private int ipv6Row;
private int connection2Row;
@ -101,6 +97,11 @@ public class NekoSettingsActivity extends BaseFragment {
private int fireworksRow;
private int needRestartRow;
private int experimentRow;
private int disableFilteringRow;
private int unlimitedFavedStickersRow;
private int experiment2Row;
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
@ -347,6 +348,11 @@ public class NekoSettingsActivity extends BaseFragment {
}));
} else if (position == stickerSizeRow) {
showStickerSizeAlert();
} else if (position == unlimitedFavedStickersRow) {
NekoConfig.toggleUnlimitedFavedStickers();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.unlimitedFavedStickers);
}
}
});
@ -396,9 +402,10 @@ public class NekoSettingsActivity extends BaseFragment {
newYearEveRow = rowCount++;
fireworksRow = rowCount++;
needRestartRow = rowCount++;
sensitiveRow = rowCount++;
experimentRow = rowCount++;
disableFilteringRow = rowCount++;
sensitive2Row = rowCount++;
unlimitedFavedStickersRow = rowCount++;
experiment2Row = rowCount++;
if (notify && listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
@ -671,8 +678,10 @@ public class NekoSettingsActivity extends BaseFragment {
} else if (position == fireworksRow) {
textCell.setTextAndCheck(LocaleController.getString("ShowFireworks", R.string.ShowFireworks), NekoConfig.fireworks, false);
} else if (position == disableFilteringRow) {
textCell.setTextAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), sensitiveEnabled, false);
textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true);
textCell.setEnabled(sensitiveCanChange, null);
} else if (position == unlimitedFavedStickersRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UnlimitedFavoredStickers", R.string.UnlimitedFavoredStickers), LocaleController.getString("UnlimitedFavoredStickersAbout", R.string.UnlimitedFavoredStickersAbout), NekoConfig.unlimitedFavedStickers, true, false);
}
break;
}
@ -686,8 +695,8 @@ public class NekoSettingsActivity extends BaseFragment {
headerCell.setText(LocaleController.getString("Connection", R.string.Connection));
} else if (position == chatRow) {
headerCell.setText(LocaleController.getString("Chat", R.string.Chat));
} else if (position == sensitiveRow) {
headerCell.setText(LocaleController.getString("SensitiveContent", R.string.SensitiveContent));
} else if (position == experimentRow) {
headerCell.setText(LocaleController.getString("Experiment", R.string.Experiment));
}
break;
}
@ -695,8 +704,6 @@ public class NekoSettingsActivity extends BaseFragment {
TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
if (position == needRestartRow) {
cell.setText(LocaleController.getString("SomeItemsNeedRestart", R.string.SomeItemsNeedRestart));
} else if (position == sensitive2Row) {
cell.setText(LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout));
}
break;
}
@ -714,7 +721,8 @@ public class NekoSettingsActivity extends BaseFragment {
position == forceTabletRow || position == mapPreviewRow || position == xmasRow || position == newYearRow ||
position == newYearEveRow || position == fireworksRow || position == transparentStatusBarRow ||
position == hideProxySponsorChannelRow || position == saveCacheToPrivateDirectoryRow ||
(position == disableFilteringRow && sensitiveCanChange) || position == stickerSizeRow;
(position == disableFilteringRow && sensitiveCanChange) || position == stickerSizeRow ||
position == unlimitedFavedStickersRow;
}
@Override
@ -755,7 +763,7 @@ public class NekoSettingsActivity extends BaseFragment {
@Override
public int getItemViewType(int position) {
if (position == messageMenu2Row || position == connection2Row || position == chat2Row) {
if (position == messageMenu2Row || position == connection2Row || position == chat2Row || position == experiment2Row) {
return 1;
} else if (position == nameOrderRow || position == mapPreviewRow || position == stickerSizeRow) {
return 2;
@ -765,12 +773,13 @@ public class NekoSettingsActivity extends BaseFragment {
position == transparentStatusBarRow || position == hideProxySponsorChannelRow || position == showViewHistoryRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
position == forceTabletRow || position == xmasRow || position == newYearRow || position == newYearEveRow ||
position == fireworksRow || position == saveCacheToPrivateDirectoryRow || position == disableFilteringRow) {
position == fireworksRow || position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow ||
position == disableFilteringRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == messageMenuRow ||
position == chatRow || position == sensitiveRow) {
} else if (position == settingsRow || position == connectionRow || position == messageMenuRow || position == chatRow ||
position == experimentRow) {
return 4;
} else if (position == needRestartRow || position == sensitive2Row) {
} else if (position == needRestartRow) {
return 7;
}
return 6;

View File

@ -50,12 +50,14 @@
<string name="ViewHistory">View history</string>
<string name="Nya">Meow!</string>
<string name="SaveCacheToPrivateDirectory">Save cache to private directory*</string>
<string name="SensitiveContent">Sensitive Content</string>
<string name="SensitiveDisableFiltering">Disable filtering</string>
<string name="SensitiveAbout">Display sensitive media in public channels on all your Telegram devices.</string>
<string name="SensitiveDisableFiltering">Disable sensitive content filtering</string>
<string name="SensitiveAbout">Display sensitive media in public channels on all your devices.</string>
<string name="StickerSize">Sticker size</string>
<string name="StickerSizeDialogMessageBigOne">A big one</string>
<string name="StickerSizeDialogMessageSmallOne">A small one</string>
<string name="StickerSizeDialogMessageReplyTo">Meow</string>
<string name="StickerSizeDialogName">Duang</string>
<string name="Experiment">Experimental</string>
<string name="UnlimitedFavoredStickers">Unlimited favored stickers</string>
<string name="UnlimitedFavoredStickersAbout">Add unlimited stickers to favorites. Stickers may not be synchronized to other devices.</string>
</resources>