Gutyn
9 years ago
44 changed files with 917 additions and 4401 deletions
@ -0,0 +1,9 @@ |
|||||
|
<component name="libraryTable"> |
||||
|
<library name="acra-4.6.1"> |
||||
|
<CLASSES> |
||||
|
<root url="jar://$PROJECT_DIR$/app/libs/acra-4.6.1.jar!/" /> |
||||
|
</CLASSES> |
||||
|
<JAVADOC /> |
||||
|
<SOURCES /> |
||||
|
</library> |
||||
|
</component> |
@ -1,10 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="uiautomator-v18-2.1.1"> |
|
||||
<CLASSES> |
|
||||
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/res" /> |
|
||||
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/jars/classes.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES /> |
|
||||
</library> |
|
||||
</component> |
|
File diff suppressed because it is too large
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,123 +0,0 @@ |
|||||
package com.breadwallet.presenter.activities; |
|
||||
|
|
||||
import android.app.Activity; |
|
||||
import android.graphics.Bitmap; |
|
||||
import android.graphics.Point; |
|
||||
import android.os.Bundle; |
|
||||
import android.view.Display; |
|
||||
import android.view.Menu; |
|
||||
import android.view.MenuItem; |
|
||||
import android.view.WindowManager; |
|
||||
import android.widget.ImageView; |
|
||||
import android.widget.TextView; |
|
||||
|
|
||||
import com.breadwallet.R; |
|
||||
import com.breadwallet.tools.qrcode.Contents; |
|
||||
import com.breadwallet.tools.qrcode.QRCodeEncoder; |
|
||||
import com.google.zxing.BarcodeFormat; |
|
||||
import com.google.zxing.WriterException; |
|
||||
|
|
||||
/** |
|
||||
* BreadWallet |
|
||||
* |
|
||||
* Created by Mihail on 8/4/15. |
|
||||
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
|
||||
* |
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
* of this software and associated documentation files (the "Software"), to deal |
|
||||
* in the Software without restriction, including without limitation the rights |
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
* copies of the Software, and to permit persons to whom the Software is |
|
||||
* furnished to do so, subject to the following conditions: |
|
||||
* |
|
||||
* The above copyright notice and this permission notice shall be included in |
|
||||
* all copies or substantial portions of the Software. |
|
||||
* |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||
* THE SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
public class ScanResultActivity extends Activity { |
|
||||
public static final String TAG = "ScanResultActivity"; |
|
||||
private TextView scanresult; |
|
||||
private ImageView scanresultimage; |
|
||||
|
|
||||
@Override |
|
||||
protected void onCreate(Bundle savedInstanceState) { |
|
||||
super.onCreate(savedInstanceState); |
|
||||
setContentView(R.layout.activity_scan_result); |
|
||||
|
|
||||
scanresult = (TextView) findViewById(R.id.scanresult); |
|
||||
scanresultimage = (ImageView) findViewById(R.id.scanresultimage); |
|
||||
String result = (String) getIntent().getExtras().get("result"); |
|
||||
String theAddress = result.substring(8); |
|
||||
scanresult.setText(theAddress); |
|
||||
generateQR(theAddress); |
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public boolean onCreateOptionsMenu(Menu menu) { |
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||
getMenuInflater().inflate(R.menu.menu_scan_result, menu); |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public boolean onOptionsItemSelected(MenuItem item) { |
|
||||
// Handle action bar item clicks here. The action bar will
|
|
||||
// automatically handle clicks on the Home/Up button, so long
|
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
|
||||
int id = item.getItemId(); |
|
||||
|
|
||||
//noinspection SimplifiableIfStatement
|
|
||||
if (id == R.id.action_settings) { |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
return super.onOptionsItemSelected(item); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Gets a String parameter to be used to encode in a QR Code Bitmap and |
|
||||
* assign it to an ImageView |
|
||||
* |
|
||||
* @param str the String to be converted into a QR Code |
|
||||
* @see Bitmap |
|
||||
*/ |
|
||||
private void generateQR(String str) { |
|
||||
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); |
|
||||
Display display = manager.getDefaultDisplay(); |
|
||||
Point point = new Point(); |
|
||||
display.getSize(point); |
|
||||
int width = point.x; |
|
||||
int height = point.y; |
|
||||
int smallerDimension = width < height ? width : height; |
|
||||
smallerDimension = smallerDimension * 3 / 4; |
|
||||
|
|
||||
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(str, |
|
||||
null, |
|
||||
Contents.Type.TEXT, |
|
||||
BarcodeFormat.QR_CODE.toString(), |
|
||||
smallerDimension); |
|
||||
try { |
|
||||
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap(); |
|
||||
scanresultimage.setImageBitmap(bitmap); |
|
||||
|
|
||||
} catch (WriterException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onBackPressed() { |
|
||||
super.onBackPressed(); |
|
||||
finish(); |
|
||||
} |
|
||||
} |
|
@ -1,5 +1,5 @@ |
|||||
|
|
||||
package com.breadwallet.presenter.fragments.allsettings.settings; |
package com.breadwallet.presenter.fragments; |
||||
|
|
||||
import android.os.Bundle; |
import android.os.Bundle; |
||||
import android.support.v4.app.Fragment; |
import android.support.v4.app.Fragment; |
@ -1,5 +1,5 @@ |
|||||
|
|
||||
package com.breadwallet.presenter.fragments.allsettings.settings; |
package com.breadwallet.presenter.fragments; |
||||
|
|
||||
import android.os.Bundle; |
import android.os.Bundle; |
||||
import android.support.annotation.Nullable; |
import android.support.annotation.Nullable; |
@ -0,0 +1,225 @@ |
|||||
|
|
||||
|
package com.breadwallet.presenter.fragments; |
||||
|
|
||||
|
import android.graphics.Point; |
||||
|
import android.os.Bundle; |
||||
|
import android.support.v4.app.Fragment; |
||||
|
import android.util.Log; |
||||
|
import android.view.LayoutInflater; |
||||
|
import android.view.View; |
||||
|
import android.view.ViewGroup; |
||||
|
import android.widget.Button; |
||||
|
import android.widget.RelativeLayout; |
||||
|
import android.widget.TextView; |
||||
|
|
||||
|
import com.breadwallet.R; |
||||
|
import com.breadwallet.tools.animation.AmountAdapter; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 7/14/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
public class FragmentScanResult extends Fragment implements View.OnClickListener { |
||||
|
public static final String TAG = "FragmentScanResult"; |
||||
|
private TextView scanresult; |
||||
|
private RelativeLayout customKeyboardLayout; |
||||
|
private TextView amountToPay; |
||||
|
public static String address; |
||||
|
|
||||
|
@Override |
||||
|
public View onCreateView(LayoutInflater inflater, |
||||
|
final ViewGroup container, Bundle savedInstanceState) { |
||||
|
// The last two arguments ensure LayoutParams are inflated
|
||||
|
// properly.
|
||||
|
final View rootView = inflater.inflate( |
||||
|
R.layout.fragment_scan_result, container, false); |
||||
|
|
||||
|
return rootView; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onActivityCreated(Bundle savedInstanceState) { |
||||
|
super.onActivityCreated(savedInstanceState); |
||||
|
scanresult = (TextView) getActivity().findViewById(R.id.scan_result); |
||||
|
customKeyboardLayout = (RelativeLayout) getActivity().findViewById(R.id.custom_keyboard_layout); |
||||
|
amountToPay = (TextView) getActivity().findViewById(R.id.amount_to_pay); |
||||
|
createCustomKeyboardButtons(); |
||||
|
Log.e(TAG, "createCustomKeyboardButtons called!!!!!!"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onResume() { |
||||
|
|
||||
|
// Log.e(TAG, "This is the address: " + address);
|
||||
|
String result = address; |
||||
|
// Log.e(TAG, "This is the result = address: " + result);
|
||||
|
String cleanResult = extractTheCleanAddress(result); |
||||
|
if (cleanResult != null) { |
||||
|
scanresult.setText("to: " + cleanResult); |
||||
|
} else { |
||||
|
scanresult.setText("NO VALID ADDRESS"); |
||||
|
} |
||||
|
super.onResume(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onPause() { |
||||
|
super.onPause(); |
||||
|
AmountAdapter.resetKeyboard(); |
||||
|
} |
||||
|
|
||||
|
public String extractTheCleanAddress(String str) { |
||||
|
if (str == null) return ""; |
||||
|
int length = str.length(); |
||||
|
String tmp; |
||||
|
if (length < 34) { |
||||
|
return ""; |
||||
|
} else { |
||||
|
tmp = str.substring(length - 34); |
||||
|
int tmpLength = tmp.length(); |
||||
|
for (int i = 0; i < tmpLength; i++) { |
||||
|
if (tmp.charAt(i) < 48) { |
||||
|
Log.e(TAG, "Bad address, char: " + tmp.charAt(i)); |
||||
|
return ""; |
||||
|
} else { |
||||
|
if (tmp.charAt(i) > 57 && tmp.charAt(i) < 65) { |
||||
|
Log.e(TAG, "Bad address, char: " + tmp.charAt(i)); |
||||
|
return ""; |
||||
|
} |
||||
|
if (tmp.charAt(i) > 90 && tmp.charAt(i) < 61) { |
||||
|
Log.e(TAG, "Bad address, char: " + tmp.charAt(i)); |
||||
|
return ""; |
||||
|
} |
||||
|
if (tmp.charAt(i) > 122) { |
||||
|
Log.e(TAG, "Bad address, char: " + tmp.charAt(i)); |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return tmp; |
||||
|
} |
||||
|
|
||||
|
private void createCustomKeyboardButtons() { |
||||
|
Point sizePoint = new Point(); |
||||
|
getActivity().getWindowManager().getDefaultDisplay().getSize(sizePoint); |
||||
|
int availableWidth = sizePoint.x; |
||||
|
Log.e(TAG, "AvailableWidth: " + availableWidth); |
||||
|
float gapRate = 0.2f; |
||||
|
float gap = (availableWidth * gapRate); |
||||
|
float interButtonGap = gap / 5; |
||||
|
float buttonSize = (availableWidth - gap) / 3; |
||||
|
int minimumHeight = (int) (buttonSize * 4 + interButtonGap * 4); |
||||
|
int buttonTextSize = 50; |
||||
|
Log.d(TAG, "The gap: " + gap + ", The buttonSize: " + buttonSize); |
||||
|
if (customKeyboardLayout == null) { |
||||
|
customKeyboardLayout = (RelativeLayout) getActivity().findViewById(R.id.custom_keyboard_layout); |
||||
|
} |
||||
|
customKeyboardLayout.setMinimumHeight(minimumHeight); |
||||
|
int childCount = 12; |
||||
|
for (int i = 0; i < childCount; i++) { |
||||
|
Button b = new Button(getActivity()); |
||||
|
b.setWidth((int) buttonSize); |
||||
|
b.setHeight((int) buttonSize); |
||||
|
b.setTextSize(buttonTextSize); |
||||
|
b.setTextColor(getResources().getColor(R.color.darkblue)); |
||||
|
b.setBackgroundResource(R.drawable.button); |
||||
|
b.setOnClickListener(this); |
||||
|
if (i < 9) |
||||
|
b.setText(String.valueOf(i + 1)); |
||||
|
switch (i) { |
||||
|
case 0: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap); |
||||
|
break; |
||||
|
case 1: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 2 + buttonSize); |
||||
|
break; |
||||
|
case 2: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 3 + buttonSize * 2); |
||||
|
break; |
||||
|
case 3: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap); |
||||
|
b.setY(buttonSize + interButtonGap); |
||||
|
break; |
||||
|
case 4: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 2 + buttonSize); |
||||
|
b.setY(buttonSize + interButtonGap); |
||||
|
break; |
||||
|
case 5: |
||||
|
b.setY(buttonSize + interButtonGap); |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 3 + buttonSize * 2); |
||||
|
break; |
||||
|
case 6: |
||||
|
b.setY(buttonSize * 2 + interButtonGap * 2); |
||||
|
b.setX(interButtonGap / 2 + interButtonGap); |
||||
|
break; |
||||
|
case 7: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 2 + buttonSize); |
||||
|
b.setY(buttonSize * 2 + interButtonGap * 2); |
||||
|
break; |
||||
|
case 8: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 3 + buttonSize * 2); |
||||
|
b.setY(buttonSize * 2 + interButtonGap * 2); |
||||
|
break; |
||||
|
case 9: |
||||
|
b.setText("."); |
||||
|
b.setY(buttonSize * 3 + interButtonGap * 3); |
||||
|
b.setX(interButtonGap / 2 + interButtonGap); |
||||
|
break; |
||||
|
case 10: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 2 + buttonSize); |
||||
|
b.setText("0"); |
||||
|
b.setY(buttonSize * 3 + interButtonGap * 3); |
||||
|
break; |
||||
|
case 11: |
||||
|
b.setX(interButtonGap / 2 + interButtonGap * 3 + buttonSize * 2 + buttonSize / 4); |
||||
|
b.setBackgroundResource(R.drawable.deletetoleft); |
||||
|
b.setWidth((int) (buttonSize / 2)); |
||||
|
b.setHeight((int) (buttonSize / 2)); |
||||
|
b.setY(buttonSize * 3 + interButtonGap * 3 + buttonSize / 4); |
||||
|
break; |
||||
|
} |
||||
|
customKeyboardLayout.addView(b); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onClick(View v) { |
||||
|
String tmp = ((Button) v).getText().toString(); |
||||
|
switch (tmp) { |
||||
|
case "": |
||||
|
AmountAdapter.doBackSpace(getActivity(), amountToPay); |
||||
|
break; |
||||
|
case ".": |
||||
|
AmountAdapter.insertComma(getActivity(), amountToPay); |
||||
|
break; |
||||
|
default: |
||||
|
AmountAdapter.insertDigit(getActivity(), amountToPay, tmp); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,5 +1,5 @@ |
|||||
|
|
||||
package com.breadwallet.presenter.fragments.allsettings.settings; |
package com.breadwallet.presenter.fragments; |
||||
|
|
||||
import android.os.Bundle; |
import android.os.Bundle; |
||||
import android.support.v4.app.Fragment; |
import android.support.v4.app.Fragment; |
@ -0,0 +1,126 @@ |
|||||
|
package com.breadwallet.tools.animation; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.util.Log; |
||||
|
import android.widget.TextView; |
||||
|
|
||||
|
import com.breadwallet.R; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 8/14/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class AmountAdapter { |
||||
|
private static final String TAG = "AmountAdapter"; |
||||
|
private static boolean comaHasBeenInserted = false; |
||||
|
private static int digitsAfterComma = 2; |
||||
|
private static final int DIGITS_LIMIT = 10; |
||||
|
private static boolean isTextColorGrey = true; |
||||
|
|
||||
|
public static void doBackSpace(Context context, TextView amountToPay) { |
||||
|
CharSequence amount = amountToPay.getText(); |
||||
|
int length = amount.length(); |
||||
|
if (digitsAfterComma < 2) { |
||||
|
digitsAfterComma++; |
||||
|
} |
||||
|
if (amount.charAt(length - 1) == '.') { |
||||
|
comaHasBeenInserted = false; |
||||
|
digitsAfterComma = 2; |
||||
|
} |
||||
|
if (length == 1) { |
||||
|
changeTextColor(context, amountToPay, 2); |
||||
|
amountToPay.setText("0"); |
||||
|
} else if (length == 2 && amount.charAt(0) == '0') { |
||||
|
changeTextColor(context, amountToPay, 2); |
||||
|
amountToPay.setText("0"); |
||||
|
} else { |
||||
|
amountToPay.setText(amount.subSequence(0, length - 1)); |
||||
|
} |
||||
|
Log.e(TAG, "doBackSpace|comaHasBeenInserted: " + comaHasBeenInserted + ", digitsAfterComma: " + |
||||
|
digitsAfterComma + ", current text: " + amountToPay.getText().toString()); |
||||
|
} |
||||
|
|
||||
|
public static void insertComma(Context context, TextView amountToPay) { |
||||
|
if (isTextColorGrey) { |
||||
|
changeTextColor(context, amountToPay, 1); |
||||
|
} |
||||
|
CharSequence amount = amountToPay.getText(); |
||||
|
int length = amount.length(); |
||||
|
if (!comaHasBeenInserted) { |
||||
|
comaHasBeenInserted = true; |
||||
|
if (length == 1 && amount.charAt(0) == '0') { |
||||
|
amountToPay.setText("0."); |
||||
|
} else { |
||||
|
amountToPay.setText(amount.toString() + "."); |
||||
|
} |
||||
|
} |
||||
|
// Log.e(TAG, "insertComma|comaHasBeenInserted: " + comaHasBeenInserted + ", digitsAfterComma: " + digitsAfterComma + ", buttonPressed: " + ".");
|
||||
|
} |
||||
|
|
||||
|
public static void insertDigit(Context context, TextView amountToPay, String tmp) { |
||||
|
CharSequence amount = amountToPay.getText(); |
||||
|
int length = amount.length(); |
||||
|
if (isTextColorGrey) { |
||||
|
changeTextColor(context, amountToPay, 1); |
||||
|
} |
||||
|
if (isDigitInsertingLegal(amountToPay.length())) { |
||||
|
if (length == 1 && amount.equals("0")) { |
||||
|
amountToPay.setText(tmp); |
||||
|
} else { |
||||
|
amountToPay.setText(amount + tmp); |
||||
|
} |
||||
|
} |
||||
|
// Log.e(TAG, "insertDigit|comaHasBeenInserted: " + comaHasBeenInserted + ", digitsAfterComma: " + digitsAfterComma + ", buttonPressed: " + tmp);
|
||||
|
} |
||||
|
|
||||
|
private static boolean isDigitInsertingLegal(int length) { |
||||
|
if (comaHasBeenInserted) { |
||||
|
if (digitsAfterComma > 0) { |
||||
|
digitsAfterComma--; |
||||
|
return true; |
||||
|
} else { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
if (length > DIGITS_LIMIT) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Sets the textColor of the amount TextView to black or grey |
||||
|
* |
||||
|
* @patam color the color of the textView: 1 Black, 2 Grey. |
||||
|
*/ |
||||
|
private static void changeTextColor(Context context, TextView textView, int color) { |
||||
|
isTextColorGrey = color == 1 ? false : true; |
||||
|
textView.setTextColor((color == 1) ? context.getResources().getColor(R.color.black) |
||||
|
: context.getResources().getColor(android.R.color.darker_gray)); |
||||
|
} |
||||
|
|
||||
|
public static void resetKeyboard() { |
||||
|
comaHasBeenInserted = false; |
||||
|
digitsAfterComma = 2; |
||||
|
Log.e(TAG, "resetKeyboard called!!!!"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
package com.breadwallet.tools.others; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.graphics.Typeface; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import java.lang.reflect.Field; |
||||
|
|
||||
|
|
||||
|
public class TypefaceUtil { |
||||
|
public static final String TAG = "TypefaceUtil"; |
||||
|
|
||||
|
/** |
||||
|
* Using reflection to override default typeface |
||||
|
* NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN |
||||
|
* |
||||
|
* @param context to work with assets |
||||
|
* @param defaultFontNameToOverride for example "monospace" |
||||
|
* @param customFontFileNameInAssets file name of the font from assets |
||||
|
*/ |
||||
|
public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) { |
||||
|
try { |
||||
|
final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets); |
||||
|
|
||||
|
final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride); |
||||
|
defaultFontTypefaceField.setAccessible(true); |
||||
|
defaultFontTypefaceField.set(null, customFontTypeface); |
||||
|
} catch (Exception e) { |
||||
|
Log.e(TAG, "Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride); |
||||
|
} |
||||
|
} |
||||
|
} |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 827 B |
After Width: | Height: | Size: 874 B |
@ -1,42 +0,0 @@ |
|||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||
xmlns:tools="http://schemas.android.com/tools" |
|
||||
android:layout_width="match_parent" |
|
||||
android:layout_height="match_parent" |
|
||||
android:paddingBottom="@dimen/activity_vertical_margin" |
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin" |
|
||||
android:paddingRight="@dimen/activity_horizontal_margin" |
|
||||
android:paddingTop="@dimen/activity_vertical_margin" |
|
||||
android:background="@drawable/backgroundmain" |
|
||||
tools:context="com.breadwallet.presenter.activities.ScanResultActivity"> |
|
||||
|
|
||||
|
|
||||
|
|
||||
<TextView |
|
||||
android:layout_width="wrap_content" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:id="@+id/scanresult" |
|
||||
android:text="@string/the_address" |
|
||||
android:gravity="center_vertical" |
|
||||
android:layout_below="@+id/textView2" |
|
||||
android:layout_centerHorizontal="true" |
|
||||
android:layout_marginTop="63dp" /> |
|
||||
|
|
||||
<TextView |
|
||||
android:layout_width="wrap_content" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" |
|
||||
android:text="The scanned address:" |
|
||||
android:id="@+id/textView2" |
|
||||
android:layout_alignParentTop="true" |
|
||||
android:layout_centerHorizontal="true" |
|
||||
android:layout_marginTop="81dp" /> |
|
||||
|
|
||||
<ImageView |
|
||||
android:layout_width="wrap_content" |
|
||||
android:layout_height="wrap_content" |
|
||||
android:id="@+id/scanresultimage" |
|
||||
android:layout_below="@+id/scanresult" |
|
||||
android:layout_centerVertical="true" |
|
||||
android:layout_centerHorizontal="true" /> |
|
||||
|
|
||||
</RelativeLayout> |
|
@ -0,0 +1,76 @@ |
|||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:paddingBottom="@dimen/activity_vertical_margin" |
||||
|
android:paddingTop="@dimen/activity_vertical_margin" |
||||
|
tools:context="com.breadwallet.presenter.activities.ScanResultActivity"> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/amount_to_pay" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="30dp" |
||||
|
android:layout_alignParentRight="true" |
||||
|
android:layout_marginLeft="3dp" |
||||
|
android:layout_marginRight="16dp" |
||||
|
android:layout_marginTop="40dp" |
||||
|
android:text="0" |
||||
|
android:textColor="@android:color/darker_gray" |
||||
|
android:textSize="26sp" /> |
||||
|
|
||||
|
<View |
||||
|
android:id="@+id/first_line" |
||||
|
android:layout_width="fill_parent" |
||||
|
android:layout_height="1dp" |
||||
|
android:layout_below="@+id/amount_to_pay" |
||||
|
android:layout_marginLeft="16dp" |
||||
|
android:layout_marginRight="16dp" |
||||
|
android:layout_marginTop="10dp" |
||||
|
android:background="@android:color/darker_gray" /> |
||||
|
|
||||
|
<RelativeLayout |
||||
|
android:id="@+id/custom_keyboard_layout" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_below="@id/first_line" |
||||
|
android:layout_marginTop="15dp"> |
||||
|
|
||||
|
</RelativeLayout> |
||||
|
|
||||
|
<View |
||||
|
android:id="@+id/second_line" |
||||
|
android:layout_width="fill_parent" |
||||
|
android:layout_height="1dp" |
||||
|
android:layout_below="@+id/custom_keyboard_layout" |
||||
|
android:layout_marginLeft="16dp" |
||||
|
android:layout_marginRight="16dp" |
||||
|
android:background="@android:color/darker_gray" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/scan_result" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_below="@+id/second_line" |
||||
|
android:layout_centerHorizontal="true" |
||||
|
android:layout_marginLeft="16dp" |
||||
|
android:layout_marginRight="16dp" |
||||
|
android:layout_marginTop="10dp" |
||||
|
android:text="@string/the_address" /> |
||||
|
|
||||
|
<ImageView |
||||
|
android:layout_width="15dp" |
||||
|
android:layout_height="20dp" |
||||
|
android:layout_alignBottom="@+id/amount_to_pay" |
||||
|
android:layout_toStartOf="@+id/amount_to_pay" |
||||
|
android:background="@drawable/bitcoin_lowercase" |
||||
|
android:id="@+id/imageView" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:id="@+id/test_text_charset" |
||||
|
android:text="␢" |
||||
|
android:layout_alignBottom="@+id/imageView" |
||||
|
android:layout_toStartOf="@+id/imageView" /> |
||||
|
|
||||
|
</RelativeLayout> |
Loading…
Reference in new issue