Skip to content

Commit

Permalink
few issues in daily quotes; trip share link
Browse files Browse the repository at this point in the history
  • Loading branch information
Swati4star committed Oct 29, 2018
1 parent db3e858 commit 0bdbfb6
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 144 deletions.
6 changes: 3 additions & 3 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "io.github.project_travel_mate"
minSdkVersion 21
targetSdkVersion 28
versionCode 44
versionName "5.5.0"
versionCode 45
versionName "5.5.2"
}

buildTypes {
Expand Down Expand Up @@ -74,7 +74,7 @@ dependencies {
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
// Lottie : animations
implementation 'com.airbnb.android:lottie:2.7.0'

// To show what's new in the application
implementation 'io.github.tonnyl:whatsnew:0.1.1'
//To display search dialog
Expand Down
1 change: 1 addition & 0 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<activity android:name=".destinations.description.RestaurantsActivity" />
<activity android:name=".destinations.description.TweetsDescriptionActivity" />
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" />
<activity android:name=".utilities.QuotesActivity" />
<activity
android:name=".DeleteProfilePictureActivity"
android:icon="@drawable/ic_delete_round"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.IOException;
import java.util.Objects;

import butterknife.ButterKnife;
import io.github.project_travel_mate.destinations.CityFragment;
import io.github.project_travel_mate.friend.FriendsProfileActivity;
import io.github.project_travel_mate.friend.MyFriendsFragment;
Expand All @@ -57,6 +58,7 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import utils.DailyQuotesManager;

import static utils.Constants.API_LINK_V2;
import static utils.Constants.AUTHORIZATION;
Expand Down Expand Up @@ -95,6 +97,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand All @@ -103,6 +106,8 @@ protected void onCreate(Bundle savedInstanceState) {
mToken = mSharedPreferences.getString(USER_TOKEN, null);
mHandler = new Handler(Looper.getMainLooper());

DailyQuotesManager.checkDailyQuote(this);

// To show what's new in our application
WhatsNew whatsNew = WhatsNew.newInstance(
new WhatsNewItem(WHATS_NEW1_TITLE, WHATS_NEW1_TEXT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
import android.os.Looper;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand All @@ -37,11 +33,8 @@
import butterknife.ButterKnife;
import io.github.project_travel_mate.MainActivity;
import io.github.project_travel_mate.R;
import io.github.project_travel_mate.utilities.DailyQuotesFragment;
import utils.DailyQuotesManager;
import utils.TravelmateSnackbars;

import static utils.Constants.QUOTES_SHOW_DAILY;
import static utils.Constants.USER_EMAIL;
import static utils.Constants.USER_TOKEN;

Expand All @@ -63,8 +56,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
LinearLayout sig;
@BindView(R.id.loginlayout)
LinearLayout log;
@BindView(R.id.quote_framelayout)
FrameLayout quoteLayout;
@BindView(R.id.forgot_password_layout)
LinearLayout mForgotPasswordLayout;
@BindView(R.id.reset_code_layout)
Expand Down Expand Up @@ -140,12 +131,7 @@ protected void onCreate(Bundle savedInstanceState) {
getRunTimePermissions();

// Check for Showing Daily Quote
if (!mSharedPreferences.getBoolean(QUOTES_SHOW_DAILY, true)) {
// If user is already logged in, open MainActivity
checkUserSession();
} else {
DailyQuotesManager.checkDailyQuote(this);
}
checkUserSession();

signup.setOnClickListener(this);
login.setOnClickListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
Expand Down Expand Up @@ -77,6 +78,7 @@
import static utils.Constants.EXTRA_MESSAGE_TRIP_OBJECT;
import static utils.Constants.SHARE_PROFILE_URI;
import static utils.Constants.SHARE_TRIP_TRIP_ID_QUERY;
import static utils.Constants.USER_EMAIL;
import static utils.Constants.USER_TOKEN;

public class MyTripInfoActivity extends AppCompatActivity implements TravelmateSnackbars {
Expand Down Expand Up @@ -117,6 +119,8 @@ public class MyTripInfoActivity extends AppCompatActivity implements TravelmateS
ProgressBar tripNameProgressBar;
@BindView(R.id.addme_to_trip)
LinearLayout addMeToTrip;
@BindView(R.id.public_trip_layout)
RelativeLayout publicPrivateInfo;

private String mFriendId = null;
private String mFriendDeleteId = null;
Expand All @@ -129,6 +133,8 @@ public class MyTripInfoActivity extends AppCompatActivity implements TravelmateS
private MaterialDialog mDialog;
private MyTripFriendNameAdapter mAdapter;
boolean isUserPartofTrip;
private String mUserEmail;
boolean isTripPublic;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -142,9 +148,10 @@ protected void onCreate(Bundle savedInstanceState) {

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mToken = sharedPreferences.getString(USER_TOKEN, null);
mUserEmail = sharedPreferences.getString(USER_EMAIL, null);
if (mTrip.getImage() != null && !mTrip.getImage().isEmpty())
Picasso.with(this).load(mTrip.getImage()).error(R.drawable.placeholder_image)
.placeholder(R.drawable.placeholder_image).into(cityImageView);
.placeholder(R.drawable.placeholder_image).into(cityImageView);
showIcon.setVisibility(GONE);
editTrip.setVisibility(GONE);
mHandler = new Handler(Looper.getMainLooper());
Expand Down Expand Up @@ -180,7 +187,7 @@ public void onClick(View v) {
mIsTripNameEdited = true;
} else {
//clicking edit trip after editing the trip name
if (tripName.getText().length() != 0 ) {
if (tripName.getText().length() != 0) {
editTrip.setImageDrawable(getResources().getDrawable(R.drawable.ic_edit_black_24dp));
tripName.setFocusableInTouchMode(false);
tripName.setCursorVisible(false);
Expand All @@ -196,16 +203,6 @@ public void onClick(View v) {
}
});


isUserPartofTrip = intent.getBooleanExtra(EXTRA_MESSAGE_PART_OF_TRIP, true);
if (isUserPartofTrip) { //user is part of the trip
addMeToTrip.setVisibility(GONE);
} else {
//user is not a part of trip
addMeToTrip.setVisibility(VISIBLE);
addNewFriend.setVisibility(GONE);
friendEmail.setVisibility(GONE);
}
}

@OnClick(R.id.city_image)
Expand Down Expand Up @@ -286,18 +283,8 @@ public void onResponse(Call call, final Response response) {
final String timeString =
new SimpleDateFormat("dd MMM''yy", Locale.US).format(cal.getTime());
tripDate.setText(timeString);
if (!isUserPartofTrip) {
if (isPublic) {
tripPublicMessage.setText(R.string.trip_public_message);
publicToggleButton.setChecked(true);
} else {
tripPublicMessage.setText(R.string.trip_private_message);
publicToggleButton.setChecked(false);
}
} else {
tripPublicMessage.setVisibility(GONE);
publicToggleButton.setVisibility(GONE);
}
isTripPublic = isPublic;

updateFriendList();
animationView.setVisibility(GONE);
} catch (JSONException | IOException | NullPointerException e) {
Expand Down Expand Up @@ -613,7 +600,31 @@ public void onResponse(Call call, final Response response) throws IOException {
try {
ob = new JSONObject(res);
JSONArray usersArray = ob.getJSONArray("users");
if (usersArray.length() == 0) {

isUserPartofTrip = false;
for (int i = 0; i < usersArray.length(); i++) {

JSONObject jsonObject = usersArray.getJSONObject(i);
String friendFirstName = jsonObject.getString("first_name");
String friendLastName = jsonObject.getString("last_name");
String friendImage = jsonObject.getString("image");
String friendJoinedOn = jsonObject.getString("date_joined");
String friendUserName = jsonObject.getString("username");
String friendStatus = jsonObject.getString("status");
int friendId = jsonObject.getInt("id");

if (friendUserName.equals(mUserEmail)) {
isUserPartofTrip = true;
continue;
}

mFriendDeleteId = String.valueOf(friendId);
tripFriends.add(new User(friendUserName, friendFirstName, friendLastName, friendId,
friendImage, friendJoinedOn, friendStatus));
}


if (tripFriends.size() == 0) {
addNewFriend.setVisibility(GONE);
friendEmail.setVisibility(GONE);
noFriendTitle.setVisibility(VISIBLE);
Expand All @@ -624,45 +635,45 @@ public void onResponse(Call call, final Response response) throws IOException {
noFriendTitle.setText(content);
noFriendTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f);

if (isUserPartofTrip) {
noFriendTitle.setOnClickListener(view -> {
noFriendTitle.setVisibility(GONE);
addNewFriend.setVisibility(VISIBLE);
friendEmail.setVisibility(VISIBLE);
friendTitle.setText(R.string.friends_show_title);
friendTitle.setTypeface(null, Typeface.BOLD);
friendTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25f);
});
addNewFriend.setVisibility(VISIBLE);
friendEmail.setVisibility(VISIBLE);
addMeToTrip.setVisibility(GONE);
publicPrivateInfo.setVisibility(VISIBLE);

if (isTripPublic) {
tripPublicMessage.setText(R.string.trip_public_message);
publicToggleButton.setChecked(true);
} else {
noFriendTitle.setVisibility(GONE);
tripPublicMessage.setText(R.string.trip_private_message);
publicToggleButton.setChecked(false);
}
} else {


for (int i = 0; i < usersArray.length(); i++) {

JSONObject jsonObject = usersArray.getJSONObject(i);
String friendFirstName = jsonObject.getString("first_name");
String friendLastName = jsonObject.getString("last_name");
String friendImage = jsonObject.getString("image");
String friendJoinedOn = jsonObject.getString("date_joined");
String friendUserName = jsonObject.getString("username");
String friendStatus = jsonObject.getString("status");
int friendId = jsonObject.getInt("id");

mFriendDeleteId = String.valueOf(friendId);
tripFriends.add(new User(friendUserName, friendFirstName, friendLastName, friendId,
friendImage, friendJoinedOn, friendStatus));
}
} else {


friendTitle.setText(R.string.friends_show_title);
friendTitle.setVisibility(VISIBLE);
showIcon.setVisibility(VISIBLE);

if (isUserPartofTrip) {
if (isUserPartofTrip) { //user is part of the trip
addNewFriend.setVisibility(VISIBLE);
friendEmail.setVisibility(VISIBLE);
addMeToTrip.setVisibility(GONE);
publicPrivateInfo.setVisibility(VISIBLE);

if (isTripPublic) {
tripPublicMessage.setText(R.string.trip_public_message);
publicToggleButton.setChecked(true);
} else {
tripPublicMessage.setText(R.string.trip_private_message);
publicToggleButton.setChecked(false);
}

} else {
//user is not a part of trip
addMeToTrip.setVisibility(VISIBLE);
addNewFriend.setVisibility(GONE);
friendEmail.setVisibility(GONE);
}


Expand Down Expand Up @@ -736,10 +747,10 @@ public void onResponse(Call call, Response response) throws IOException {
mHandler.post(() -> {
if (response.isSuccessful()) {
TravelmateSnackbars.createSnackBar(findViewById(R.id.activityMyTripInfo),
R.string.trip_name_updated, Snackbar.LENGTH_SHORT).show();
R.string.trip_name_updated, Snackbar.LENGTH_SHORT).show();
} else {
TravelmateSnackbars.createSnackBar(findViewById(R.id.activityMyTripInfo),
res, Snackbar.LENGTH_LONG).show();
res, Snackbar.LENGTH_LONG).show();
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import android.support.annotation.MainThread;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import android.arch.persistence.room.migration.Migration;
import android.content.Context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -37,10 +36,8 @@
import io.github.project_travel_mate.roompersistence.ChecklistViewModel;
import io.github.project_travel_mate.roompersistence.Injection;
import io.github.project_travel_mate.roompersistence.ViewModelFactory;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.flowables.ConnectableFlowable;
import io.reactivex.schedulers.Schedulers;
import objects.ChecklistItem;
import utils.TravelmateSnackbars;
Expand Down
Loading

0 comments on commit 0bdbfb6

Please sign in to comment.