* commit '12902d687fa1bd4bff3c2dfc079c71eacb00eedd': Strings for NI position request are moved to resources
This commit is contained in:
committed by
Android Git Automerger
commit
ee27dd356e
@@ -26,6 +26,8 @@ import android.os.Bundle;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
import com.android.internal.location.GpsNetInitiatedHandler;
|
import com.android.internal.location.GpsNetInitiatedHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,10 +44,6 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
|
|||||||
private static final int POSITIVE_BUTTON = AlertDialog.BUTTON_POSITIVE;
|
private static final int POSITIVE_BUTTON = AlertDialog.BUTTON_POSITIVE;
|
||||||
private static final int NEGATIVE_BUTTON = AlertDialog.BUTTON_NEGATIVE;
|
private static final int NEGATIVE_BUTTON = AlertDialog.BUTTON_NEGATIVE;
|
||||||
|
|
||||||
// Dialog button text
|
|
||||||
public static final String BUTTON_TEXT_ACCEPT = "Accept";
|
|
||||||
public static final String BUTTON_TEXT_DENY = "Deny";
|
|
||||||
|
|
||||||
// Received ID from intent, -1 when no notification is in progress
|
// Received ID from intent, -1 when no notification is in progress
|
||||||
private int notificationId = -1;
|
private int notificationId = -1;
|
||||||
|
|
||||||
@@ -67,12 +65,13 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
|
|||||||
// Set up the "dialog"
|
// Set up the "dialog"
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
final AlertController.AlertParams p = mAlertParams;
|
||||||
|
Context context = getApplicationContext();
|
||||||
p.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
|
p.mIconId = com.android.internal.R.drawable.ic_dialog_usb;
|
||||||
p.mTitle = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_TITLE);
|
p.mTitle = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_TITLE);
|
||||||
p.mMessage = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_MESSAGE);
|
p.mMessage = intent.getStringExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_MESSAGE);
|
||||||
p.mPositiveButtonText = BUTTON_TEXT_ACCEPT;
|
p.mPositiveButtonText = String.format(context.getString(R.string.gpsVerifYes));
|
||||||
p.mPositiveButtonListener = this;
|
p.mPositiveButtonListener = this;
|
||||||
p.mNegativeButtonText = BUTTON_TEXT_DENY;
|
p.mNegativeButtonText = String.format(context.getString(R.string.gpsVerifNo));
|
||||||
p.mNegativeButtonListener = this;
|
p.mNegativeButtonListener = this;
|
||||||
|
|
||||||
notificationId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1);
|
notificationId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1);
|
||||||
|
|||||||
@@ -2348,4 +2348,19 @@
|
|||||||
<!-- Text for message for an unknown external media state [CHAR LIMIT=NONE] -->
|
<!-- Text for message for an unknown external media state [CHAR LIMIT=NONE] -->
|
||||||
<string name="media_unknown_state">External media in unknown state.</string>
|
<string name="media_unknown_state">External media in unknown state.</string>
|
||||||
|
|
||||||
|
<!-- Network positioning notification ticker. The name of the user (e.g. John Doe) who sent
|
||||||
|
the request is shown as a dynamic string. -->
|
||||||
|
<string name="gpsNotifTicker">Location request from <xliff:g id="name">%s</xliff:g></string>
|
||||||
|
<!-- Network positioning notification and verification title to inform the user about
|
||||||
|
an incoming location request. -->
|
||||||
|
<string name="gpsNotifTitle">Location request</string>
|
||||||
|
<!-- Network positioning notification message. The name of the user (e.g. John Doe) and
|
||||||
|
service (SUPL-service) who sent the request is shown as dynamic strings.
|
||||||
|
Translation should not be longer than master text. -->
|
||||||
|
<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>
|
||||||
|
<!-- Network positioning verification Yes. Button to push to share location information. -->
|
||||||
|
<string name="gpsVerifYes">Yes</string>
|
||||||
|
<!-- Network positioning verification No. Button to push to deny sharing of location
|
||||||
|
information. -->
|
||||||
|
<string name="gpsVerifNo">No</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.os.Bundle;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A GPS Network-initiated Handler class used by LocationManager.
|
* A GPS Network-initiated Handler class used by LocationManager.
|
||||||
*
|
*
|
||||||
@@ -182,8 +184,8 @@ public class GpsNetInitiatedHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = getNotifTitle(notif);
|
String title = getNotifTitle(notif, mContext);
|
||||||
String message = getNotifMessage(notif);
|
String message = getNotifMessage(notif, mContext);
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "setNiNotification, notifyId: " + notif.notificationId +
|
if (DEBUG) Log.d(TAG, "setNiNotification, notifyId: " + notif.notificationId +
|
||||||
", title: " + title +
|
", title: " + title +
|
||||||
@@ -203,7 +205,7 @@ public class GpsNetInitiatedHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mNiNotification.flags = Notification.FLAG_ONGOING_EVENT;
|
mNiNotification.flags = Notification.FLAG_ONGOING_EVENT;
|
||||||
mNiNotification.tickerText = getNotifTicker(notif);
|
mNiNotification.tickerText = getNotifTicker(notif, mContext);
|
||||||
|
|
||||||
// if not to popup dialog immediately, pending intent will open the dialog
|
// if not to popup dialog immediately, pending intent will open the dialog
|
||||||
Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent();
|
Intent intent = !mPopupImmediately ? getDlgIntent(notif) : new Intent();
|
||||||
@@ -234,8 +236,8 @@ public class GpsNetInitiatedHandler {
|
|||||||
private Intent getDlgIntent(GpsNiNotification notif)
|
private Intent getDlgIntent(GpsNiNotification notif)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
String title = getDialogTitle(notif);
|
String title = getDialogTitle(notif, mContext);
|
||||||
String message = getDialogMessage(notif);
|
String message = getDialogMessage(notif, mContext);
|
||||||
|
|
||||||
// directly bring up the NI activity
|
// directly bring up the NI activity
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@@ -412,41 +414,40 @@ public class GpsNetInitiatedHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// change this to configure notification display
|
// change this to configure notification display
|
||||||
static private String getNotifTicker(GpsNiNotification notif)
|
static private String getNotifTicker(GpsNiNotification notif, Context context)
|
||||||
{
|
{
|
||||||
String ticker = String.format("Position request! ReqId: [%s] ClientName: [%s]",
|
String ticker = String.format(context.getString(R.string.gpsNotifTicker),
|
||||||
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
|
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
|
||||||
decodeString(notif.text, mIsHexInput, notif.textEncoding));
|
decodeString(notif.text, mIsHexInput, notif.textEncoding));
|
||||||
return ticker;
|
return ticker;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change this to configure notification display
|
// change this to configure notification display
|
||||||
static private String getNotifTitle(GpsNiNotification notif)
|
static private String getNotifTitle(GpsNiNotification notif, Context context)
|
||||||
{
|
{
|
||||||
String title = String.format("Position Request");
|
String title = String.format(context.getString(R.string.gpsNotifTitle));
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change this to configure notification display
|
// change this to configure notification display
|
||||||
static private String getNotifMessage(GpsNiNotification notif)
|
static private String getNotifMessage(GpsNiNotification notif, Context context)
|
||||||
{
|
{
|
||||||
String message = String.format(
|
String message = String.format(context.getString(R.string.gpsNotifMessage),
|
||||||
"NI Request received from [%s] for client [%s]!",
|
|
||||||
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
|
decodeString(notif.requestorId, mIsHexInput, notif.requestorIdEncoding),
|
||||||
decodeString(notif.text, mIsHexInput, notif.textEncoding));
|
decodeString(notif.text, mIsHexInput, notif.textEncoding));
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change this to configure dialog display (for verification)
|
// change this to configure dialog display (for verification)
|
||||||
static public String getDialogTitle(GpsNiNotification notif)
|
static public String getDialogTitle(GpsNiNotification notif, Context context)
|
||||||
{
|
{
|
||||||
return getNotifTitle(notif);
|
return getNotifTitle(notif, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// change this to configure dialog display (for verification)
|
// change this to configure dialog display (for verification)
|
||||||
static private String getDialogMessage(GpsNiNotification notif)
|
static private String getDialogMessage(GpsNiNotification notif, Context context)
|
||||||
{
|
{
|
||||||
return getNotifMessage(notif);
|
return getNotifMessage(notif, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user