SaveInsta


Source link: https://github.com/lopspower/SaveInsta

SaveInsta

With SaveInsta download all Instagram photos and videos that you love.

This application is an example of the implementation of the dynamic update of your theme based on a main color. The application retrieve the dominant color of an image and change the theme of the activity in runtime.

Guidelines Example

3 Steps to download photo/video from Instagram:

  1. Open your Instagram, choose Copy Share URL on photo/video you want to save
  2. Open SaveInsta and let it do the magic
  3. Back to SaveInsta, download Photo/Video you love by click to Save button at the bottom right of SaveInsta, or click to Close button at the top right to remove. Open Gallery to see the result!

Get Dominant Color of ImageView

You need to Download DominantImageColor and write this method in your project:

public static int getDominantColor(ImageView imageView) {

int color = 0;
try {

  Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

  String dominantColor = DominantImageColor.getDominantColorOfImage(bitmap);

  color = Color.parseColor(dominantColor);

}
 catch (Exception ex) {

  ex.printStackTrace();

}

return color; 
}

Set Theme Programmatically

3 components must be modified for best possible immersion:

  • mToolbar.setBackgroundColor(dominantColor);
  • getWindow().setStatusBarColor(dominantColor);
  • getWindow().setNavigationBarColor(dominantColor);

For a better visual you need to add animation for each change:

For that, you also get the current color of the theme colorPrimary. To do that just call ContextCompat.getColor(this, R.color.colorPrimary); .

ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorPrimary, dominantColor);
 colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

  @Override
  public void onAnimationUpdate(ValueAnimator animator) {

 mToolbar.setBackgroundColor((int) animator.getAnimatedValue());

  
}
 
}
);
 colorAnimation.start();

⚠? Please note that the status bar is not the same color as your toolbar. So you have to darken to meet the best practices of Android Material Design. For that use this method:

public static int darkerColor(int color) {

float[] hsv = new float[3];
Color.colorToHSV(color, hsv);

hsv[2] *= 0.8f; // value component
return Color.HSVToColor(hsv);
 
}

⚠? Attention to the color of the text and icons on your toolbar. You must detect if the dominant color is a dark color or not. If this is the case the color of your text should be light and vice versa.

public static boolean isColorDark(int color) {

double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
if (darkness < 0.5) {

  return false; // It's a light color

}
 else {

  return true; // It's a dark color

}
 
}

Update in Runtime

This treatment can be long, so it is best not to leave it in the UI thread. The following example retrieves the dominant color in a separate thread, and then returns to the UI thread to change the theme:

mCurrentThemeColor is the main color theme of your application. To recover just do ContextCompat.getColor(this, R.color.colorPrimary); .

final Handler handler = new Handler();
 new Thread(new Runnable() {

@Override
public void run() {

  // Get Dominant Color
  final int color = getDominantColor(mImageToDownload);

  if (color != 0) {

handler.post(new Runnable() {

 @Override

 public void run() {

// Set Theme Color

setThemeColor(mCurrentThemeColor, color);

 
}

}
);

  
}
 else if (BuildConfig.DEBUG) {

Log.e(getClass().getName(), "Color Unknown");

  
}

}
 
}
).start();

👉 You can see a full implementation here

License

SaveInsta by Lopez Mikhael is licensed under a Apache License 2.0.

Resources

Small library that contains common extensions for Android. Aims:

  • Provide the shortest way to do things
  • Reduce count of "Compat" and "Utils" classes
  • Remove boilerplate code

A very small library to implement a connection indicator view. These connections may be GPS, Network or other loading indicators.

JFixture is an open source library based on the popular .NET library, AutoFixture.

JFixture is a Java library to assist in the writing of Unit Tests, particularly when following Test Driven Development. It generates types based on the concept of 'constrained non-determinism', which is an implementation of the Generated Value xUnit test pattern.

Rx wrapper for the Firebase Android library.

Failsafe is a lightweight, zero-dependency library for handling failures. It was designed to be as easy to use as possible, with a concise API for handling everyday use cases and the flexibility to handle everything else.

This project is implementation of ideas from Managing state reactive way article.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes