fix issues in android studio, like new file to file

This commit is contained in:
Jordan 2025-03-31 06:18:05 -07:00
parent ac9df75e84
commit 2c7928daaa
3 changed files with 14 additions and 25 deletions

View File

@ -28,6 +28,7 @@ react {
// codegenDir = file("../../node_modules/@react-native/codegen") // codegenDir = file("../../node_modules/@react-native/codegen")
// the sub-project for whisper-native // the sub-project for whisper-native
// whisper_android = file("$root/whisper-android/")
/* Variants */ /* Variants */
// The list of variants to that are debuggable. For those we're going to // The list of variants to that are debuggable. For those we're going to

View File

@ -13,34 +13,18 @@ import com.whispertflite.engine.WhisperEngine;
public class NativeWhisperModule extends NativeLocalStorageSpec { public class NativeWhisperModule extends NativeLocalStorageSpec {
public static final String NAME = "NativeLocalStorage"; public static final String NAME = "NativeLocalStorage";
private WhisperEngineNative mNativeEngine;
public NativeLocalStorageModule(ReactApplicationContext reactContext) { public NativeWhisperModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
mNativeEngine = new WhisperEngineNative(reactContext);
} }
@Override @Override
public String getName() { public void loadWhisper(String path) {}
return NAME;
}
@Override @Override
public void setItem(String value, String key) { public void translate(String text, String language) {
SharedPreferences sharedPref = getReactApplicationContext().getSharedPreferences("my_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(key, value);
editor.apply();
}
@Override
public String getItem(String key) {
SharedPreferences sharedPref = getReactApplicationContext().getSharedPreferences("my_prefs", Context.MODE_PRIVATE);
String username = sharedPref.getString(key, null);
return username;
}
@Override
public void removeItem(String key) {
SharedPreferences sharedPref = getReactApplicationContext().getSharedPreferences("my_prefs", Context.MODE_PRIVATE);
sharedPref.edit().remove(key).apply();
} }
} }

View File

@ -1,5 +1,5 @@
pluginManagement { pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString()) includeBuild(file(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString())
} }
plugins { id("com.facebook.react.settings") } plugins { id("com.facebook.react.settings") }
@ -26,13 +26,17 @@ rootProject.name = 'translation-terrace'
dependencyResolutionManagement { dependencyResolutionManagement {
versionCatalogs { versionCatalogs {
reactAndroidLibs { reactAndroidLibs {
from(files(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../gradle/libs.versions.toml"))) from(files(file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../gradle/libs.versions.toml")))
} }
} }
} }
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle"); apply from: file(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules() useExpoModules()
include ':whisper-android'
project(':whisper-android').projectDir = file(rootProject.projectDir, '../whisper_native')
include ':app' include ':app'
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile()) includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())