remove global NumberFormat for more flexible Locale handling
This commit is contained in:
parent
541410447d
commit
d85a2e87c9
|
@ -75,7 +75,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
private MenuItem mItemOnOff = null;
|
private MenuItem mItemOnOff = null;
|
||||||
private TextView downloadText = null;
|
private TextView downloadText = null;
|
||||||
private TextView uploadText = null;
|
private TextView uploadText = null;
|
||||||
private NumberFormat mNumberFormat = null;
|
|
||||||
private TextView mTxtOrbotLog = null;
|
private TextView mTxtOrbotLog = null;
|
||||||
|
|
||||||
private Button mBtnBrowser = null;
|
private Button mBtnBrowser = null;
|
||||||
|
@ -473,10 +472,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java
|
|
||||||
* @see android.app.Activity#onPause()
|
|
||||||
*/
|
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1430,18 +1425,12 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for interacting with the main interface of the service.
|
|
||||||
*/
|
|
||||||
// this is the connection that gets called back when a successfull bind occurs
|
// this is the connection that gets called back when a successfull bind occurs
|
||||||
// we should use this to activity monitor unbind so that we don't have to call
|
// we should use this to activity monitor unbind so that we don't have to call
|
||||||
// bindService() a million times
|
// bindService() a million times
|
||||||
|
|
||||||
private void setLocale ()
|
private void setLocale ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Configuration config = getResources().getConfiguration();
|
Configuration config = getResources().getConfiguration();
|
||||||
String lang = mPrefs.getString(PREF_DEFAULT_LOCALE, "");
|
String lang = mPrefs.getString(PREF_DEFAULT_LOCALE, "");
|
||||||
|
|
||||||
|
@ -1452,9 +1441,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
config.locale = locale;
|
config.locale = locale;
|
||||||
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
mNumberFormat = NumberFormat.getInstance(Locale.getDefault());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1477,30 +1463,31 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatCount(long count) {
|
private String formatCount(long count) {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
|
||||||
// Converts the supplied argument into a string.
|
// Converts the supplied argument into a string.
|
||||||
// Under 2Mb, returns "xxx.xKb"
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
// Over 2Mb, returns "xxx.xxMb"
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
|
|
||||||
//Locale.getDefault();
|
|
||||||
|
|
||||||
if (count < 1e6)
|
if (count < 1e6)
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kbps);
|
return numberFormat.format(Math.round(((float) ((int) (count * 10 / 1024)) / 10)))
|
||||||
|
+ getString(R.string.kbps);
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mbps);
|
else
|
||||||
|
return numberFormat.format(Math
|
||||||
//return count+" kB";
|
.round(((float) ((int) (count * 100 / 1024 / 1024)) / 100)))
|
||||||
|
+ getString(R.string.mbps);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatTotal(long count) {
|
private String formatTotal(long count) {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
|
||||||
// Converts the supplied argument into a string.
|
// Converts the supplied argument into a string.
|
||||||
// Under 2Mb, returns "xxx.xKb"
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
// Over 2Mb, returns "xxx.xxMb"
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
if (count < 1e6)
|
if (count < 1e6)
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*10/1024))/10))) + getString(R.string.kb);
|
return numberFormat.format(Math.round(((float) ((int) (count * 10 / 1024)) / 10)))
|
||||||
|
+ getString(R.string.kb);
|
||||||
return mNumberFormat.format(Math.round(((float)((int)(count*100/1024/1024))/100))) + getString(R.string.mb);
|
else
|
||||||
|
return numberFormat.format(Math
|
||||||
//return count+" kB";
|
.round(((float) ((int) (count * 100 / 1024 / 1024)) / 100)))
|
||||||
|
+ getString(R.string.mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue