This file contains hidden or 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
| <?php | |
| define("MYSQL_SERVER", "mysql"); | |
| define("MYSQL_USER", "myusername"); | |
| define("MYSQL_PASSWORD", "mypassword"); | |
| define("MYSQL_DB", "mydbname"); | |
| define("LOG_IP", false); | |
| define("DELETE_ALL_LOGGED_IP", false); | |
| define("CREATE_DB_IF_NOT_EXISTS", true); | |
| define("CREATE_TABLES_IF_NOT_EXIST", true); | |
| define("TITLE","RW-PHPLinks v1.0<br/>Annuaire de sites"); |
This file contains hidden or 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
| public class LocaleManager { | |
| private static final String LANGUAGE_KEY = "CHOOSE_LANGUAGE"; | |
| public static Context setLocale(Context c) { | |
| String savedLanguage = getLanguage(c); | |
| return savedLanguage == null ? c : updateResources(c, savedLanguage); | |
| } | |
| public static Context setNewLocale(Context c, String language) { | |
| persistLanguage(c, language); |
This file contains hidden or 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 com.util | |
| import android.graphics.Canvas | |
| import android.graphics.Color | |
| import android.graphics.Paint | |
| import android.support.v7.widget.RecyclerView | |
| import android.support.v7.widget.helper.ItemTouchHelper.Callback | |
| import android.support.v7.widget.helper.ItemTouchHelper.* | |
| import android.view.MotionEvent | |
| import android.support.v7.widget.helper.ItemTouchHelper.ACTION_STATE_SWIPE |
This file contains hidden or 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
| // Sauvegarde de l'adapter fin de pouvoir appeler notifyDataSetChanged après suppression d'un élément depuis l'adapter, en vue refresh liste | |
| lateinit var adapter: RecyclerView.Adapter<*> | |
| fun saveAdapter(adapterToSave: RecyclerView.Adapter<*>) { | |
| adapter = adapterToSave | |
| } | |
| fun getSavedkAdapter(): RecyclerView.Adapter<*>{ | |
| return adapter |
This file contains hidden or 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
| lateinit var secretKey : SecretKey | |
| lateinit var iv : ByteArray | |
| fun encrypt(context:Context, strToEncrypt: String): ByteArray { | |
| val plainText = strToEncrypt.toByteArray(Charsets.UTF_8) | |
| val keygen = KeyGenerator.getInstance("AES") | |
| keygen.init(256) | |
| val key = keygen.generateKey() | |
| secretKey = key | |
| val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING") | |
| cipher.init(Cipher.ENCRYPT_MODE, key) |
This file contains hidden or 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
| fun encrypt(context:Context, strToEncrypt: String): ByteArray { | |
| val plainText = strToEncrypt.toByteArray(Charsets.UTF_8) | |
| val keygen = KeyGenerator.getInstance("AES") | |
| keygen.init(256) | |
| val key = keygen.generateKey() | |
| saveSecretKey(context, key) | |
| val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING") | |
| cipher.init(Cipher.ENCRYPT_MODE, key) | |
| val cipherText = cipher.doFinal(plainText) |
This file contains hidden or 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
| fun hashAndSavePasswordHash(context: Context, clearPassword: String) { | |
| val digest = MessageDigest.getInstance("SHA-1") | |
| val result = digest.digest(clearPassword.toByteArray(Charsets.UTF_8)) | |
| val sb = StringBuilder() | |
| for (b in result) { | |
| sb.append(String.format("%02X", b)) | |
| } | |
| val hashedPassword = sb.toString() | |
| val sharedPref = PreferenceManager.getDefaultSharedPreferences(context) | |
| val editor = sharedPref.edit() |
This file contains hidden or 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
| val handleScroll = View.OnScrollChangeListener { v, x, y, ox, oy -> | |
| viewPager.scrollTo(ox, oy) | |
| return@OnScrollChangeListener | |
| } | |
| viewPager.setOnScrollChangeListener(handleScroll) | |
This file contains hidden or 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
| var alertDialogBuilder = AlertDialog.Builder(context, R.style.AlertDialogThemeCustom) | |
| alertDialogBuilder.setTitle("Deletion") | |
| alertDialogBuilder.setMessage("Do you confirm the deletion ?") | |
| alertDialogBuilder.setCancelable(false) | |
| alertDialogBuilder.setPositiveButton("Yes, delete", DialogInterface.OnClickListener { dialog, which -> | |
| // ... | |
| dialog.cancel() | |
| } ) | |
| alertDialogBuilder.setNegativeButton("No, cancel", DialogInterface.OnClickListener { dialog, which -> | |
| // Do nothing |
This file contains hidden or 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
| val accountManager = this.applicationContext.getSystemService(Context.ACCOUNT_SERVICE) as AccountManager | |
| val account = Account("syncaccount", "com.datasync.syncserviceaccount") | |
| val accounts = accountManager.accounts | |
| accounts.forEach { | |
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { | |
| accountManager.removeAccount(account, null, null) | |
| } else { | |
| accountManager.removeAccountExplicitly(account) | |
| } | |
| } |
OlderNewer