mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-25 16:59:01 +09:00
pt 1 in reviving the android build (copied from pm 28a1, wish me luck)
This commit is contained in:
parent
efa9662725
commit
d7788a6d6d
4249 changed files with 468189 additions and 0 deletions
51
mobile/android/base/java/org/mozilla/gecko/GuestSession.java
Normal file
51
mobile/android/base/java/org/mozilla/gecko/GuestSession.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
// Utility methods for entering/exiting guest mode.
|
||||
public final class GuestSession {
|
||||
private static final String LOGTAG = "GeckoGuestSession";
|
||||
|
||||
public static final String NOTIFICATION_INTENT = "org.mozilla.gecko.GUEST_SESSION_INPROGRESS";
|
||||
|
||||
private static PendingIntent getNotificationIntent(Context context) {
|
||||
Intent intent = new Intent(NOTIFICATION_INTENT);
|
||||
intent.setClassName(context, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
|
||||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
public static void showNotification(Context context) {
|
||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
||||
final Resources res = context.getResources();
|
||||
builder.setContentTitle(res.getString(R.string.guest_browsing_notification_title))
|
||||
.setContentText(res.getString(R.string.guest_browsing_notification_text))
|
||||
.setSmallIcon(R.drawable.alert_guest)
|
||||
.setOngoing(true)
|
||||
.setContentIntent(getNotificationIntent(context));
|
||||
|
||||
final NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.notify(R.id.guestNotification, builder.build());
|
||||
}
|
||||
|
||||
public static void hideNotification(Context context) {
|
||||
final NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(R.id.guestNotification);
|
||||
}
|
||||
|
||||
public static void onNotificationIntentReceived(BrowserApp context) {
|
||||
context.showGuestModeDialog(BrowserApp.GuestModeDialog.LEAVING);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue