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

This is a sample project which helps anybody who wish to work with GreenDAO library.

This application contains all the thing you need to start creating project using GreenDAO.

Easy way to put and get data and Object for the shared preferences in Android.

Make things easy when you need to write a sql statment for Android SQLite.

A library allowing you to manage Wi-Fi peer-to-peer connectivity in a reactive way. The library itself is a RxJava wrapper for Android's WifiP2pManager, used for discovering available peers, setup connection to peers and query for the list of peers.

When a p2p connection is formed over wifi, devices continue to maintain the uplink connection over mobile or any other available network for internet connectivity.

SimpleNFC is a project which include insanely easy way of reading NFC data.

Doughnut Chart

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