handle language change
This commit is contained in:
parent
e1bcc44fbe
commit
729bdf5d90
@ -25,6 +25,7 @@ public abstract class AbstractLiveActivity extends AppCompatActivity {
|
|||||||
public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions
|
public abstract void vehicleStatusReceived(long imei, int opCode, int status); // --> UpdateOptions
|
||||||
public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
|
public abstract void emergencyAlarmReceived(int position, double lat, double lng); // --> UpdateEmergencyAlarm
|
||||||
public abstract GoogleMap getMap(); // --> UpdateEmergencyAlarm
|
public abstract GoogleMap getMap(); // --> UpdateEmergencyAlarm
|
||||||
|
public abstract void setLanguage();
|
||||||
|
|
||||||
/** Misc */
|
/** Misc */
|
||||||
public AbstractSDParentActivity getParentTab() {
|
public AbstractSDParentActivity getParentTab() {
|
||||||
|
@ -132,6 +132,17 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
setDate();
|
setDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLanguage() {
|
||||||
|
TextView labelVehicle = findViewById(R.id.labelVehicle);
|
||||||
|
TextView labelStartDate = findViewById(R.id.labelStartDate);
|
||||||
|
TextView labelEndDate = findViewById(R.id.labelEndDate);
|
||||||
|
|
||||||
|
labelVehicle.setText(R.string.vehicle);
|
||||||
|
labelStartDate.setText(R.string.startDate);
|
||||||
|
labelEndDate.setText(R.string.endDate);
|
||||||
|
displayButton.setText(R.string.display);
|
||||||
|
}
|
||||||
|
|
||||||
private void displayHistory(ArrayList<HistPos> positions) {
|
private void displayHistory(ArrayList<HistPos> positions) {
|
||||||
LatLng latLng = null;
|
LatLng latLng = null;
|
||||||
PolylineOptions polylineOptions = new PolylineOptions();
|
PolylineOptions polylineOptions = new PolylineOptions();
|
||||||
|
@ -296,6 +296,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
registerBroadcastIntents();
|
registerBroadcastIntents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLanguage() {
|
||||||
|
TextView textView = findViewById(R.id.unit_name);
|
||||||
|
textView.setText(R.string.unitName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manipulates the map once available.
|
* Manipulates the map once available.
|
||||||
* This callback is triggered when the map is ready to be used.
|
* This callback is triggered when the map is ready to be used.
|
||||||
|
@ -732,12 +732,13 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
|||||||
// recreate UI
|
// recreate UI
|
||||||
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
Locale locale = new Locale(AppParams.LANGUAGETMP);
|
||||||
Locale.setDefault(locale);
|
Locale.setDefault(locale);
|
||||||
android.content.res.Configuration configuration = new android.content.res.Configuration();
|
setLocale(getLiveActivity(), locale);
|
||||||
configuration.locale = locale;
|
|
||||||
getBaseContext().getResources().updateConfiguration(configuration,
|
|
||||||
getBaseContext().getResources().getDisplayMetrics());
|
|
||||||
|
|
||||||
// change UI for RadioActivity and MessageActivity
|
// change UI for RadioActivity and MessageActivity
|
||||||
|
if (getLiveActivity() != null)
|
||||||
|
getLiveActivity().setLanguage();
|
||||||
|
if (getHistoryActivity() != null)
|
||||||
|
getHistoryActivity().setLanguage();
|
||||||
if (getRadioActivity() != null)
|
if (getRadioActivity() != null)
|
||||||
getRadioActivity().onCreate(getRadioActivity().savedInstanceState);
|
getRadioActivity().onCreate(getRadioActivity().savedInstanceState);
|
||||||
if (getMessageActivity() != null)
|
if (getMessageActivity() != null)
|
||||||
@ -748,6 +749,13 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
|||||||
getAlarmActivity().onCreate(getAlarmActivity().getSavedInstanceState());
|
getAlarmActivity().onCreate(getAlarmActivity().getSavedInstanceState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setLocale(Activity activity, Locale locale) {
|
||||||
|
Resources resources = activity.getResources();
|
||||||
|
Configuration config = resources.getConfiguration();
|
||||||
|
config.setLocale(locale);
|
||||||
|
resources.updateConfiguration(config, resources.getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
//timer stuff
|
//timer stuff
|
||||||
private void timerMethod() {
|
private void timerMethod() {
|
||||||
if (!AppParams.DEMO)
|
if (!AppParams.DEMO)
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
android:gravity="center_vertical" >
|
android:gravity="center_vertical" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/unit_name"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/unitName"
|
android:text="@string/unitName"
|
||||||
|
Loading…
Reference in New Issue
Block a user