2019-04-28 18:54:22 +02:00
|
|
|
package com.darkweb.genesissearchengine;
|
2019-03-27 19:07:03 +01:00
|
|
|
|
|
|
|
import android.content.Context;
|
2019-05-10 20:44:08 +02:00
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
import android.content.pm.PackageManager;
|
2019-03-27 19:07:03 +01:00
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.NetworkInfo;
|
2019-05-10 20:44:08 +02:00
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
|
2019-05-30 21:19:30 +02:00
|
|
|
import java.io.*;
|
2019-05-10 20:44:08 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
2019-03-27 19:07:03 +01:00
|
|
|
|
2019-05-30 21:19:30 +02:00
|
|
|
import static android.content.Context.MODE_PRIVATE;
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
public class helperMethod
|
|
|
|
{
|
|
|
|
public static boolean isNetworkAvailable(Context application_context)
|
|
|
|
{
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) application_context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
|
|
|
|
if (networkInfo != null && networkInfo.isConnected())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-10 20:44:08 +02:00
|
|
|
public static boolean readPrefs(String valueKey,Context applicationContext) {
|
|
|
|
SharedPreferences prefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(applicationContext);
|
|
|
|
return prefs.getBoolean(valueKey,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void savePrefs(String valueKey, boolean value,Context applicationContext) {
|
|
|
|
SharedPreferences prefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(applicationContext);
|
|
|
|
SharedPreferences.Editor edit = prefs.edit();
|
|
|
|
edit.putBoolean(valueKey, value);
|
|
|
|
edit.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setPlaystoreStatus(Context context) {
|
|
|
|
|
|
|
|
String GooglePlayStorePackageNameOld = "com.google.market";
|
|
|
|
String GooglePlayStorePackageNameNew = "com.android.vending";
|
|
|
|
|
|
|
|
PackageManager packageManager = context.getPackageManager();
|
|
|
|
List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
|
|
|
|
|
|
|
|
for (PackageInfo packageInfo : packages)
|
|
|
|
{
|
|
|
|
if (packageInfo.packageName.equals(GooglePlayStorePackageNameOld) ||
|
|
|
|
packageInfo.packageName.equals(GooglePlayStorePackageNameNew)) {
|
|
|
|
status.isPlayStoreInstalled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-05-30 21:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static String readInternalHTML(Context applicationContext)
|
|
|
|
{
|
|
|
|
SharedPreferences prefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(applicationContext);
|
|
|
|
return prefs.getString("internalhtml","");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setInternalHTML(String html,Context applicationContext)
|
|
|
|
{
|
|
|
|
SharedPreferences prefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(applicationContext);
|
|
|
|
SharedPreferences.Editor edit = prefs.edit();
|
|
|
|
edit.putString("internalhtml", html);
|
|
|
|
edit.commit();
|
2019-05-10 20:44:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|