Android Open Source - lildebi Install Log View Activity






From Project

Back to project page lildebi.

License

The source code is released under:

GNU General Public License

If you think the Android project lildebi 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 info.guardianproject.lildebi;
//from w w w  .ja  va  2s  .c  om
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import org.apache.commons.io.FileUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class InstallLogViewActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.install_log_view);
        setProgressBarIndeterminateVisibility(true);
        new LoadLogTask().execute();
        Button shareButton = (Button) findViewById(R.id.shareButton);
        shareButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                shareInstallLog(NativeHelper.install_log);
            }
        });

    }

    protected void shareInstallLog(File f) {
        if (!NativeHelper.isSdCardPresent()) {
            Toast.makeText(this, R.string.no_sdcard_message, Toast.LENGTH_LONG)
                    .show();
            return;
        }
        final File fToSend = new File(NativeHelper.publicFiles, f.getName());
        try {
            FileUtils.copyFile(f, fToSend);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Intent i = new Intent(android.content.Intent.ACTION_SEND);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, "install.log from Lil' Debi");
        i.putExtra(Intent.EXTRA_TEXT,
                "Attached is an log sent by Lil' Debi.  For more info, see:\n"
                        + "https://github.com/guardianproject/lildebi\n\n"
                        + "manufacturer: " + Build.MANUFACTURER + "\n"
                        + "model: " + Build.MODEL + "\n"
                        + "product: " + Build.PRODUCT + "\n"
                        + "brand: " + Build.BRAND + "\n"
                        + "device: " + Build.DEVICE + "\n"
                        + "board: " + Build.BOARD + "\n"
                        + "ID: " + Build.ID + "\n"
                        + "CPU ABI: " + Build.CPU_ABI + "\n"
                        + "release: " + Build.VERSION.RELEASE + "\n"
                        + "incremental: " + Build.VERSION.INCREMENTAL + "\n"
                        + "codename: " + Build.VERSION.CODENAME + "\n"
                        + "SDK: " + Build.VERSION.SDK_INT + "\n"
                        );
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fToSend));
        startActivity(Intent.createChooser(i, "How do you want to share?"));
    }

    private class LoadLogTask extends AsyncTask<Void, Void, String> {

        @Override
        protected String doInBackground(Void... params) {
            StringBuilder log = new StringBuilder("");
            try {
                BufferedReader in = new BufferedReader(new FileReader(
                        NativeHelper.install_log));
                String line = "";
                while (line != null) {
                    log.append(line + "\n");
                    line = in.readLine();
                    if (isCancelled())
                        break;
                }
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return log.toString();
        }

        protected void onPostExecute(String result) {
            final TextView installLog = (TextView) findViewById(R.id.installLogView);
            installLog.setText(result);
            setProgressBarIndeterminateVisibility(false);
        }
    }

}




Java Source Code List

info.guardianproject.lildebi.BootCompletedReceiver.java
info.guardianproject.lildebi.InstallActivity.java
info.guardianproject.lildebi.InstallLogViewActivity.java
info.guardianproject.lildebi.InstallService.java
info.guardianproject.lildebi.LilDebiAction.java
info.guardianproject.lildebi.LilDebiApplication.java
info.guardianproject.lildebi.LilDebi.java
info.guardianproject.lildebi.MediaEjectReceiver.java
info.guardianproject.lildebi.MediaMountedReceiver.java
info.guardianproject.lildebi.MediaUnmountedReceiver.java
info.guardianproject.lildebi.NativeHelper.java
info.guardianproject.lildebi.PreferencesActivity.java
info.guardianproject.lildebi.SelectArch.java
info.guardianproject.lildebi.SelectMirror.java
info.guardianproject.lildebi.SelectRelease.java
info.guardianproject.lildebi.StreamDisplay.java
info.guardianproject.lildebi.StreamThread.java
info.guardianproject.lildebi.UnsupportedDeviceActivity.java
org.torproject.android.service.TorServiceConstants.java
org.torproject.android.service.TorServiceUtils.java