diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/experience/adapter/AppGridAdapter.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/experience/adapter/AppGridAdapter.java index 4e436b324687e1a0cd2ca396896d55ff7728639d..3dab84353d90fe59db0e2e7afca24c5d083ef0f3 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/experience/adapter/AppGridAdapter.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/experience/adapter/AppGridAdapter.java @@ -84,8 +84,7 @@ public class AppGridAdapter extends DelegateAdapter.Adapter private UserInfoAdapter infoAdapter; private Uri imageUri; + private String picturePath; @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(AccountChangedEvent event) { @@ -139,13 +139,9 @@ public class AccountInfoActivity extends BaseActivity MyToast.MakeText(getString(R.string.get_avatar_not_image), 1000); return; } - Log.d(TAG, "GALLERY picturePath: " + picturePath); uploadImage(picturePath); cursor.close(); } else if (requestCode == RESULT_LOAD_IMAGE_BY_CAMERA) { - Log.d(TAG, "CAMERA imageUri: " + imageUri.toString()); - String picturePath = UriUtils.getFilePathFromUri(imageUri, this); - Log.d(TAG, "CAMERA picturePath: " + picturePath); uploadImage(picturePath); } else { Log.e(TAG, "onActivityResult requestCode is error"); @@ -263,6 +259,8 @@ public class AccountInfoActivity extends BaseActivity } catch (IOException e) { e.printStackTrace(); } + picturePath = outputImage.getAbsolutePath(); + if (Build.VERSION.SDK_INT < 24) { imageUri = Uri.fromFile(outputImage); } else { @@ -270,7 +268,7 @@ public class AccountInfoActivity extends BaseActivity getPackageName() + ".fileprovider", outputImage); } // 启动相机程序 - Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, RESULT_LOAD_IMAGE_BY_CAMERA); } diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java index 1ba7cb9dc613e42980576ea9b780203ac92b1488..8bfb2661fad0d11c34553e85274ac3fee129db5a 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/java/com/mindspore/himindspore/ui/me/PersonalFragment.java @@ -219,8 +219,7 @@ public class PersonalFragment extends BaseFragment implements startActivity(new Intent(getActivity(), SetActivity.class)); break; case id.per_space_layout: - startIntentUserInformation(); - break; +// startIntentUserInformation(); case id.per_dynamic_number: case id.per_dynamic: MyToast.FunctionNoOpen(); diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/lesson_cache.png b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/lesson_cache.png new file mode 100644 index 0000000000000000000000000000000000000000..6f72b30c1137db6850c875ad90206ca71ed0abf4 Binary files /dev/null and b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/lesson_cache.png differ diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cached.png b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/lesson_cached.png similarity index 100% rename from model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cached.png rename to model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/lesson_cached.png diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cache.png b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cache.png index 6f72b30c1137db6850c875ad90206ca71ed0abf4..bf7deb0d15b55549935140318f508465c135f193 100644 Binary files a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cache.png and b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/per_cache.png differ diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/trend_likes.png b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/trend_likes.png index b7703fa02ef5740de2fecdc8f4ee268e3dd9f3a3..510cc3d0b901d33a317f3c12408fe909ccca932a 100644 Binary files a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/trend_likes.png and b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/drawable-xxhdpi/trend_likes.png differ diff --git a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml index 85d257ccb2c5c404d671382a2894f06ef663460a..67329cfeba5f9a53944b28cbb049e5fa5d3a87be 100644 --- a/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml +++ b/model_zoo/official/lite/MindSpore_inhand/app/src/main/res/layout/activity_lessons.xml @@ -161,7 +161,7 @@ android:id="@+id/cache_icon" android:layout_width="21dp" android:layout_height="21dp" - android:background="@drawable/per_cache" + android:background="@drawable/lesson_cache" android:layout_gravity="center_horizontal"/> + app:topImageView="@drawable/lesson_cache" /> 喜欢 缓存中 已缓存 + 创建文件夹失败 问题反馈 GITEE代码 官方网站 diff --git a/model_zoo/official/lite/MindSpore_inhand/common/build.gradle b/model_zoo/official/lite/MindSpore_inhand/common/build.gradle index 861c6dd42c26f29ca5de6a97c60ed3b06e4de51e..fc94c9bc9b0e74d3d32dfaf52840c3a9fcd208fd 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/build.gradle +++ b/model_zoo/official/lite/MindSpore_inhand/common/build.gradle @@ -17,9 +17,15 @@ android { } buildTypes { + debug { + minifyEnabled config.android.minifyEnabled + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + buildConfigField "String", "serverUrl", "\"http://172.100.21.248:8888/\"" + } release { minifyEnabled config.android.minifyEnabled proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + buildConfigField "String", "serverUrl", "\"http://124.70.210.216:8888/\"" } } compileOptions { diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java index 266e73d5bfde9230372ad89d4e2203bea2d3b5f5..d26b95654d865c3a8395ff34539dbf7a103522d1 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/config/StorageUtils.java @@ -17,9 +17,9 @@ public class StorageUtils { public static final String CRASH_PATH = Environment.getExternalStorageDirectory().getPath() + "/MindSpore/CrashLog/"; - public static final String VIDEO_DOWNLOAD_PATH = - Environment.getExternalStorageDirectory().getPath() + "/" - + Environment.DIRECTORY_DOWNLOADS + "/" + APP_NAME + "/"; + public static final String VIDEO_DOWNLOAD_PATH_NAME = VIDEO_PATH + APP_NAME; + + public static final String VIDEO_DOWNLOAD_PATH = VIDEO_DOWNLOAD_PATH_NAME + "/"; public static final File ABSOLUTE_FILE = Environment.getExternalStorageDirectory() .getAbsoluteFile(); diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/net/HttpUtils.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/net/HttpUtils.java index b8f56b6ef2254dbe58632d61b3689dd17bbc4ee2..c0ce0569ed8a30ec552f599837fc9baf4a4d4fe8 100644 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/net/HttpUtils.java +++ b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/net/HttpUtils.java @@ -40,8 +40,8 @@ public class HttpUtils { private Context context; public final static String API_APP = "https://download.mindspore.cn/model_zoo/official/lite/apk/"; - - public final static String API_DATA = "http://124.70.210.216:8888/"; //cong + public final static String API_DATA = BuildConfig.serverUrl; +// public final static String API_DATA = "http://124.70.210.216:8888/"; //cong // public final static String API_DATA = "http://192.168.0.155:8888/"; //kang // public final static String API_DATA = "http://172.100.24.218:8888/"; //kang // public final static String API_DATA = "http://172.100.21.248:8888/"; // weiqi diff --git a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/UriUtils.java b/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/UriUtils.java deleted file mode 100644 index ee3d22962df502e3947bbfe84f5f6273992aee08..0000000000000000000000000000000000000000 --- a/model_zoo/official/lite/MindSpore_inhand/common/src/main/java/com/mindspore/common/utils/UriUtils.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.mindspore.common.utils; - -import android.content.ContentResolver; -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; -import android.provider.MediaStore; -import android.text.TextUtils; -import android.util.Log; - -import com.mindspore.common.config.StorageUtils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -public class UriUtils { - private static final String TAG = UriUtils.class.getSimpleName(); - - public static String getFilePathFromUri(Uri uri, Context context) { - if (uri == null) { - return null; - } - switch (uri.getScheme()) { - case "content": - return getFileFromContentUri(uri, context); - case "file": - return uri.getPath(); - default: - return null; - } - } - - - /** - * Gets the corresponding path to a file from the given content:// URI - * - * @param contentUri The content:// URI to find the file path from - * @return the file path as a string - */ - - private static String getFileFromContentUri(Uri contentUri, Context context) { - if (contentUri == null) { - return null; - } - File file = null; - String filePath = ""; - String fileName; - String[] filePathColumn = {MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DISPLAY_NAME}; - ContentResolver contentResolver = context.getContentResolver(); - Cursor cursor = contentResolver.query(contentUri, filePathColumn, null, - null, null); - if (cursor != null) { - cursor.moveToFirst(); - int index = cursor.getColumnIndex(filePathColumn[0]); - if (index >= 0) { - filePath = cursor.getString(index); - } - fileName = cursor.getString(cursor.getColumnIndex(filePathColumn[1])); - cursor.close(); - if (!TextUtils.isEmpty(filePath)) { - file = new File(filePath); - if (!file.exists() || file.length() <= 0) { - filePath = getPathFromInputStreamUri(context, contentUri, fileName); - } - } else { - filePath = getPathFromInputStreamUri(context, contentUri, fileName); - } - } - return filePath; - } - - /** - * 用流拷贝文件一份到自己APP目录下 - * - * @param context - * @param uri - * @param fileName - * @return - */ - public static String getPathFromInputStreamUri(Context context, Uri uri, String fileName) { - InputStream inputStream = null; - String filePath = null; - - if (uri.getAuthority() != null) { - try { - inputStream = context.getContentResolver().openInputStream(uri); - File file = createTemporalFileFrom(context, inputStream, fileName); - filePath = file.getPath(); - - } catch (Exception e) { - Log.e(TAG, e.getMessage()); - } finally { - try { - if (inputStream != null) { - inputStream.close(); - } - } catch (Exception e) { - Log.e(TAG, e.getMessage()); - } - } - } - - return filePath; - } - - private static File createTemporalFileFrom(Context context, InputStream inputStream, String fileName) - throws IOException { - File targetFile = null; - - if (inputStream != null) { - int read; - byte[] buffer = new byte[8 * 1024]; - //自己定义拷贝文件路径 - targetFile = new File(StorageUtils.CRASH_PATH, fileName); - if (targetFile.exists()) { - targetFile.delete(); - } - OutputStream outputStream = new FileOutputStream(targetFile); - - while ((read = inputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, read); - } - outputStream.flush(); - - try { - outputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - return targetFile; - } -} \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/config.gradle b/model_zoo/official/lite/MindSpore_inhand/config.gradle index 36c859ede75545d4e994f5836fa890f6cde866c9..f16f1871132fd089a2df34bc801f7f3a6695a23b 100644 --- a/model_zoo/official/lite/MindSpore_inhand/config.gradle +++ b/model_zoo/official/lite/MindSpore_inhand/config.gradle @@ -41,11 +41,11 @@ ext { camera_view : "1.0.0-alpha25", camera_extensions : "1.0.0-alpha25", huawei_hms_segmentation : "2.2.0.300", - huawei_hms_ocr : "2.0.5.300", + huawei_hms_ocr : "2.0.5.301", huawei_hms_skeleton : "2.0.4.300", huawei_hms_scenedetection: "2.0.3.300", - huawei_hms_handkeypoint : "2.1.0.300", - huawei_hms_translate : "2.2.0.300", + huawei_hms_handkeypoint : "3.1.0.301", + huawei_hms_translate : "3.0.0.300", recyclerview : "1.1.0", core : "1.5.0-alpha05", junit : "4.+", diff --git a/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/java/com/mindspore/modelcamera/ui/TextTranslationActivity.java b/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/java/com/mindspore/modelcamera/ui/TextTranslationActivity.java index f82ab6ac01936b7ec62e99ea5469a709180cdd43..e01b926242a4cd01523034541165e001445f9161 100644 --- a/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/java/com/mindspore/modelcamera/ui/TextTranslationActivity.java +++ b/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/java/com/mindspore/modelcamera/ui/TextTranslationActivity.java @@ -20,12 +20,14 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; +import android.os.Build; import android.provider.MediaStore; import android.text.ClipboardManager; import android.text.method.ScrollingMovementMethod; import android.util.Log; import android.util.Pair; import android.view.View; +import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; @@ -37,7 +39,6 @@ import androidx.core.content.FileProvider; import com.alibaba.android.arouter.facade.annotation.Route; import com.bumptech.glide.Glide; import com.huawei.hmf.tasks.OnFailureListener; -import com.huawei.hmf.tasks.OnSuccessListener; import com.huawei.hmf.tasks.Task; import com.huawei.hms.mlsdk.MLAnalyzerFactory; import com.huawei.hms.mlsdk.common.MLApplication; @@ -51,15 +52,14 @@ import com.huawei.hms.mlsdk.translate.MLTranslatorFactory; import com.huawei.hms.mlsdk.translate.cloud.MLRemoteTranslateSetting; import com.huawei.hms.mlsdk.translate.cloud.MLRemoteTranslator; import com.mindspore.common.base.mvp.BaseActivity; -import com.mindspore.common.config.StorageUtils; import com.mindspore.common.sp.Preferences; import com.mindspore.common.utils.BitmapUtils; import com.mindspore.common.utils.StringUtils; -import com.mindspore.customview.ui.AppTitleView; import com.mindspore.modelcamera.R; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.List; @Route(path = "/camera/TextTranslationActivity") @@ -71,10 +71,12 @@ public class TextTranslationActivity extends BaseActivity { private TextView mTextView; private MLRemoteTranslator mlRemoteTranslator; - private static final int RC_CHOOSE_PHOTO = 1; private static final int RC_CHOOSE_CAMERA = 2; + private static final int TAG_TEXT = 1; + private static final int TAG_IMAGE = 2; + private boolean isPreViewShow = false; private ImageView imgPreview, mImageView; @@ -90,15 +92,20 @@ public class TextTranslationActivity extends BaseActivity { private Bitmap bitmapFore; private MLTextAnalyzer mAnalyzer; + private boolean isTextTranslator = true; + private Button translatorButton; + @Override protected void init() { MLApplication.getInstance().setApiKey(Preferences.API_KEY); - AppTitleView appTitle = findViewById(R.id.text_online_activity_toolbar); mEditText = findViewById(R.id.text_edit); mEditText.setMovementMethod(ScrollingMovementMethod.getInstance()); mTextView = findViewById(R.id.text_view); imgPreview = findViewById(R.id.img_origin); mTextView.setMovementMethod(ScrollingMovementMethod.getInstance()); + translatorButton = findViewById(R.id.btn_translation); + + setState(); MLLocalTextSetting setting = new MLLocalTextSetting.Factory() .setOCRMode(MLLocalTextSetting.OCR_DETECT_MODE) @@ -112,24 +119,18 @@ public class TextTranslationActivity extends BaseActivity { return R.layout.activity_text_translation; } - private void remoteTranslator() { - String sourceText = mEditText.getText().toString(); + private void remoteTranslator(String sourceText) { MLRemoteTranslateSetting setting = new MLRemoteTranslateSetting .Factory() .setTargetLangCode(StringUtils.isChinese(sourceText) ? "en" : "zh") .create(); - mlRemoteTranslator = MLTranslatorFactory.getInstance().getRemoteTranslator(setting); Task task = mlRemoteTranslator.asyncTranslate(sourceText); - task.addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(String text) { - mTextView.setText(text); - } - + task.addOnSuccessListener(text -> { + mTextView.setText(text); }).addOnFailureListener(e -> TextTranslationActivity.this.displayFailure(e)); } @@ -146,10 +147,24 @@ public class TextTranslationActivity extends BaseActivity { } public void onClickTranslation(View view) { - this.remoteTranslator(); + if (translatorButton.getTag() instanceof Integer) { + if ((Integer) view.getTag() == TAG_TEXT) { + remoteTranslator(getContentString()); + } else { + translatorButton.setText("翻译"); + translatorButton.setTag(TAG_TEXT); + showTextRecognition(); + } + } } + + public void onClickForText(View view) { + isTextTranslator = true; + setState(); + } + public void onClickTextCopy(View view) { String s = mTextView.getText().toString(); if (!s.equals("")) { @@ -162,38 +177,68 @@ public class TextTranslationActivity extends BaseActivity { } public void onClickPhoto(View view) { - openGalley(RC_CHOOSE_PHOTO); - mEditText.setVisibility(View.GONE); - imgPreview.setVisibility(View.VISIBLE); + isTextTranslator = false; + setState(); + openGalley(); } public void onClickCamera(View view) { + isTextTranslator = false; + setState(); openCamera(); - mEditText.setVisibility(View.GONE); - imgPreview.setVisibility(View.VISIBLE); } + public void setState() { + if (isTextTranslator) { + mEditText.setVisibility(View.VISIBLE); + imgPreview.setVisibility(View.GONE); + translatorButton.setText(R.string.btn_translation); + translatorButton.setTag(TAG_TEXT); + } else { + mEditText.setVisibility(View.GONE); + imgPreview.setVisibility(View.VISIBLE); + translatorButton.setText(R.string.btn_recognition); + translatorButton.setTag(TAG_IMAGE); + } + mTextView.setText(""); - private void openGalley(int request) { - Intent intent = new Intent(Intent.ACTION_PICK, null); - intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); - startActivityForResult(intent, request); } - public void onClickSave(View view) { - if (this.bitmapFore == null) { - Log.e(TAG, "null processed image"); - Toast.makeText(this.getApplicationContext(), R.string.no_pic_neededSave, Toast.LENGTH_SHORT).show(); + public String getContentString() { + if (isTextTranslator) { + return mEditText.getText().toString(); } else { - BitmapUtils.saveToAlbum(getApplicationContext(), this.bitmapFore); - Toast.makeText(this.getApplicationContext(), R.string.save_success, Toast.LENGTH_SHORT).show(); + return mTextView.getText().toString(); } } + private void openGalley() { + Intent intent = new Intent(Intent.ACTION_PICK, null); + intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); + startActivityForResult(intent, RC_CHOOSE_PHOTO); + } + + private void openCamera() { Intent intentToTakePhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - String mTempPhotoPath = StorageUtils.STORAGE_PHOTO; - imageUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileprovider", new File(mTempPhotoPath)); + + String mTempPhotoPath = getExternalCacheDir() + "/photo.jpeg"; + File outputImage = new File(mTempPhotoPath); + try { + if (outputImage.exists()) { + outputImage.delete(); + } + outputImage.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (Build.VERSION.SDK_INT < 24) { + imageUri = Uri.fromFile(outputImage); + } else { + imageUri = FileProvider.getUriForFile(this, + getPackageName() + ".fileprovider", outputImage); + } intentToTakePhoto.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intentToTakePhoto, RC_CHOOSE_CAMERA); } @@ -223,7 +268,6 @@ public class TextTranslationActivity extends BaseActivity { if (originBitmap != null) { Glide.with(this).load(originBitmap).into(imgPreview); isPreViewShow = true; - showTextRecognition(); } else { isPreViewShow = false; } @@ -244,7 +288,6 @@ public class TextTranslationActivity extends BaseActivity { if (originBitmap != null) { Glide.with(this).load(originBitmap).into(imgPreview); isPreViewShow = true; - showTextRecognition(); } else { isPreViewShow = false; } @@ -252,7 +295,6 @@ public class TextTranslationActivity extends BaseActivity { private void showTextRecognition() { MLFrame frame = MLFrame.fromBitmap(originBitmap); - Task task = mAnalyzer.asyncAnalyseFrame(frame); task.addOnSuccessListener(text -> TextTranslationActivity.this.displaySuccess(text)).addOnFailureListener(new OnFailureListener() { @Override @@ -270,32 +312,7 @@ public class TextTranslationActivity extends BaseActivity { result.append(line.getStringValue()).append("\n"); } } -// remoteTranslator(result); -// result.trim(); -// string.replaceAll("[^0-9a-zA-Z]",""); - MLRemoteTranslateSetting setting = new MLRemoteTranslateSetting - .Factory() - .setTargetLangCode(StringUtils.isChinese(result.toString()) ? "en" : "zh") - .create(); - - - mlRemoteTranslator = MLTranslatorFactory.getInstance().getRemoteTranslator(setting); - - Task task = mlRemoteTranslator.asyncTranslate(result.toString()); - task.addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(String text) { - mTextView.setText(text); - } - - }).addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(Exception e) { - - } - }); - -// this.mTextView.setText(result); + mTextView.setText(result); } private Pair getTargetSize() { @@ -338,4 +355,6 @@ public class TextTranslationActivity extends BaseActivity { mlRemoteTranslator.stop(); } } + + } \ No newline at end of file diff --git a/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/res/layout/activity_text_translation.xml b/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/res/layout/activity_text_translation.xml index e74b75eb69caccc5c73b81173fe358feb07f2fee..233fab9d6ce693f96c27676d432aaaa38155db9e 100644 --- a/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/res/layout/activity_text_translation.xml +++ b/model_zoo/official/lite/MindSpore_inhand/modelcamera/src/main/res/layout/activity_text_translation.xml @@ -26,8 +26,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" - android:layout_margin="10dp" + android:layout_margin="5dp" android:background="@drawable/bg_edit_text" + android:padding="10dp" android:visibility="gone" /> -