Skip to content

Commit

Permalink
App reduced to minimal functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank Narula committed Nov 28, 2017
1 parent 538ccd3 commit 934b8ac
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 217 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ typings/

# All json files
*.json
!serviceAccountKey.json
!package*

# All rules
Expand Down
2 changes: 1 addition & 1 deletion App/SmartHome/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ static void configSmartHome(View rootView, MainActivity current) {
current.tv.setText("NO INTERNET CONNECTION");
current.statusCard = rootView.findViewById(R.id.statusCard);
current.alertCard = rootView.findViewById(R.id.notifCard);

current.statusCard.setVisibility(View.INVISIBLE);
current.alertCard.setVisibility(View.INVISIBLE);
current.roomCard.setVisibility(View.INVISIBLE);
rootView.findViewById(R.id.homePage)
.setBackgroundDrawable(current.getResources().getDrawable(R.drawable.app_background));
Helpers.fixBackgroundRepeat(rootView.findViewById(R.id.homePage));
Expand All @@ -88,6 +90,10 @@ public void onDataChange(DataSnapshot dataSnapshot) {
User regUser = dataSnapshot.getValue(User.class);
if(regUser != null ){
finalCurrent.tv.setText("Registered User :\nName- " + regUser.name + "\nPhone- " + regUser.contact);
finalCurrent.statusCard.setVisibility(View.VISIBLE);
finalCurrent.alertCard.setVisibility(View.VISIBLE);
v.findViewById(R.id.roomCard).setVisibility(View.VISIBLE);
finalCurrent.roomCard.setVisibility(View.VISIBLE);
finalCurrent.statusCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -240,11 +246,7 @@ public void onCancelled(DatabaseError databaseError) {
});
}

static void configSensorData(View rootView, MainActivity current) {
showLatestSensorReadings(rootView, current);
}

private static void showLatestSensorReadings(View rootView,MainActivity current) {
static void showLatestSensorReadings(View rootView,MainActivity current) {

rootView.findViewById(R.id.sensorsStatus)
.setBackgroundDrawable(current.getResources().getDrawable(R.drawable.app_background));
Expand All @@ -253,8 +255,7 @@ private static void showLatestSensorReadings(View rootView,MainActivity current)
current.lightValue = rootView.findViewById(R.id.lightValue);
current.tempValue = rootView.findViewById(R.id.tempValue);
current.humValue = rootView.findViewById(R.id.humValue);
current.inStatus = rootView.findViewById(R.id.inSwitch);
current.outStatus = rootView.findViewById(R.id.outSwitch);
current.motion = rootView.findViewById(R.id.mSwitch);

final MainActivity finalCurrent = current;

Expand All @@ -267,8 +268,7 @@ public void onChildAdded(DataSnapshot snap, String s) {
finalCurrent.lightValue.setText(String.valueOf(latestSensor.light));
finalCurrent.humValue.setText(String.valueOf(latestSensor.humidity));
finalCurrent.tempValue.setText(String.valueOf(latestSensor.temp));
finalCurrent.inStatus.setChecked(latestSensor.inDoorMotion);
finalCurrent.outStatus.setChecked(latestSensor.outDoorMotion);
finalCurrent.motion.setChecked(latestSensor.motion);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MainActivity extends AppCompatActivity {
EditText OTRK;
TextView tv,lightValue,humValue,tempValue,msg;
DatabaseReference userDB,sensorDB,alertsDB;
Switch inStatus,outStatus;
Switch motion;
CardView statusCard,roomCard,alertCard;
ImageView img;
RecyclerView alertsList;
Expand Down Expand Up @@ -167,7 +167,7 @@ private void setView(View rootView, int option, MainActivity current) {
break;
case Constants.SENSOR_OP_CODE:
if (current != null && rootView != null)
Helpers.configSensorData(rootView, current);
Helpers.showLatestSensorReadings(rootView, current);
break;
case Constants.SMART_HOME_OP:
if (current != null && rootView != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

class State {
public Double temp,humidity,light,ax,ay,az,timestamp,latestIndoorMovement,latestOutdoorMovement;
public boolean inDoorMotion,outDoorMotion;
public Double temp,humidity,light,ax,ay,az,timestamp,latestMovement;
public boolean motion;
State(){
// empty constructor
}
Expand Down
39 changes: 8 additions & 31 deletions App/SmartHome/app/src/main/res/layout/fragment_sensors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
android:layout_height="wrap_content">

<Switch
android:id="@+id/inSwitch"
android:text="Indoor Motion"
android:id="@+id/mSwitch"
android:text="Motion"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:checked="false"
android:clickable="false"
Expand All @@ -28,29 +28,6 @@
android:padding="@dimen/card_margin" />
</android.support.v7.widget.CardView>


<android.support.v7.widget.CardView
android:layout_marginTop="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin"
card_view:cardCornerRadius="@dimen/card_radius"
card_view:cardBackgroundColor="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Switch
android:id="@+id/outSwitch"
android:text="OutDoor Motion"
android:clickable="false"
android:checked="false"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@android:color/holo_green_dark"
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/card_margin" />
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
android:padding="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
Expand All @@ -63,7 +40,7 @@
android:layout_height="wrap_content">

<TextView
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAlignment="center"
android:textColor="@android:color/holo_red_dark"
android:text="Temperature"
Expand All @@ -73,7 +50,7 @@

<TextView
android:id="@+id/tempValue"
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textAlignment="textEnd"
android:layout_width="match_parent"
Expand All @@ -90,7 +67,7 @@
android:layout_height="wrap_content">

<TextView
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAlignment="center"
android:textColor="@android:color/holo_blue_dark"
android:text="Humidity"
Expand All @@ -100,7 +77,7 @@

<TextView
android:id="@+id/humValue"
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAlignment="textEnd"
android:layout_width="match_parent"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
Expand All @@ -118,7 +95,7 @@
android:layout_height="wrap_content">

<TextView
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAlignment="center"
android:textColor="@android:color/holo_orange_dark"
android:text="Light"
Expand All @@ -128,7 +105,7 @@

<TextView
android:id="@+id/lightValue"
android:padding="@dimen/card_radius"
android:padding="@dimen/card_margin"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textAlignment="textEnd"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions App/SmartHome/app/src/main/res/layout/fragment_smart_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<android.support.v7.widget.CardView
app:cardBackgroundColor="@android:color/holo_orange_light"
app:cardCornerRadius="45dp"
android:visibility="invisible"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginEnd="8dp"
Expand Down Expand Up @@ -56,6 +57,7 @@
android:layout_width="90dp"
android:layout_height="90dp"
android:id="@+id/statusCard"
android:visibility="invisible"
android:layout_marginBottom="30dp"
android:layout_alignBottom="@+id/groupCard"
android:layout_alignStart="@+id/roomCard">
Expand Down Expand Up @@ -93,6 +95,7 @@
android:id="@+id/notifCard"
android:layout_alignTop="@+id/roomCard"
android:layout_toStartOf="@+id/roomCard"
android:visibility="invisible"
android:layout_marginEnd="57dp"
android:layout_marginTop="7dp">

Expand Down Expand Up @@ -127,6 +130,7 @@
android:layout_width="90dp"
android:layout_height="90dp"
android:id="@+id/groupCard"
android:visibility="invisible"
android:layout_marginBottom="9dp"
android:layout_above="@+id/roomCard"
android:layout_toStartOf="@+id/statusCard"
Expand Down
Loading

0 comments on commit 934b8ac

Please sign in to comment.