This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ***.utils; | |
import java.io.IOException; | |
import java.net.InetAddress; | |
import java.net.InetSocketAddress; | |
import java.net.Proxy; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ***.utils; | |
import android.Manifest; | |
import android.annotation.SuppressLint; | |
import android.content.Context; | |
import android.content.pm.PackageManager; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.net.wifi.WifiInfo; | |
import android.net.wifi.WifiManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ***.utils; | |
import android.Manifest; | |
import android.annotation.SuppressLint; | |
import android.app.Activity; | |
import android.app.AlertDialog; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.location.Criteria; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ***.utils; | |
import android.app.Activity; | |
import android.support.v7.app.AlertDialog; | |
import com.microsoft.appcenter.distribute.Distribute; | |
import com.microsoft.appcenter.distribute.DistributeListener; | |
import com.microsoft.appcenter.distribute.ReleaseDetails; | |
import com.microsoft.appcenter.distribute.UpdateAction; | |
import ***.BuildConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param v | |
*/ | |
public static void hideKeyboard(View v) { | |
if (v == null || v.getContext() == null) return; | |
InputMethodManager imm = (InputMethodManager) | |
v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
if (imm != null && imm.isAcceptingText()) { | |
imm.hideSoftInputFromWindow(v.getRootView().getWindowToken(), 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get {@link Bitmap} object from {@link View} | |
* | |
* @param view | |
* @return | |
*/ | |
public Bitmap getBitmapFromView(View view) { | |
//Define a bitmap with the same size as the view | |
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); | |
//Bind a canvas to it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param date | |
* @return | |
*/ | |
public static Date getLocalizedDate(Date date) { | |
try { | |
Calendar c = Calendar.getInstance(); | |
c.setTime(date); | |
c.add(Calendar.MILLISECOND, TimeZone.getDefault().getRawOffset()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Decimal Localization Format, like #,###.## for US or #.###,## for ID | |
* | |
* @param Numobj | |
* @return | |
*/ | |
//TODO: change to automatic localization detection | |
public static String DecimalFormater(Object Numobj) { | |
Object obj = String.valueOf(Numobj).matches("-?\\d+(\\.\\d+)?") ? Numobj : 0.00; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* TODO: modify function for get color contrast based on `background color` and `foreground color` (not black or white only) | |
* based on sensitive eyes (Y of YIQ) {@linkplain "https://en.wikipedia.org/wiki/YIQ"} | |
*/ | |
public static int getContrastColor(int color) { | |
@SuppressLint("Range") | |
double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000; | |
return y >= 178 || color == Color.TRANSPARENT ? Color.rgb(130, 130, 130) : Color.WHITE; | |
} |
NewerOlder