Skip to content

Instantly share code, notes, and snippets.

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:keyHeight="7%p"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- <Row></Row> -->
<Row android:keyWidth="9.09%p">
<Key android:codes="-25" android:keyIcon="@drawable/ic_double_pointer_left" />
<Key android:codes="-26" android:keyIcon="@drawable/ic_double_pointer_right" />
<Key android:codes="-108" android:keyIcon="@drawable/ic_arrow_left" android:isRepeatable="true" />
/*
* Copyright (C) 2008-2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package sra.keyboard;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
@matthewmorrone
matthewmorrone / CustomEditTextPreference.java
Last active November 10, 2020 22:20
stuff to reimplement
package com.custom.keyboard;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
// import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import top.defaults.colorpicker.ColorPickerPopup;
public boolean getPresentationShown() {
try {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("presentation", false);
}
catch (Exception e) {
return false;
}
}
public void setPresentationShown() {
private void layoutAndShowPopupWindow(Key key, int xPosition) {
popupWindow = new PopupWindow(popupView,
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
popupWindow.setClippingEnabled(false);// <-- let popup display above keyboard
int location[] = new int[2];
key.getLocationInWindow(location);
int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
popupView.measure(measureSpec, measureSpec);
int popupWidth = popupView.getMeasuredWidth();
@matthewmorrone
matthewmorrone / customColorArray.java
Created September 26, 2020 13:28
I don't actually know how these matrices work
String bg = sharedPreferences.getString("bg", "#FF000000");
int[] bgc = Util.fromColor(bg);
float[] sCustomColorArray = {
1.0f, 0, 0, 0, bgc[1], // red
0, 1.0f, 0, 0, bgc[2], // green
0, 0, 1.0f, 0, bgc[3], // blue
0, 0, 0, 1.0f, bgc[0] // alpha
};
mDefaultFilter = sCustomColorArray;
static Integer[] performLottery(int numNumbers, int numbersToPick) {
List<Integer> numbers = new ArrayList<>();
for(int i = 0; i < numNumbers; i++) numbers.add(i + 1);
Collections.shuffle(numbers);
return numbers.subList(0, numbersToPick).toArray(new Integer[numbersToPick]);
}
static int factorial(int number) {
int result = 1;
for (int factor = 2; factor <= number; factor++) {
result *= factor;
}
return result;
}
static boolean isPalindrome(String s) {
StringBuilder sb = new StringBuilder();
for (char c : s.toCharArray()) {
if (Character.isLetter(c)) {
sb.append(c);
}
}
String forward = sb.toString().toLowerCase();
String backward = sb.reverse().toString().toLowerCase();
return forward.equals(backward);