diff --git a/app/src/main/java/com/tgc/sky/BuildConfig.java b/app/src/main/java/com/tgc/sky/BuildConfig.java index d17a067..0c090c0 100644 --- a/app/src/main/java/com/tgc/sky/BuildConfig.java +++ b/app/src/main/java/com/tgc/sky/BuildConfig.java @@ -6,7 +6,7 @@ public class BuildConfig { public static String SKY_STAGE_NAME = "Live"; public static String SKY_SERVER_HOSTNAME = "live.radiance.thatgamecompany.com"; public static String SKY_VERSION = "0.17.5"; - public static final String SKY_BUILD_ACCESS_KEY = "1743442606-0c9545db24db0fee924a028c500c75f968145e6f15d2535ff2ca414798eba96a"; + public static String SKY_BUILD_ACCESS_KEY = "1743442606-0c9545db24db0fee924a028c500c75f968145e6f15d2535ff2ca414798eba96a"; public static int VERSION_CODE = 192395; } diff --git a/app/src/main/java/git/artdeell/skymodloader/MainActivity.java b/app/src/main/java/git/artdeell/skymodloader/MainActivity.java index 36cc269..6c67769 100644 --- a/app/src/main/java/git/artdeell/skymodloader/MainActivity.java +++ b/app/src/main/java/git/artdeell/skymodloader/MainActivity.java @@ -35,6 +35,7 @@ import git.artdeell.skymodloader.iconloader.IconLoader; public class MainActivity extends Activity { + private static final String DEFAULT_BUILD_KEY = com.tgc.sky.BuildConfig.SKY_BUILD_ACCESS_KEY; private SharedPreferences sharedPreferences; private boolean ceserverEnabled; private boolean hideCanvasMenu; @@ -155,6 +156,16 @@ private void loadGame() { MainActivity.customServer(BuildConfig.SKY_SERVER_HOSTNAME); } + // Custom build access key override + if (sharedPreferences.getBoolean("custom_build_key", false)) { + String customKey = sharedPreferences.getString("build_access_key", ""); + if (customKey != null && !customKey.trim().isEmpty()) { + BuildConfig.SKY_BUILD_ACCESS_KEY = customKey; + } else { + BuildConfig.SKY_BUILD_ACCESS_KEY = DEFAULT_BUILD_KEY; + } + } + new ElfRefcountLoader(libPath + ":/system/lib64", modsDir).load(); BuildConfig.APPLICATION_ID = SKY_PACKAGE_NAME; startActivity(new Intent(this, GameActivity.class)); @@ -277,7 +288,7 @@ private void copyToClipboard(String stackTrace) { // Only show the toast for versions below API level 33 (Android 13) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { - Toast.makeText(this, "Stack trace copied to clipboard", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.stack_trace_copied), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/git/artdeell/skymodloader/elfmod/ModManagerActivity.java b/app/src/main/java/git/artdeell/skymodloader/elfmod/ModManagerActivity.java index 4f13021..d35022e 100644 --- a/app/src/main/java/git/artdeell/skymodloader/elfmod/ModManagerActivity.java +++ b/app/src/main/java/git/artdeell/skymodloader/elfmod/ModManagerActivity.java @@ -3,6 +3,8 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -13,6 +15,7 @@ import android.util.Log; import android.view.View; import android.widget.Button; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -44,6 +47,7 @@ import git.artdeell.skymodloader.updater.VersionNumber; public class ModManagerActivity extends Activity implements LoadingListener, ModUpdater { + private static final String DEFAULT_BUILD_KEY = com.tgc.sky.BuildConfig.SKY_BUILD_ACCESS_KEY; private static final int REQUEST_MOD = 1024 * 121; @SuppressLint("StaticFieldLeak") private static ElfUIBackbone loader; @@ -205,9 +209,15 @@ public void setCustomServer(boolean flag) { } public void setServerUrl(String url) { - sharedPreferences.edit().putString("server_host", url).apply(); + } + + public void setCustomBuildKey(boolean flag) { + sharedPreferences.edit().putBoolean("custom_build_key", flag).apply(); + } + public void setBuildAccessKey(String key) { + sharedPreferences.edit().putString("build_access_key", key).apply(); } public void onAddMod(View v) { @@ -389,6 +399,8 @@ public void onExtraSettingsDialog(View view) { SwitchMaterial enableCeserver = new SwitchMaterial(this); SwitchMaterial enableServer = new SwitchMaterial(this); TextInputEditText serverSelector = new TextInputEditText(this); + SwitchMaterial enableCustomBuildKey = new SwitchMaterial(this); + TextInputEditText buildKeyInput = new TextInputEditText(this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( @@ -423,11 +435,15 @@ public void onExtraSettingsDialog(View view) { enableServer.setLayoutParams(layoutParams); enableServer.setText(R.string.switch_custom_server); enableServer.setChecked(sharedPreferences.getBoolean("custom_server", false)); - enableServer.setOnCheckedChangeListener((buttonView, isChecked) -> setCustomServer(isChecked)); + enableServer.setOnCheckedChangeListener((buttonView, isChecked) -> { + setCustomServer(isChecked); + serverSelector.setEnabled(isChecked); + }); serverSelector.setText(sharedPreferences.getString("server_host", "insert-url")); serverSelector.setSingleLine(true); serverSelector.setImeOptions(EditorInfo.IME_ACTION_DONE); + serverSelector.setEnabled(enableServer.isChecked()); serverSelector.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @@ -440,11 +456,87 @@ public void afterTextChanged(Editable s) { } }); + // Create paste button first so it can be referenced in toggle listener + ImageView pasteButton = new ImageView(this); + pasteButton.setImageResource(R.drawable.content_paste_24); + pasteButton.setPadding(dpToPixels(8), dpToPixels(8), dpToPixels(8), dpToPixels(8)); + pasteButton.setOnClickListener(v -> { + ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboard != null && clipboard.hasPrimaryClip()) { + ClipData clip = clipboard.getPrimaryClip(); + if (clip != null && clip.getItemCount() > 0) { + CharSequence pastedText = clip.getItemAt(0).getText(); + if (pastedText != null) { + buildKeyInput.setText(pastedText); + Toast.makeText(this, getString(R.string.pasted_from_clipboard), Toast.LENGTH_SHORT).show(); + } + } + } + }); + + // Create restore button to reset to default key + ImageView restoreButton = new ImageView(this); + restoreButton.setImageResource(R.drawable.restore_24); + restoreButton.setPadding(dpToPixels(8), dpToPixels(8), dpToPixels(8), dpToPixels(8)); + restoreButton.setOnClickListener(v -> { + buildKeyInput.setText(DEFAULT_BUILD_KEY); + Toast.makeText(this, getString(R.string.restored_default_key), Toast.LENGTH_SHORT).show(); + }); + + enableCustomBuildKey.setTextSize(15); + enableCustomBuildKey.setLayoutParams(layoutParams); + enableCustomBuildKey.setText(R.string.switch_custom_build_key); + enableCustomBuildKey.setChecked(sharedPreferences.getBoolean("custom_build_key", false)); + enableCustomBuildKey.setOnCheckedChangeListener((buttonView, isChecked) -> { + setCustomBuildKey(isChecked); + buildKeyInput.setEnabled(isChecked); + pasteButton.setEnabled(isChecked); + pasteButton.setAlpha(isChecked ? 1.0f : 0.4f); + restoreButton.setEnabled(isChecked); + restoreButton.setAlpha(isChecked ? 1.0f : 0.4f); + }); + + buildKeyInput.setText(sharedPreferences.getString("build_access_key", DEFAULT_BUILD_KEY)); + buildKeyInput.setHint(R.string.build_key_hint); + buildKeyInput.setSingleLine(true); + buildKeyInput.setImeOptions(EditorInfo.IME_ACTION_DONE); + buildKeyInput.setEnabled(enableCustomBuildKey.isChecked()); + pasteButton.setEnabled(enableCustomBuildKey.isChecked()); + pasteButton.setAlpha(enableCustomBuildKey.isChecked() ? 1.0f : 0.4f); + restoreButton.setEnabled(enableCustomBuildKey.isChecked()); + restoreButton.setAlpha(enableCustomBuildKey.isChecked() ? 1.0f : 0.4f); + buildKeyInput.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + @Override + public void afterTextChanged(Editable s) { + String key = s.toString(); + setBuildAccessKey(key); + } + }); + + // Create horizontal layout for build key input + buttons + LinearLayout buildKeyRow = new LinearLayout(this); + buildKeyRow.setOrientation(LinearLayout.HORIZONTAL); + buildKeyRow.setGravity(android.view.Gravity.CENTER_VERTICAL); + + LinearLayout.LayoutParams inputParams = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f); + buildKeyInput.setLayoutParams(inputParams); + + buildKeyRow.addView(buildKeyInput); + buildKeyRow.addView(pasteButton); + buildKeyRow.addView(restoreButton); + dialogY.container.addView(hideCanvasMenu, layoutParams); dialogY.container.addView(bypassUpdate, layoutParams); dialogY.container.addView(enableCeserver, layoutParams); dialogY.container.addView(enableServer, layoutParams); dialogY.container.addView(serverSelector, layoutParams); + dialogY.container.addView(enableCustomBuildKey, layoutParams); + dialogY.container.addView(buildKeyRow, layoutParams); dialogY.dialog.show(); } diff --git a/app/src/main/res/drawable/content_paste_24.xml b/app/src/main/res/drawable/content_paste_24.xml new file mode 100644 index 0000000..2558e61 --- /dev/null +++ b/app/src/main/res/drawable/content_paste_24.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/restore_24.xml b/app/src/main/res/drawable/restore_24.xml new file mode 100644 index 0000000..bb5ecde --- /dev/null +++ b/app/src/main/res/drawable/restore_24.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ff9ad4..c0e3daf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -56,6 +56,11 @@ Bypass Game Updates Enable Cheat Engine Server Enable Custom Server + Use custom build access key + Build access key + Pasted from clipboard + Restored default key + Stack trace copied to clipboard Close mod icon