diff --git a/.gitignore b/.gitignore index e225ca8..e2ae1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ + # Created by https://www.gitignore.io/api/androidstudio ### AndroidStudio ### diff --git a/README.md b/README.md index 7d24dbf..bb87b25 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ -# audacity +# Audacity -A Collabrative Project under Udacity Scholarship Programme -Giving The Community A Common Platform Where Student's, Developers Together Can Showcase Their Work And Build Their Personal Portfolio. Feel Free To Share And Experience Everything Around Udacity +Brief Idea: +'Giving The Community A Common Platform Where Students, Developers together can Showcase their work And build their Personal Portfolio. Feel Free To Share And Experience Everything Around Udacity` + +## Disclaimer +> `This project is only for the students who participated in Udacity Scholarship Programme (Android Basics Course).` ## What's Included?
    @@ -10,7 +14,7 @@ Giving The Community A Common Platform Where Student's, Developers Together Can
  1. Results
-## Future Addons +## Future Add-ons
  1. Git Integration
  2. Slack Channel
  3. @@ -18,19 +22,20 @@ Giving The Community A Common Platform Where Student's, Developers Together Can
  4. Popular Apps
-## Maintainers - +## Project Maintained by: + +* [Kshitij Suri](https://github.com/kshitijsuri90) +* [pallab (Pallab Kalita)](#) +* [maddySmith (Maddala Krishnachaitanya)](https://github.com/sloth-grrr) +* [SABDAR SHAIK](https://github.com/sabdar18) +* [Suhanshu Patel](https://github.com/Suhanshu123) +* [Mohan Cm](https://github.com/mohancm) +* [Naseem](https://github.com/naseemali925) +* [Ankush S Shetkar](https://github.com/lifeLessCoder) +* [Sumit Roy(sroy)](https://github.com/sroy8091) ## Contributors -All Google Udacity Andriod Basics Scholars are eligible to Contribute. +All Google Udacity Android Basics Scholars are eligible to Contribute. Please Read The Contributing Guide Here ## How You Can Contribute? ## @@ -120,7 +125,7 @@ Now, it may be desirable to squash some of your smaller commits down into a smal ```shell # Rebase all commits on your development branch -git checkout +git checkout git rebase -i master ``` diff --git a/app/build.gradle b/app/build.gradle index cf654c4..b994452 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,9 +38,10 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - implementation 'com.google.firebase:firebase-auth:12.0.1' + implementation 'com.google.firebase:firebase-auth:15.0.0' + implementation 'com.google.firebase:firebase-database:15.0.0' implementation 'de.hdodenhof:circleimageview:2.2.0' - implementation 'com.google.android.gms:play-services-auth:12.0.1' + implementation 'com.google.android.gms:play-services-auth:15.0.0' // Android Support Libraries implementation 'com.android.support:recyclerview-v7:27.1.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dc2d4f2..5b55adf 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + @@ -20,6 +20,8 @@ + + \ No newline at end of file diff --git a/app/src/main/java/com/example/android/audacity/DashboardActivity.java b/app/src/main/java/com/example/android/audacity/DashboardActivity.java index d177ada..fbb18c5 100644 --- a/app/src/main/java/com/example/android/audacity/DashboardActivity.java +++ b/app/src/main/java/com/example/android/audacity/DashboardActivity.java @@ -22,6 +22,9 @@ import com.example.android.audacity.fragments.HottestAppFragment; import com.example.android.audacity.fragments.QuizzesFragment; import com.example.android.audacity.fragments.ResultsFragment; +import com.google.android.gms.auth.api.signin.GoogleSignIn; +import com.google.android.gms.auth.api.signin.GoogleSignInClient; +import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; @@ -30,6 +33,8 @@ public class DashboardActivity extends AppCompatActivity implements NavigationVi private DrawerLayout mDrawer; private NavigationView mNavigationView; private FirebaseAuth mFirebaseAuth; + private GoogleSignInClient mGoogleSignInClient; + private GoogleSignInOptions gso; @Override protected void onCreate(Bundle savedInstanceState) { @@ -38,10 +43,16 @@ protected void onCreate(Bundle savedInstanceState) { mFirebaseAuth = FirebaseAuth.getInstance(); if (mFirebaseAuth == null) { - startActivity(new Intent(this, LoginActivity.class)); - finish(); - + navigateToLogin(); } + + gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) + .requestIdToken(getString(R.string.default_web_client_id)) + .requestEmail() + .build(); + + mGoogleSignInClient = GoogleSignIn.getClient(this, gso); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDrawer = findViewById(R.id.drawer_layout); @@ -140,10 +151,9 @@ public boolean onOptionsItemSelected(MenuItem item) { break; case R.id.nav_sign_out: if (mFirebaseAuth != null) { + mGoogleSignInClient.signOut(); mFirebaseAuth.signOut(); - Intent intent1 = new Intent(DashboardActivity.this, LoginActivity.class); - startActivity(intent1); - finish(); + navigateToLogin(); } break; default: @@ -151,4 +161,10 @@ public boolean onOptionsItemSelected(MenuItem item) { } return super.onOptionsItemSelected(item); } + + private void navigateToLogin() { + Intent intent = new Intent(DashboardActivity.this, LoginActivity.class); + startActivity(intent); + finish(); + } } diff --git a/app/src/main/java/com/example/android/audacity/LoginActivity.java b/app/src/main/java/com/example/android/audacity/LoginActivity.java index ae8c768..a9e267c 100644 --- a/app/src/main/java/com/example/android/audacity/LoginActivity.java +++ b/app/src/main/java/com/example/android/audacity/LoginActivity.java @@ -6,20 +6,14 @@ import android.os.Bundle; import android.util.Log; import android.view.View; -import android.widget.Button; import android.widget.Toast; -import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signin.GoogleSignIn; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.auth.api.signin.GoogleSignInClient; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; -import com.google.android.gms.auth.api.signin.GoogleSignInResult; -import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.SignInButton; import com.google.android.gms.common.api.ApiException; -import com.google.android.gms.common.api.GoogleApi; -import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthCredential; @@ -32,7 +26,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList private static final String TAG = LoginActivity.class.getSimpleName(); private FirebaseAuth mFirebaseAuth; - private SignInButton googleSignInButton; + private SignInButton mGoogleSignInButton; private GoogleSignInClient mGoogleSignInClient; private static final int RC_SIGN_IN = 1012; @@ -54,8 +48,11 @@ protected void onCreate(Bundle savedInstanceState) { showDashboard(); } - googleSignInButton = findViewById(R.id.google_sign_in_button); - googleSignInButton.setOnClickListener(this); + mGoogleSignInButton = findViewById(R.id.google_sign_in_button); + mGoogleSignInButton.setSize(SignInButton.SIZE_WIDE); + mGoogleSignInButton.setOnClickListener(this); + + } @Override @@ -119,7 +116,7 @@ public void onComplete(@NonNull Task task) { private void showDashboard() { Intent intent = new Intent(LoginActivity.this, DashboardActivity.class); startActivity(intent); - + finish(); } diff --git a/app/src/main/java/com/example/android/audacity/SplashActivity.java b/app/src/main/java/com/example/android/audacity/SplashActivity.java new file mode 100644 index 0000000..c3afe96 --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/SplashActivity.java @@ -0,0 +1,17 @@ +package com.example.android.audacity; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +public class SplashActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + startActivity(new Intent(SplashActivity.this, LoginActivity.class)); + // close splash activity + finish(); + + } +} diff --git a/app/src/main/java/com/example/android/audacity/adapters/ChallengesAdapter.java b/app/src/main/java/com/example/android/audacity/adapters/ChallengesAdapter.java new file mode 100644 index 0000000..8d92e92 --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/adapters/ChallengesAdapter.java @@ -0,0 +1,74 @@ +package com.example.android.audacity.adapters; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.example.android.audacity.R; +import com.example.android.audacity.pojo.Challenge; +import com.example.android.audacity.utilities.Helpers; + +import java.util.ArrayList; + +public class ChallengesAdapter extends RecyclerView.Adapter { + + private ArrayList mChallengeData; + private Context mContext; + + public ChallengesAdapter(ArrayList mChallengeData, Context mContext) { + this.mChallengeData = mChallengeData; + this.mContext = mContext; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View rootView = LayoutInflater.from(mContext).inflate(R.layout.item_challenge, parent, false); + return new ViewHolder(rootView); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Challenge challenge = mChallengeData.get(position); + + String title = challenge.getChallengeName(); + String moderatorName = challenge.getModeratorName(); + String endDate = challenge.getEndDate(); + String profileImage = challenge.getProfileImage(); + + holder.challengeName.setText(title); + holder.moderatorName.setText(moderatorName); + holder.endDate.setText(Helpers.formatDate(endDate)); + Glide.with(mContext).load(profileImage).into(holder.profileImage); + } + + @Override + public int getItemCount() { + return mChallengeData.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + private TextView challengeName; + private TextView moderatorName; + private TextView startDate; + private TextView endDate; + private ImageView profileImage; + private Button detailViewButton; + + public ViewHolder(View itemView) { + super(itemView); + challengeName = itemView.findViewById(R.id.challenge_title); + moderatorName = itemView.findViewById(R.id.challenge_moderator_name); + endDate = itemView.findViewById(R.id.challenge_date); + profileImage = itemView.findViewById(R.id.challenge_profile_image); + + } + } +} diff --git a/app/src/main/java/com/example/android/audacity/adapters/HottestAppAdapter.java b/app/src/main/java/com/example/android/audacity/adapters/HottestAppAdapter.java new file mode 100644 index 0000000..c2254b3 --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/adapters/HottestAppAdapter.java @@ -0,0 +1,73 @@ +package com.example.android.audacity.adapters; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.example.android.audacity.R; +import com.example.android.audacity.pojo.HottestApp; +import com.example.android.audacity.utilities.Helpers; + +import java.util.ArrayList; + +public class HottestAppAdapter extends RecyclerView.Adapter { + + private ArrayList mHottestAppData; + private Context mContext; + + public HottestAppAdapter(ArrayList hottestAppData, Context context) { + this.mHottestAppData = hottestAppData; + this.mContext = context; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View rootView = LayoutInflater.from(mContext).inflate(R.layout.item_hottest_app,parent , false); + return new ViewHolder(rootView); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + HottestApp hottestApp = mHottestAppData.get(position); + + String title = hottestApp.getAppTitle(); + String studentName =hottestApp.getStudentName(); + String postedOn = hottestApp.getPostedDate(); + String profileImage = hottestApp.getProfileImage(); + + holder.appTitle.setText(title); + holder.studentName.setText(studentName); + holder.postedOn.setText(Helpers.formatDate(postedOn)); + Glide.with(mContext).load(profileImage).into(holder.profileImage); + } + + @Override + public int getItemCount() { + return mHottestAppData.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + private TextView appTitle; + private TextView studentName; + private TextView postedOn; + private ImageView profileImage; + private Button detailViewButton; + + public ViewHolder(View itemView) { + super(itemView); + appTitle = itemView.findViewById(R.id.hottest_app_title); + studentName = itemView.findViewById(R.id.hottest_app_student_name); + postedOn = itemView.findViewById(R.id.hottest_app_date); + profileImage = itemView.findViewById(R.id.hottest_app_profile_image); + detailViewButton = itemView.findViewById(R.id.hottest_app_detail_button); + } + } +} diff --git a/app/src/main/java/com/example/android/audacity/fragments/ChallengesFragment.java b/app/src/main/java/com/example/android/audacity/fragments/ChallengesFragment.java index aa6dcb8..8c97939 100644 --- a/app/src/main/java/com/example/android/audacity/fragments/ChallengesFragment.java +++ b/app/src/main/java/com/example/android/audacity/fragments/ChallengesFragment.java @@ -2,29 +2,92 @@ import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ProgressBar; import com.example.android.audacity.R; +import com.example.android.audacity.adapters.ChallengesAdapter; +import com.example.android.audacity.pojo.Challenge; +import com.example.android.audacity.pojo.Challenge; +import com.example.android.audacity.utilities.Constants; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; + +import java.util.ArrayList; /** * A simple {@link Fragment} subclass. */ public class ChallengesFragment extends Fragment { + private static final String CHALLENGES_TAG = ChallengesFragment.class.getSimpleName(); + private ProgressBar mProgressBar; + private RecyclerView mRecyclerView; + private ChallengesAdapter mChallengeAdapter; + private RecyclerView.LayoutManager mLayoutManager; + private ArrayList mChallengesData; + private FirebaseDatabase mFirebaseDb; + private DatabaseReference mDbRef; + private View mRootView; public ChallengesFragment() { - // Required empty public constructor + mFirebaseDb = FirebaseDatabase.getInstance(); + mDbRef = mFirebaseDb.getReference(Constants.CHALLENGES_STRING); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_challenges, container, false); + mRootView = inflater.inflate(R.layout.fragment_challenges, container, false); + mProgressBar = mRootView.findViewById(R.id.challenge_progress_bar); + mRecyclerView = mRootView.findViewById(R.id.challenge_recycler_view); + mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); + + mChallengesData = new ArrayList<>(); + mChallengeAdapter = new ChallengesAdapter(mChallengesData, getContext()); + + return mRootView; + } + + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mRecyclerView.setLayoutManager(mLayoutManager); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setAdapter(mChallengeAdapter); + setChallengesData(); + } + + private void setChallengesData() { + mProgressBar.setVisibility(View.VISIBLE); + mDbRef.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot snapshot : dataSnapshot.getChildren()) { + Challenge challenge = snapshot.getValue(Challenge.class); + mChallengesData.add(challenge); + } + mProgressBar.setVisibility(View.INVISIBLE); + mChallengeAdapter.notifyDataSetChanged(); + } + @Override + public void onCancelled(DatabaseError databaseError) { + Log.w(CHALLENGES_TAG, "loadPost:onCancelled", databaseError.toException()); + } + }); } } diff --git a/app/src/main/java/com/example/android/audacity/fragments/HomeFragment.java b/app/src/main/java/com/example/android/audacity/fragments/HomeFragment.java index 17b2b31..18ae625 100644 --- a/app/src/main/java/com/example/android/audacity/fragments/HomeFragment.java +++ b/app/src/main/java/com/example/android/audacity/fragments/HomeFragment.java @@ -1,22 +1,54 @@ package com.example.android.audacity.fragments; +import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; +import com.bumptech.glide.Glide; import com.example.android.audacity.R; +import com.example.android.audacity.pojo.Challenge; +import com.example.android.audacity.pojo.HottestApp; +import com.example.android.audacity.utilities.Constants; +import com.example.android.audacity.utilities.Helpers; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; /** * A simple {@link Fragment} subclass. */ public class HomeFragment extends Fragment { + private FirebaseDatabase mFirebaseDb; + private DatabaseReference mDbRef; + private View mRootView; + private Context mContext; + + private TextView mHottestAppTitle; + private TextView mHottestStudentName; + private TextView mHottestPostedOn; + private ImageView mHottestProfileImage; + + private TextView mChallengeName; + private TextView mChallengeModName; + private TextView mChallengeEndDate; + private ImageView mChallengeProfileImage; public HomeFragment() { - // Required empty public constructor + mFirebaseDb = FirebaseDatabase.getInstance(); + mDbRef = mFirebaseDb.getReference(); } @@ -24,7 +56,73 @@ public HomeFragment() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_home, container, false); + mRootView = inflater.inflate(R.layout.fragment_home, container, false); + mRootView.setVisibility(View.INVISIBLE); + mContext = mRootView.getContext(); + mHottestAppTitle = mRootView.findViewById(R.id.hottest_app_title); + mHottestStudentName = mRootView.findViewById(R.id.hottest_app_student_name); + mHottestPostedOn = mRootView.findViewById(R.id.hottest_app_date); + mHottestProfileImage = mRootView.findViewById(R.id.hottest_app_profile_image); + + mChallengeName = mRootView.findViewById(R.id.challenge_title); + mChallengeModName = mRootView.findViewById(R.id.challenge_moderator_name); + mChallengeEndDate = mRootView.findViewById(R.id.challenge_date); + mChallengeProfileImage = mRootView.findViewById(R.id.challenge_profile_image); + + return mRootView; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + setHottestAppData(); + setChallengeData(); } + private void setChallengeData() { + mDbRef.child(Constants.CHALLENGES_STRING).limitToLast(1).addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot snapshot : dataSnapshot.getChildren()) { + Challenge challenge = snapshot.getValue(Challenge.class); + mChallengeName.setText(challenge.getChallengeName()); + mChallengeModName.setText(challenge.getModeratorName()); + mChallengeEndDate.setText(Helpers.formatDate(challenge.getStartDate())); + String profileImage = challenge.getProfileImage(); + if (profileImage != null) { + Glide.with(mContext).load(profileImage).into(mChallengeProfileImage); + } + } + mRootView.setVisibility(View.VISIBLE); + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + } + + private void setHottestAppData() { + mDbRef.child(Constants.HOTTEST_APP_STRING).limitToLast(1).addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot snapshot : dataSnapshot.getChildren()) { + HottestApp hottestApp = snapshot.getValue(HottestApp.class); + mHottestAppTitle.setText(hottestApp.getAppTitle()); + mHottestStudentName.setText(hottestApp.getStudentName()); + mHottestPostedOn.setText(Helpers.formatDate(hottestApp.getPostedDate())); + String profileImage = hottestApp.getProfileImage(); + if (profileImage != null) { + Glide.with(mContext).load(profileImage).into(mHottestProfileImage); + } + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + } } diff --git a/app/src/main/java/com/example/android/audacity/fragments/HottestAppFragment.java b/app/src/main/java/com/example/android/audacity/fragments/HottestAppFragment.java index eb83bf7..9b6dfa1 100644 --- a/app/src/main/java/com/example/android/audacity/fragments/HottestAppFragment.java +++ b/app/src/main/java/com/example/android/audacity/fragments/HottestAppFragment.java @@ -2,21 +2,50 @@ import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ProgressBar; import com.example.android.audacity.R; +import com.example.android.audacity.adapters.HottestAppAdapter; +import com.example.android.audacity.pojo.HottestApp; +import com.example.android.audacity.utilities.Constants; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; + +import java.util.ArrayList; +import java.util.MissingResourceException; /** * A simple {@link Fragment} subclass. */ public class HottestAppFragment extends Fragment { + private static final String HOTTEST_APP_TAG = HottestAppFragment.class.getSimpleName(); + + private ProgressBar mProgressBar; + private RecyclerView mRecyclerView; + private HottestAppAdapter mHottestAppAdapter; + private RecyclerView.LayoutManager mLayoutManager; + private ArrayList mHottestAppData; + private FirebaseDatabase mFirebaseDb; + private DatabaseReference mDbRef; + private View mRootView; public HottestAppFragment() { - // Required empty public constructor + mFirebaseDb = FirebaseDatabase.getInstance(); + mDbRef = mFirebaseDb.getReference(Constants.HOTTEST_APP_STRING); + } @@ -24,7 +53,44 @@ public HottestAppFragment() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_hottest_app, container, false); + mRootView = inflater.inflate(R.layout.fragment_hottest_app, container, false); + mProgressBar = mRootView.findViewById(R.id.hottest_progress_bar); + mRecyclerView = mRootView.findViewById(R.id.hottest_app_recycler_view); + mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); + + mHottestAppData = new ArrayList<>(); + mHottestAppAdapter = new HottestAppAdapter(mHottestAppData, getContext()); + + return mRootView; } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mRecyclerView.setLayoutManager(mLayoutManager); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setAdapter(mHottestAppAdapter); + setHottestAppData(); + } + + private void setHottestAppData() { + mProgressBar.setVisibility(View.VISIBLE); + mDbRef.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot snapshot : dataSnapshot.getChildren()) { + HottestApp hottestApp = snapshot.getValue(HottestApp.class); + mHottestAppData.add(hottestApp); + } + mProgressBar.setVisibility(View.INVISIBLE); + mHottestAppAdapter.notifyDataSetChanged(); + } + @Override + public void onCancelled(DatabaseError databaseError) { + Log.w(HOTTEST_APP_TAG, "loadPost:onCancelled", databaseError.toException()); + } + }); + } + + } diff --git a/app/src/main/java/com/example/android/audacity/pojo/Challenge.java b/app/src/main/java/com/example/android/audacity/pojo/Challenge.java new file mode 100644 index 0000000..9716151 --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/pojo/Challenge.java @@ -0,0 +1,162 @@ +package com.example.android.audacity.pojo; + + +public class Challenge { + + private Boolean approved; + private String challengeDescription; + private String challengeName; + private String emailAddress; + private String endDate; + private String imageLink; + private String moderatorName; + private String profileImage; + private String referenceUrl; + private String slackId; + private String startDate; + private String timestamp; + private String videoLink; + + /** + * No args constructor for use in serialization + */ + public Challenge() { + } + + /** + * @param timestamp + * @param startDate + * @param referenceUrl + * @param approved + * @param profileImage + * @param challengeName + * @param moderatorName + * @param imageLink + * @param videoLink + * @param emailAddress + * @param endDate + * @param slackId + * @param challengeDescription + */ + public Challenge(Boolean approved, String challengeDescription, String challengeName, String emailAddress, String endDate, String imageLink, String moderatorName, String profileImage, String referenceUrl, String slackId, String startDate, String timestamp, String videoLink) { + super(); + this.approved = approved; + this.challengeDescription = challengeDescription; + this.challengeName = challengeName; + this.emailAddress = emailAddress; + this.endDate = endDate; + this.imageLink = imageLink; + this.moderatorName = moderatorName; + this.profileImage = profileImage; + this.referenceUrl = referenceUrl; + this.slackId = slackId; + this.startDate = startDate; + this.timestamp = timestamp; + this.videoLink = videoLink; + } + + public Boolean getApproved() { + return approved; + } + + public void setApproved(Boolean approved) { + this.approved = approved; + } + + public String getChallengeDescription() { + return challengeDescription; + } + + public void setChallengeDescription(String challengeDescription) { + this.challengeDescription = challengeDescription; + } + + public String getChallengeName() { + return challengeName; + } + + public void setChallengeName(String challengeName) { + this.challengeName = challengeName; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getImageLink() { + return imageLink; + } + + public void setImageLink(String imageLink) { + this.imageLink = imageLink; + } + + public String getModeratorName() { + return moderatorName; + } + + public void setModeratorName(String moderatorName) { + this.moderatorName = moderatorName; + } + + public String getProfileImage() { + return profileImage; + } + + public void setProfileImage(String profileImage) { + this.profileImage = profileImage; + } + + public String getReferenceUrl() { + return referenceUrl; + } + + public void setReferenceUrl(String referenceUrl) { + this.referenceUrl = referenceUrl; + } + + public String getSlackId() { + return slackId; + } + + public void setSlackId(String slackId) { + this.slackId = slackId; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getVideoLink() { + return videoLink; + } + + public void setVideoLink(String videoLink) { + this.videoLink = videoLink; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android/audacity/pojo/HottestApp.java b/app/src/main/java/com/example/android/audacity/pojo/HottestApp.java new file mode 100644 index 0000000..6a40edd --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/pojo/HottestApp.java @@ -0,0 +1,168 @@ +package com.example.android.audacity.pojo; + + +public class HottestApp { + + private String appDescription; + private String appTitle; + private boolean approved; + private String emailAddress; + private String githubUrl; + private String image; + private String postedDate; + private String profileImage; + private String slackId; + private String studentName; + private String timestamp; + private String videoLink; + + /** + * No args constructor for use in serialization + */ + public HottestApp() { + } + + /** + * @param timestamp + * @param approved + * @param postedDate + * @param profileImage + * @param githubUrl + * @param videoLink + * @param studentName + * @param image + * @param emailAddress + * @param appTitle + * @param slackId + * @param appDescription + */ + public HottestApp(String appDescription, String appTitle, boolean approved, String emailAddress, String githubUrl, String image, String postedDate, String profileImage, String slackId, String studentName, String timestamp, String videoLink) { + super(); + this.appDescription = appDescription; + this.appTitle = appTitle; + this.approved = approved; + this.emailAddress = emailAddress; + this.githubUrl = githubUrl; + this.image = image; + this.postedDate = postedDate; + this.profileImage = profileImage; + this.slackId = slackId; + this.studentName = studentName; + this.timestamp = timestamp; + this.videoLink = videoLink; + } + + public String getAppDescription() { + return appDescription; + } + + public void setAppDescription(String appDescription) { + this.appDescription = appDescription; + } + + public String getAppTitle() { + return appTitle; + } + + public void setAppTitle(String appTitle) { + this.appTitle = appTitle; + } + + public boolean isApproved() { + return approved; + } + + public void setApproved(boolean approved) { + this.approved = approved; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getGithubUrl() { + return githubUrl; + } + + public void setGithubUrl(String githubUrl) { + this.githubUrl = githubUrl; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getPostedDate() { + return postedDate; + } + + public void setPostedDate(String postedDate) { + this.postedDate = postedDate; + } + + public String getProfileImage() { + return profileImage; + } + + public void setProfileImage(String profileImage) { + this.profileImage = profileImage; + } + + public String getSlackId() { + return slackId; + } + + public void setSlackId(String slackId) { + this.slackId = slackId; + } + + public String getStudentName() { + return studentName; + } + + public void setStudentName(String studentName) { + this.studentName = studentName; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getVideoLink() { + return videoLink; + } + + public void setVideoLink(String videoLink) { + this.videoLink = videoLink; + } + + @Override + public String toString() { + return new StringBuffer() + .append("appDescription " + appDescription) + .append("appTitle " + appTitle) + .append("approved " + approved) + .append("emailAddress "+ emailAddress) + .append("githubUrl "+ githubUrl) + .append("image " +image) + .append("postedDate "+ postedDate) + .append("profileImage "+ profileImage) + .append("slackId "+ slackId) + .append("studentName " + studentName) + .append("timestamp "+ timestamp) + .append("videoLink "+ videoLink).toString(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/android/audacity/utilities/Constants.java b/app/src/main/java/com/example/android/audacity/utilities/Constants.java new file mode 100644 index 0000000..839321d --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/utilities/Constants.java @@ -0,0 +1,6 @@ +package com.example.android.audacity.utilities; + +public class Constants { + public static final String HOTTEST_APP_STRING = "hottest_app"; + public static final String CHALLENGES_STRING = "challenges"; +} diff --git a/app/src/main/java/com/example/android/audacity/utilities/Helpers.java b/app/src/main/java/com/example/android/audacity/utilities/Helpers.java new file mode 100644 index 0000000..36a69ca --- /dev/null +++ b/app/src/main/java/com/example/android/audacity/utilities/Helpers.java @@ -0,0 +1,21 @@ +package com.example.android.audacity.utilities; + + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class Helpers { + public static String formatDate(String date) { + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); + Date myDate = null; + try { + myDate = fmt.parse(date); + SimpleDateFormat fmtOut = new SimpleDateFormat("dd-MM-yyyy"); + return fmtOut.format(myDate); + } catch (ParseException e) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/app/src/main/res/drawable-hdpi/logo.png b/app/src/main/res/drawable-hdpi/logo.png new file mode 100644 index 0000000..c8a0d13 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/logo.png differ diff --git a/app/src/main/res/drawable-mdpi/logo.png b/app/src/main/res/drawable-mdpi/logo.png new file mode 100644 index 0000000..0336e27 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/logo.png differ diff --git a/app/src/main/res/drawable-xhdpi/logo.png b/app/src/main/res/drawable-xhdpi/logo.png new file mode 100644 index 0000000..79e66d0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/logo.png differ diff --git a/app/src/main/res/drawable-xxhdpi/logo.png b/app/src/main/res/drawable-xxhdpi/logo.png new file mode 100644 index 0000000..2b504f9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/logo.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/logo.png b/app/src/main/res/drawable-xxxhdpi/logo.png new file mode 100644 index 0000000..1465e57 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/logo.png differ diff --git a/app/src/main/res/drawable/background.xml b/app/src/main/res/drawable/background.xml new file mode 100644 index 0000000..0bcb5fb --- /dev/null +++ b/app/src/main/res/drawable/background.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/chevron_right.xml b/app/src/main/res/drawable/chevron_right.xml new file mode 100644 index 0000000..4c14998 --- /dev/null +++ b/app/src/main/res/drawable/chevron_right.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/round.xml b/app/src/main/res/drawable/round.xml index 041a0ab..8386570 100644 --- a/app/src/main/res/drawable/round.xml +++ b/app/src/main/res/drawable/round.xml @@ -11,5 +11,5 @@ android:right="3dp" android:top="3dp" /> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/round_google.xml b/app/src/main/res/drawable/round_google.xml new file mode 100644 index 0000000..8540351 --- /dev/null +++ b/app/src/main/res/drawable/round_google.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/splash_theme.xml b/app/src/main/res/drawable/splash_theme.xml new file mode 100644 index 0000000..a424ff6 --- /dev/null +++ b/app/src/main/res/drawable/splash_theme.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/google_sans.ttf b/app/src/main/res/font/google_sans.ttf new file mode 100644 index 0000000..ab605f9 Binary files /dev/null and b/app/src/main/res/font/google_sans.ttf differ diff --git a/app/src/main/res/font/google_sans_bold.ttf b/app/src/main/res/font/google_sans_bold.ttf new file mode 100644 index 0000000..8049766 Binary files /dev/null and b/app/src/main/res/font/google_sans_bold.ttf differ diff --git a/app/src/main/res/font/google_sans_bold_italic.ttf b/app/src/main/res/font/google_sans_bold_italic.ttf new file mode 100644 index 0000000..e940d02 Binary files /dev/null and b/app/src/main/res/font/google_sans_bold_italic.ttf differ diff --git a/app/src/main/res/font/google_sans_italic.ttf b/app/src/main/res/font/google_sans_italic.ttf new file mode 100644 index 0000000..bfb1a2c Binary files /dev/null and b/app/src/main/res/font/google_sans_italic.ttf differ diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 1ba52ad..2d74e6d 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -14,6 +14,7 @@ android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:layout_marginTop="136dp" + android:fontFamily="@font/google_sans_bold" android:text="@string/login_welcome_title" android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textColor="@android:color/white" @@ -22,17 +23,22 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + + + + diff --git a/app/src/main/res/layout/app_bar_dashboard.xml b/app/src/main/res/layout/app_bar_dashboard.xml index d42124c..665effe 100644 --- a/app/src/main/res/layout/app_bar_dashboard.xml +++ b/app/src/main/res/layout/app_bar_dashboard.xml @@ -5,18 +5,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".DashboardActivity"> - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_challenges.xml b/app/src/main/res/layout/fragment_challenges.xml index 546dcf7..6358fb2 100644 --- a/app/src/main/res/layout/fragment_challenges.xml +++ b/app/src/main/res/layout/fragment_challenges.xml @@ -1,13 +1,38 @@ - - - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" + tools:listitem="@layout/item_challenge"> + + + + + - + diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 86c357d..816df76 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,13 +1,88 @@ - - - + android:layout_height="wrap_content"> + + + + + + + + + + + - + + + diff --git a/app/src/main/res/layout/fragment_hottest_app.xml b/app/src/main/res/layout/fragment_hottest_app.xml index 99f33ab..783375d 100644 --- a/app/src/main/res/layout/fragment_hottest_app.xml +++ b/app/src/main/res/layout/fragment_hottest_app.xml @@ -1,13 +1,38 @@ - - - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" + tools:listitem="@layout/item_hottest_app"> + + + + + - + diff --git a/app/src/main/res/layout/item_challenge.xml b/app/src/main/res/layout/item_challenge.xml new file mode 100644 index 0000000..f262d32 --- /dev/null +++ b/app/src/main/res/layout/item_challenge.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + +