-
Notifications
You must be signed in to change notification settings - Fork 61
Pull request to update for supporting LCP #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ | |
import android.app.AlertDialog; | ||
import android.content.DialogInterface; | ||
|
||
import android.os.Handler; | ||
import android.os.Message; | ||
/** | ||
* @author chtian | ||
* | ||
|
@@ -71,6 +73,8 @@ public void done() { | |
|
||
private Context context; | ||
private final String testPath = "epubtest"; | ||
private Handler mHandler = null; | ||
private String mBookName; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
|
@@ -100,41 +104,85 @@ protected void onCreate(Bundle savedInstanceState) { | |
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, | ||
long arg3) { | ||
|
||
String bookName = list.get(arg2); | ||
mBookName = list.get(arg2); | ||
|
||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + testPath + "/" + bookName; | ||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + testPath + "/" + mBookName; | ||
|
||
Toast.makeText(context, "Select " + bookName, Toast.LENGTH_SHORT).show(); | ||
Toast.makeText(context, "Select " + mBookName, Toast.LENGTH_SHORT).show(); | ||
|
||
m_SdkErrorHandler_Messages = new Stack<String>(); | ||
|
||
EPub3.setSdkErrorHandler(ContainerList.this); | ||
Container container = EPub3.openBook(path); | ||
EPub3.setSdkErrorHandler(null); | ||
|
||
ContainerHolder.getInstance().put(container.getNativePtr(), container); | ||
|
||
Intent intent = new Intent(getApplicationContext(), BookDataActivity.class); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.putExtra(Constants.BOOK_NAME, bookName); | ||
intent.putExtra(Constants.CONTAINER_ID, container.getNativePtr()); | ||
|
||
SdkErrorHandlerMessagesCompleted callback = new SdkErrorHandlerMessagesCompleted(intent) { | ||
@Override | ||
public void once() { | ||
startActivity(m_intent); | ||
} | ||
mHandler = new Handler() { | ||
@Override | ||
public void handleMessage(Message msg) { | ||
Container container = (Container)msg.obj; | ||
if(container == null){ | ||
//error message show | ||
SdkErrorHandlerMessagesCompleted callback = new SdkErrorHandlerMessagesCompleted(null) { | ||
@Override | ||
public void once() { | ||
//do notthing | ||
} | ||
}; | ||
// async! | ||
popSdkErrorHandlerMessage(context, callback); | ||
} | ||
else{ | ||
ContainerHolder.getInstance().put(container.getNativePtr(), container); | ||
|
||
Intent intent = new Intent(getApplicationContext(), BookDataActivity.class); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.putExtra(Constants.BOOK_NAME, mBookName); | ||
intent.putExtra(Constants.CONTAINER_ID, container.getNativePtr()); | ||
|
||
SdkErrorHandlerMessagesCompleted callback = new SdkErrorHandlerMessagesCompleted(intent) { | ||
@Override | ||
public void once() { | ||
startActivity(m_intent); | ||
} | ||
}; | ||
|
||
// async! | ||
popSdkErrorHandlerMessage(context, callback); | ||
} | ||
} | ||
}; | ||
|
||
// async! | ||
popSdkErrorHandlerMessage(context, callback); | ||
//Run on thread | ||
OpenBookOnThread task = new OpenBookOnThread(path); | ||
task.start(); | ||
} | ||
}); | ||
|
||
// Loads the native lib and sets the path to use for cache | ||
EPub3.setCachePath(getCacheDir().getAbsolutePath()); | ||
} | ||
|
||
class OpenBookOnThread extends Thread{ | ||
String mPath; | ||
OpenBookOnThread(final String path){ | ||
mPath = path; | ||
} | ||
@Override | ||
public void run() | ||
{ | ||
Container container = EPub3.openBook(mPath); | ||
EPub3.setSdkErrorHandler(null); | ||
Message msg = new Message(); | ||
msg.obj = container; | ||
mHandler.sendMessage(msg); | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly to my question on iOS ( https://github.com/readium/SDKLauncher-iOS/pull/68/files#r49284709 ) I wonder if a new thread is necessary here? Instead, could the "client" user interface can be dispatched into its own execution context, when it needs it? Side note: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like iOS, It is necessary for the UI thread. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your feedback @fasooDev6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "OpenContainer" can not be excuted on the main thread in roder to apply for integrate the readium-DRM(LCP) from DRM Inside. Because it is block readium-DRM to receive user input when run UI dialog. Also, we try to use the "asyncTask" android framework in place to implement the existing, but where the UI dialog to run the openContainer could not be applied because it must reside in separate project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC @clebeaupin who is in the process of implementing support for Content Module (and has developed the entire Android Studio / Gradle port, and LCP-JNI integration) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up: @clebeaupin implemented the asynchronous |
||
|
||
private void containerRegisterContentModules(Context context) | ||
{ | ||
DrmInitialize drmInitialize = new DrmInitialize(); | ||
drmInitialize.initialize(context); | ||
} | ||
|
||
private Stack<String> m_SdkErrorHandler_Messages = null; | ||
|
||
// async! | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// DrmInitialize.java | ||
// SDKLauncher-OSX | ||
// | ||
// Created by Fasoo.com Development Team on 2015-12-12. | ||
// ( M.N. Kim ) | ||
// | ||
// Copyright (c) 2015 The Readium Foundation and contributors. All rights reserved. | ||
// | ||
// The Readium SDK 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/> | ||
// | ||
package org.readium.sdk.android.launcher; | ||
|
||
import android.content.Context; | ||
|
||
public class DrmInitialize { | ||
void initialize(Context context){ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there is a similar PR for the proposed above code change (nil container):
https://github.com/readium/SDKLauncher-Android/pull/76/files#diff-c50ac569905f558500aec3f615f04357