SampleApp: remove SkWindow::onPDFSaved, it does not work

Remove SkWindow::onPDFSaved, it does not work and it is not used anymore.

Also, it is very SampleApp -specific feature implemented in SkWindow class.
SkWindow class is probably intended to be more app-agnosting than
what this method implies.

Presumably the idea of the callback was to inform the user of
SampleApp that the PDF was saved to a certain location.

For Android SampleApp, show a hardcoded toast that the PDF was saved to
/sdcard.

BUG=skia:4733
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1547923002

Review URL: https://codereview.chromium.org/1547923002
This commit is contained in:
kkinnunen 2016-01-18 00:47:14 -08:00 committed by Commit bot
parent ab11c3f14c
commit 3ca7336049
7 changed files with 6 additions and 67 deletions

View File

@ -36,8 +36,6 @@ public:
void setVsync(bool);
bool destroyRequested() { return fDestroyRequested; }
virtual void onPDFSaved(const char title[], const char desc[], const char path[]);
protected:
// overrides from SkWindow
virtual void onHandleInval(const SkIRect&);

View File

@ -72,9 +72,6 @@ public:
virtual SkSurface* createSurface();
virtual void onPDFSaved(const char title[], const char desc[],
const char path[]) {}
protected:
virtual bool onEvent(const SkEvent&);
virtual bool onDispatchClick(int x, int y, Click::State, void* owner, unsigned modi);

View File

@ -23,7 +23,6 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
@ -209,7 +208,6 @@ public class SkiaSampleActivity extends Activity
private static final int SET_TITLE = 1;
private static final int SET_SLIDES = 2;
private static final int TOAST_DOWNLOAD = 3;
private Handler mHandler = new Handler() {
@Override
@ -222,10 +220,6 @@ public class SkiaSampleActivity extends Activity
case SET_SLIDES:
mSlideList.addAll((String[]) msg.obj);
break;
case TOAST_DOWNLOAD:
Toast.makeText(SkiaSampleActivity.this, (String) msg.obj,
Toast.LENGTH_SHORT).show();
break;
default:
break;
}
@ -243,28 +237,6 @@ public class SkiaSampleActivity extends Activity
mHandler.obtainMessage(SET_SLIDES, slideList).sendToTarget();
}
// Called by JNI
public void addToDownloads(final String title, final String desc, final String path) {
File file = new File(path);
final long length = file.exists() ? file.length() : 0;
if (length == 0) {
String failed = getString(R.string.save_failed);
mHandler.obtainMessage(TOAST_DOWNLOAD, failed).sendToTarget();
return;
}
String toast = getString(R.string.file_saved).replace("%s", title);
mHandler.obtainMessage(TOAST_DOWNLOAD, toast).sendToTarget();
final DownloadManager manager =
(DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
new Thread("Add PDF to downloads") {
@Override
public void run() {
final String mimeType = "application/pdf";
manager.addCompletedDownload(title, desc, true, mimeType, path, length, true);
}
}.start();
}
private boolean setOpenGLContextSettings(boolean requestedOpenGLAPI, int requestedSampleCount) {
if (mSampleView != null &&
mSampleView.getMSAASampleCount() == requestedSampleCount &&

View File

@ -18,6 +18,7 @@ import android.opengl.GLSurfaceView;
import android.os.Build;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Toast;
public class SkiaSampleView extends GLSurfaceView {
@ -177,6 +178,9 @@ public class SkiaSampleView extends GLSurfaceView {
mSampleRenderer.saveToPDF();
}
});
String msg = getContext().getString(R.string.pdf_save_info);
Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
}
public boolean getUsesOpenGLAPI() {

View File

@ -27,13 +27,11 @@ struct ActivityGlue {
jweak m_obj;
jmethodID m_setTitle;
jmethodID m_setSlideList;
jmethodID m_addToDownloads;
ActivityGlue() {
m_env = nullptr;
m_obj = nullptr;
m_setTitle = nullptr;
m_setSlideList = nullptr;
m_addToDownloads = nullptr;
}
} gActivityGlue;
@ -122,30 +120,6 @@ void SkOSWindow::onHandleInval(const SkIRect& rect)
env->CallVoidMethod(gWindowGlue.m_obj, gWindowGlue.m_inval);
}
void SkOSWindow::onPDFSaved(const char title[], const char desc[],
const char path[])
{
JNIEnv* env = gActivityGlue.m_env;
if (!env || !gActivityGlue.m_addToDownloads || !gActivityGlue.m_obj) {
return;
}
if (env->IsSameObject(gActivityGlue.m_obj, nullptr)) {
SkDebugf("ERROR: The JNI WeakRef to the Activity is invalid");
return;
}
jstring jtitle = env->NewStringUTF(title);
jstring jdesc = env->NewStringUTF(desc);
jstring jpath = env->NewStringUTF(path);
env->CallVoidMethod(gActivityGlue.m_obj, gActivityGlue.m_addToDownloads,
jtitle, jdesc, jpath);
env->DeleteLocalRef(jtitle);
env->DeleteLocalRef(jdesc);
env->DeleteLocalRef(jpath);
}
///////////////////////////////////////////
/////////////// SkEvent impl //////////////
///////////////////////////////////////////
@ -198,8 +172,6 @@ JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env,
gActivityGlue.m_obj = env->NewWeakGlobalRef(jsampleActivity);
gActivityGlue.m_setTitle = GetJMethod(env, clazz, "setTitle", "(Ljava/lang/CharSequence;)V");
gActivityGlue.m_setSlideList = GetJMethod(env, clazz, "setSlideList", "([Ljava/lang/String;)V");
gActivityGlue.m_addToDownloads = GetJMethod(env, clazz, "addToDownloads",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
env->DeleteLocalRef(clazz);
// setup jni hooks to the java renderer

View File

@ -8,11 +8,10 @@
<string name="tiling">Toggle Tiling</string>
<string name="bbox">Toggle SKP BBox</string>
<string name="save_to_pdf">Save to PDF</string>
<string name="save_failed">Save Failed</string>
<string name="file_saved">%s saved!</string>
<string name="pdf_save_info">View saved as PDF to directory \"/sdcard\"</string>
<string name="glcontext_menu">Set OpenGL Context Type</string>
<string name="glcontext_opengles">OpenGL ES</string>
<string name="glcontext_msaa4_opengles">OpenGL ES, MSAA4</string>
<string name="glcontext_opengl">OpenGL</string>
<string name="glcontext_msaa4_opengl">OpenGL, MSAA4</string>
</resources>
</resources>

View File

@ -188,9 +188,6 @@ void SkOSWindow::onSetTitle(const char title[]) {
void SkOSWindow::onHandleInval(const SkIRect& rect) {
}
void SkOSWindow::onPDFSaved(const char title[], const char desc[], const char path[]) {
}
///////////////////////////////////////////
/////////////// SkEvent impl //////////////
///////////////////////////////////////////