Skip to content

Commit 7a24fdd

Browse files
committed
Russian translation and small fixes
Used Google translate so quality is big question mark
1 parent 3767cd4 commit 7a24fdd

File tree

8 files changed

+254
-61
lines changed

8 files changed

+254
-61
lines changed

app/src/main/java/com/nitramite/apcupsdmonitor/CustomUpsAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public View getView(int position, View view, ViewGroup parent) {
4949
name.setText(upsArrayList.get(position).getUPS_NAME());
5050

5151
model.setText(upsArrayList.get(position).getMODEL());
52-
lineVoltageOnly.setText(upsArrayList.get(position).getLineVoltageOnlyStr());
53-
batteryVoltageOnly.setText(upsArrayList.get(position).getBatteryVoltageOnlyStr());
52+
lineVoltageOnly.setText(upsArrayList.get(position).getLineVoltageOnlyStr(rowView.getContext()));
53+
batteryVoltageOnly.setText(upsArrayList.get(position).getBatteryVoltageOnlyStr(rowView.getContext()));
5454

5555
// Set status (Always shown)
5656
status.setText(upsArrayList.get(position).getSTATUS());
@@ -63,7 +63,8 @@ public View getView(int position, View view, ViewGroup parent) {
6363

6464
// Set battery charge level
6565
chargePB.setValue(upsArrayList.get(position).getBatteryChargeLevelInteger());
66-
percentageTv.setText(String.valueOf(upsArrayList.get(position).getBatteryChargeLevelInteger()) + "%");
66+
String getBatteryChargeLevelInteger = upsArrayList.get(position).getBatteryChargeLevelInteger() + "%";
67+
percentageTv.setText(getBatteryChargeLevelInteger);
6768

6869
return rowView;
6970
}

app/src/main/java/com/nitramite/apcupsdmonitor/UPS.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.nitramite.apcupsdmonitor;
22

3+
import android.content.Context;
34
import android.util.Log;
45

56
// UPS Object
@@ -162,57 +163,57 @@ public Boolean isOnline() {
162163
this.getSTATUS().equals("UPS OL CHRG"); // UPSC
163164
}
164165

165-
public String getLineVoltageStr() {
166-
return (this.LINE_VOLTAGE == null ? "-" : this.LINE_VOLTAGE + " line voltage");
166+
public String getLineVoltageStr(Context context) {
167+
return (this.LINE_VOLTAGE == null ? "-" : this.LINE_VOLTAGE + " " + context.getString(R.string.ups_line_voltage));
167168
}
168169

169-
public String getLineVoltageOnlyStr() {
170-
return (this.LINE_VOLTAGE == null ? "-" : this.LINE_VOLTAGE.replace("Volts line voltage", "").replace("Volts", "").replace(" ", "") + "V");
170+
public String getLineVoltageOnlyStr(Context context) {
171+
return (this.LINE_VOLTAGE == null ? "-" : this.LINE_VOLTAGE.replace(context.getString(R.string.ups_volts_line_voltage), "").replace("Volts", "").replace(" ", "") + "V");
171172
}
172173

173174

174-
public String getLoadPercentStr() {
175-
return (this.LOAD_PERCENT == null ? "Not available" : LOAD_PERCENT + " of load");
175+
public String getLoadPercentStr(Context context) {
176+
return (this.LOAD_PERCENT == null ? context.getString(R.string.ups_not_available) : LOAD_PERCENT + " " + context.getString(R.string.ups_of_load));
176177
}
177178

178179
public Integer getLoadPercentInteger() {
179180
return (this.LOAD_PERCENT == null ? null : Integer.parseInt(LOAD_PERCENT.replace(" ", "").split("\\.")[0]));
180181
}
181182

182183

183-
public String getBatteryChargeLevelStr() {
184-
return (this.BATTERY_CHARGE_LEVEL == null ? "N/A Charge level" : BATTERY_CHARGE_LEVEL + " battery charge");
184+
public String getBatteryChargeLevelStr(Context context) {
185+
return (this.BATTERY_CHARGE_LEVEL == null ? context.getString(R.string.ups_na_charge_level) : BATTERY_CHARGE_LEVEL + " " + context.getString(R.string.ups_battery_charge));
185186
}
186187

187188
public Integer getBatteryChargeLevelInteger() {
188189
return (this.BATTERY_CHARGE_LEVEL == null ? -1 : Integer.parseInt(BATTERY_CHARGE_LEVEL.replace(" ", "").split("\\.")[0]));
189190
}
190191

191192

192-
public String getBATTERY_TIME_LEFT() {
193-
return (this.BATTERY_TIME_LEFT == null ? "Battery time left N/A" : "Battery time left: " + this.BATTERY_TIME_LEFT);
193+
public String getBATTERY_TIME_LEFT(Context context) {
194+
return (this.BATTERY_TIME_LEFT == null ? context.getString(R.string.ups_battery_time_left_na) : context.getString(R.string.ups_battery_time_left) + ": " + this.BATTERY_TIME_LEFT);
194195
}
195196

196197

197-
public String getLastTransferReasonStr() {
198-
return (this.LAST_TRANSFER_REASON == null ? "Last transfer reason N/A" : "Last: " + this.LAST_TRANSFER_REASON);
198+
public String getLastTransferReasonStr(Context context) {
199+
return (this.LAST_TRANSFER_REASON == null ? context.getString(R.string.ups_last_transfer_reason_na) : context.getString(R.string.ups_last) + ": " + this.LAST_TRANSFER_REASON);
199200
}
200201

201202

202-
public String getBatteryVoltageOnlyStr() {
203+
public String getBatteryVoltageOnlyStr(Context context) {
203204
return (BATTERY_VOLTAGE == null ? "N/A" : BATTERY_VOLTAGE.replace("Volts", "").replace(" ", "") + "V");
204205
}
205206

206-
public String getBATTERY_DATE() {
207-
return (BATTERY_DATE == null ? "Battery date N/A" : "Battery date " + BATTERY_DATE);
207+
public String getBATTERY_DATE(Context context) {
208+
return (BATTERY_DATE == null ? context.getString(R.string.ups_battery_date_na) : context.getString(R.string.ups_battery_date) + " " + BATTERY_DATE);
208209
}
209210

210211
public String getFIRMWARE() {
211212
return (this.FIRMWARE == null ? "N/A" : this.FIRMWARE);
212213
}
213214

214-
public String getSTART_TIME() {
215-
return (this.START_TIME == null ? "Start time N/A" : "Start time: " + this.START_TIME);
215+
public String getSTART_TIME(Context context) {
216+
return (this.START_TIME == null ? context.getString(R.string.ups_start_time_na) : context.getString(R.string.ups_start_time) + ": " + this.START_TIME);
216217
}
217218

218219
public String getLAST_SECONDS_ON_BATTERY() {

app/src/main/java/com/nitramite/apcupsdmonitor/UpsEditor.java

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.os.Environment;
1212
import android.preference.PreferenceManager;
1313
import android.os.Bundle;
14-
import android.view.View;
1514
import android.widget.Button;
1615
import android.widget.EditText;
1716
import android.widget.Switch;
@@ -66,12 +65,12 @@ protected void onCreate(Bundle savedInstanceState) {
6665

6766
// Set values
6867
if (upsId == null) {
69-
setTitle("UPS Editor (Create new)");
68+
setTitle(getString(R.string.ups_editor_create_new));
7069
// Defaults
7170
statusCommandET.setText(Constants.STATUS_COMMAND);
7271
eventsLocationET.setText(Constants.EVENTS_LOCATION);
7372
} else {
74-
setTitle("UPS Editor (Update existing)");
73+
setTitle(getString(R.string.ups_editor_update_existing));
7574
UPS ups = databaseHelper.getAllUps(upsId).get(0);
7675
connectionTypeSwitch.setChecked(ups.UPS_CONNECTION_TYPE.equals("1"));
7776
serverAddressET.setText(ups.UPS_SERVER_ADDRESS);
@@ -89,33 +88,27 @@ protected void onCreate(Bundle savedInstanceState) {
8988

9089

9190
Button tutorialBtn = findViewById(R.id.tutorialBtn);
92-
tutorialBtn.setOnClickListener(new View.OnClickListener() {
93-
@Override
94-
public void onClick(View view) {
95-
String url = "http://www.nitramite.com/apcupsdmonitor.html";
96-
Intent i = new Intent(Intent.ACTION_VIEW);
97-
i.setData(Uri.parse(url));
98-
startActivity(i);
99-
}
91+
tutorialBtn.setOnClickListener(view -> {
92+
String url = "http://www.nitramite.com/apcupsdmonitor.html";
93+
Intent i = new Intent(Intent.ACTION_VIEW);
94+
i.setData(Uri.parse(url));
95+
startActivity(i);
10096
});
10197

10298
Button selectPrivateKeyLocationBtn = findViewById(R.id.selectPrivateKeyLocationBtn);
103-
selectPrivateKeyLocationBtn.setOnClickListener(new View.OnClickListener() {
104-
@Override
105-
public void onClick(View view) {
106-
if (hasPermissions(UpsEditor.this, new String[]{permissionReadStorage})) {
107-
File mPath = new File(Environment.getExternalStorageDirectory() + "//DIR//");
108-
final FileDialog fileDialog = new FileDialog(UpsEditor.this, mPath, "");
109-
fileDialog.addFileListener(new FileDialog.FileSelectedListener() {
110-
public void fileSelected(File file) {
111-
Toast.makeText(UpsEditor.this, getString(R.string.path) + ": " + file.toString(), Toast.LENGTH_SHORT).show();
112-
privateKeyLocationET.setText(file.toString());
113-
}
114-
});
115-
fileDialog.showDialog();
116-
} else {
117-
ActivityCompat.requestPermissions(UpsEditor.this, new String[]{permissionReadStorage}, READ_EXTERNAL_STORAGE_REQUEST_CODE);
118-
}
99+
selectPrivateKeyLocationBtn.setOnClickListener(view -> {
100+
if (hasPermissions(UpsEditor.this, new String[]{permissionReadStorage})) {
101+
File mPath = new File(Environment.getExternalStorageDirectory() + "//DIR//");
102+
final FileDialog fileDialog = new FileDialog(UpsEditor.this, mPath, "");
103+
fileDialog.addFileListener(new FileDialog.FileSelectedListener() {
104+
public void fileSelected(File file) {
105+
Toast.makeText(UpsEditor.this, getString(R.string.path) + ": " + file.toString(), Toast.LENGTH_SHORT).show();
106+
privateKeyLocationET.setText(file.toString());
107+
}
108+
});
109+
fileDialog.showDialog();
110+
} else {
111+
ActivityCompat.requestPermissions(UpsEditor.this, new String[]{permissionReadStorage}, READ_EXTERNAL_STORAGE_REQUEST_CODE);
119112
}
120113
});
121114

app/src/main/java/com/nitramite/apcupsdmonitor/UpsViewer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private void drawData(UPS ups, String serverOutput) {
197197
if (sharedPreferences.getBoolean(Constants.SP_SHOW_LINE_VOLTAGE, true)) {
198198
lineVoltageLayout.setVisibility(View.VISIBLE);
199199
TextView lineVoltageOnly = (TextView) findViewById(R.id.lineVoltageOnly);
200-
lineVoltageOnly.setText(ups.getLineVoltageOnlyStr());
200+
lineVoltageOnly.setText(ups.getLineVoltageOnlyStr(this));
201201
} else {
202202
lineVoltageLayout.setVisibility(View.GONE);
203203
}
@@ -208,7 +208,7 @@ private void drawData(UPS ups, String serverOutput) {
208208
if (sharedPreferences.getBoolean(Constants.SP_SHOW_BATTERY_VOLTAGE, true)) {
209209
batteryVoltageLayout.setVisibility(View.VISIBLE);
210210
TextView batteryVoltageOnly = (TextView) findViewById(R.id.batteryVoltageOnly);
211-
batteryVoltageOnly.setText(ups.getBatteryVoltageOnlyStr());
211+
batteryVoltageOnly.setText(ups.getBatteryVoltageOnlyStr(this));
212212
} else {
213213
batteryVoltageLayout.setVisibility(View.GONE);
214214
}
@@ -230,7 +230,7 @@ private void drawData(UPS ups, String serverOutput) {
230230
if (sharedPreferences.getBoolean(Constants.SP_SHOW_LOAD_PERCENTAGE, true)) {
231231
batteryLoadPercentageLayout.setVisibility(View.VISIBLE);
232232
TextView loadPercent = (TextView) findViewById(R.id.loadPercent);
233-
loadPercent.setText(ups.getLoadPercentStr());
233+
loadPercent.setText(ups.getLoadPercentStr(this));
234234
ProgressBar loadPercentPB = (ProgressBar) findViewById(R.id.loadPercentPB);
235235
if (ups.getLoadPercentInteger() != null) {
236236
loadPercentPB.setProgress(ups.getLoadPercentInteger());
@@ -248,7 +248,7 @@ private void drawData(UPS ups, String serverOutput) {
248248
if (sharedPreferences.getBoolean(Constants.SP_SHOW_PERCENT_BATTERY_CHARGE, true)) {
249249
batteryChargeLevelLayout.setVisibility(View.VISIBLE);
250250
TextView batteryChargeLevel = (TextView) findViewById(R.id.batteryChargeLevel);
251-
batteryChargeLevel.setText(ups.getBatteryChargeLevelStr());
251+
batteryChargeLevel.setText(ups.getBatteryChargeLevelStr(this));
252252
ProgressBar chargePB = (ProgressBar) findViewById(R.id.chargePB);
253253
if (ups.getBatteryChargeLevelInteger() != null) {
254254
chargePB.setVisibility(View.VISIBLE);
@@ -266,7 +266,7 @@ private void drawData(UPS ups, String serverOutput) {
266266
if (sharedPreferences.getBoolean(Constants.SP_SHOW_LAST_TRANSFER_REASON, true)) {
267267
lastTransferReasonLayout.setVisibility(View.VISIBLE);
268268
TextView lastTransferReason = (TextView) findViewById(R.id.lastTransferReason);
269-
lastTransferReason.setText(ups.getLastTransferReasonStr());
269+
lastTransferReason.setText(ups.getLastTransferReasonStr(this));
270270
} else {
271271
lastTransferReasonLayout.setVisibility(View.GONE);
272272
}
@@ -277,7 +277,7 @@ private void drawData(UPS ups, String serverOutput) {
277277
if (sharedPreferences.getBoolean(Constants.SP_SHOW_BATTERY_TIME_LEFT, true)) {
278278
batteryTimeLeftLayout.setVisibility(View.VISIBLE);
279279
TextView batteryTimeLeft = (TextView) findViewById(R.id.batteryTimeLeft);
280-
batteryTimeLeft.setText(ups.getBATTERY_TIME_LEFT());
280+
batteryTimeLeft.setText(ups.getBATTERY_TIME_LEFT(this));
281281
} else {
282282
batteryTimeLeftLayout.setVisibility(View.GONE);
283283
}
@@ -288,7 +288,7 @@ private void drawData(UPS ups, String serverOutput) {
288288
if (sharedPreferences.getBoolean(Constants.SP_SHOW_BATTERY_DATE, true)) {
289289
batteryDateLayout.setVisibility(View.VISIBLE);
290290
TextView batteryDate = (TextView) findViewById(R.id.batteryDate);
291-
batteryDate.setText(ups.getBATTERY_DATE());
291+
batteryDate.setText(ups.getBATTERY_DATE(this));
292292
} else {
293293
batteryDateLayout.setVisibility(View.GONE);
294294
}
@@ -310,7 +310,7 @@ private void drawData(UPS ups, String serverOutput) {
310310
if (sharedPreferences.getBoolean(Constants.SP_SHOW_START_TIME, false)) {
311311
startTimeLayout.setVisibility(View.VISIBLE);
312312
TextView startTime = (TextView) findViewById(R.id.startTime);
313-
startTime.setText(ups.getSTART_TIME());
313+
startTime.setText(ups.getSTART_TIME(this));
314314
} else {
315315
startTimeLayout.setVisibility(View.GONE);
316316
}

app/src/main/res/menu/menu_menu.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<item
66
android:id="@+id/action_refresh"
77
android:icon="@drawable/ic_refresh"
8-
android:title="Refresh"
8+
android:title="@string/menu_refresh"
99
app:showAsAction="ifRoom"
1010
tools:ignore="HardcodedText" />
1111

1212
<item
1313
android:id="@+id/action_settings"
1414
android:icon="@drawable/ic_settings"
15-
android:title="Settings"
15+
android:title="@string/menu_settings"
1616
app:showAsAction="ifRoom"
1717
tools:ignore="HardcodedText" />
1818

@@ -23,7 +23,7 @@
2323

2424
<item
2525
android:id="@+id/action_rate_app"
26-
android:title="Rate app"
26+
android:title="@string/menu_rate_app"
2727
app:showAsAction="never"
2828
tools:ignore="HardcodedText" />
2929

app/src/main/res/menu/menu_ups_viewer.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
<item
66
android:id="@+id/action_refresh"
77
android:icon="@drawable/ic_refresh"
8-
android:title="Refresh"
8+
android:title="@string/menu_ups_viewer_refresh"
99
app:showAsAction="ifRoom"
1010
tools:ignore="HardcodedText" />
1111

1212
<item
1313
android:id="@+id/action_statistics"
1414
android:icon="@drawable/ic_bar_chart"
15-
android:title="Statistics"
15+
android:title="@string/menu_ups_viewer_statistics"
1616
app:showAsAction="always"
1717
tools:ignore="AlwaysShowAction,HardcodedText" />
1818

1919
<item
2020
android:id="@+id/action_debug_output"
21-
android:title="Debug output"
21+
android:title="@string/menu_ups_viewer_debug_output"
2222
app:showAsAction="never"
2323
tools:ignore="HardcodedText" />
2424

0 commit comments

Comments
 (0)