Skip to content

Commit

Permalink
GibQuote v2.7.0 | GibCoordination | Updater Changes
Browse files Browse the repository at this point in the history
** README.md has been updated

* Check for updates in GibQuoteFragment

* Show acknowledgement 'We\'re Updated' when the App is updated

* Bring in CoordinatorLayout into GibQuoteFragment
  - FAB Menu animation has been re-implemented
  - Hide/Show FAB, move FAB implemented

Signed-off-by: a7r3 <arvindultimate7352@gmail.com>
  • Loading branch information
a7r3 committed Jan 13, 2018
1 parent 5965655 commit 714dea6
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 193 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GibQuote

<img src="https://user-images.githubusercontent.com/14874906/33614955-c87e6be0-d9fe-11e7-9f62-72dd3cfb046c.png" width="576" height="1024">
<img src="https://user-images.githubusercontent.com/14874906/34907584-1768d6e8-f8a7-11e7-80fc-1b3f2334f838.png">

<b>Random Project</b> to fetch <b>Random Quotes</b> from <b>Random Providers</b>

Expand All @@ -10,27 +10,35 @@ Application Icon used from <b>[FlatIcon](https://flaticon.com)

## Features

* Fetch quotes from three providers
* Fetch quotes from three online providers (+1 Offline)
- **Offline Quote Database** (gathered from internet)
- 19997 Quotes - Some of them are faulty, blame my extraction script ;-;
- [Talaikis](https://talaikis.com/random_quotes_api)
- [Forismatic](https://forismatic.com/en/api)
- [Storm](https://quotes.stormconsultancy.co.uk/api)

* Share Quote by long-pressing it
> Quote providers can be changed by long pressing the FAB
> and selecting 'Change Quote Provider'
* Save Favorite Quotes (SQLite)
* **Share a Quote** to your favorite social circles by long-pressing it
* **Save Quotes** which you may like
- Double Tap a quote to delete it (after additional prompt)

* (TODO) Show Quotes / QoTD at a particular time (Notification)

* Show **Quote of the Day** at a particular time, every day! (Notification)
* **Get your App updated**, with the help of In-built updater, using GitHub API
* Three Base themes
- Light
- Dark
- Translucent (with Animating Gradients)
* Two ways of navigation
- Navigation Drawer
- Bottom Navigation menu

* (TODO) Set of Primary and Accent color schemes
## TODO

* Set of Primary and Accent color schemes
* Using Firebase JobDispatcher / Evernote's android-job for Scheduling Notifications
* Grabbing some other quotes for you! [Need to add 5421 + 74000 Quotes]
* You say!

## License

Expand Down
17 changes: 8 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 27
versionCode 2
versionName "2.6.6"
versionName '2.7.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -24,22 +24,21 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

implementation('com.mikepenz:aboutlibraries:6.0.1@aar') {
transitive = true
}
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.android.support:support-annotations:27.0.2'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
compile 'com.getkeepsafe.taptargetview:taptargetview:1.10.0'
compile 'com.takisoft.fix:preference-v7:27+'
compile 'com.takisoft.fix:preference-v7-datetimepicker:+'
compile 'com.takisoft.fix:preference-v7-colorpicker:+'
compile 'com.takisoft.fix:preference-v7:27.0.2.0'
compile 'com.takisoft.fix:preference-v7-datetimepicker:27.0.2.0'
compile 'com.takisoft.fix:preference-v7-colorpicker:27.0.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:27+'
compile 'com.android.support:cardview-v7:27+'
compile 'com.android.support:recyclerview-v7:27+'
compile 'com.android.support:appcompat-v7:27+'
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
testCompile 'junit:junit:4.12'
}
21 changes: 2 additions & 19 deletions app/src/main/java/com/arvind/quote/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
private final String[] requiredPerms = {
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
private boolean isStoragePermissionGranted = false;
public static boolean isStoragePermissionGranted = false;
// Layout under which fragments would reside
private DrawerLayout drawerLayout;
// Provides toggling action to open the Navigation Drawer
Expand All @@ -73,16 +73,6 @@ public static void setActionBarTitle(String title) {
actionBar.setTitle(title);
}

public static void showActionBar() {
if (actionBar != null)
actionBar.show();
}

public static void hideActionBar() {
if (actionBar != null)
actionBar.hide();
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Expand Down Expand Up @@ -202,7 +192,6 @@ public void onClick(View view) {
setActionBarTitle("GibQuote");

// Listen for clicks on any MenuItem present in the Navigation Drawer
// MenuItem is Identified by its position
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Expand Down Expand Up @@ -250,12 +239,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
}

if (isStoragePermissionGranted)
if (sharedPreferences.getBoolean("UPDATE_CHECK", true))
new Updater(this)
.setTagsUrl(GIT_TAG_URL)
.setRootLayout(R.id.root_layout)
.checkForUpdates();
}

private void switchFragment(MenuItem item) {
Expand Down Expand Up @@ -291,7 +274,7 @@ private void switchFragment(MenuItem item) {
getSupportFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.replace(R.id.frame_layout, fragment, fragment.getClass().getCanonicalName())
.replace(R.id.frame_layout, fragment, fragment.getClass().getSimpleName())
.commit();
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void onClick(View v) {
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Log.d("QAdapter", "kek");
if(!isClickable)
return false;
CommonUtils.shareQuote(context, quoteList.get(getAdapterPosition()));
Expand Down
81 changes: 81 additions & 0 deletions app/src/main/java/com/arvind/quote/behavior/GibFabBehavior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.arvind.quote.behavior;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import com.arvind.quote.R;

/**
* Behavior Class of the FAB (In GibQuoteFragment)
* Describes what the FAB (the LinearLayout in which it is present, actually) should do
* in response to changes in the parent CoordinatorLayout
*
* Behavior is linked in XML (app:layout_behavior)
*/
public class GibFabBehavior extends CoordinatorLayout.Behavior<LinearLayout> {

private String TAG = "GibFabBehavior";
private FloatingActionButton gibQuoteFab;

// Required Constructor, called on inflating CoordinatorLayout
public GibFabBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, LinearLayout child, View dependency) {
gibQuoteFab = child.findViewById(R.id.gib_quote_fab);
Log.d(TAG, "dependency : " + dependency.getTag());
return dependency instanceof Snackbar.SnackbarLayout || dependency instanceof RecyclerView;
}

@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull LinearLayout child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
// Accept Scrolling behaviors in Descendant View
// The acceptable descendant in our case being the RecyclerView in which quotes are displayed
return target instanceof RecyclerView;
}

@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull LinearLayout child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
Log.d(TAG, "Nested scroll on : " + target.getTag());
if(dxConsumed == 0 | dxUnconsumed == 0)
gibQuoteFab.hide();
}

@Override
public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull LinearLayout child, @NonNull View target, int type) {
super.onStopNestedScroll(coordinatorLayout, child, target, type);
gibQuoteFab.show();
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, LinearLayout child, View dependency) {
// getTranslationY -> Gets final Y value to translate to
// getHeight -> Height of the view
//
// Behavior:
// > Snackbar going down (Final -ve value)** ----v
// -> getTranslationY = 0 && getHeight = +ve |
// --> Difference is -ve equal
// ---> Minimum of 0 & -ve => -ve value |
// ----> Fab goes down too! (Final -ve value)** -^
if(dependency instanceof Snackbar.SnackbarLayout) {
child.setTranslationY(Math.min(0, dependency.getTranslationY() - dependency.getHeight()));
// We've modified the one of the child's parameters, so return true
return true;
}
// Done nothing
return false;
}

}
Loading

0 comments on commit 714dea6

Please sign in to comment.