Search in sources :

Example 6 with Information

use of seemoo.fitbit.information.Information in project fitness-app by seemoo-lab.

the class WorkActivity method initialize.

/**
 * Initializes several objects.
 */
private void initialize() {
    device = (BluetoothDevice) getIntent().getExtras().get("device");
    buttonHandler = new ButtonHandler(activity);
    buttonHandler.addButton(R.id.button_WorkActivity_1);
    buttonHandler.addButton(R.id.button_WorkActivity_2);
    buttonHandler.addButton(R.id.button_WorkActivity_3);
    buttonHandler.addButton(R.id.button_WorkActivity_4);
    buttonHandler.addButton(R.id.button_WorkActivity_5);
    buttonHandler.addButton(R.id.button_WorkActivity_6);
    clearAlarmsButton = (FloatingActionButton) findViewById(R.id.button_WorkActivity_7);
    clearAlarmsButton.setVisibility(View.GONE);
    buttonHandler.addSpecialButton(R.id.button_WorkActivity_8);
    buttonHandler.addSpecialButton(R.id.button_WorkActivity_9);
    saveButton = (FloatingActionButton) findViewById(R.id.button_WorkActivity_10);
    saveButton.setVisibility(View.GONE);
    ArrayAdapter<Information> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, informationToDisplay.getList());
    mListView = (ListView) findViewById(R.id.WorkActivityList);
    mListView.setAdapter(arrayAdapter);
    toast_short = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    toast_long = Toast.makeText(activity, "", Toast.LENGTH_LONG);
    settings.put(R.id.settings_workactivity_1, false);
    settings.put(R.id.settings_workactivity_2, false);
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.setVisibility(View.GONE);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onLoadResource(WebView view, String url) {
            if (url.equals("https://www.fitbit.com/oauth") || url.equals("https://www.fitbit.com/oauth/oauth_login_allow")) {
                toast_long.setText("Please copy the PIN.");
                toast_long.show();
                Timer timer = new Timer();
                timer.schedule(new TimerTask() {

                    @Override
                    public void run() {
                        activity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                buttonHandler.setVisible(R.id.button_WorkActivity_8);
                            }
                        });
                    }
                }, 3000);
            }
        }
    });
    editText = (EditText) findViewById(R.id.editText);
    editText.setVisibility(View.GONE);
    textView = (TextView) findViewById(R.id.textView);
    textView.setText(ConstantValues.ASK_AUTH_PIN);
    textView.setVisibility(View.GONE);
    client = new HttpsClient(toast_short, this);
}
Also used : ButtonHandler(seemoo.fitbit.miscellaneous.ButtonHandler) Information(seemoo.fitbit.information.Information) Timer(java.util.Timer) TimerTask(java.util.TimerTask) HttpsClient(seemoo.fitbit.https.HttpsClient) WebSettings(android.webkit.WebSettings) WebView(android.webkit.WebView) ArrayAdapter(android.widget.ArrayAdapter) WebViewClient(android.webkit.WebViewClient)

Aggregations

Information (seemoo.fitbit.information.Information)6 InformationList (seemoo.fitbit.information.InformationList)5 WebSettings (android.webkit.WebSettings)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ArrayAdapter (android.widget.ArrayAdapter)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 HttpsClient (seemoo.fitbit.https.HttpsClient)1 Alarm (seemoo.fitbit.information.Alarm)1 ButtonHandler (seemoo.fitbit.miscellaneous.ButtonHandler)1