mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014 Merged-In: Ib4b72e0a277d8b2fb78837bed5d2e9cccd819a07 Change-Id: I9d0e133b64c2d6afb795eb049c58bc2ff5ab79b5
This commit is contained in:
commit
0f20a65101
@ -19,9 +19,6 @@ package com.android.inputmethod.dictionarypack;
|
|||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.app.DownloadManager.Query;
|
import android.app.DownloadManager.Query;
|
||||||
import android.app.DownloadManager.Request;
|
import android.app.DownloadManager.Request;
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -36,10 +33,7 @@ import android.provider.Settings;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.ConnectivityManagerCompatUtils;
|
|
||||||
import com.android.inputmethod.compat.NotificationCompatUtils;
|
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.common.LocaleUtils;
|
|
||||||
import com.android.inputmethod.latin.makedict.FormatSpec;
|
import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||||
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
||||||
import com.android.inputmethod.latin.utils.DebugLogUtils;
|
import com.android.inputmethod.latin.utils.DebugLogUtils;
|
||||||
@ -843,54 +837,6 @@ public final class UpdateHandler {
|
|||||||
return compareMetadataForUpgrade(context, clientId, currentMetadata, newMetadata);
|
return compareMetadataForUpgrade(context, clientId, currentMetadata, newMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the notification that informs the user a dictionary is available.
|
|
||||||
*
|
|
||||||
* When this notification is clicked, the dialog for downloading the dictionary
|
|
||||||
* over a metered connection is shown.
|
|
||||||
*/
|
|
||||||
private static void showDictionaryAvailableNotification(final Context context,
|
|
||||||
final String clientId, final ContentValues installCandidate) {
|
|
||||||
final String localeString = installCandidate.getAsString(MetadataDbHelper.LOCALE_COLUMN);
|
|
||||||
final Intent intent = new Intent();
|
|
||||||
intent.setClass(context, DownloadOverMeteredDialog.class);
|
|
||||||
intent.putExtra(DownloadOverMeteredDialog.CLIENT_ID_KEY, clientId);
|
|
||||||
intent.putExtra(DownloadOverMeteredDialog.WORDLIST_TO_DOWNLOAD_KEY,
|
|
||||||
installCandidate.getAsString(MetadataDbHelper.WORDLISTID_COLUMN));
|
|
||||||
intent.putExtra(DownloadOverMeteredDialog.SIZE_KEY,
|
|
||||||
installCandidate.getAsInteger(MetadataDbHelper.FILESIZE_COLUMN));
|
|
||||||
intent.putExtra(DownloadOverMeteredDialog.LOCALE_KEY, localeString);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
|
||||||
final PendingIntent notificationIntent = PendingIntent.getActivity(context,
|
|
||||||
0 /* requestCode */, intent,
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
|
|
||||||
final NotificationManager notificationManager =
|
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
// None of those are expected to happen, but just in case...
|
|
||||||
if (null == notificationIntent || null == notificationManager) return;
|
|
||||||
|
|
||||||
final String language = (null == localeString) ? ""
|
|
||||||
: LocaleUtils.constructLocaleFromString(localeString).getDisplayLanguage();
|
|
||||||
final String titleFormat = context.getString(R.string.dict_available_notification_title);
|
|
||||||
final String notificationTitle = String.format(titleFormat, language);
|
|
||||||
final Notification.Builder builder = new Notification.Builder(context)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setContentIntent(notificationIntent)
|
|
||||||
.setContentTitle(notificationTitle)
|
|
||||||
.setContentText(context.getString(R.string.dict_available_notification_description))
|
|
||||||
.setTicker(notificationTitle)
|
|
||||||
.setOngoing(false)
|
|
||||||
.setOnlyAlertOnce(true)
|
|
||||||
.setSmallIcon(R.drawable.ic_notify_dictionary);
|
|
||||||
NotificationCompatUtils.setColor(builder,
|
|
||||||
context.getResources().getColor(R.color.notification_accent_color));
|
|
||||||
NotificationCompatUtils.setPriorityToLow(builder);
|
|
||||||
NotificationCompatUtils.setVisibilityToSecret(builder);
|
|
||||||
NotificationCompatUtils.setCategoryToRecommendation(builder);
|
|
||||||
final Notification notification = NotificationCompatUtils.build(builder);
|
|
||||||
notificationManager.notify(DICT_AVAILABLE_NOTIFICATION_ID, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs a word list if it has never been requested.
|
* Installs a word list if it has never been requested.
|
||||||
*
|
*
|
||||||
|
@ -119,8 +119,7 @@ public final class AudioAndHapticFeedbackManager {
|
|||||||
// Go ahead with the system default
|
// Go ahead with the system default
|
||||||
if (viewToPerformHapticFeedbackOn != null) {
|
if (viewToPerformHapticFeedbackOn != null) {
|
||||||
viewToPerformHapticFeedbackOn.performHapticFeedback(
|
viewToPerformHapticFeedbackOn.performHapticFeedback(
|
||||||
HapticFeedbackConstants.KEYBOARD_TAP,
|
HapticFeedbackConstants.KEYBOARD_TAP);
|
||||||
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,12 @@
|
|||||||
package="com.android.inputmethod.tools.edittextvariations"
|
package="com.android.inputmethod.tools.edittextvariations"
|
||||||
android:versionName="0.67"
|
android:versionName="0.67"
|
||||||
android:versionCode="67">
|
android:versionCode="67">
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
<supports-screens android:resizeable="true"/>
|
<supports-screens android:resizeable="true"/>
|
||||||
<uses-sdk android:targetSdkVersion="27"
|
<uses-sdk android:targetSdkVersion="27"
|
||||||
android:minSdkVersion="11"/>
|
android:minSdkVersion="11"/>
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
<application android:icon="@drawable/ic_launcher"
|
<application android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:allowBackup="false">
|
android:allowBackup="false">
|
||||||
@ -34,6 +37,10 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".EditorActivity"
|
||||||
|
android:windowSoftInputMode="stateHidden|adjustPan"
|
||||||
|
android:theme="@style/defaultActivityTheme"
|
||||||
|
android:label="@string/app_name"/>
|
||||||
<receiver android:name=".NotificationBroadcastReceiver"
|
<receiver android:name=".NotificationBroadcastReceiver"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
</application>
|
</application>
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
<string name="menu_softinput_hidden" translatable="false">Keyboard Hidden</string>
|
<string name="menu_softinput_hidden" translatable="false">Keyboard Hidden</string>
|
||||||
<!-- The menu title to send a notification to test direct reply. [CHAR LIMIT=20] -->
|
<!-- The menu title to send a notification to test direct reply. [CHAR LIMIT=20] -->
|
||||||
<string name="menu_direct_reply">Direct Reply</string>
|
<string name="menu_direct_reply">Direct Reply</string>
|
||||||
|
<!-- The menu title to show a application overlay with NOT_FOCUSABLE | ALT_FOCUSABLE_IM. [CHAR LIMIT=26] -->
|
||||||
|
<string name="menu_show_ime_focusable_overlay">Show IME focusable overlay</string>
|
||||||
|
<!-- The menu title to hide a application overlay with NOT_FOCUSABLE | ALT_FOCUSABLE_IM. [CHAR LIMIT=26] -->
|
||||||
|
<string name="menu_hide_ime_focusable_overlay">Hide IME focusable overlay</string>
|
||||||
<!-- The example of custom action key label. Must be short to fit on key. 5 chars or less is preferable. [CHAR LIMIT=7] -->
|
<!-- The example of custom action key label. Must be short to fit on key. 5 chars or less is preferable. [CHAR LIMIT=7] -->
|
||||||
<string name="custom_action_label">Custom</string>
|
<string name="custom_action_label">Custom</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -16,18 +16,31 @@
|
|||||||
|
|
||||||
package com.android.inputmethod.tools.edittextvariations;
|
package com.android.inputmethod.tools.edittextvariations;
|
||||||
|
|
||||||
|
import static android.graphics.Color.BLUE;
|
||||||
|
import static android.view.Gravity.LEFT;
|
||||||
|
import static android.view.Gravity.TOP;
|
||||||
|
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||||
|
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||||
|
import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
||||||
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -45,7 +58,9 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -61,9 +76,11 @@ public final class EditTextVariations extends Activity implements TextView.OnEdi
|
|||||||
private static final int MENU_SOFTINPUT_VISIBLE = 4;
|
private static final int MENU_SOFTINPUT_VISIBLE = 4;
|
||||||
private static final int MENU_SOFTINPUT_HIDDEN = 5;
|
private static final int MENU_SOFTINPUT_HIDDEN = 5;
|
||||||
private static final int MENU_DIRECT_REPLY = 6;
|
private static final int MENU_DIRECT_REPLY = 6;
|
||||||
|
private static final int MENU_TOGGLE_IME_FOCUSABLE_OVERLAY = 7;
|
||||||
private static final String PREF_THEME = "theme";
|
private static final String PREF_THEME = "theme";
|
||||||
private static final String PREF_NAVIGATE = "navigate";
|
private static final String PREF_NAVIGATE = "navigate";
|
||||||
private static final String PREF_SOFTINPUT = "softinput";
|
private static final String PREF_SOFTINPUT = "softinput";
|
||||||
|
private static final int NOTIFICATION_PERMISSION_REQUEST_CODE = 0;
|
||||||
|
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
private View[] fields;
|
private View[] fields;
|
||||||
@ -80,6 +97,9 @@ public final class EditTextVariations extends Activity implements TextView.OnEdi
|
|||||||
|
|
||||||
private ArrayAdapter<String> mAutoCompleteAdapter;
|
private ArrayAdapter<String> mAutoCompleteAdapter;
|
||||||
|
|
||||||
|
private TextView mOverlayTextView;
|
||||||
|
private boolean mShowOverlay = true;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Override
|
@Override
|
||||||
@ -166,9 +186,12 @@ public final class EditTextVariations extends Activity implements TextView.OnEdi
|
|||||||
if (NotificationUtils.DIRECT_REPLY_SUPPORTED) {
|
if (NotificationUtils.DIRECT_REPLY_SUPPORTED) {
|
||||||
menu.add(Menu.NONE, MENU_DIRECT_REPLY, 5, R.string.menu_direct_reply);
|
menu.add(Menu.NONE, MENU_DIRECT_REPLY, 5, R.string.menu_direct_reply);
|
||||||
}
|
}
|
||||||
|
menu.add(Menu.NONE, MENU_TOGGLE_IME_FOCUSABLE_OVERLAY, 6,
|
||||||
|
mShowOverlay ? getString(R.string.menu_show_ime_focusable_overlay)
|
||||||
|
: getString(R.string.menu_hide_ime_focusable_overlay));
|
||||||
try {
|
try {
|
||||||
final PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
final PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
menu.add(Menu.NONE, MENU_VERSION, 6,
|
menu.add(Menu.NONE, MENU_VERSION, 7,
|
||||||
getString(R.string.menu_version, pinfo.versionName))
|
getString(R.string.menu_version, pinfo.versionName))
|
||||||
.setEnabled(false);
|
.setEnabled(false);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
@ -199,11 +222,53 @@ public final class EditTextVariations extends Activity implements TextView.OnEdi
|
|||||||
saveSoftInputMode(itemId == MENU_SOFTINPUT_VISIBLE);
|
saveSoftInputMode(itemId == MENU_SOFTINPUT_VISIBLE);
|
||||||
restartActivity();
|
restartActivity();
|
||||||
} else if (itemId == MENU_DIRECT_REPLY) {
|
} else if (itemId == MENU_DIRECT_REPLY) {
|
||||||
NotificationUtils.sendDirectReplyNotification(this);
|
final boolean needPermissionCheck = isNeedNotificationPermission()
|
||||||
|
&& checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) !=
|
||||||
|
PackageManager.PERMISSION_GRANTED;
|
||||||
|
if (needPermissionCheck) {
|
||||||
|
requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS },
|
||||||
|
NOTIFICATION_PERMISSION_REQUEST_CODE);
|
||||||
|
} else {
|
||||||
|
NotificationUtils.sendDirectReplyNotification(this);
|
||||||
|
}
|
||||||
|
} else if (itemId == MENU_TOGGLE_IME_FOCUSABLE_OVERLAY) {
|
||||||
|
if (!Settings.canDrawOverlays(this)) {
|
||||||
|
Toast.makeText(this,
|
||||||
|
"Not allowed to show overlay.\nCheck \"Settings > "
|
||||||
|
+ "Display over other apps\"", Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
toggleOverlayView(true /* needsIme */);
|
||||||
|
item.setTitle(mShowOverlay ? getString(R.string.menu_show_ime_focusable_overlay)
|
||||||
|
: getString(R.string.menu_hide_ime_focusable_overlay));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||||
|
int[] grantResults) {
|
||||||
|
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
||||||
|
if (grantResults.length == 1 &&
|
||||||
|
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// Permission is granted. Continue to send the notification.
|
||||||
|
NotificationUtils.sendDirectReplyNotification(this);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "POST_NOTIFICATIONS Permissions denied.");
|
||||||
|
Toast.makeText(this, "Required permission has denied",
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
if (mOverlayTextView != null) {
|
||||||
|
getWindowManager().removeView(mOverlayTextView);
|
||||||
|
mOverlayTextView = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final DialogInterface dialog, final int which) {
|
public void onClick(final DialogInterface dialog, final int which) {
|
||||||
saveTheme(ThemeItem.THEME_LIST.get(which));
|
saveTheme(ThemeItem.THEME_LIST.get(which));
|
||||||
@ -476,4 +541,36 @@ public final class EditTextVariations extends Activity implements TextView.OnEdi
|
|||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isNeedNotificationPermission() {
|
||||||
|
for(Field field : Manifest.permission.class.getFields()) {
|
||||||
|
if (field.getName().equals("POST_NOTIFICATIONS")) {
|
||||||
|
Log.d(TAG, "Need notification permission.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleOverlayView(boolean needsIme) {
|
||||||
|
if (mOverlayTextView == null) {
|
||||||
|
Context overlayContext = createDisplayContext(getDisplay())
|
||||||
|
.createWindowContext(TYPE_APPLICATION_OVERLAY, null /* options */);
|
||||||
|
int focusableFlags = FLAG_NOT_FOCUSABLE | (needsIme ? FLAG_ALT_FOCUSABLE_IM : 0);
|
||||||
|
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||||
|
TYPE_APPLICATION_OVERLAY, FLAG_WATCH_OUTSIDE_TOUCH | focusableFlags);
|
||||||
|
final Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds();
|
||||||
|
params.width = windowBounds.width() / 3;
|
||||||
|
params.height = windowBounds.height() / 3;
|
||||||
|
params.gravity = TOP | LEFT;
|
||||||
|
|
||||||
|
mOverlayTextView = new TextView(overlayContext);
|
||||||
|
mOverlayTextView.setText("I'm an IME focusable overlay");
|
||||||
|
mOverlayTextView.setBackgroundColor(BLUE);
|
||||||
|
getWindowManager().addView(mOverlayTextView, params);
|
||||||
|
}
|
||||||
|
mOverlayTextView.setVisibility(mShowOverlay ? View.VISIBLE : View.GONE);
|
||||||
|
// Toggle the overlay visibility after the call.
|
||||||
|
mShowOverlay = !mShowOverlay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.tools.edittextvariations;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
public final class EditorActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
LinearLayout layout = new LinearLayout(this);
|
||||||
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
EditText editText = new EditText(this);
|
||||||
|
editText.setHint("reply the message");
|
||||||
|
layout.addView(editText);
|
||||||
|
setContentView(layout);
|
||||||
|
}
|
||||||
|
}
|
@ -57,7 +57,7 @@ final class NotificationUtils {
|
|||||||
synchronized (sLock) {
|
synchronized (sLock) {
|
||||||
if (!sNotificationChannelInitialized) {
|
if (!sNotificationChannelInitialized) {
|
||||||
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
|
||||||
CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
|
||||||
channel.setDescription(CHANNEL_DESCRIPTION);
|
channel.setDescription(CHANNEL_DESCRIPTION);
|
||||||
context.getSystemService(NotificationManager.class)
|
context.getSystemService(NotificationManager.class)
|
||||||
.createNotificationChannel(channel);
|
.createNotificationChannel(channel);
|
||||||
@ -79,12 +79,15 @@ final class NotificationUtils {
|
|||||||
|
|
||||||
final int notificationId = sNextNotificationId.getAndIncrement();
|
final int notificationId = sNextNotificationId.getAndIncrement();
|
||||||
final PendingIntent pendingIntent = getReplyPendingIntent(context, notificationId);
|
final PendingIntent pendingIntent = getReplyPendingIntent(context, notificationId);
|
||||||
|
final PendingIntent activityIntent = PendingIntent.getActivity(context, 0,
|
||||||
|
new Intent(context, EditorActivity.class), 0);
|
||||||
final Notification.Action action =
|
final Notification.Action action =
|
||||||
new Notification.Action.Builder(null, "Direct Reply Test", pendingIntent)
|
new Notification.Action.Builder(null, "Direct Reply Test", pendingIntent)
|
||||||
.addRemoteInput(remoteInput)
|
.addRemoteInput(remoteInput)
|
||||||
.build();
|
.build();
|
||||||
final Notification notification = createNotificationBuilder(context)
|
final Notification notification = createNotificationBuilder(context)
|
||||||
.setContentText("Content Title")
|
.setContentText("Content Title")
|
||||||
|
.setContentIntent(activityIntent)
|
||||||
.setSmallIcon(R.drawable.ic_launcher)
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
.setContentText("Message from " + UserHandle.getUserHandleForUid(Process.myUid()))
|
.setContentText("Message from " + UserHandle.getUserHandleForUid(Process.myUid()))
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user