com.rossmartin.dropbox.PhoneGapSync.java Source code

Java tutorial

Introduction

Here is the source code for com.rossmartin.dropbox.PhoneGapSync.java

Source

/*
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
    
     http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
 */

package com.rossmartin.dropbox;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import org.apache.cordova.*;

public class PhoneGapSync extends CordovaActivity {
    private static final String TAG = "CordovaActivity";
    static final int REQUEST_LINK_TO_DBX = 1337; // This value is up to you, must be the same as in your plugin though

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        //super.registerForContextMenu(super.appView);
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            // viewport hack needed for KitKat and maybe future versions
            super.appView.getSettings().setLoadWithOverviewMode(true);
            super.appView.getSettings().setUseWideViewPort(true);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_LINK_TO_DBX) {
            if (resultCode == Activity.RESULT_OK) {
                // ... You can now start using Dropbox Sync API.
                super.sendJavascript("dropbox_linked();");
            } else {
                // ... Link failed or was cancelled by the user.
                Log.v(TAG, "Dropbox link failed or was cancelled by the user.");
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

}