增加 越南语 增加app登录

master
wangh 9 months ago
parent a5d15780e8
commit ce32ecb483

@ -15,8 +15,12 @@
tools:targetApi="31">
<activity
android:name=".AppLoginActivity"
android:exported="false" />
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".broadcast.ScanERCodeReceiver"
android:enabled="true"
@ -24,13 +28,7 @@
<activity
android:name=".ReadActivity"
android:exported="true">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
android:exported="true"/>
<activity
android:name=".WriteUserActivity"
android:exported="false" />
@ -40,11 +38,10 @@
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
</application>

@ -1,14 +1,69 @@
package com.example.jinyu_rfid;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import com.example.jinyu_rfid.databinding.ActivityAppLoginBinding;
import com.example.jinyu_rfid.uitls.SharedPreferencesUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
public class AppLoginActivity extends AppCompatActivity {
private ActivityAppLoginBinding binding;
private Resources resources;
private Configuration config;
private int index;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_login);
resources = getResources();
config = resources.getConfiguration();
var languageString = SharedPreferencesUtils.getstring("language", "中文");
getLocaleStringXML(languageString);
resources.updateConfiguration(config, resources.getDisplayMetrics());
binding = DataBindingUtil.setContentView(this, R.layout.activity_app_login);
binding.appLanguage.setSelection(index);
var workmode = SharedPreferencesUtils.getInt("workmode", 0);
binding.mainWork.setSelection(workmode);
}
public void appLoginClick(View view) {
// 工作模式 0=net
var workModeStr = binding.mainWork.getSelectedItem().toString();
var strings = Arrays.asList(getResources().getStringArray(R.array.work_mode));
SharedPreferencesUtils.putInt("workmode", strings.indexOf(workModeStr));
// 选择语言
var s = binding.appLanguage.getSelectedItem().toString();
SharedPreferencesUtils.putstring("language", s);
getLocaleStringXML(s);
resources.updateConfiguration(config, resources.getDisplayMetrics());
startActivity(new Intent(this, ReadActivity.class));
finish();
}
private void getLocaleStringXML(String languageString) {
if (languageString.equals("中文")) {
config.locale = Locale.CHINA;
index = 0;
} else if (languageString.equals("English")) {
config.locale = Locale.ENGLISH;
index = 1;
} else {
config.locale = new Locale("vi", "VN");
index = 2;
}
}
}

@ -4,9 +4,8 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="user"
type="com.example.jinyu_rfid.been.LoginVm" />
</data>
<LinearLayout
@ -20,6 +19,7 @@
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:src="@mipmap/logo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
@ -39,9 +39,11 @@
android:id="@+id/main_work"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/language" />
android:entries="@array/work_mode" />
</LinearLayout>
</LinearLayout> <LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
@ -57,21 +59,14 @@
android:textSize="18sp" />
<Spinner
android:id="@+id/main_language"
android:id="@+id/app_language"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/language" />
</LinearLayout>
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:checked="@={user.remember}"
android:text="@string/remember_me" />
<Button
android:layout_width="match_parent"
@ -80,7 +75,7 @@
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:letterSpacing="0.2"
android:onClick="login_click"
android:onClick="appLoginClick"
android:text="@string/login_button_name"
android:textSize="20sp"
android:textStyle="bold" />

@ -31,4 +31,6 @@
<string name="write_success">write success</string>
<string name="binding_success">mes binding success</string>
<string name="work_model_select">working mode</string>
<string name="net_model">network mode</string>
<string name="standalone_mode">"standalone mode "</string>
</resources>

@ -32,4 +32,6 @@
<string name="write_success">Viết thành công</string>
<string name="binding_success">Kết nối MES thành công</string>
<string name="work_model_select">Chế độ làm việc</string>
<string name="net_model">Chế độ mạng</string>
<string name="standalone_mode">Chế độ đơn</string>
</resources>

@ -6,9 +6,8 @@
<item>Tiếng Việt</item>
</string-array>
<string-array name="work_mode">
<item>English</item>
<item>Tiếng Việt</item>
<item>@string/net_model</item>
<item>@string/standalone_mode</item>
</string-array>

@ -30,5 +30,7 @@
<string name="write_failed">写入失败</string>
<string name="write_success">写入成功</string>
<string name="binding_success">MES 绑定成功</string>
<string name="work_model_select">工作模式</string>>
<string name="work_model_select">工作模式</string>
<string name="net_model">网络模式</string>
<string name="standalone_mode">单机模式</string>>
</resources>
Loading…
Cancel
Save