blob: 92003bf7bf76e8ac48abde16a95f82c3e868c26c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* 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.libreoffice.impressremote;
import org.libreoffice.impressremote.communication.CommunicationService;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
/**
* This class is used to centralise the processing of Broadcasts concerning
* presentation/connection status changes which result in a change of activity.
*
* I.e. this will switch to the correct activity and correctly set up the
* activity backstack when switching activity.
*
* To use create this on activity startup, and pass messages from your
* BroadcastReceiver's onReceive.
*
*/
public class ActivityChangeBroadcastProcessor {
private Activity mActivity;
public ActivityChangeBroadcastProcessor(Activity aActivity) {
mActivity = aActivity;
}
public void addToFilter(IntentFilter aFilter) {
aFilter.addAction(CommunicationService.STATUS_CONNECTED_NOSLIDESHOW);
aFilter.addAction(CommunicationService.STATUS_CONNECTED_SLIDESHOW_RUNNING);
aFilter.addAction(CommunicationService.STATUS_PAIRING_PINVALIDATION);
}
public void onReceive(Context aContext, Intent aIntent) {
if (aIntent.getAction().equals(
CommunicationService.STATUS_CONNECTED_NOSLIDESHOW)) {
Intent nIntent = new Intent(mActivity,
StartPresentationActivity.class);
nIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mActivity.startActivity(nIntent);
} else if (aIntent
.getAction()
.equals(CommunicationService.STATUS_CONNECTED_SLIDESHOW_RUNNING)) {
Intent nIntent = new Intent(mActivity, PresentationActivity.class);
nIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mActivity.startActivity(nIntent);
} else if (aIntent.getAction().equals(
CommunicationService.STATUS_PAIRING_PINVALIDATION)) {
Intent nIntent = new Intent(mActivity, PairingActivity.class);
nIntent.putExtras(aIntent.getExtras()); // Pass on pin and other info.
mActivity.startActivity(nIntent);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|