1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-07 13:47:49 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleAppInstallerActivity.java

68 lines
2.4 KiB
Java

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();
if (pbwReader != null && app != null) {
debugTextView.setText("THIS IS HIGHLY EXPERIMENTAL PROCEED AT YOUR OWN RISK\n\n\n" + app.getName() + " Version " + app.getVersion() + " by " + app.getCreator() + "\n");
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();
}
}