Skip to content

Commit dea74b0

Browse files
Hakan GustavssonKenneth Andersson
authored andcommitted
Strings for NI position request are moved to resources
The strings used by the framework for network initiated position requests are now string resources that can be properly localized. Change-Id: If1cba89adb1bfcb9c8fdb59b9c5aa1107b11279e
1 parent e1de3f3 commit dea74b0

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

core/java/com/android/internal/app/NetInitiatedActivity.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import android.widget.Toast;
2727
import android.util.Log;
2828
import android.location.LocationManager;
29+
30+
import com.android.internal.R;
2931
import com.android.internal.location.GpsNetInitiatedHandler;
3032

3133
/**
@@ -42,10 +44,6 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
4244
private static final int POSITIVE_BUTTON = AlertDialog.BUTTON_POSITIVE;
4345
private static final int NEGATIVE_BUTTON = AlertDialog.BUTTON_NEGATIVE;
4446

45-
// Dialog button text
46-
public static final String BUTTON_TEXT_ACCEPT = "Accept";
47-
public static final String BUTTON_TEXT_DENY = "Deny";
48-
4947
// Received ID from intent, -1 when no notification is in progress
5048
private int notificationId = -1;
5149

@@ -67,12 +65,13 @@ protected void onCreate(Bundle savedInstanceState) {
6765
// Set up the "dialog"
6866
final Intent intent = getIntent();
6967
final AlertController.AlertParams p = mAlertParams;
68+
Context context = getApplicationContext();
7069
p.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
7170
p.mTitle = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_TITLE);
7271
p.mMessage = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_MESSAGE);
73-
p.mPositiveButtonText = BUTTON_TEXT_ACCEPT;
72+
p.mPositiveButtonText = String.format(context.getString(R.string.gpsVerifYes));
7473
p.mPositiveButtonListener = this;
75-
p.mNegativeButtonText = BUTTON_TEXT_DENY;
74+
p.mNegativeButtonText = String.format(context.getString(R.string.gpsVerifNo));
7675
p.mNegativeButtonListener = this;
7776

7877
notificationId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1);

core/res/res/values/strings.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,4 +2273,20 @@
22732273
<!-- Shown when the users bandwidth is reduced because of excessive data use -->
22742274
<string name="throttled_notification_title">Mobile data limit exceeded</string>
22752275
<string name="throttled_notification_message">Touch to learn more about mobile data use</string>
2276+
2277+
<!-- Network positioning notification ticker. The name of the user (e.g. John Doe) who sent
2278+
the request is shown as a dynamic string. -->
2279+
<string name="gpsNotifTicker">Location request from <xliff:g id="name">%s</xliff:g></string>
2280+
<!-- Network positioning notification and verification title to inform the user about
2281+
an incoming location request. -->
2282+
<string name="gpsNotifTitle">Location request</string>
2283+
<!-- Network positioning notification message. The name of the user (e.g. John Doe) and
2284+
service (SUPL-service) who sent the request is shown as dynamic strings.
2285+
Translation should not be longer than master text. -->
2286+
<string name="gpsNotifMessage">Requested by <xliff:g id="name">%1$s</xliff:g> (<xliff:g id="service" example="SUPL-service">%2$s</xliff:g>)</string>
2287+
<!-- Network positioning verification Yes. Button to push to share location information. -->
2288+
<string name="gpsVerifYes">Yes</string>
2289+
<!-- Network positioning verification No. Button to push to deny sharing of location
2290+
information. -->
2291+
<string name="gpsVerifNo">No</string>
22762292
</resources>

location/java/com/android/internal/location/GpsNetInitiatedHandler.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import android.os.RemoteException;
2828
import android.util.Log;
2929

30+
import com.android.internal.R;
31+
3032
/**
3133
* A GPS Network-initiated Handler class used by LocationManager.
3234
*
@@ -187,8 +189,8 @@ private synchronized void setNiNotification(GpsNiNotification notif) {
187189
return;
188190
}
189191

190-
String title = getNotifTitle(notif);
191-
String message = getNotifMessage(notif);
192+
String title = getNotifTitle(notif, mContext);
193+
String message = getNotifMessage(notif, mContext);
192194

193195
if (DEBUG) Log.d(TAG, "setNiNotification, notifyId: " + notif.notificationId +
194196
", title: " + title +
@@ -208,7 +210,7 @@ private synchronized void setNiNotification(GpsNiNotification notif) {
208210
}
209211

210212
mNiNotification.flags = Notification.FLAG_ONGOING_EVENT;
211-
mNiNotification.tickerText = getNotifTicker(notif);
213+
mNiNotification.tickerText = getNotifTicker(notif, mContext);
212214

213215
// if not to popup dialog immediately, pending intent will open the dialog
214216
Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent();
@@ -239,8 +241,8 @@ private void openNiDialog(GpsNiNotification notif)
239241
private Intent getDlgIntent(GpsNiNotification notif)
240242
{
241243
Intent intent = new Intent();
242-
String title = getDialogTitle(notif);
243-
String message = getDialogMessage(notif);
244+
String title = getDialogTitle(notif, mContext);
245+
String message = getDialogMessage(notif, mContext);
244246

245247
// directly bring up the NI activity
246248
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -417,41 +419,40 @@ static private String decodeString(String original, boolean isHex, int coding)
417419
}
418420

419421
// change this to configure notification display
420-
static private String getNotifTicker(GpsNiNotification notif)
422+
static private String getNotifTicker(GpsNiNotification notif, Context context)
421423
{
422-
String ticker = String.format("Position request! ReqId: [%s] ClientName: [%s]",
424+
String ticker = String.format(context.getString(R.string.gpsNotifTicker),
423425
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
424426
decodeString(notif.text, mIsHexInput, notif.textEncoding));
425427
return ticker;
426428
}
427429

428430
// change this to configure notification display
429-
static private String getNotifTitle(GpsNiNotification notif)
431+
static private String getNotifTitle(GpsNiNotification notif, Context context)
430432
{
431-
String title = String.format("Position Request");
433+
String title = String.format(context.getString(R.string.gpsNotifTitle));
432434
return title;
433435
}
434436

435437
// change this to configure notification display
436-
static private String getNotifMessage(GpsNiNotification notif)
438+
static private String getNotifMessage(GpsNiNotification notif, Context context)
437439
{
438-
String message = String.format(
439-
"NI Request received from [%s] for client [%s]!",
440+
String message = String.format(context.getString(R.string.gpsNotifMessage),
440441
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
441442
decodeString(notif.text, mIsHexInput, notif.textEncoding));
442443
return message;
443444
}
444445

445446
// change this to configure dialog display (for verification)
446-
static public String getDialogTitle(GpsNiNotification notif)
447+
static public String getDialogTitle(GpsNiNotification notif, Context context)
447448
{
448-
return getNotifTitle(notif);
449+
return getNotifTitle(notif, context);
449450
}
450451

451452
// change this to configure dialog display (for verification)
452-
static private String getDialogMessage(GpsNiNotification notif)
453+
static private String getDialogMessage(GpsNiNotification notif, Context context)
453454
{
454-
return getNotifMessage(notif);
455+
return getNotifMessage(notif, context);
455456
}
456457

457458
}

0 commit comments

Comments
 (0)