Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
import java.nio.charset.StandardCharsets;

import de.robv.android.xposed.XposedBridge;
import ps.reso.instaeclipse.R;
import ps.reso.instaeclipse.utils.feature.FeatureFlags;
import ps.reso.instaeclipse.utils.i18n.I18n;

public class ConfigManager {

// Import meta config from clipboard
public static void importConfigFromClipboard(Context context) {

android.app.ProgressDialog progress = new android.app.ProgressDialog(context);
progress.setMessage("Importing config...");
progress.setMessage(I18n.t(context, R.string.ig_config_importing));
progress.setCancelable(false);
progress.show();

Expand Down Expand Up @@ -54,14 +56,14 @@ public static void importConfigFromClipboard(Context context) {

new Handler(Looper.getMainLooper()).post(() -> {
progress.dismiss();
Toast.makeText(context, "✅ Imported into mc_overrides.json", Toast.LENGTH_LONG).show();
Toast.makeText(context, I18n.t(context, R.string.ig_config_import_success), Toast.LENGTH_LONG).show();
XposedBridge.log("InstaEclipse | ✅ JSON imported from clipboard into mc_overrides.json");
});
} catch (Exception e) {
XposedBridge.log("InstaEclipse | ❌ Clipboard import failed: " + e.getMessage());
new Handler(Looper.getMainLooper()).post(() -> {
progress.dismiss();
Toast.makeText(context, "❌ Failed to import config", Toast.LENGTH_LONG).show();
Toast.makeText(context, I18n.t(context, R.string.ig_config_import_failed), Toast.LENGTH_LONG).show();
});
} finally {
// 100% guarantee the flag is OFF after an attempt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

import ps.reso.instaeclipse.R;

public class JsonExportActivity extends Activity {

private static final int SAVE_JSON_FILE = 5678;
Expand All @@ -27,7 +29,7 @@ private void openJsonSaver() {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/json");
intent.putExtra(Intent.EXTRA_TITLE, "mc_overrides_exported.json");
intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.ig_config_export_file_name));
startActivityForResult(intent, SAVE_JSON_FILE);
}

Expand All @@ -36,36 +38,36 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SAVE_JSON_FILE && resultCode == RESULT_OK && data != null) {
Uri uri = data.getData();
if (uri == null) {
Toast.makeText(this, "❌ Invalid URI", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.ig_config_invalid_uri), Toast.LENGTH_SHORT).show();
finish();
return;
}

new Handler(Looper.getMainLooper()).postDelayed(() -> {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard == null || !clipboard.hasPrimaryClip()) {
Toast.makeText(this, "❌ Clipboard is empty.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_clipboard_empty), Toast.LENGTH_LONG).show();
finish();
return;
}

ClipData clipData = clipboard.getPrimaryClip();
if (clipData == null || clipData.getItemCount() == 0) {
Toast.makeText(this, "❌ Clipboard has no data.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_clipboard_no_data), Toast.LENGTH_LONG).show();
finish();
return;
}

CharSequence text = clipData.getItemAt(0).getText();
if (text == null || text.length() == 0) {
Toast.makeText(this, "❌ Clipboard text is empty.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_clipboard_text_empty), Toast.LENGTH_LONG).show();
finish();
return;
}

String json = text.toString().trim();
if (!json.startsWith("{") || !json.endsWith("}")) {
Toast.makeText(this, "❌ Clipboard does not contain valid JSON.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_clipboard_invalid_json), Toast.LENGTH_LONG).show();
finish();
return;
}
Expand All @@ -74,10 +76,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
assert outputStream != null;
outputStream.write(json.getBytes(StandardCharsets.UTF_8));
outputStream.flush();
Toast.makeText(this, "✅ JSON exported successfully.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_export_success), Toast.LENGTH_LONG).show();

} catch (Exception e) {
Toast.makeText(this, "❌ Failed to save file: " + e.getMessage(), Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_failed_save_file, e.getMessage()), Toast.LENGTH_LONG).show();
}

finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

import ps.reso.instaeclipse.R;
import ps.reso.instaeclipse.utils.feature.FeatureFlags;

public class JsonImportActivity extends Activity {
Expand All @@ -30,7 +31,7 @@ private void openJsonPicker() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/json");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Select JSON Config"), PICK_JSON_FILE);
startActivityForResult(Intent.createChooser(intent, getString(R.string.ig_config_select_json)), PICK_JSON_FILE);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Expand All @@ -50,16 +51,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//Toast.makeText(this, "Config copied, returning to import…", Toast.LENGTH_SHORT).show();
} else {
FeatureFlags.isImportingConfig = false;
Toast.makeText(this, "❌ Not a valid JSON file", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_not_valid_json), Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
FeatureFlags.isImportingConfig = false; // <- make sure we reset on error
Toast.makeText(this, "❌ Failed to read file: " + e.getMessage(), Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.ig_config_failed_read_file, e.getMessage()), Toast.LENGTH_LONG).show();
}
} else {
// User pressed back / cancelled
FeatureFlags.isImportingConfig = false; // <- ensure OFF on cancel
Toast.makeText(this, "Cancelled or no file selected", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.ig_config_cancelled_no_file), Toast.LENGTH_SHORT).show();
}
}
finish(); // Done, return to Instagram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import ps.reso.instaeclipse.R;
import ps.reso.instaeclipse.Xposed.Module;
import ps.reso.instaeclipse.mods.devops.config.ConfigManager;
import ps.reso.instaeclipse.mods.ui.utils.BottomSheetHookUtil;
Expand All @@ -24,6 +25,7 @@
import ps.reso.instaeclipse.utils.feature.FeatureFlags;
import ps.reso.instaeclipse.utils.feature.FeatureStatusTracker;
import ps.reso.instaeclipse.utils.ghost.GhostModeUtils;
import ps.reso.instaeclipse.utils.i18n.I18n;
import ps.reso.instaeclipse.utils.toast.CustomToast;

public class UIHookManager {
Expand Down Expand Up @@ -110,7 +112,7 @@ public void onGlobalLayout() {
messageList.scrollBy(0, 100); // scroll back down

FeatureFlags.isGhostSeen = true;
Toast.makeText(activity, "✅ Message was marked as read", Toast.LENGTH_SHORT).show();
Toast.makeText(activity, I18n.t(activity, R.string.ig_toast_message_marked_read), Toast.LENGTH_SHORT).show();

}, 300);

Expand Down Expand Up @@ -158,7 +160,7 @@ protected void afterHookedMethod(MethodHookParam param) {
CustomToast.toastShown = true;

new Handler(Looper.getMainLooper()).postDelayed(() -> {
StringBuilder sb = new StringBuilder("InstaEclipse Loaded 🎯\n");
StringBuilder sb = new StringBuilder(I18n.t(activity, R.string.ig_toast_instaeclipse_loaded) + "\n");
for (Map.Entry<String, Boolean> entry : FeatureStatusTracker.getStatus().entrySet()) {
sb.append(entry.getValue() ? "✅ " : "❌ ").append(entry.getKey()).append("\n");
}
Expand Down
Loading