Added pebble watch app to assets folder, and added an 'installWatchApp()' function - still not working - installes from pebble store, not the pbw file...
This commit is contained in:
@@ -73,6 +73,11 @@ public abstract class SdDataSource {
|
||||
Log.v(TAG, "stop()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the watch app on the watch.
|
||||
*/
|
||||
public void installWatchApp() { Log.v(TAG,"installWatchApp"); }
|
||||
|
||||
/**
|
||||
* Display a Toast message on screen.
|
||||
* @param msg - message to display.
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
package uk.org.openseizuredetector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -36,6 +38,11 @@ import com.getpebble.android.kit.Constants;
|
||||
import com.getpebble.android.kit.PebbleKit;
|
||||
import com.getpebble.android.kit.util.PebbleDictionary;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
@@ -576,6 +583,39 @@ public class SdDataSourcePebble extends SdDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the wach app that is bundled in the 'assets' folder of this
|
||||
* phone app.
|
||||
* from https://github.com/pebble-examples/pebblekit-android-example/blob/master/android/Eclipse/src/com/getpebble/pebblekitexample/MainActivity.java#L148
|
||||
*/
|
||||
@Override
|
||||
public void installWatchApp() {
|
||||
Log.v(TAG, "SdDataSourcePebble.installWatchApp()");
|
||||
final String WATCHAPP_FILENAME = "pebble_sd.pbw";
|
||||
|
||||
try {
|
||||
// Read .pbw from assets/
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
File file = new File(mContext.getExternalFilesDir(null), WATCHAPP_FILENAME);
|
||||
InputStream is = mContext.getResources().getAssets().open(WATCHAPP_FILENAME);
|
||||
OutputStream os = new FileOutputStream(file);
|
||||
byte[] pbw = new byte[is.available()];
|
||||
is.read(pbw);
|
||||
os.write(pbw);
|
||||
is.close();
|
||||
os.close();
|
||||
|
||||
// Install via Pebble Android app
|
||||
intent.setDataAndType(Uri.fromFile(file), "application/pbw");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(mContext, "App install failed: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ public class StartupActivity extends Activity {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.camera_prefs, true);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.general_prefs, true);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.network_datasource_prefs, true);
|
||||
PreferenceManager.setDefaultValues(this, R.xml.pebble_datasource_prefs, false);
|
||||
|
||||
Button b = (Button)findViewById(R.id.settingsButton);
|
||||
b.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -105,7 +104,9 @@ public class StartupActivity extends Activity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.v(TAG, "pebble button clicked");
|
||||
mUtil.startPebbleApp();
|
||||
mUtil.showToast("pebble button clicked");
|
||||
//mUtil.startPebbleApp();
|
||||
mConnection.mSdServer.mSdDataSource.installWatchApp();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user