diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java index 90cd7fa..50f1877 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java @@ -203,7 +203,6 @@ protected void onStart() public void onPause() { super.onPause(); - overridePendingTransition(0, 0); } diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java index c7edab8..a507139 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java @@ -4,6 +4,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.GridLayoutManager; @@ -12,7 +14,12 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; +import android.widget.ImageView; import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.google.android.gms.tasks.Task; +import com.google.android.gms.tasks.TaskCompletionSource; import garbagecollectors.com.unipool.R; import garbagecollectors.com.unipool.adapters.HomeActivityTEA; @@ -24,7 +31,7 @@ public class HomeActivity extends BaseActivity static public RelativeLayout noEntryRelativeLayout; - @Override + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -42,6 +49,11 @@ protected void onCreate(Bundle savedInstanceState) drawerLayout = findViewById(R.id.home_layout); noEntryRelativeLayout = findViewById(R.id.no_entry_message); + noEntryRelativeLayout.setOnLongClickListener(v -> + { + changeToSOLogo(); + return true; + }); navDrawerStateListener(); @@ -74,6 +86,30 @@ protected void onCreate(Bundle savedInstanceState) } + private void changeToSOLogo() + { + TaskCompletionSource timerSource = new TaskCompletionSource<>(); + Task timerTask = timerSource.getTask(); + + Handler handler = new Handler(); + handler.postDelayed(() -> timerSource.setResult(null), 3350); + + ImageView mainImage = noEntryRelativeLayout.findViewById(R.id.sad_smiley); + TextView header = noEntryRelativeLayout.findViewById(R.id.such_empty); + TextView footer = noEntryRelativeLayout.findViewById(R.id.no_entry_description); + + mainImage.setBackground(ContextCompat.getDrawable(HomeActivity.this, R.drawable.ic_so_icon)); + header.setText("Is Bae"); + footer.setText(""); + + timerTask.addOnCompleteListener(task -> + { + mainImage.setBackground(ContextCompat.getDrawable(HomeActivity.this, R.drawable.ic_negative_smiley)); + header.setText("Such empty..."); + footer.setText("Maybe you can create a new entry?"); + }); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java index d81f330..a26fce5 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java @@ -1,5 +1,6 @@ package garbagecollectors.com.unipool.activities; +import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; @@ -39,7 +40,9 @@ public class MessageListActivity extends AppCompatActivity EditText messageArea; ScrollView scrollView; - private static TreeMap personalMessageMap; //key = CreatedItTime + ProgressDialog messageProgressDialog; + + private static TreeMap personalMessageMap; //key = CreatedAtTime private static User chatUser; private static PairUp pairUp; @@ -62,11 +65,17 @@ protected void onCreate(Bundle savedInstanceState) messagesOnScreen = new ArrayList<>(); + messageProgressDialog = new ProgressDialog(this); + messageProgressDialog.setMessage("Fetching your messages..."); + messageProgressDialog.show(); + setScrollViewToBottom(); DatabaseReference userMessageDatabaseReference = FirebaseDatabase.getInstance(). getReference("messages/" + BaseActivity.getFinalCurrentUser().getUserId()); + //load from local + userMessageDatabaseReference.addChildEventListener(new ChildEventListener() { @Override @@ -76,7 +85,6 @@ public void onChildAdded(DataSnapshot dataSnapshot, String s) if (message != null) { - messageArea.setHint("Fetching messages...."); UtilityMethods.putMessageInMap(BaseActivity.getMessages(), message); if (!message.getMessageId().equals("def@ult") && (message.getSenderId().equals(chatUser.getUserId()) @@ -89,9 +97,11 @@ public void onChildAdded(DataSnapshot dataSnapshot, String s) showMessage(message); } } + + else if(message.getMessageId().equals("def@ult")) + messageProgressDialog.dismiss(); } - messageArea.setHint("Write a message..."); } @Override @@ -167,21 +177,12 @@ public void onBackPressed() setName("asdsafasde"); } - private void setScrollViewToBottom() - { - View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1); - int bottom = lastChild.getBottom() + scrollView.getPaddingBottom(); - int sy = scrollView.getScrollY(); - int sh = scrollView.getHeight(); - int delta = bottom - (sy + sh); - - scrollView.smoothScrollBy(0, delta); - } - private void showMessage(Message message) { messagesOnScreen.add(message.getMessageId()); + //messageProgressDialog.dismiss(); + if(message.getSenderId().equals(BaseActivity.getFinalCurrentUser().getUserId())) { addMessageBox(message.getMessage(), message.getCreatedAtTime(), 1); @@ -230,6 +231,17 @@ public void addMessageBox(String message, Long createdAtTime, int type) setScrollViewToBottom(); } + private void setScrollViewToBottom() + { + View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1); + int bottom = lastChild.getBottom() + scrollView.getPaddingBottom(); + int sy = scrollView.getScrollY(); + int sh = scrollView.getHeight(); + int delta = bottom - (sy + sh); + + scrollView.smoothScrollBy(0, delta); + } + public static void setPairUp(PairUp pairUp) diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java index fe136f1..135325b 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java @@ -26,6 +26,7 @@ import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.PendingResult; import com.google.android.gms.common.api.Status; +import com.google.android.gms.location.places.AutocompleteFilter; import com.google.android.gms.location.places.Place; import com.google.android.gms.location.places.PlaceLikelihood; import com.google.android.gms.location.places.PlaceLikelihoodBuffer; @@ -203,8 +204,14 @@ private void showPlaceAutocomplete(int i) { try { + AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder() + .setTypeFilter(Place.TYPE_COUNTRY) + .setCountry("IN") + .build(); + Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) + .setFilter(autocompleteFilter) .build(this); startActivityForResult(intent, i); diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java index 032e6df..cc1b66c 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java @@ -37,8 +37,8 @@ public class SplashActivity extends AppCompatActivity FirebaseAuth mAuth; static FirebaseUser currentUser; - private TaskCompletionSource delaySource = new TaskCompletionSource<>(); - private Task delayTask = delaySource.getTask(); + private TaskCompletionSource timerSource = new TaskCompletionSource<>(); + private Task timerTask = timerSource.getTask(); private TaskCompletionSource UserDBSource = new TaskCompletionSource<>(); private Task UserDBTask = UserDBSource.getTask(); @@ -72,7 +72,8 @@ protected void onCreate(Bundle savedInstanceState) messageDatabaseReference = FirebaseDatabase.getInstance().getReference("messages/" + currentUser.getUid()); - new Handler().postDelayed(() -> delaySource.setResult(null), 2350); + Handler handler = new Handler(); + handler.postDelayed(() -> timerSource.setResult(null), 12350); userDatabaseReference.addListenerForSingleValueEvent(new ValueEventListener() { @@ -106,9 +107,11 @@ public void onCancelled(DatabaseError databaseError) } }); - Task allTask = Tasks.whenAll(UserDBTask, EntryDBTask, delayTask); + Task allTask = Tasks.whenAll(UserDBTask, EntryDBTask); allTask.addOnSuccessListener(aVoid -> { + handler.removeCallbacksAndMessages(null); + DataSnapshot userData = (DataSnapshot) UserDBTask.getResult(); DataSnapshot entryData = (DataSnapshot) EntryDBTask.getResult(); @@ -155,6 +158,12 @@ public void onCancelled(DatabaseError databaseError) // apologize profusely to the user! Toast.makeText(getApplicationContext(), "Network Issues!", Toast.LENGTH_SHORT).show(); }); + + timerTask.addOnCompleteListener(task -> + { + if(timerTask.getResult() == null) + Toast.makeText(this, "Network not that good, I'm trying...", Toast.LENGTH_LONG).show(); + }); } public static ArrayList getTripEntryList() diff --git a/app/src/main/res/drawable/ic_so_icon.xml b/app/src/main/res/drawable/ic_so_icon.xml new file mode 100644 index 0000000..f30b47c --- /dev/null +++ b/app/src/main/res/drawable/ic_so_icon.xml @@ -0,0 +1,5 @@ + + + + diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 62db075..17ea4db 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -51,6 +51,7 @@