Merge "Fixes for notification history" into rvc-dev am: 5c4c2ed6b3
Change-Id: I55f08a8db4236cfbc23a3b602b1fc0c8e7138519
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<ScrollView
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/scroll"
|
||||
android:layout_width="match_parent"
|
||||
@@ -124,22 +124,15 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:paddingBottom="16dp" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/rounded_bg">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/notification_list"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/rounded_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:scrollbars="none"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -156,21 +149,14 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:paddingBottom="16dp" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="3dp"
|
||||
android:clipChildren="true"
|
||||
android:background="@drawable/rounded_bg">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/notification_list"
|
||||
android:elevation="3dp"
|
||||
android:background="@drawable/rounded_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:scrollbars="none"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -198,4 +184,4 @@
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
@@ -73,18 +73,12 @@
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/listDivider"/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:clipChildren="true"
|
||||
android:layout_height="wrap_content">
|
||||
<com.android.settings.notification.history.NotificationHistoryRecyclerView
|
||||
android:id="@+id/notification_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:importantForAccessibility="yes"
|
||||
android:scrollbars="none"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -77,7 +77,7 @@ public class NotificationHistoryActivity extends Activity {
|
||||
View viewForPackage = LayoutInflater.from(this)
|
||||
.inflate(R.layout.notification_history_app_layout, null);
|
||||
|
||||
final View container = viewForPackage.findViewById(R.id.list_container);
|
||||
final View container = viewForPackage.findViewById(R.id.notification_list);
|
||||
container.setVisibility(View.GONE);
|
||||
ImageButton expand = viewForPackage.findViewById(R.id.expand);
|
||||
expand.setContentDescription(container.getVisibility() == View.VISIBLE
|
||||
|
@@ -16,13 +16,22 @@
|
||||
|
||||
package com.android.settings.notification.history;
|
||||
|
||||
import static android.provider.Settings.EXTRA_APP_PACKAGE;
|
||||
import static android.provider.Settings.EXTRA_CHANNEL_ID;
|
||||
import static android.provider.Settings.EXTRA_CONVERSATION_ID;
|
||||
|
||||
import android.app.INotificationManager;
|
||||
import android.app.NotificationHistory.HistoricalNotification;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Slog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -63,8 +72,37 @@ public class NotificationHistoryAdapter extends
|
||||
holder.setTitle(hn.getTitle());
|
||||
holder.setSummary(hn.getText());
|
||||
holder.setPostedTime(hn.getPostedTimeMs());
|
||||
holder.addOnClick(hn.getPackage(), hn.getUserId(), hn.getChannelId(),
|
||||
hn.getConversationId());
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
.putExtra(EXTRA_APP_PACKAGE, hn.getPackage())
|
||||
.putExtra(EXTRA_CHANNEL_ID, hn.getChannelId())
|
||||
.putExtra(EXTRA_CONVERSATION_ID, hn.getConversationId());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
holder.itemView.getContext().startActivityAsUser(intent, UserHandle.of(hn.getUserId()));
|
||||
});
|
||||
holder.itemView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(View host,
|
||||
AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
CharSequence description =
|
||||
host.getResources().getText(R.string.notification_history_view_settings);
|
||||
AccessibilityNodeInfo.AccessibilityAction customClick =
|
||||
new AccessibilityNodeInfo.AccessibilityAction(
|
||||
AccessibilityNodeInfo.ACTION_CLICK, description);
|
||||
info.addAction(customClick);
|
||||
//info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(View host, int action, Bundle args) {
|
||||
if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS.getId()) {
|
||||
onItemSwipeDeleted(position);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -34,6 +34,7 @@ public class NotificationHistoryRecyclerView extends RecyclerView {
|
||||
ItemTouchHelper touchHelper = new ItemTouchHelper(
|
||||
new DismissTouchHelper(0, ItemTouchHelper.START | ItemTouchHelper.END));
|
||||
touchHelper.attachToRecyclerView(this);
|
||||
setNestedScrollingEnabled(false);
|
||||
}
|
||||
|
||||
public void setOnItemSwipeDeleteListener(OnItemSwipeDeleteListener listener) {
|
||||
|
@@ -16,20 +16,10 @@
|
||||
|
||||
package com.android.settings.notification.history;
|
||||
|
||||
import static android.provider.Settings.EXTRA_APP_PACKAGE;
|
||||
import static android.provider.Settings.EXTRA_CHANNEL_ID;
|
||||
import static android.provider.Settings.EXTRA_CONVERSATION_ID;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.DateTimeView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -61,28 +51,4 @@ public class NotificationHistoryViewHolder extends RecyclerView.ViewHolder {
|
||||
void setPostedTime(long postedTime) {
|
||||
mTime.setTime(postedTime);
|
||||
}
|
||||
|
||||
void addOnClick(String pkg, int userId, String channelId, String conversationId) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
.putExtra(EXTRA_APP_PACKAGE, pkg)
|
||||
.putExtra(EXTRA_CHANNEL_ID, channelId)
|
||||
.putExtra(EXTRA_CONVERSATION_ID, conversationId);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
itemView.getContext().startActivityAsUser(intent, UserHandle.of(userId));
|
||||
});
|
||||
ViewCompat.setAccessibilityDelegate(itemView, new AccessibilityDelegateCompat() {
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(View host,
|
||||
AccessibilityNodeInfoCompat info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
CharSequence description =
|
||||
host.getResources().getText(R.string.notification_history_view_settings);
|
||||
AccessibilityNodeInfoCompat.AccessibilityActionCompat customClick =
|
||||
new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
|
||||
AccessibilityNodeInfoCompat.ACTION_CLICK, description);
|
||||
info.addAction(customClick);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Slog;
|
||||
@@ -81,9 +82,15 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
void setProfileBadge(Drawable badge) {
|
||||
mProfileBadge.setImageDrawable(badge);
|
||||
mProfileBadge.setVisibility(badge != null ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
void addOnClick(String pkg, int userId, PendingIntent pi) {
|
||||
Intent appIntent = itemView.getContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(pkg);
|
||||
boolean isPendingIntentValid = pi != null && PendingIntent.getActivity(
|
||||
itemView.getContext(), 0, pi.getIntent(), PendingIntent.FLAG_NO_CREATE) != null;
|
||||
if (isPendingIntentValid || appIntent != null) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
if (pi != null) {
|
||||
try {
|
||||
@@ -91,9 +98,7 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
} catch (PendingIntent.CanceledException e) {
|
||||
Slog.e(TAG, "Could not launch", e);
|
||||
}
|
||||
} else {
|
||||
Intent appIntent = itemView.getContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(pkg);
|
||||
} else if (appIntent != null) {
|
||||
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
itemView.getContext().startActivityAsUser(appIntent, UserHandle.of(userId));
|
||||
@@ -116,4 +121,5 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user