Commit 08f3090b authored by Giacomo Lavermicocca's avatar Giacomo Lavermicocca Committed by Pietro Saccardi

fix some wrong if position - add label in activity to show function used

parent 02059f9b
......@@ -50,23 +50,10 @@ public class MainActivity extends AppCompatActivity {
}
});
// Toast.makeText(getApplicationContext(), val, Toast.LENGTH_LONG).show();
//
// Intent intent = getIntent();
// Bundle extras = intent.getExtras();
// if (extras != null) {
// mAppWidgetId = extras.getInt(
// AppWidgetManager.EXTRA_APPWIDGET_ID,
// AppWidgetManager.INVALID_APPWIDGET_ID);
// Log.e("TAGG", mAppWidgetId+"");
// }
FirebaseMessaging.getInstance().subscribeToTopic("OPEN");
String value = "";
if(getIntent().getExtras() != null) {
value = getIntent().getExtras().getString("OPEN");
String value = getIntent().getExtras().getString("OPEN");
SendSms sms = new SendSms();
......@@ -80,10 +67,32 @@ public class MainActivity extends AppCompatActivity {
TextView mTextField = (TextView) findViewById(R.id.timer);
TextView mTextSummary = (TextView) findViewById(R.id.tvSummary);
SetText(mTextSummary, value);
CountD(mTextField);
}
}
private void SetText(TextView mTextSummary, String function) {
switch (function)
{
case "OPEN_0":
mTextSummary.setText("ESCO");
break;
case "OPEN_1":
mTextSummary.setText("GARAGE");
break;
case "OPEN_2":
mTextSummary.setText("PORTONE");
break;
case "OPEN_3":
mTextSummary.setText("ENTRO");
break;
}
}
private void CountD(final TextView mTextField)
{
new CountDownTimer(10000, 1000) {
......
......@@ -5,14 +5,9 @@ import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
import java.util.Random;
/**
* Created by Giacomo on 26/08/2017.
*/
......@@ -24,7 +19,7 @@ public class MainActivityWidget extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_main_widget);
views.setOnClickPendingIntent(R.id.btn_esci, makePIntent(context, 0, "OPEN_0"));
views.setOnClickPendingIntent(R.id.btn_esco, makePIntent(context, 0, "OPEN_0"));
views.setOnClickPendingIntent(R.id.btn_garage, makePIntent(context, 1, "OPEN_1"));
views.setOnClickPendingIntent(R.id.btn_portone, makePIntent(context, 2, "OPEN_2"));
views.setOnClickPendingIntent(R.id.btn_entro, makePIntent(context, 3, "OPEN_3"));
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
......@@ -13,12 +12,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="10"
android:fontFamily="sans-serif"
android:textSize="70dp"
android:layout_above="@+id/button2" />
android:layout_above="@+id/btnEsci"
android:layout_below="@+id/tvSummary" />
<Button
android:id="@+id/btnEsci"
......@@ -30,4 +29,16 @@
android:layout_alignParentStart="true"
android:text="Esci"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/tvSummary"
android:fontFamily="sans-serif"
android:textSize="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="..." />
</RelativeLayout>
......@@ -28,7 +28,7 @@
android:theme="@style/MyButton" />
<Button
android:id="@+id/btn_esci"
android:id="@+id/btn_esco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ESCI"
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
</menu>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="numeroSim">
<item name="0">Scelto al momento</item>
<item name="1">SIM 1</item>
<item name="2">SIM 2</item>
</string-array>
<string-array name="numeroSimValues">
<item name="0">0</item>
<item name="1">1</item>
<item name="2">2</item>
</string-array>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment