2015-04-06 20:58:35 +02:00
package nodomain.freeyourgadget.gadgetbridge.pebble ;
import android.app.Activity ;
import android.content.Intent ;
import android.net.Uri ;
import android.os.Bundle ;
import android.support.v4.app.NavUtils ;
import android.view.MenuItem ;
import android.view.View ;
import android.widget.Button ;
import android.widget.TextView ;
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService ;
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp ;
import nodomain.freeyourgadget.gadgetbridge.R ;
public class PebbleAppInstallerActivity extends Activity {
private final String TAG = this . getClass ( ) . getSimpleName ( ) ;
TextView debugTextView ;
Button installButton ;
@Override
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState ) ;
setContentView ( R . layout . activity_appinstaller ) ;
getActionBar ( ) . setDisplayHomeAsUpEnabled ( true ) ;
debugTextView = ( TextView ) findViewById ( R . id . debugTextView ) ;
installButton = ( Button ) findViewById ( R . id . installButton ) ;
final Uri uri = getIntent ( ) . getData ( ) ;
PBWReader pbwReader = new PBWReader ( uri , getApplicationContext ( ) ) ;
GBDeviceApp app = pbwReader . getGBDeviceApp ( ) ;
2015-04-07 19:33:23 +02:00
2015-04-06 20:58:35 +02:00
if ( pbwReader ! = null & & app ! = null ) {
2015-04-07 23:57:12 +02:00
debugTextView . setText ( " THIS IS HIGHLY EXPERIMENTAL PROCEED AT YOUR OWN RISK \ n \ n \ n " + app . getName ( ) + " Version " + app . getVersion ( ) + " by " + app . getCreator ( ) + " \ n " ) ;
2015-04-06 20:58:35 +02:00
installButton . setEnabled ( true ) ;
installButton . setOnClickListener ( new View . OnClickListener ( ) {
@Override
public void onClick ( View v ) {
Intent startIntent = new Intent ( PebbleAppInstallerActivity . this , BluetoothCommunicationService . class ) ;
startIntent . setAction ( BluetoothCommunicationService . ACTION_INSTALL_PEBBLEAPP ) ;
startIntent . putExtra ( " app_uri " , uri . toString ( ) ) ;
startService ( startIntent ) ;
}
} ) ;
}
}
@Override
public boolean onOptionsItemSelected ( MenuItem item ) {
switch ( item . getItemId ( ) ) {
case android . R . id . home :
NavUtils . navigateUpFromSameTask ( this ) ;
return true ;
}
return super . onOptionsItemSelected ( item ) ;
}
@Override
protected void onDestroy ( ) {
super . onDestroy ( ) ;
}
}