forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: [jni] add Activity and refactor to use our specific descendant
- Loading branch information
Showing
10 changed files
with
137 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2014 Team XBMC | ||
* http://xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "Activity.h" | ||
#include "Intent.h" | ||
|
||
#include "jutils/jutils-details.hpp" | ||
|
||
#include <android/native_activity.h> | ||
|
||
using namespace jni; | ||
|
||
CJNIActivity::CJNIActivity(const ANativeActivity *nativeActivity) : CJNIContext(nativeActivity) | ||
{ | ||
} | ||
|
||
CJNIActivity::~CJNIActivity() | ||
{ | ||
} | ||
|
||
bool CJNIActivity::moveTaskToBack(bool nonRoot) | ||
{ | ||
return call_method<jboolean>(jhobject(m_context), | ||
"moveTaskToBack", "(Z)Z", | ||
nonRoot); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
/// \brief CJNIApplicationMainActivity::CJNIApplicationMainActivity | ||
/// \param nativeActivity | ||
/// | ||
|
||
CJNIApplicationMainActivity* CJNIApplicationMainActivity::m_appInstance(NULL); | ||
|
||
CJNIApplicationMainActivity::CJNIApplicationMainActivity(const ANativeActivity *nativeActivity) | ||
: CJNIActivity(nativeActivity) | ||
{ | ||
m_appInstance = this; | ||
} | ||
|
||
CJNIApplicationMainActivity::~CJNIApplicationMainActivity() | ||
{ | ||
m_appInstance = NULL; | ||
} | ||
|
||
void CJNIApplicationMainActivity::_onNewIntent(JNIEnv *env, jobject context, jobject intent) | ||
{ | ||
(void)env; | ||
(void)context; | ||
if(m_appInstance) | ||
m_appInstance->onNewIntent(CJNIIntent(jhobject(intent))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2014 Team XBMC | ||
* http://xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "JNIBase.h" | ||
#include "Context.h" | ||
|
||
struct ANativeActivity; | ||
|
||
class CJNIActivity : public CJNIContext | ||
{ | ||
public: | ||
CJNIActivity(const ANativeActivity *nativeActivity); | ||
~CJNIActivity(); | ||
|
||
static bool moveTaskToBack(bool nonRoot); | ||
|
||
private: | ||
CJNIActivity(); | ||
}; | ||
|
||
/////////////////////////////////// | ||
|
||
class CJNIApplicationMainActivity : public CJNIActivity | ||
{ | ||
public: | ||
CJNIApplicationMainActivity(const ANativeActivity *nativeActivity); | ||
~CJNIApplicationMainActivity(); | ||
|
||
static CJNIApplicationMainActivity* GetAppInstance() { return m_appInstance; } | ||
|
||
static void _onNewIntent(JNIEnv *env, jobject context, jobject intent); | ||
|
||
private: | ||
static CJNIApplicationMainActivity *m_appInstance; | ||
|
||
protected: | ||
virtual void onNewIntent(CJNIIntent intent)=0; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters