keys.scala, etc.: Make merging public keys have a progress bar.
[tripe-android] / toy-activity.scala
index 868b3d2..7ee4dad 100644 (file)
@@ -12,66 +12,9 @@ import android.view.View;
 
 import scala.util.control.Breaks;
 
-object Setup {
-  private final val TAG = "Setup";
-  private val BREAK = new Breaks;
-  import BREAK.{breakable, break};
-
-  def setup(ctx: Context) {
-    val bindir = ctx.getDir("bin", MODE_WORLD_READABLE);
-    val assets = ctx.getAssets;
-
-    val abis =
-      try { classOf[Build].getField("SUPPORTED_ABIS").get(null).asInstanceOf[Array[String]] }
-      catch {
-       case _: NoSuchFieldException => Array(CPU_ABI, CPU_ABI2) flatMap {
-         case null | "" => None
-         case s => Some(s)
-       }
-      };
-
-    Log.d(TAG, s"abis = ${abis.mkString(", ")}");
-    Log.d(TAG, s"assets: ${assets.list("bin").mkString(", ")}");
-
-    for (abi <- abis) {
-      val binsrc = s"bin/$abi";
-      for (base <- assets.list(binsrc)) {
-       val prog = new File(bindir, base);
-       if (!prog.exists) try {
-         Log.d(TAG, s"creating $prog...");
-         val in = assets.open(s"$binsrc/$base");
-         Log.d(TAG, "opened source...");
-         val out = new FileOutputStream(prog);
-         Log.d(TAG, "opened target...");
-         val buf = new Array[Byte](4096);
-         breakable {
-           while (true) {
-             val n = in.read(buf);
-             Log.d(TAG, s"read $n bytes...");
-             if (n <= 0) break;
-             out.write(buf, 0, n);
-           }
-         }
-         in.close();
-         out.close();
-         Log.d(TAG, "set permissions...");
-         if (!prog.setReadable(true, false) ||
-             !prog.setExecutable(true, false))
-           throw new IOException("failed to set program permissions");
-       } catch {
-         case exc: IOException =>
-           Log.wtf(TAG, "fuck, failed to create prog", exc);
-       }
-      }
-    }
-    Log.d(TAG, "all OK");
-  }
-}
 
 object ToyActivity {
   private final val TAG = "ToyActivity";
-  System.loadLibrary("jni");
-  @native protected def foo();
 }
 
 class ToyActivity extends Activity {
@@ -79,15 +22,11 @@ class ToyActivity extends Activity {
 
   override protected def onCreate(joy: Bundle) {
     super.onCreate(joy);
-    Setup.setup(this);
+    app.setup(this);
     setContentView(R.layout.toy);
+    Log.d(TAG, s"created ${this}");
   }
   def clickOk(v: View) {
     Log.d(TAG, "OK, OK.  (Scala was here.)");
-    foo();
-
-    val bindir = getDir("bin", MODE_WORLD_READABLE);
-    Runtime.getRuntime.exec(Array(new File(bindir, "prog").getPath,
-                                 "testing", "1", "2", "3"));
   }
 }