Skip to content

Commit

Permalink
Merge remote-tracking branch 'target/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed Jan 31, 2024
2 parents 43353aa + 6904dca commit b40a0f8
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 56 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ jobs:
matrix:
flavor:
# - FullRelease
- MiniRelease
- MiniReleaseNoGcm
- MiniDebug
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -320,6 +319,8 @@ jobs:
run: |
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
export DEBUG_BUILD=true
sed '/signingConfig signingConfigs.release/d' TMessagesProj/build.gradle > TMessagesProj/build.gradle.tmp
mv TMessagesProj/build.gradle.tmp TMessagesProj/build.gradle
./gradlew TMessagesProj:assemble${{ matrix.flavor }}
APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk')
Expand Down
3 changes: 3 additions & 0 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ android {
srcDirs "src/main/java", "src/gservcies/java"
}
jni.srcDirs = ["./jni/"]
jniLibs {
srcDir "src/main/libs"
}
manifest {
srcFile "src/gservcies/AndroidManifest.xml"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
import tw.nekomimi.nekogram.utils.ProxyUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.ExternalStickerCacheHelper;

public class LaunchActivity extends BasePermissionsActivity implements INavigationLayout.INavigationLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {
public final static String EXTRA_FORCE_NOT_INTERNAL_APPS = "force_not_internal_apps";
Expand Down Expand Up @@ -1496,6 +1497,8 @@ private void checkCurrentAccount() {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatSwithcedToForum);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesEnabledUpdate);
// Na: [ExternalStickerCache] remove observers
ExternalStickerCacheHelper.removeNotificationObservers(currentAccount);
}
currentAccount = UserConfig.selectedAccount;
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.appDidLogout);
Expand All @@ -1518,6 +1521,8 @@ private void checkCurrentAccount() {
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatSwithcedToForum);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesEnabledUpdate);
// Na: [ExternalStickerCache] add observers
ExternalStickerCacheHelper.addNotificationObservers(currentAccount);
}

private void checkLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
import tw.nekomimi.nekogram.utils.ShareUtil;
import tw.nekomimi.nekogram.utils.StickersUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.ExternalStickerCacheHelper;

public class StickersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {

Expand Down Expand Up @@ -1721,6 +1723,10 @@ protected void onRemoveButtonClick() {
options.add(R.drawable.msg_reorder, LocaleController.getString("StickersReorder", R.string.StickersReorder), () -> processSelectionOption(4, stickerSet));
options.add(R.drawable.msg_share, LocaleController.getString("StickersShare", R.string.StickersShare), () -> processSelectionOption(2, stickerSet));
options.add(R.drawable.msg_delete, LocaleController.getString("StickersRemove", R.string.StickersRemove), true, () -> processSelectionOption(MENU_DELETE, stickerSet));
if (!NaConfig.INSTANCE.getExternalStickerCache().String().isBlank()) {
options.add(R.drawable.menu_views_reposts, LocaleController.getString(R.string.ExternalStickerCacheRefresh), () -> ExternalStickerCacheHelper.refreshCacheFiles(stickerSet));
options.add(R.drawable.msg_delete, LocaleController.getString(R.string.ExternalStickerCacheDelete), () -> ExternalStickerCacheHelper.deleteCacheFiles(stickerSet));
}
}
options.setMinWidth(190);
options.show();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package tw.nekomimi.nekogram.config.cell;

import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.LocaleController;
import org.telegram.ui.Cells.TextSettingsCell;
import tw.nekomimi.nekogram.config.CellGroup;

public class ConfigCellText extends AbstractConfigCell implements WithKey, WithOnClick {
private final String key;
private final String value;
private final Runnable onClick;
private boolean enabled = true;
private TextSettingsCell cell;

public ConfigCellText(String key, String customValue, Runnable onClick) {
this.key = key;
this.value = (customValue == null) ? "" : customValue;
this.onClick = onClick;
}

public ConfigCellText(String key, Runnable onClick) {
this(key, null, onClick);
}

public int getType() {
return CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL;
}

public String getKey() {
return key;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
if (this.cell != null) this.cell.setEnabled(this.enabled);
}

public void onBindViewHolder(RecyclerView.ViewHolder holder) {
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
this.cell = cell;
String title = LocaleController.getString(key);
cell.setTextAndValue(title, value, cellGroup.needSetDivider(this));
cell.setEnabled(enabled);
}

public void onClick() {
if (!enabled) return;
if (onClick != null) {
try {
onClick.run();
} catch (Exception ignored) {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tw.nekomimi.nekogram.config.cell;

public interface WithKey {
String getKey();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tw.nekomimi.nekogram.config.cell;

public interface WithOnClick {
void onClick();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@

import tw.nekomimi.nekogram.config.CellGroup;
import tw.nekomimi.nekogram.config.ConfigItem;
import tw.nekomimi.nekogram.config.cell.AbstractConfigCell;
import tw.nekomimi.nekogram.config.cell.ConfigCellAutoTextCheck;
import tw.nekomimi.nekogram.config.cell.ConfigCellCustom;
import tw.nekomimi.nekogram.config.cell.ConfigCellSelectBox;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextCheck;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextDetail;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextInput;
import tw.nekomimi.nekogram.config.cell.*;

public class BaseNekoXSettingsActivity extends BaseFragment {
protected BlurredRecyclerView listView;
Expand Down Expand Up @@ -79,7 +73,9 @@ protected ConfigItem getBindConfig(AbstractConfigCell row) {
}

protected String getRowKey(AbstractConfigCell row) {
if (row instanceof ConfigCellTextCheck) {
if (row instanceof WithKey) {
return ((WithKey) row).getKey();
} else if (row instanceof ConfigCellTextCheck) {
return ((ConfigCellTextCheck) row).getKey();
} else if (row instanceof ConfigCellSelectBox) {
return ((ConfigCellSelectBox) row).getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.Toast;

Expand All @@ -24,7 +23,6 @@
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
Expand All @@ -41,15 +39,13 @@
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.BlurredRecyclerView;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.UndoView;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Locale;

import kotlin.Unit;

Expand Down Expand Up @@ -108,20 +104,36 @@ public class NekoExperimentalSettingsActivity extends BaseNekoXSettingsActivity
NaConfig.INSTANCE.getExternalStickerCache(), LocaleController.getString(R.string.ExternalStickerCacheHint), this::onExternalStickerCacheButtonClick));
private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider());

private final AbstractConfigCell header3 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString(R.string.ExternalStickerCache)));
private final AbstractConfigCell externalStickerCacheRow = cellGroup.appendCell(new ConfigCellAutoTextCheck(
NaConfig.INSTANCE.getExternalStickerCache(), LocaleController.getString(R.string.ExternalStickerCacheHint), this::onExternalStickerCacheButtonClick));
private final AbstractConfigCell externalStickerCacheAutoSyncRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getExternalStickerCacheAutoRefresh(), LocaleController.getString(R.string.ExternalStickerCacheAutoRefreshHint)));
private final AbstractConfigCell externalStickerCacheDirNameTypeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NaConfig.INSTANCE.getExternalStickerCacheDirNameType(), new String[]{ "Short name", "ID" }, null));
private final AbstractConfigCell externalStickerCacheSyncAllRow = cellGroup.appendCell(new ConfigCellText("ExternalStickerCacheRefreshAll", ExternalStickerCacheHelper::syncAllCaches));
private final AbstractConfigCell externalStickerCacheDeleteAllRow = cellGroup.appendCell(new ConfigCellText("ExternalStickerCacheDeleteAll", ExternalStickerCacheHelper::deleteAllCaches));
private final AbstractConfigCell divider2 = cellGroup.appendCell(new ConfigCellDivider());

private UndoView tooltip;

private static final int INTENT_PICK_CUSTOM_EMOJI_PACK = 114;
private static final int INTENT_PICK_EXTERNAL_STICKER_DIRECTORY = 514;

private void setExternalStickerCacheCellsEnabled(boolean enabled) {
((ConfigCellText) externalStickerCacheSyncAllRow).setEnabled(enabled);
((ConfigCellText) externalStickerCacheDeleteAllRow).setEnabled(enabled);
}

private void refreshExternalStickerStorageState() {
ConfigCellAutoTextCheck cell = (ConfigCellAutoTextCheck) externalStickerCacheRow;
setExternalStickerCacheCellsEnabled(!cell.getBindConfig().String().isEmpty());
Context context = ApplicationLoader.applicationContext;
ExternalStickerCacheHelper.checkUri(cell, context);
}

private void onExternalStickerCacheButtonClick(boolean isChecked) {
if (isChecked) {
// clear config
setExternalStickerCacheCellsEnabled(false);
ConfigCellAutoTextCheck cell = (ConfigCellAutoTextCheck) externalStickerCacheRow;
cell.setSubtitle(null);
NaConfig.INSTANCE.getExternalStickerCache().setConfigString("");
Expand Down Expand Up @@ -179,6 +191,8 @@ public void onItemClick(int id) {
((ConfigCellTextCheck) a).onClick((TextCheckCell) view);
} else if (a instanceof ConfigCellSelectBox) {
((ConfigCellSelectBox) a).onClick(view);
} else if (a instanceof WithOnClick) {
((WithOnClick) a).onClick();
} else if (a instanceof ConfigCellTextInput) {
((ConfigCellTextInput) a).onClick();
} else if (a instanceof ConfigCellAutoTextCheck) {
Expand Down
12 changes: 12 additions & 0 deletions TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,18 @@ object NaConfig {
var externalStickerCacheUri: Uri?
get() = externalStickerCache.String().let { if (it.isBlank()) return null else return Uri.parse(it) }
set(value) = externalStickerCache.setConfigString(value.toString())
val externalStickerCacheAutoRefresh =
addConfig(
"ExternalStickerCacheAutoRefresh",
ConfigItem.configTypeBool,
false
)
val externalStickerCacheDirNameType =
addConfig(
"ExternalStickerCacheDirNameType",
ConfigItem.configTypeInt,
0
)

private fun addConfig(
k: String,
Expand Down
Loading

0 comments on commit b40a0f8

Please sign in to comment.