Browse Source

Another commit

gradlePlay
Gutyn 9 years ago
parent
commit
cd2a010a2a
  1. 2
      .gitignore
  2. 9
      .idea/libraries/acra_4_6_1.xml
  3. 10
      .idea/libraries/uiautomator_v18_2_1_1.xml
  4. 3974
      .idea/workspace.xml
  5. 5
      app/app.iml
  6. 5
      app/build.gradle
  7. BIN
      app/libs/acra-4.6.1.jar
  8. 10
      app/src/androidTest/java/com/breadwallet/presenter/activities/tests/MainActivityTest.java
  9. 2
      app/src/androidTest/java/com/breadwallet/presenter/activities/tests/ScanResultActivityTest.java
  10. 5
      app/src/main/AndroidManifest.xml
  11. 0
      app/src/main/assets/fonts/AlexandriaFLF.ttf
  12. BIN
      app/src/main/assets/fonts/Everson Mono.ttf
  13. BIN
      app/src/main/assets/fonts/Roboto-Light.ttf
  14. BIN
      app/src/main/assets/fonts/Roboto-Thin.ttf
  15. 64
      app/src/main/java/com/breadwallet/presenter/BreadWalletApp.java
  16. 39
      app/src/main/java/com/breadwallet/presenter/activities/DecoderActivity.java
  17. 6
      app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java
  18. 165
      app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java
  19. 123
      app/src/main/java/com/breadwallet/presenter/activities/ScanResultActivity.java
  20. 2
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java
  21. 85
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentCurrency.java
  22. 2
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentRecoveryPhrase.java
  23. 225
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentScanResult.java
  24. 3
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentSettings.java
  25. 2
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentWipeWallet.java
  26. 22
      app/src/main/java/com/breadwallet/presenter/fragments/MainFragment.java
  27. 54
      app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentDecoder.java
  28. 54
      app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentQR.java
  29. 22
      app/src/main/java/com/breadwallet/presenter/fragments/SharingFragment.java
  30. 27
      app/src/main/java/com/breadwallet/tools/adapter/CurrencyListAdapter.java
  31. 13
      app/src/main/java/com/breadwallet/tools/adapter/CustomPagerAdapter.java
  32. 126
      app/src/main/java/com/breadwallet/tools/animation/AmountAdapter.java
  33. 65
      app/src/main/java/com/breadwallet/tools/animation/FragmentAnimator.java
  34. 10
      app/src/main/java/com/breadwallet/tools/others/CurrencyManager.java
  35. 32
      app/src/main/java/com/breadwallet/tools/others/TypefaceUtil.java
  36. BIN
      app/src/main/res/drawable/backgroundmain_cropped.png
  37. BIN
      app/src/main/res/drawable/bitcoin_lowercase.png
  38. BIN
      app/src/main/res/drawable/deletetoleft.png
  39. 42
      app/src/main/res/layouts/activities/layout/activity_scan_result.xml
  40. 24
      app/src/main/res/layouts/fragments/layout/fragment_local_currency.xml
  41. 2
      app/src/main/res/layouts/fragments/layout/fragment_qr_main.xml
  42. 76
      app/src/main/res/layouts/fragments/layout/fragment_scan_result.xml
  43. 2
      app/src/main/res/layouts/layout/currency_list_item.xml
  44. 9
      app/src/main/res/values/strings.xml

2
.gitignore

@ -25,3 +25,5 @@ proguard/
# Log Files # Log Files
*.log *.log

9
.idea/libraries/acra_4_6_1.xml

@ -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>

10
.idea/libraries/uiautomator_v18_2_1_1.xml

@ -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>

3974
.idea/workspace.xml

File diff suppressed because it is too large

5
app/app.iml

@ -78,7 +78,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.2/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.uiautomator/uiautomator-v18/2.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.3/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/rules/0.3/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/rules/0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/runner/0.3/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/runner/0.3/jars" />
@ -101,11 +100,10 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="uiautomator-v18-2.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
@ -114,6 +112,7 @@
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" name="acra-4.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="rules-0.3" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />

5
app/build.gradle

@ -16,7 +16,7 @@ android {
defaultConfig { defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "com.breadwallet" applicationId "com.breadwallet"
minSdkVersion 18 minSdkVersion 17
targetSdkVersion 22 targetSdkVersion 22
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -47,6 +47,7 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/acra-4.6.1.jar')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.zxing:core:3.2.0' //QRCode scanner compile 'com.google.zxing:core:3.2.0' //QRCode scanner
@ -59,5 +60,5 @@ dependencies {
// Set this dependency to build and run Espresso tests // Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
// Set this dependency to build and run UI Automator tests // Set this dependency to build and run UI Automator tests
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1' // androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
} }

BIN
app/libs/acra-4.6.1.jar

Binary file not shown.

10
app/src/androidTest/java/com/breadwallet/presenter/activities/tests/MainActivityTest.java

@ -73,15 +73,9 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
} }
@MediumTest @MediumTest
public void testBurgerButtonClickability() { public void testBurgerButton() {
// TouchUtils.clickView(this,burgerButtonLayout);
// TouchUtils.clickView(this,scanQRCode);
// activity.onBackPressed();
// TouchUtils.clickView(this, copyAddressFromClipboard);
// activity.onBackPressed();
onView(withId(R.id.burgerbuttonlayout)).perform(click()); onView(withId(R.id.burgerbuttonlayout)).perform(click());
// onView(withId(R.id.settings)).perform(click());
} }
@MediumTest @MediumTest

2
app/src/androidTest/java/com/breadwallet/presenter/activities/tests/ScanResultActivityTest.java

@ -2,8 +2,6 @@ package com.breadwallet.presenter.activities.tests;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import com.breadwallet.presenter.activities.ScanResultActivity;
/** /**
* BreadWallet * BreadWallet
* *

5
app/src/main/AndroidManifest.xml

@ -17,7 +17,6 @@
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true" android:largeHeap="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
>
<activity <activity
android:name=".presenter.activities.IntroActivity" android:name=".presenter.activities.IntroActivity"
android:label="@string/app_name" android:label="@string/app_name"
@ -32,10 +31,6 @@
android:name=".presenter.activities.MainActivity" android:name=".presenter.activities.MainActivity"
android:label="@string/title_activity_main" android:label="@string/title_activity_main"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.ScanResultActivity"
android:label="@string/title_activity_scan_result"
android:screenOrientation="portrait" />
<activity <activity
android:name=".presenter.activities.DecoderActivity" android:name=".presenter.activities.DecoderActivity"
android:label="@string/title_activity_decoder" android:label="@string/title_activity_decoder"

0
app/src/main/assets/fonts/AlexandriaFLF.ttf

BIN
app/src/main/assets/fonts/Everson Mono.ttf

Binary file not shown.

BIN
app/src/main/assets/fonts/Roboto-Light.ttf

Binary file not shown.

BIN
app/src/main/assets/fonts/Roboto-Thin.ttf

Binary file not shown.

64
app/src/main/java/com/breadwallet/presenter/BreadWalletApp.java

@ -2,32 +2,42 @@ package com.breadwallet.presenter;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.graphics.Point;
import android.os.Handler; import android.os.Handler;
import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.tools.others.TypefaceUtil;
import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 7/22/15. * Created by Mihail on 7/22/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -37,22 +47,50 @@ import com.breadwallet.R;
* THE SOFTWARE. * THE SOFTWARE.
*/ */
@ReportsCrashes(
mailTo = "mihail@breadwallet.com", // my email here
customReportContent = {
ReportField.APP_VERSION_CODE,
ReportField.APP_VERSION_NAME,
ReportField.ANDROID_VERSION,
ReportField.PACKAGE_NAME,
ReportField.REPORT_ID,
ReportField.BUILD,
ReportField.STACK_TRACE
},
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text
)
public class BreadWalletApp extends Application { public class BreadWalletApp extends Application {
public static final String TAG = "BreadWalletApp"; public static final String TAG = "BreadWalletApp";
private boolean customToastAvailable = true; private boolean customToastAvailable = true;
private String oldMessage; private String oldMessage;
private Toast toast; private Toast toast;
; public static int DISPLAY_WIDTH_PX;
public static int DISPLAY_HEIGHT_PX;
@Override
public void onCreate() {
super.onCreate();
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
DISPLAY_WIDTH_PX = size.x;
DISPLAY_HEIGHT_PX = size.y;
ACRA.init(this);
TypefaceUtil.overrideFont(getApplicationContext(), "DEFAULT", "fonts/Roboto-Light.ttf");
}
/** /**
* Shows a custom toast using the given string as a paramater, * Shows a custom toast using the given string as a paramater,
* *
* @param message the message to be shown in the custom toast * @param message the message to be shown in the custom toast
*/ */
public void showCustomToast(Activity app, String message, int yOffSet, int duration) { public void showCustomToast(Activity app, String message, int yOffSet, int duration) {
if (toast == null) toast = new Toast(getApplicationContext()); if (toast == null) toast = new Toast(getApplicationContext());
if (customToastAvailable || !oldMessage.equals(message)) { if (customToastAvailable || !oldMessage.equals(message)) {
// toast.cancel();
oldMessage = message; oldMessage = message;
customToastAvailable = false; customToastAvailable = false;
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@ -72,4 +110,18 @@ public class BreadWalletApp extends Application {
toast.show(); toast.show();
} }
} }
public int getRelativeLeft(View myView) {
if (myView.getParent() == myView.getRootView())
return myView.getLeft();
else
return myView.getLeft() + getRelativeLeft((View) myView.getParent());
}
public int getRelativeTop(View myView) {
if (myView.getParent() == myView.getRootView())
return myView.getTop();
else
return myView.getTop() + getRelativeTop((View) myView.getParent());
}
} }

39
app/src/main/java/com/breadwallet/presenter/activities/DecoderActivity.java

@ -2,18 +2,14 @@
package com.breadwallet.presenter.activities; package com.breadwallet.presenter.activities;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.graphics.PointF; import android.graphics.PointF;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.TextView;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.presenter.fragments.FragmentScanResult;
import com.breadwallet.tools.animation.FragmentAnimator;
import com.breadwallet.tools.qrcode.QRCodeReaderView; import com.breadwallet.tools.qrcode.QRCodeReaderView;
/** /**
@ -46,10 +42,7 @@ public class DecoderActivity extends Activity implements QRCodeReaderView.OnQRCo
public static final String TAG = "DecoderActivity"; public static final String TAG = "DecoderActivity";
private boolean accessGranted = true; private boolean accessGranted = true;
private TextView myTextView;
private QRCodeReaderView mydecoderview; private QRCodeReaderView mydecoderview;
private ImageView line_image;
private Intent intent;
private DecoderActivity decoderActivity; private DecoderActivity decoderActivity;
public DecoderActivity() { public DecoderActivity() {
@ -61,23 +54,6 @@ public class DecoderActivity extends Activity implements QRCodeReaderView.OnQRCo
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_decoder); setContentView(R.layout.activity_decoder);
// //
intent = new Intent(this, ScanResultActivity.class);
myTextView = (TextView) findViewById(R.id.exampleTextView);
line_image = (ImageView) findViewById(R.id.red_line_image);
TranslateAnimation mAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0.5f);
mAnimation.setDuration(1000);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setInterpolator(new LinearInterpolator());
line_image.setAnimation(mAnimation);
} }
/** /**
@ -87,12 +63,15 @@ public class DecoderActivity extends Activity implements QRCodeReaderView.OnQRCo
*/ */
@Override @Override
public void onQRCodeRead(String text, PointF[] points) { public void onQRCodeRead(String text, PointF[] points) {
Log.e(TAG, "QRCode was read!");
if (accessGranted) { if (accessGranted) {
accessGranted = false; accessGranted = false;
myTextView.setText(text); if(text!= null){
// Log.e(TAG, "Activity STARTED!!!!!"); FragmentScanResult.address = text;
intent.putExtra("result", text); FragmentAnimator.animateScanResultFragment();
startActivity(intent); } else {
throw new NullPointerException("The scanned text is null!");
}
finish(); finish();
} }
} }

6
app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java

@ -47,9 +47,11 @@ public class IntroActivity extends Activity {
@Override @Override
public void run() { public void run() {
startActivity(intent); startActivity(intent);
finish(); if(!IntroActivity.this.isDestroyed()){
finish();
}
} }
}, 800); }, 800);
} }
} }

165
app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java

@ -3,10 +3,10 @@ package com.breadwallet.presenter.activities;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.PersistableBundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.ScaleAnimation; import android.view.animation.ScaleAnimation;
@ -17,13 +17,14 @@ import android.widget.Toast;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.presenter.BreadWalletApp; import com.breadwallet.presenter.BreadWalletApp;
import com.breadwallet.presenter.fragments.FragmentAbout;
import com.breadwallet.presenter.fragments.FragmentCurrency;
import com.breadwallet.presenter.fragments.FragmentRecoveryPhrase;
import com.breadwallet.presenter.fragments.FragmentScanResult;
import com.breadwallet.presenter.fragments.FragmentSettings;
import com.breadwallet.presenter.fragments.FragmentWipeWallet;
import com.breadwallet.presenter.fragments.MainFragmentDecoder; import com.breadwallet.presenter.fragments.MainFragmentDecoder;
import com.breadwallet.presenter.fragments.MainFragmentSettingsAll; import com.breadwallet.presenter.fragments.MainFragmentSettingsAll;
import com.breadwallet.presenter.fragments.allsettings.FragmentSettings;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentAbout;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentCurrency;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentRecoveryPhrase;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentWipeWallet;
import com.breadwallet.tools.adapter.CustomPagerAdapter; import com.breadwallet.tools.adapter.CustomPagerAdapter;
import com.breadwallet.tools.adapter.ParallaxViewPager; import com.breadwallet.tools.adapter.ParallaxViewPager;
import com.breadwallet.tools.animation.FragmentAnimator; import com.breadwallet.tools.animation.FragmentAnimator;
@ -35,20 +36,20 @@ import java.util.Map;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 8/4/15. * Created by Mihail on 8/4/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -63,15 +64,16 @@ public class MainActivity extends FragmentActivity {
public static final String PREFS_NAME = "MyPrefsFile"; public static final String PREFS_NAME = "MyPrefsFile";
public static MainActivity app; public static MainActivity app;
public static boolean decoderFragmentOn; public static boolean decoderFragmentOn;
public static boolean scanResultFragmentOn;
public CustomPagerAdapter pagerAdapter; public CustomPagerAdapter pagerAdapter;
public RelativeLayout pageIndicator; public static RelativeLayout pageIndicator;
public ImageView pageIndicatorLeft; public ImageView pageIndicatorLeft;
public ImageView pageIndicatorRight; public ImageView pageIndicatorRight;
public Map<String, Integer> burgerButtonMap; public Map<String, Integer> burgerButtonMap;
public Button burgerButton; public Button burgerButton;
public Button locker; public Button locker;
public MainFragmentSettingsAll mainFragmentSettingsAll; public MainFragmentSettingsAll mainFragmentSettingsAll;
public ParallaxViewPager parallaxViewPager; public static ParallaxViewPager parallaxViewPager;
public FragmentSettings fragmentSettings; public FragmentSettings fragmentSettings;
public FragmentAbout fragmentAbout; public FragmentAbout fragmentAbout;
public MainFragmentDecoder mainFragmentDecoder; public MainFragmentDecoder mainFragmentDecoder;
@ -80,12 +82,14 @@ public class MainActivity extends FragmentActivity {
public FragmentRecoveryPhrase fragmentRecoveryPhrase; public FragmentRecoveryPhrase fragmentRecoveryPhrase;
public FragmentWipeWallet fragmentWipeWallet; public FragmentWipeWallet fragmentWipeWallet;
public RelativeLayout burgerButtonLayout; public RelativeLayout burgerButtonLayout;
public FragmentScanResult fragmentScanResult;
private boolean onBackPressedAvailable = true; private boolean onBackPressedAvailable = true;
private boolean doubleBackToExitPressedOnce; private boolean doubleBackToExitPressedOnce;
public static final int BURGER = 0; public static final int BURGER = 0;
public static final int CLOSE = 1; public static final int CLOSE = 1;
public static final int BACK = 2; public static final int BACK = 2;
public static final float PAGE_INDICATOR_SCALE_UP = 1.3f; public static final float PAGE_INDICATOR_SCALE_UP = 1.3f;
public static boolean beenThroughSavedInstanceMethod = false;
/** /**
* Public constructor used to assign the current instance to the app variable * Public constructor used to assign the current instance to the app variable
@ -95,29 +99,34 @@ public class MainActivity extends FragmentActivity {
app = this; app = this;
} }
@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
beenThroughSavedInstanceMethod = true;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Log.e(TAG, "Activity created!"); Log.e(TAG, "Activity created!");
if (savedInstanceState != null) {
return;
}
initializeViews(); initializeViews();
burgerButtonLayout.setOnTouchListener(new View.OnTouchListener() { burgerButtonLayout.setOnClickListener(new View.OnClickListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent motionEvent) { public void onClick(View v) {
// Log.d(TAG, "CLicked on the burgerLayoutHelper!");
SpringAnimator.showAnimation(burgerButton); SpringAnimator.showAnimation(burgerButton);
if (FragmentAnimator.level > 1) { if (FragmentAnimator.level > 1 || scanResultFragmentOn) {
// Log.e(TAG, "CHECK:Should press back!"); Log.e(TAG, "CHECK:Should press back!");
app.onBackPressed(); app.onBackPressed();
} else { } else {
FragmentAnimator.pressMenuButton(app, mainFragmentSettingsAll); FragmentAnimator.pressMenuButton(app, mainFragmentSettingsAll);
// Log.e(TAG, "CHECK:Should press menu"); Log.e(TAG, "CHECK:Should press menu");
} }
return true;
} }
}); });
} }
@ -134,7 +143,6 @@ public class MainActivity extends FragmentActivity {
CurrencyManager.stoptimertask(); CurrencyManager.stoptimertask();
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -146,6 +154,7 @@ public class MainActivity extends FragmentActivity {
/** /**
* Initializes all the views and components * Initializes all the views and components
*/ */
private void initializeViews() { private void initializeViews() {
burgerButtonLayout = (RelativeLayout) findViewById(R.id.burgerbuttonlayout); burgerButtonLayout = (RelativeLayout) findViewById(R.id.burgerbuttonlayout);
burgerButton = (Button) findViewById(R.id.mainbuttonburger); burgerButton = (Button) findViewById(R.id.mainbuttonburger);
@ -163,6 +172,7 @@ public class MainActivity extends FragmentActivity {
fragmentCurrency = new FragmentCurrency(); fragmentCurrency = new FragmentCurrency();
fragmentRecoveryPhrase = new FragmentRecoveryPhrase(); fragmentRecoveryPhrase = new FragmentRecoveryPhrase();
fragmentWipeWallet = new FragmentWipeWallet(); fragmentWipeWallet = new FragmentWipeWallet();
fragmentScanResult = new FragmentScanResult();
parallaxViewPager = ((ParallaxViewPager) findViewById(R.id.pager)); parallaxViewPager = ((ParallaxViewPager) findViewById(R.id.pager));
parallaxViewPager parallaxViewPager
.setOverlapPercentage(0.99f) .setOverlapPercentage(0.99f)
@ -175,65 +185,96 @@ public class MainActivity extends FragmentActivity {
scaleView(pageIndicatorLeft, 1f, PAGE_INDICATOR_SCALE_UP, 1f, PAGE_INDICATOR_SCALE_UP); scaleView(pageIndicatorLeft, 1f, PAGE_INDICATOR_SCALE_UP, 1f, PAGE_INDICATOR_SCALE_UP);
} }
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) { if (keyCode == KeyEvent.KEYCODE_MENU) {
// return 'true' to prevent further propagation of the key event
if (FragmentAnimator.level > 1) { if (FragmentAnimator.level > 1) {
// Log.e(TAG, "CHECK:Should press back!");
this.onBackPressed(); this.onBackPressed();
} else { } else {
// Log.e(TAG, "CHECK:Should press menu"); if(scanResultFragmentOn){
app.onBackPressed();
}
FragmentAnimator.pressMenuButton(app, mainFragmentSettingsAll); FragmentAnimator.pressMenuButton(app, mainFragmentSettingsAll);
} }
return true; return true;
} }
// let the system handle all other key events // let the system handle all other key events
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
Log.e(TAG, "onBackPressed!!!!"); Log.e(TAG, "onBackPressed!");
if (onBackPressedAvailable) { if (onBackPressedAvailable) {
onBackPressedAvailable = false; onBackPressedAvailable = false;
new Handler().postDelayed(new Runnable() { makeOnBackPressedAvailable(300);
@Override
public void run() { //old implimentation, keep in case the new ones fail
onBackPressedAvailable = true; // if (!FragmentAnimator.wipeWalletOpen) {
} // if (FragmentAnimator.level == 0) {
}, 300); // if (doubleBackToExitPressedOnce) {
if (!FragmentAnimator.wipeWalletOpen) { // super.onBackPressed();
if (FragmentAnimator.level == 0) { // return;
// }
// if (decoderFragmentOn) {
// FragmentAnimator.hideDecoderFragment();
// } else {
// this.doubleBackToExitPressedOnce = true;
// ((BreadWalletApp) getApplicationContext()).showCustomToast(this,
// getResources().getString(R.string.mainactivity_press_back_again), 100, Toast.LENGTH_SHORT);
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// doubleBackToExitPressedOnce = false;
// }
// }, 1000);
// }
// } else if (FragmentAnimator.level == 1) {
// FragmentAnimator.pressMenuButton(this, mainFragmentSettingsAll);
// if (FragmentAnimator.multiplePressingAvailable)
// FragmentAnimator.hideDecoderFragment();
// } else {
// FragmentAnimator.animateSlideToRight(this);
// }
// } else {
// FragmentAnimator.pressWipeWallet(this, fragmentSettings);
// activityButtonsEnable(true);
// }
if (FragmentAnimator.wipeWalletOpen) {
FragmentAnimator.pressWipeWallet(this, fragmentSettings);
activityButtonsEnable(true);
return;
}
//switch the level of fragments creation.
switch (FragmentAnimator.level) {
case 0:
if (doubleBackToExitPressedOnce) { if (doubleBackToExitPressedOnce) {
super.onBackPressed(); super.onBackPressed();
return; break;
} }
if (decoderFragmentOn) { if (decoderFragmentOn) {
FragmentAnimator.hideDecoderFragment(); FragmentAnimator.hideDecoderFragment();
} else { break;
this.doubleBackToExitPressedOnce = true; }
((BreadWalletApp) getApplicationContext()).showCustomToast(this, if (scanResultFragmentOn) {
getResources().getString(R.string.mainactivity_press_back_again), 100, Toast.LENGTH_SHORT); FragmentAnimator.hideScanResultFragment();
new Handler().postDelayed(new Runnable() { break;
@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
}, 1000);
} }
} else if (FragmentAnimator.level == 1) { this.doubleBackToExitPressedOnce = true;
((BreadWalletApp) getApplicationContext()).showCustomToast(this,
getResources().getString(R.string.mainactivity_press_back_again), 140, Toast.LENGTH_SHORT);
makeDoubleBackToExitPressedOnce(1000);
break;
case 1:
FragmentAnimator.pressMenuButton(this, mainFragmentSettingsAll); FragmentAnimator.pressMenuButton(this, mainFragmentSettingsAll);
if (FragmentAnimator.multiplePressingAvailable) if (FragmentAnimator.multiplePressingAvailable)
FragmentAnimator.hideDecoderFragment(); FragmentAnimator.hideDecoderFragment();
} else { break;
default:
FragmentAnimator.animateSlideToRight(this); FragmentAnimator.animateSlideToRight(this);
} break;
} else {
FragmentAnimator.pressWipeWallet(this, fragmentSettings);
activityButtonsEnable(true);
} }
} }
} }
@ -307,4 +348,22 @@ public class MainActivity extends FragmentActivity {
anim.setFillAfter(true); // Needed to keep the result of the animation anim.setFillAfter(true); // Needed to keep the result of the animation
v.startAnimation(anim); v.startAnimation(anim);
} }
private void makeOnBackPressedAvailable(int ms) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
onBackPressedAvailable = true;
}
}, ms);
}
private void makeDoubleBackToExitPressedOnce(int ms) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
}, ms);
}
} }

123
app/src/main/java/com/breadwallet/presenter/activities/ScanResultActivity.java

@ -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();
}
}

2
app/src/main/java/com/breadwallet/presenter/fragments/allsettings/settings/FragmentAbout.java → app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java

@ -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;

85
app/src/main/java/com/breadwallet/presenter/fragments/allsettings/settings/FragmentCurrency.java → app/src/main/java/com/breadwallet/presenter/fragments/FragmentCurrency.java

@ -1,16 +1,17 @@
package com.breadwallet.presenter.fragments.allsettings.settings; package com.breadwallet.presenter.fragments;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -56,6 +57,8 @@ public class FragmentCurrency extends Fragment {
private TextView noInternetConnection; private TextView noInternetConnection;
private CurrencyListAdapter adapter; private CurrencyListAdapter adapter;
private TextView currencyItemText; private TextView currencyItemText;
private ProgressBar currencyProgressBar;
SharedPreferences settings;
@Override @Override
public View onCreateView(LayoutInflater inflater, public View onCreateView(LayoutInflater inflater,
@ -67,40 +70,11 @@ public class FragmentCurrency extends Fragment {
app = MainActivity.app; app = MainActivity.app;
currencyList = (ListView) rootView.findViewById(R.id.currency_list_view); currencyList = (ListView) rootView.findViewById(R.id.currency_list_view);
currencyList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); currencyList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
currencyProgressBar = (ProgressBar) rootView.findViewById(R.id.currency_progress_barr);
currencyRefresh = (Button) rootView.findViewById(R.id.currencyRefresh); currencyRefresh = (Button) rootView.findViewById(R.id.currencyRefresh);
noInternetConnection = (TextView) rootView.findViewById(R.id.noInternetConnectionText); noInternetConnection = (TextView) rootView.findViewById(R.id.noInternetConnectionText);
adapter = CurrencyManager.getCurrencyAddapterIfReady(); settings = getActivity().getSharedPreferences(MainActivity.PREFS_NAME, 0);
tryAndSetAdapter(); new ListInitiatorTask().execute();
currencyRefresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter = CurrencyManager.getCurrencyAddapterIfReady();
tryAndSetAdapter();
}
});
currencyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Integer pos = new Integer(position);
if (!adapter.scaledItemsIDs.contains(pos)) {
if (!adapter.isTextSizeAcceptable((TextView) view.findViewById(R.id.currency_item_text))) {
adapter.scaledItemsIDs.add(pos);
Log.e(TAG, "Unaccepted textView size!");
}
}
adapter.notifyDataSetChanged();
adapter.setSelectedIndex(position);
currencyItemText = (TextView) view.findViewById(R.id.currency_item_text);
final String selectedCurrency = currencyItemText.getText().toString();
SharedPreferences settings = getActivity().getSharedPreferences(MainActivity.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(CURRENT_CURRENCY, selectedCurrency.substring(0, 3));
editor.putInt(POSITION, position);
editor.commit();
}
});
return rootView; return rootView;
} }
@ -110,11 +84,54 @@ public class FragmentCurrency extends Fragment {
currencyList.setAdapter(adapter); currencyList.setAdapter(adapter);
currencyRefresh.setVisibility(View.GONE); currencyRefresh.setVisibility(View.GONE);
noInternetConnection.setVisibility(View.GONE); noInternetConnection.setVisibility(View.GONE);
currencyProgressBar.setVisibility(View.GONE);
} else { } else {
((BreadWalletApp) app.getApplicationContext()).showCustomToast(getActivity(), ((BreadWalletApp) app.getApplicationContext()).showCustomToast(getActivity(),
getResources().getString(R.string.no_internet_connection), 500, Toast.LENGTH_SHORT); getResources().getString(R.string.no_internet_connection), 500, Toast.LENGTH_SHORT);
currencyRefresh.setVisibility(View.VISIBLE); currencyRefresh.setVisibility(View.VISIBLE);
noInternetConnection.setVisibility(View.VISIBLE); noInternetConnection.setVisibility(View.VISIBLE);
currencyProgressBar.setVisibility(View.GONE);
}
}
private class ListInitiatorTask extends AsyncTask {
@Override
protected Object doInBackground(Object[] params) {
try {
Thread.sleep(400);
} catch (InterruptedException e) {
e.printStackTrace();
}
adapter = CurrencyManager.getCurrencyAddapterIfReady();
return null;
}
@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
tryAndSetAdapter();
currencyRefresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter = CurrencyManager.getCurrencyAddapterIfReady();
tryAndSetAdapter();
}
});
currencyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
adapter.notifyDataSetChanged();
currencyItemText = (TextView) view.findViewById(R.id.currency_item_text);
final String selectedCurrency = currencyItemText.getText().toString();
SharedPreferences.Editor editor = settings.edit();
editor.putString(CURRENT_CURRENCY, selectedCurrency.substring(0, 3));
editor.putInt(POSITION, position);
editor.commit();
}
});
} }
} }
} }

2
app/src/main/java/com/breadwallet/presenter/fragments/allsettings/settings/FragmentRecoveryPhrase.java → app/src/main/java/com/breadwallet/presenter/fragments/FragmentRecoveryPhrase.java

@ -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;

225
app/src/main/java/com/breadwallet/presenter/fragments/FragmentScanResult.java

@ -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;
}
}
}

3
app/src/main/java/com/breadwallet/presenter/fragments/allsettings/FragmentSettings.java → app/src/main/java/com/breadwallet/presenter/fragments/FragmentSettings.java

@ -1,5 +1,5 @@
package com.breadwallet.presenter.fragments.allsettings; package com.breadwallet.presenter.fragments;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -15,7 +15,6 @@ import android.widget.TextView;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.presenter.activities.MainActivity; import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentCurrency;
import com.breadwallet.tools.animation.FragmentAnimator; import com.breadwallet.tools.animation.FragmentAnimator;
/** /**

2
app/src/main/java/com/breadwallet/presenter/fragments/allsettings/settings/FragmentWipeWallet.java → app/src/main/java/com/breadwallet/presenter/fragments/FragmentWipeWallet.java

@ -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;

22
app/src/main/java/com/breadwallet/presenter/fragments/MainFragment.java

@ -16,7 +16,6 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.tools.adapter.CustomPagerAdapter;
import com.breadwallet.tools.animation.FragmentAnimator; import com.breadwallet.tools.animation.FragmentAnimator;
import com.breadwallet.tools.others.MyClipboardManager; import com.breadwallet.tools.others.MyClipboardManager;
@ -50,8 +49,7 @@ public class MainFragment extends Fragment {
private Button scanQRButton; private Button scanQRButton;
private Button payAddressFromClipboardButton; private Button payAddressFromClipboardButton;
public EditText addressEditText; public EditText addressEditText;
AlertDialog alertDialog; private AlertDialog alertDialog;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -74,7 +72,6 @@ public class MainFragment extends Fragment {
if (FragmentAnimator.multiplePressingAvailable) { if (FragmentAnimator.multiplePressingAvailable) {
FragmentAnimator.pauseTheAnimationAvailabilityFor(300); FragmentAnimator.pauseTheAnimationAvailabilityFor(300);
FragmentAnimator.animateDecoderFragment(); FragmentAnimator.animateDecoderFragment();
CustomPagerAdapter.adapter.showFragments(false);
} }
} }
}); });
@ -89,6 +86,7 @@ public class MainFragment extends Fragment {
alertDialog.dismiss(); alertDialog.dismiss();
} }
String address = MyClipboardManager.readFromClipboard(getActivity()); String address = MyClipboardManager.readFromClipboard(getActivity());
Log.e(TAG, "The address before check: " + address);
if (checkIfAddressIsValid(address)) { if (checkIfAddressIsValid(address)) {
payAddressFromClipboardButton.setBackgroundResource(R.drawable.buttonbluepressed); payAddressFromClipboardButton.setBackgroundResource(R.drawable.buttonbluepressed);
addressEditText.setText(address); addressEditText.setText(address);
@ -98,6 +96,22 @@ public class MainFragment extends Fragment {
payAddressFromClipboardButton.setBackgroundResource(R.drawable.buttonblue); payAddressFromClipboardButton.setBackgroundResource(R.drawable.buttonblue);
} }
}, 50); }, 50);
if (MainFragmentDecoder.accessGranted) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
MainFragmentDecoder.accessGranted = true;
}
}, 300);
MainFragmentDecoder.accessGranted = false;
Log.e(TAG, "The address: " + address);
if (address != null) {
FragmentScanResult.address = address;
FragmentAnimator.animateScanResultFragment();
} else {
throw new NullPointerException();
}
}
} else { } else {
alertDialog.setTitle(getResources().getString(R.string.alert)); alertDialog.setTitle(getResources().getString(R.string.alert));

54
app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentDecoder.java

@ -1,7 +1,6 @@
package com.breadwallet.presenter.fragments; package com.breadwallet.presenter.fragments;
import android.content.Intent;
import android.graphics.PointF; import android.graphics.PointF;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -15,27 +14,26 @@ import android.widget.RelativeLayout;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.presenter.activities.MainActivity; import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.presenter.activities.ScanResultActivity;
import com.breadwallet.tools.animation.FragmentAnimator; import com.breadwallet.tools.animation.FragmentAnimator;
import com.breadwallet.tools.animation.SpringAnimator; import com.breadwallet.tools.animation.SpringAnimator;
import com.breadwallet.tools.qrcode.QRCodeReaderView; import com.breadwallet.tools.qrcode.QRCodeReaderView;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 7/14/15. * Created by Mihail on 7/14/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -49,11 +47,9 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
public static final String TAG = "MainFragmentDecoder"; public static final String TAG = "MainFragmentDecoder";
private boolean accessGranted = true; public static boolean accessGranted = true;
public static QRCodeReaderView mydecoderview; public static QRCodeReaderView mydecoderview;
private ImageView camera_guide_image; private ImageView camera_guide_image;
private Intent intent;
private static boolean addViewAllowed;
public static MainFragmentDecoder mainFragmentDecoder; public static MainFragmentDecoder mainFragmentDecoder;
private RelativeLayout layout; private RelativeLayout layout;
@ -67,7 +63,6 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
View rootView = inflater.inflate(R.layout.fragment_decoder, container, false); View rootView = inflater.inflate(R.layout.fragment_decoder, container, false);
intent = new Intent(getActivity(), ScanResultActivity.class);
camera_guide_image = (ImageView) rootView.findViewById(R.id.camera_guide_image); camera_guide_image = (ImageView) rootView.findViewById(R.id.camera_guide_image);
SpringAnimator.showExpandCameraGuide(camera_guide_image); SpringAnimator.showExpandCameraGuide(camera_guide_image);
@ -79,8 +74,7 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
layout = (RelativeLayout) getView().findViewById(R.id.fragment_decoder_layout); layout = (RelativeLayout) getView().findViewById(R.id.fragment_decoder_layout);
// mydecoderview = new QRCodeReaderView(getActivity().getApplicationContext()); Log.e(TAG, "The layout is: " + layout);
// mydecoderview.setOnQRCodeReadListener(mainFragmentDecoder);
} }
@ -101,15 +95,15 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
} }
}, 300); }, 300);
accessGranted = false; accessGranted = false;
intent.putExtra("result", text); if (text != null) {
startActivity(intent); FragmentScanResult.address = text;
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FragmentAnimator.hideDecoderFragment(); FragmentAnimator.hideDecoderFragment();
FragmentAnimator.animateScanResultFragment();
} else {
throw new NullPointerException();
} }
}, 1000); }
} }
} }
@ -128,36 +122,35 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
addViewAllowed = true; Log.e(TAG, "In the onResume()");
// addViewAllowed = true;
startQRScanner(); startQRScanner();
MainActivity.app.activityButtonsEnable(false);
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
addViewAllowed = false; Log.e(TAG, "In the onPause()");
// addViewAllowed = false;
stopQRScanner(); stopQRScanner();
} }
private void startQRScanner() { private void startQRScanner() {
MainActivity.app.activityButtonsEnable(false);
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (mydecoderview == null) { if (mydecoderview == null) {
mydecoderview = new QRCodeReaderView(MainActivity.app); mydecoderview = new QRCodeReaderView(MainActivity.app);
mydecoderview.setOnQRCodeReadListener(mainFragmentDecoder);
mydecoderview.getCameraManager().startPreview();
} }
mydecoderview.setOnQRCodeReadListener(mainFragmentDecoder);
mydecoderview.getCameraManager().startPreview();
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (addViewAllowed) { layout.addView(mydecoderview, 0);
addViewAllowed = false;
layout.addView(mydecoderview, 0);
}
} }
}, 800); }, 800);
@ -172,7 +165,8 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
@Override @Override
public void run() { public void run() {
layout.removeView(mydecoderview); layout.removeView(mydecoderview);
mydecoderview.getCameraManager().stopPreview(); if (mydecoderview.getCameraManager().isOpen())
mydecoderview.getCameraManager().stopPreview();
} }
}); });
mydecoderview = null; mydecoderview = null;
@ -181,7 +175,7 @@ public class MainFragmentDecoder extends Fragment implements QRCodeReaderView.On
public void run() { public void run() {
MainActivity.app.activityButtonsEnable(true); MainActivity.app.activityButtonsEnable(true);
} }
},300); }, 300);
} }

54
app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentQR.java

@ -4,6 +4,7 @@ package com.breadwallet.presenter.fragments;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.util.Log; import android.util.Log;
@ -26,6 +27,10 @@ import com.breadwallet.tools.qrcode.QRCodeEncoder;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/** /**
* BreadWallet * BreadWallet
* <p/> * <p/>
@ -57,10 +62,13 @@ public class MainFragmentQR extends Fragment {
private static final String TEST_ADDRESS = "mhBmRiqosSHR9YnPTKc3xXcvhEcKtjet2p"; private static final String TEST_ADDRESS = "mhBmRiqosSHR9YnPTKc3xXcvhEcKtjet2p";
private TextView mainAddressText; private TextView mainAddressText;
private RelativeLayout addressLayout; private RelativeLayout addressLayout;
private Bitmap bitmap; public Bitmap bitmap;
public SharingFragment sharingFragment; public SharingFragment sharingFragment;
public FragmentManager fm; public FragmentManager fm;
private int count; private int count;
private int firstToastY = -1;
private int secondToastY = -1;
public static File qrCodeImageFile;
@Override @Override
public View onCreateView(LayoutInflater inflater, public View onCreateView(LayoutInflater inflater,
@ -68,19 +76,21 @@ public class MainFragmentQR extends Fragment {
// The last two arguments ensure LayoutParams are inflated // The last two arguments ensure LayoutParams are inflated
// properly. // properly.
final View rootView = inflater.inflate( final View rootView = inflater.inflate(
R.layout.fragmentqr_main, container, false); R.layout.fragment_qr_main, container, false);
qrcode = (ImageView) rootView.findViewById(R.id.mainimageqrcode); qrcode = (ImageView) rootView.findViewById(R.id.mainimageqrcode);
sharingFragment = new SharingFragment(); sharingFragment = new SharingFragment();
generateQR(); generateQR();
mainAddressText = (TextView) rootView.findViewById(R.id.mainaddresstext); mainAddressText = (TextView) rootView.findViewById(R.id.mainaddresstext);
addressLayout = (RelativeLayout) rootView.findViewById(R.id.theAddressLayout); addressLayout = (RelativeLayout) rootView.findViewById(R.id.theAddressLayout);
fm = getActivity().getSupportFragmentManager(); fm = getActivity().getSupportFragmentManager();
final BreadWalletApp breadWalletApp = (BreadWalletApp) MainActivity.app.getApplication();
addressLayout.setOnClickListener(new View.OnClickListener() { addressLayout.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (FragmentAnimator.multiplePressingAvailable) { if (FragmentAnimator.multiplePressingAvailable) {
FragmentAnimator.pauseTheAnimationAvailabilityFor(300); FragmentAnimator.pauseTheAnimationAvailabilityFor(300);
sharingFragment.setTheAddress(mainAddressText.getText().toString()); sharingFragment.setTheAddress(mainAddressText.getText().toString());
saveBitmapToFile();
sharingFragment.show(fm, "sharingFragment"); sharingFragment.show(fm, "sharingFragment");
} }
} }
@ -89,13 +99,18 @@ public class MainFragmentQR extends Fragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (count == 0) { if (count == 0) {
((BreadWalletApp) getActivity().getApplication()).showCustomToast(MainActivity.app, if (firstToastY == -1)
getResources().getString(R.string.toast_qr_tip), 460, Toast.LENGTH_LONG); firstToastY = BreadWalletApp.DISPLAY_HEIGHT_PX - breadWalletApp.getRelativeTop(mainAddressText) + 400;
breadWalletApp.showCustomToast(MainActivity.app,
getResources().getString(R.string.toast_qr_tip), firstToastY, Toast.LENGTH_LONG);
Log.e(TAG, "Toast show nr: " + count); Log.e(TAG, "Toast show nr: " + count);
count++; count++;
} else if (count == 1) { } else if (count == 1) {
((BreadWalletApp) getActivity().getApplication()).showCustomToast(MainActivity.app, if (secondToastY == -1)
getResources().getString(R.string.toast_address_tip), 140, Toast.LENGTH_LONG); secondToastY = BreadWalletApp.DISPLAY_HEIGHT_PX - breadWalletApp.getRelativeTop(mainAddressText);
breadWalletApp.showCustomToast(MainActivity.app,
getResources().getString(R.string.toast_address_tip),
secondToastY, Toast.LENGTH_LONG);
Log.e(TAG, "Toast show nr: " + count); Log.e(TAG, "Toast show nr: " + count);
count--; count--;
} }
@ -128,4 +143,31 @@ public class MainFragmentQR extends Fragment {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void saveBitmapToFile() {
FileOutputStream out = null;
String path = Environment.getExternalStorageDirectory().toString();
qrCodeImageFile = new File(path, "qrImage" + ".jpeg");
if (qrCodeImageFile.exists()) {
Log.d(TAG, "File exists! deleting");
qrCodeImageFile.delete();
} else {
Log.d(TAG, "File did not exist, creating a new one");
}
try {
out = new FileOutputStream(qrCodeImageFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); // bmp is your Bitmap instance
// PNG is a lossless format, the compression factor (100) is ignored
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }

22
app/src/main/java/com/breadwallet/presenter/fragments/SharingFragment.java

@ -2,20 +2,20 @@ package com.breadwallet.presenter.fragments;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 7/24/15. * Created by Mihail on 7/24/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -30,6 +30,7 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -42,6 +43,7 @@ import com.breadwallet.tools.others.MyClipboardManager;
public class SharingFragment extends DialogFragment { public class SharingFragment extends DialogFragment {
public static final String TAG = "SharingFragment";
private TextView copyAddress; private TextView copyAddress;
private TextView sendEmail; private TextView sendEmail;
private TextView sendMessage; private TextView sendMessage;
@ -87,9 +89,12 @@ public class SharingFragment extends DialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "abc@gmail.com", null)); "mailto", "", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.bitcoin_address)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.bitcoin_address));
emailIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.sharing_message) + theAddress); emailIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.sharing_message) + " " + theAddress);
Uri uri = Uri.parse("file://" + MainFragmentQR.qrCodeImageFile.getAbsolutePath());
Log.e(TAG, "The qrCodeImageFile.getAbsolutePath(): " + MainFragmentQR.qrCodeImageFile.getAbsolutePath());
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.dialog_email_title))); startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.dialog_email_title)));
getDialog().cancel(); getDialog().cancel();
} }
@ -100,7 +105,7 @@ public class SharingFragment extends DialogFragment {
public void onClick(View v) { public void onClick(View v) {
Intent sendIntent = new Intent(Intent.ACTION_VIEW); Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:")); sendIntent.setData(Uri.parse("sms:"));
sendIntent.putExtra("sms_body", getResources().getString(R.string.sharing_message) + theAddress); sendIntent.putExtra("sms_body", getResources().getString(R.string.sharing_message) + " " + theAddress);
startActivity(sendIntent); startActivity(sendIntent);
getDialog().cancel(); getDialog().cancel();
} }
@ -119,4 +124,5 @@ public class SharingFragment extends DialogFragment {
public void setTheAddress(String address) { public void setTheAddress(String address) {
theAddress = address; theAddress = address;
} }
} }

27
app/src/main/java/com/breadwallet/tools/adapter/CurrencyListAdapter.java

@ -4,7 +4,6 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Point; import android.graphics.Point;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -15,7 +14,7 @@ import android.widget.TextView;
import com.breadwallet.R; import com.breadwallet.R;
import com.breadwallet.presenter.activities.MainActivity; import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.presenter.fragments.allsettings.settings.FragmentCurrency; import com.breadwallet.presenter.fragments.FragmentCurrency;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -50,7 +49,6 @@ public class CurrencyListAdapter extends ArrayAdapter<String> {
Context mContext; Context mContext;
int layoutResourceId; int layoutResourceId;
public int selectedIndex = -1;
public TextView textViewItem; public TextView textViewItem;
public Point displayParameters = new Point(); public Point displayParameters = new Point();
public List<Integer> scaledItemsIDs = new ArrayList<>(); public List<Integer> scaledItemsIDs = new ArrayList<>();
@ -67,12 +65,6 @@ public class CurrencyListAdapter extends ArrayAdapter<String> {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
/*
* The convertView argument is essentially a "ScrapView" as described is Lucas post
* http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/
* It will have a non-null value when ListView is asking you recycle the row layout.
* So, when convertView is not null, you should simply update its contents instead of inflating a new row layout.
*/
SharedPreferences settings = MainActivity.app.getSharedPreferences(MainActivity.PREFS_NAME, 0); SharedPreferences settings = MainActivity.app.getSharedPreferences(MainActivity.PREFS_NAME, 0);
final int tmp = settings.getInt(FragmentCurrency.POSITION, 0); final int tmp = settings.getInt(FragmentCurrency.POSITION, 0);
if (convertView == null) { if (convertView == null) {
@ -86,21 +78,12 @@ public class CurrencyListAdapter extends ArrayAdapter<String> {
textViewItem.setText(this.getItem(position)); textViewItem.setText(this.getItem(position));
ImageView checkMark = (ImageView) convertView.findViewById(R.id.currency_checkmark); ImageView checkMark = (ImageView) convertView.findViewById(R.id.currency_checkmark);
if (selectedIndex >= 0) { if (position == tmp) {
if (selectedIndex == position) {
checkMark.setVisibility(View.VISIBLE);
} else {
checkMark.setVisibility(View.GONE);
}
} else if (position == tmp) {
checkMark.setVisibility(View.VISIBLE); checkMark.setVisibility(View.VISIBLE);
} else { } else {
checkMark.setVisibility(View.GONE); checkMark.setVisibility(View.GONE);
} }
if (scaledItemsIDs.contains(new Integer(position))) { normalizeTextView();
normalizeTextView();
Log.w(TAG, "The list contains the item and is being normalized!");
}
return convertView; return convertView;
@ -111,10 +94,6 @@ public class CurrencyListAdapter extends ArrayAdapter<String> {
return IGNORE_ITEM_VIEW_TYPE; return IGNORE_ITEM_VIEW_TYPE;
} }
public void setSelectedIndex(int index) {
selectedIndex = index;
}
public boolean isTextSizeAcceptable(TextView textView) { public boolean isTextSizeAcceptable(TextView textView) {
textView.measure(0, 0); textView.measure(0, 0);
int textWidth = textView.getMeasuredWidth(); int textWidth = textView.getMeasuredWidth();

13
app/src/main/java/com/breadwallet/tools/adapter/CustomPagerAdapter.java

@ -4,8 +4,10 @@ import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;
import android.view.View; import android.view.View;
import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.presenter.fragments.MainFragment; import com.breadwallet.presenter.fragments.MainFragment;
import com.breadwallet.presenter.fragments.MainFragmentQR; import com.breadwallet.presenter.fragments.MainFragmentQR;
@ -14,20 +16,20 @@ import java.util.List;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 5/23/15. * Created by Mihail on 5/23/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -74,6 +76,7 @@ public class CustomPagerAdapter extends FragmentPagerAdapter {
* @param b parameter that specifies to show or to hide the fragments * @param b parameter that specifies to show or to hide the fragments
*/ */
public void showFragments(boolean b) { public void showFragments(boolean b) {
Log.w(TAG, "Warning showFragments called with variable: " + b);
if (main == null) main = mainFragment.getView(); if (main == null) main = mainFragment.getView();
if (mainQR == null) mainQR = mainFragmentQR.getView(); if (mainQR == null) mainQR = mainFragmentQR.getView();
if (b) { if (b) {
@ -83,6 +86,7 @@ public class CustomPagerAdapter extends FragmentPagerAdapter {
public void run() { public void run() {
main.setVisibility(View.VISIBLE); main.setVisibility(View.VISIBLE);
mainQR.setVisibility(View.VISIBLE); mainQR.setVisibility(View.VISIBLE);
MainActivity.pageIndicator.setVisibility(View.VISIBLE);
} }
}, 200); }, 200);
@ -93,6 +97,7 @@ public class CustomPagerAdapter extends FragmentPagerAdapter {
public void run() { public void run() {
main.setVisibility(View.GONE); main.setVisibility(View.GONE);
mainQR.setVisibility(View.GONE); mainQR.setVisibility(View.GONE);
MainActivity.pageIndicator.setVisibility(View.GONE);
} }
}, 200); }, 200);

126
app/src/main/java/com/breadwallet/tools/animation/AmountAdapter.java

@ -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!!!!");
}
}

65
app/src/main/java/com/breadwallet/tools/animation/FragmentAnimator.java

@ -16,20 +16,20 @@ import java.util.Stack;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 7/13/15. * Created by Mihail on 7/13/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -50,15 +50,41 @@ public class FragmentAnimator {
public static Object lockObject = new Object(); public static Object lockObject = new Object();
public static void animateDecoderFragment() { public static void animateDecoderFragment() {
MainActivity.beenThroughSavedInstanceMethod = false;
MainActivity.app.decoderFragmentOn = true; MainActivity.app.decoderFragmentOn = true;
//Disabled inspection: <Expected resource type anim> //Disabled inspection: <Expected resource type anim>
FragmentTransaction fragmentTransaction = MainActivity.app.getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = MainActivity.app.getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_top); fragmentTransaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_top);
fragmentTransaction.replace(R.id.mainlayout, MainActivity.app.mainFragmentDecoder); fragmentTransaction.replace(R.id.mainlayout, MainActivity.app.mainFragmentDecoder);
int temp = fragmentTransaction.commitAllowingStateLoss(); int temp = fragmentTransaction.commitAllowingStateLoss();
CustomPagerAdapter.adapter.showFragments(false);
Log.e(TAG, String.valueOf(temp)); Log.e(TAG, String.valueOf(temp));
} }
public static void animateScanResultFragment() {
Log.e(TAG, "animateScanResultFragment");
MainActivity.beenThroughSavedInstanceMethod = false;
MainActivity.app.scanResultFragmentOn = true;
InputMethodManager keyboard = (InputMethodManager) MainActivity.app.
getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.hideSoftInputFromWindow(CustomPagerAdapter.adapter.
mainFragment.addressEditText.getWindowToken(), 0);
MainActivity.app.setBurgerButtonImage(MainActivity.app.BACK);
//Disabled inspection: <Expected resource type anim>
FragmentTransaction fragmentTransaction = MainActivity.app.getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.animator.from_right, R.animator.to_left);
fragmentTransaction.replace(R.id.mainlayout, MainActivity.app.fragmentScanResult);
int temp = fragmentTransaction.commitAllowingStateLoss();
CustomPagerAdapter.adapter.showFragments(false);
Log.e(TAG, String.valueOf(temp));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
SpringAnimator.showBouncySlide(MainActivity.app.fragmentScanResult.getView(), SpringAnimator.TO_RIGHT, 70);
}
}, 200);
}
/** /**
* Animate the transition on burgerButton/MenuButton pressed * Animate the transition on burgerButton/MenuButton pressed
*/ */
@ -69,7 +95,7 @@ public class FragmentAnimator {
level++; level++;
MainActivity.app.setBurgerButtonImage(context.CLOSE); MainActivity.app.setBurgerButtonImage(context.CLOSE);
FragmentTransaction fragmentTransaction = context.getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = context.getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.animator.from_bottom, R.animator.from_bottom); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.from_top);
fragmentTransaction.replace(R.id.mainlayout, context.mainFragmentSettingsAll); fragmentTransaction.replace(R.id.mainlayout, context.mainFragmentSettingsAll);
fragmentTransaction.commit(); fragmentTransaction.commit();
CustomPagerAdapter.adapter.showFragments(false); CustomPagerAdapter.adapter.showFragments(false);
@ -81,7 +107,7 @@ public class FragmentAnimator {
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
SpringAnimator.showBouncySlideVertical(to.getView(), SpringAnimator.TO_RIGHT); SpringAnimator.showBouncySlideVertical(to.getView(), SpringAnimator.TO_LEFT);
} }
}, 200); }, 200);
@ -90,7 +116,7 @@ public class FragmentAnimator {
settingsAllON = false; settingsAllON = false;
MainActivity.app.setBurgerButtonImage(context.BURGER); MainActivity.app.setBurgerButtonImage(context.BURGER);
FragmentTransaction fragmentTransaction = context.getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = context.getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.animator.to_bottom, R.animator.to_bottom); fragmentTransaction.setCustomAnimations(R.animator.to_top, R.animator.to_top);
fragmentTransaction.remove(context.mainFragmentSettingsAll); fragmentTransaction.remove(context.mainFragmentSettingsAll);
fragmentTransaction.commit(); fragmentTransaction.commit();
CustomPagerAdapter.adapter.showFragments(true); CustomPagerAdapter.adapter.showFragments(true);
@ -200,10 +226,29 @@ public class FragmentAnimator {
FragmentAnimator.multiplePressingAvailable = true; FragmentAnimator.multiplePressingAvailable = true;
} }
}, 300); }, 300);
MainActivity.app.getSupportFragmentManager().beginTransaction(). if (!MainActivity.beenThroughSavedInstanceMethod)
setCustomAnimations(R.animator.from_top, R.animator.to_bottom). MainActivity.app.getSupportFragmentManager().beginTransaction().
remove(MainActivity.app.mainFragmentDecoder).commit(); setCustomAnimations(R.animator.from_top, R.animator.to_bottom).
remove(MainActivity.app.mainFragmentDecoder).commit();
CustomPagerAdapter.adapter.showFragments(true);
}
public static void hideScanResultFragment() {
Log.e(TAG, "hideScanResultFragment");
CustomPagerAdapter.adapter.showFragments(true);
MainActivity.app.scanResultFragmentOn = false;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FragmentAnimator.multiplePressingAvailable = true;
}
}, 300);
if (!MainActivity.beenThroughSavedInstanceMethod)
MainActivity.app.getSupportFragmentManager().beginTransaction().
setCustomAnimations(R.animator.from_left, R.animator.to_right).
remove(MainActivity.app.fragmentScanResult).commit();
MainActivity.app.setBurgerButtonImage(MainActivity.app.BURGER);
} }
} }

10
app/src/main/java/com/breadwallet/tools/others/CurrencyManager.java

@ -22,20 +22,20 @@ import java.util.TimerTask;
/** /**
* BreadWallet * BreadWallet
* * <p/>
* Created by Mihail on 7/22/15. * Created by Mihail on 7/22/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
* * <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* * <p/>
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* * <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -80,6 +80,8 @@ public class CurrencyManager {
} else { } else {
if (list == null) list = new ArrayList<>(); if (list == null) list = new ArrayList<>();
} }
if (list.size() > 0)
list.add("TES - testing text extra long text mega long text oh my god that's a long text");
return list; return list;
} }

32
app/src/main/java/com/breadwallet/tools/others/TypefaceUtil.java

@ -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);
}
}
}

BIN
app/src/main/res/drawable/backgroundmain_cropped.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
app/src/main/res/drawable/bitcoin_lowercase.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

BIN
app/src/main/res/drawable/deletetoleft.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

42
app/src/main/res/layouts/activities/layout/activity_scan_result.xml

@ -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>

24
app/src/main/res/layouts/fragments/layout/fragment_local_currency.xml

@ -15,21 +15,33 @@
android:layout_height="wrap_content"></ListView> android:layout_height="wrap_content"></ListView>
<TextView <TextView
android:id="@+id/noInternetConnectionText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="No Internet Connection"
android:id="@+id/noInternetConnectionText"
android:textColor="@color/dark_grey"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="136dp" /> android:layout_marginTop="136dp"
android:text="No Internet Connection"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/grey"
android:visibility="gone" />
<Button <Button
android:id="@+id/currencyRefresh"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@color/white"
android:text="Refresh" android:text="Refresh"
android:id="@+id/currencyRefresh" android:textColor="@color/blue"
android:visibility="gone" />
<ProgressBar
android:id="@+id/currency_progress_barr"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />

2
app/src/main/res/layouts/fragments/layout/fragmentqr_main.xml → app/src/main/res/layouts/fragments/layout/fragment_qr_main.xml

@ -27,7 +27,7 @@
android:id="@+id/theAddressLayout" android:id="@+id/theAddressLayout"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="80dp"
android:layout_below="@+id/mainimageqrcode" android:layout_below="@+id/mainimageqrcode"
android:orientation="vertical"> android:orientation="vertical">

76
app/src/main/res/layouts/fragments/layout/fragment_scan_result.xml

@ -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="&#9250;"
android:layout_alignBottom="@+id/imageView"
android:layout_toStartOf="@+id/imageView" />
</RelativeLayout>

2
app/src/main/res/layouts/layout/currency_list_item.xml

@ -17,7 +17,7 @@
android:text="" android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/grey" android:textColor="@color/grey"
android:textSize="20sp" /> android:textSize="16sp" />
<ImageView <ImageView
android:id="@+id/currency_checkmark" android:id="@+id/currency_checkmark"

9
app/src/main/res/values/strings.xml

@ -41,17 +41,18 @@
<string name="mainactivity_press_back_again">Press again to exit!</string> <string name="mainactivity_press_back_again">Press again to exit!</string>
<string name="no_internet_connection">No internet connection</string> <string name="no_internet_connection">No internet connection</string>
<string name="warning">WARNING</string> <string name="warning">WARNING</string>
<string name="dialog_do_not_let_anyone">DO NOT let anyone see your recovery phrase or they can spend your bitcoins.\n\n" + <string name="dialog_do_not_let_anyone">DO NOT let anyone see your recovery phrase or they can spend your bitcoins.\n\n
"NEVER type your recovery phrase into password managers or elsewhere.\n" + NEVER type your recovery phrase into password managers or elsewhere.\nOther devices may be infected.\n\nDO NOT take a screenshot.\nScreenshots are visible to other apps and devices.</string>
"Other devices may be infected.\n\nDO NOT take a screenshot.\nScreenshots are visible to other apps and devices.</string>
<string name="show">show</string> <string name="show">show</string>
<string name="cancel">cancel</string> <string name="cancel">cancel</string>
<string name="alert">Alert</string> <string name="alert">Alert</string>
<string name="mainfragment_clipboard_invalid_data">"clipboard doesn't contain a valid bitcoin address"</string> <string name="mainfragment_clipboard_invalid_data">"clipboard doesn't contain a valid bitcoin address\n"</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="sharing_message">Hi, here is my bitcoin address: </string> <string name="sharing_message">Hi, here is my bitcoin address: </string>
<string name="dialog_receive_bitcoins">Receive bitcoins</string> <string name="dialog_receive_bitcoins">Receive bitcoins</string>
<string name="toast_address_copied">Address copied to clipboard</string> <string name="toast_address_copied">Address copied to clipboard</string>
<string name="dialog_email_title">Send your bitcoin address</string> <string name="dialog_email_title">Send your bitcoin address</string>
<string name="bitcoin_address">"Bitcoin Address"</string> <string name="bitcoin_address">"Bitcoin Address"</string>
<string name="crash_toast_text">Crashed! Report sent to the developer\'s email.</string>
<string name="bitcoin_lower_unicode">&#384;</string>
</resources> </resources>

Loading…
Cancel
Save