Android Open Source - AIRShare Launcher Activity






From Project

Back to project page AIRShare.

License

The source code is released under:

Apache License

If you think the Android project AIRShare listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ggt.airshare;
//w w  w.  ja v a 2  s  .  com
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.google.analytics.tracking.android.EasyTracker;
import com.ipaulpro.afilechooser.utils.FileUtils;

import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Launcher activity of the app.
 * <p/>
 * Small help and possibility to pick a file.
 *
 * @author guiguito
 */
public class LauncherActivity extends MotherActivity {

    public static final String KEY_NO_BUTTON = "KEY_NO_BUTTON";

    @InjectView(R.id.mPickAFileButton)
    Button mPickAFileButton;

    private static final int REQUEST_CHOOSER = 1234;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_launcher);

        if (getIntent().hasExtra(KEY_NO_BUTTON) && getIntent().getBooleanExtra(KEY_NO_BUTTON, false)) {
            mPickAFileButton.setVisibility(View.GONE);
        }
        mShowHelpMenuItem = false;
    }

    @OnClick(R.id.mPickAFileButton)
    public void onPickAFileClicked() {
        // Create the ACTION_GET_CONTENT Intent
        Intent getContentIntent = FileUtils.createGetContentIntent();
        Intent intent = Intent.createChooser(getContentIntent,
                getString(R.string.pick_a_file));
        startActivityForResult(intent, REQUEST_CHOOSER);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case REQUEST_CHOOSER:
                if (resultCode == RESULT_OK) {
                    Intent intent = new Intent(this, ShairingActivity.class);
                    Uri uri = data.getData();
                    intent.setAction(Intent.ACTION_SEND);
                    String mimeType = FileUtils.getMimeType(this, uri);
                    //TODO add google drive and one drive support
                    if (mimeType != null) {
                        intent.setType(mimeType);
                        intent.putExtra(Intent.EXTRA_STREAM, uri);
                        startActivity(intent);
                    } else {
                        //EasyTracker.getTracker(this).sendEvent("Event", "data not supported", uri.toString(), null);
                        Toast.makeText(this, getString(R.string.we_cant_share_this), Toast.LENGTH_LONG).show();
                    }
                }
                break;
        }
    }
}




Java Source Code List

com.ggt.airshare.AIRShareApplication.java
com.ggt.airshare.LauncherActivity.java
com.ggt.airshare.MotherActivity.java
com.ggt.airshare.ShairingActivity.java
com.ggt.airshare.httpserver.NanoHTTPD.java
com.ggt.airshare.httpserver.ShAIReHttpServerListener.java
com.ggt.airshare.httpserver.ShAIReHttpServer.java
com.ggt.airshare.httpserver.ShaireServiceListener.java
com.ggt.airshare.httpserver.ShaireService.java
com.ggt.airshare.urlshortener.UrlShortenerException.java
com.ggt.airshare.urlshortener.UrlShortenerListener.java
com.ggt.airshare.urlshortener.UrlShortener.java
com.ggt.airshare.utils.ContactsUtils.java
com.ggt.airshare.utils.FileUtils.java
com.ggt.airshare.utils.HTMLUtils.java
com.ggt.airshare.utils.NetworkUtils.java
com.ggt.airshare.utils.ShAIReConstants.java
com.google.zxing.client.android.Contents.java
com.google.zxing.client.android.FinishListener.java
com.google.zxing.client.android.Intents.java
com.google.zxing.client.android.encode.ContactEncoder.java
com.google.zxing.client.android.encode.EncodeActivity.java
com.google.zxing.client.android.encode.Formatter.java
com.google.zxing.client.android.encode.MECARDContactEncoder.java
com.google.zxing.client.android.encode.QRCodeEncoder.java
com.google.zxing.client.android.encode.VCardContactEncoder.java
com.ianhanniballake.localstorage.LocalStorageProvider.java
com.ipaulpro.afilechooser.FileChooserActivity.java
com.ipaulpro.afilechooser.FileListAdapter.java
com.ipaulpro.afilechooser.FileListFragment.java
com.ipaulpro.afilechooser.FileLoader.java
com.ipaulpro.afilechooser.utils.FileUtils.java
de.psdev.licensesdialog.LicenseResolver.java
de.psdev.licensesdialog.LicensesDialogFragment.java
de.psdev.licensesdialog.LicensesDialog.java
de.psdev.licensesdialog.NoticesHtmlBuilder.java
de.psdev.licensesdialog.NoticesXmlParser.java
de.psdev.licensesdialog.SingleLicenseDialogFragment.java
de.psdev.licensesdialog.SingleLicenseDialog.java
de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20.java
de.psdev.licensesdialog.licenses.BSD3ClauseLicense.java
de.psdev.licensesdialog.licenses.ISCLicense.java
de.psdev.licensesdialog.licenses.License.java
de.psdev.licensesdialog.licenses.MITLicense.java
de.psdev.licensesdialog.licenses.NanoHttpdLicense.java
de.psdev.licensesdialog.licenses.ViewerJSLicense.java
de.psdev.licensesdialog.licenses.XstreamLicense.java
de.psdev.licensesdialog.model.Notice.java
de.psdev.licensesdialog.model.Notices.java