From 06984192594ce24456e982ddc476cba7f85c7e47 Mon Sep 17 00:00:00 2001 From: Jonathan Raes Date: Fri, 9 Jun 2017 10:41:25 +0200 Subject: [PATCH 1/9] check network state --- app/src/main/AndroidManifest.xml | 2 +- .../blockchain/ProgressTracker.java | 9 +++ .../digitalvotingpass/SplashActivity.java | 17 ++++- .../com/digitalvotingpass/utilities/Util.java | 10 +++ .../res/layout/activity_splash_screen.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../ElectionChoiceActivityTest.java | 68 +++++++++++++++++++ .../electionchoice/ElectionTest.java | 44 ++++++++++++ 8 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java create mode 100644 app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9929ec3..49eaf33 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,8 +8,8 @@ - + diff --git a/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java b/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java index 907cc70..971b9f5 100644 --- a/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java +++ b/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java @@ -1,5 +1,8 @@ package com.digitalvotingpass.blockchain; +import android.util.Log; + +import org.bitcoinj.core.Peer; import org.bitcoinj.core.listeners.DownloadProgressTracker; import java.util.Date; @@ -17,6 +20,12 @@ protected void progress(double pct, int blocksSoFar, Date date) { listener.onDownloadProgress(pct, blocksSoFar, date); } + @Override + public void await() throws InterruptedException { + super.await(); + Log.e("Waiting", "await"); + } + @Override protected void startDownload(int blocks) { super.startDownload(blocks); diff --git a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java index 07b984d..ad23f81 100644 --- a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java +++ b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java @@ -8,16 +8,20 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; +import android.os.HandlerThread; import android.support.annotation.NonNull; +import android.support.design.widget.Snackbar; import android.support.v13.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.widget.ProgressBar; import android.widget.TextView; +import android.widget.Toast; import com.digitalvotingpass.blockchain.BlockChain; import com.digitalvotingpass.blockchain.BlockchainCallBackListener; import com.digitalvotingpass.camera.Camera2BasicFragment; import com.digitalvotingpass.electionchoice.ElectionChoiceActivity; +import com.digitalvotingpass.utilities.Util; import java.text.DecimalFormat; import java.util.Date; @@ -75,14 +79,25 @@ public void onCreate(Bundle savedInstanceState) { downloadProgressBar = (ProgressBar) findViewById(R.id.download_progress_bar); if (savedInstanceState == null) { + HandlerThread thread = new HandlerThread("BlockChainThread"); + thread.start(); blockChain = BlockChain.getInstance(); - handler = new Handler(); + handler = new Handler(thread.getLooper()); initTextHandler = new Handler(); initTextHandler.post(initTextUpdater); handler.post(startBlockChain); } } + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (!Util.isOnline(getApplicationContext())) { + Toast.makeText(getApplicationContext(), "GAYYYYYY", Toast.LENGTH_LONG).show(); + + } + } + @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { diff --git a/app/src/main/java/com/digitalvotingpass/utilities/Util.java b/app/src/main/java/com/digitalvotingpass/utilities/Util.java index 0b743da..e69e3e6 100644 --- a/app/src/main/java/com/digitalvotingpass/utilities/Util.java +++ b/app/src/main/java/com/digitalvotingpass/utilities/Util.java @@ -1,8 +1,11 @@ package com.digitalvotingpass.utilities; import android.app.Activity; +import android.content.Context; import android.content.res.Resources; import android.graphics.Color; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.support.v7.widget.Toolbar; import android.util.Log; @@ -118,4 +121,11 @@ public static String byteArrayToHexString(byte[] bArray) { } return ""; } + + public static boolean isOnline(Context ctx) { + ConnectivityManager cm = + (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo netInfo = cm.getActiveNetworkInfo(); + return netInfo != null && netInfo.isConnectedOrConnecting(); + } } diff --git a/app/src/main/res/layout/activity_splash_screen.xml b/app/src/main/res/layout/activity_splash_screen.xml index 21e8224..292d716 100644 --- a/app/src/main/res/layout/activity_splash_screen.xml +++ b/app/src/main/res/layout/activity_splash_screen.xml @@ -1,4 +1,5 @@ com.digitalvotingpass.ELECTION_OBJECT_KEY com.digitalvotingpass.shared + Please enable network connection January February diff --git a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java new file mode 100644 index 0000000..f94f05c --- /dev/null +++ b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java @@ -0,0 +1,68 @@ +package com.digitalvotingpass.electionchoice; + +import android.content.Context; + +import org.bitcoinj.core.Asset; +import org.bitcoinj.core.Sha256Hash; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; + +/** + * Created by wkmeijer on 7-6-17. + */ +public class ElectionChoiceActivityTest { + private ElectionChoiceActivity activity; + private Sha256Hash mockHash = new Sha256Hash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + + @Mock + Context mMockContext; + + @Before + public void initTests() { + activity = new ElectionChoiceActivity(); + } + + + @Test + public void testLoadElectionsEmpty() throws Exception { + ArrayList assetList = new ArrayList<>(); + ArrayList expected = new ArrayList<>(); + + assertEquals(expected, activity.loadElections(assetList)); + } + + @Test + public void testLoadElectionsSingleInput() throws Exception { + ArrayList assetList = new ArrayList<>(); + Asset asset1 = new Asset("votingpass", mockHash); + assetList.add(asset1); + ArrayList expected = new ArrayList<>(); + expected.add(new Election("", "votingpass", asset1)); + + assertEquals(expected, activity.loadElections(assetList)); + } + + @Test + public void testLoadElectionsMultipleInputs() throws Exception { + ArrayList assetList = new ArrayList<>(); + Asset asset1 = new Asset("votingpass", mockHash); + Asset asset2 = new Asset("votingpass1", mockHash); + Asset asset3 = new Asset("votingpass2", mockHash); + assetList.add(asset1); + assetList.add(asset2); + assetList.add(asset3); + + ArrayList expected = new ArrayList<>(); + expected.add(new Election("", "votingpass", asset1)); + expected.add(new Election("", "votingpass1", asset2)); + expected.add(new Election("", "votingpass2", asset3)); + + assertEquals(expected, activity.loadElections(assetList)); + } + +} \ No newline at end of file diff --git a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java new file mode 100644 index 0000000..862df51 --- /dev/null +++ b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java @@ -0,0 +1,44 @@ +package com.digitalvotingpass.electionchoice; + +import org.bitcoinj.core.Asset; +import org.bitcoinj.core.Sha256Hash; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Created by wkmeijer on 7-6-17. + */ +public class ElectionTest { + private Sha256Hash mockHash = new Sha256Hash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + + @Test + public void equalsActualEqual() throws Exception { + Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + Election e2 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + assertTrue(e1.equals(e2)); + } + + @Test + public void equalsNonEqualPlace() throws Exception { + Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + Election e2 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + assertTrue(e1.equals(e2)); + } + + @Test + public void equalsNonEqualKind() throws Exception { + Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + Election e2 = new Election("Delft", "Provincial election", new Asset("G_Delft", mockHash)); + assertFalse(e1.equals(e2)); + } + + @Test + public void equalsNonEqualAssetName() throws Exception { + Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); + Election e2 = new Election("Delft", "Municipal election", new Asset("T_Delft", mockHash)); + assertFalse(e1.equals(e2)); + } + +} \ No newline at end of file From aa13e4d38e5e462654f2ba726ee1436b72597564 Mon Sep 17 00:00:00 2001 From: Jonathan Raes Date: Fri, 9 Jun 2017 11:42:37 +0200 Subject: [PATCH 2/9] show no network status and message when no network in splash --- .../digitalvotingpass/SplashActivity.java | 8 +++++--- app/src/main/res/values/strings.xml | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java index ad23f81..41b9764 100644 --- a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java +++ b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java @@ -13,6 +13,7 @@ import android.support.design.widget.Snackbar; import android.support.v13.app.ActivityCompat; import android.support.v4.content.ContextCompat; +import android.util.Log; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -92,9 +93,10 @@ public void onCreate(Bundle savedInstanceState) { @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); - if (!Util.isOnline(getApplicationContext())) { - Toast.makeText(getApplicationContext(), "GAYYYYYY", Toast.LENGTH_LONG).show(); - + if (!Util.isOnline(getApplicationContext()) && hasFocus) { + initTextHandler.removeCallbacks(initTextUpdater); + Toast.makeText(getApplicationContext(), getString(R.string.please_enable_connect_message), Toast.LENGTH_LONG).show(); + currentTask.setText(getString(R.string.no_connection)); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ddd5603..6306b4b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,7 +70,8 @@ com.digitalvotingpass.ELECTION_OBJECT_KEY com.digitalvotingpass.shared - Please enable network connection + Please enable network connection + No Network January February From 07437d3557b1d80165245395e53e9bac7ed3398f Mon Sep 17 00:00:00 2001 From: Jonathan Raes Date: Fri, 9 Jun 2017 11:55:18 +0200 Subject: [PATCH 3/9] clean --- .../blockchain/ProgressTracker.java | 6 -- .../digitalvotingpass/SplashActivity.java | 8 ++- .../ElectionChoiceActivityTest.java | 68 ------------------- .../electionchoice/ElectionTest.java | 44 ------------ 4 files changed, 5 insertions(+), 121 deletions(-) delete mode 100644 app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java delete mode 100644 app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java diff --git a/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java b/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java index 971b9f5..4351673 100644 --- a/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java +++ b/app/src/main/java/com/digitalvotingpass/blockchain/ProgressTracker.java @@ -20,12 +20,6 @@ protected void progress(double pct, int blocksSoFar, Date date) { listener.onDownloadProgress(pct, blocksSoFar, date); } - @Override - public void await() throws InterruptedException { - super.await(); - Log.e("Waiting", "await"); - } - @Override protected void startDownload(int blocks) { super.startDownload(blocks); diff --git a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java index 41b9764..2d31a1e 100644 --- a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java +++ b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java @@ -80,16 +80,18 @@ public void onCreate(Bundle savedInstanceState) { downloadProgressBar = (ProgressBar) findViewById(R.id.download_progress_bar); if (savedInstanceState == null) { - HandlerThread thread = new HandlerThread("BlockChainThread"); - thread.start(); blockChain = BlockChain.getInstance(); - handler = new Handler(thread.getLooper()); + handler = new Handler(); initTextHandler = new Handler(); initTextHandler.post(initTextUpdater); handler.post(startBlockChain); } } + /** + * When the view is focused, check network state and display an error when network is unavailable. + * @param hasFocus + */ @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); diff --git a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java deleted file mode 100644 index f94f05c..0000000 --- a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionChoiceActivityTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.digitalvotingpass.electionchoice; - -import android.content.Context; - -import org.bitcoinj.core.Asset; -import org.bitcoinj.core.Sha256Hash; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - -import java.util.ArrayList; - -import static org.junit.Assert.assertEquals; - -/** - * Created by wkmeijer on 7-6-17. - */ -public class ElectionChoiceActivityTest { - private ElectionChoiceActivity activity; - private Sha256Hash mockHash = new Sha256Hash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - - @Mock - Context mMockContext; - - @Before - public void initTests() { - activity = new ElectionChoiceActivity(); - } - - - @Test - public void testLoadElectionsEmpty() throws Exception { - ArrayList assetList = new ArrayList<>(); - ArrayList expected = new ArrayList<>(); - - assertEquals(expected, activity.loadElections(assetList)); - } - - @Test - public void testLoadElectionsSingleInput() throws Exception { - ArrayList assetList = new ArrayList<>(); - Asset asset1 = new Asset("votingpass", mockHash); - assetList.add(asset1); - ArrayList expected = new ArrayList<>(); - expected.add(new Election("", "votingpass", asset1)); - - assertEquals(expected, activity.loadElections(assetList)); - } - - @Test - public void testLoadElectionsMultipleInputs() throws Exception { - ArrayList assetList = new ArrayList<>(); - Asset asset1 = new Asset("votingpass", mockHash); - Asset asset2 = new Asset("votingpass1", mockHash); - Asset asset3 = new Asset("votingpass2", mockHash); - assetList.add(asset1); - assetList.add(asset2); - assetList.add(asset3); - - ArrayList expected = new ArrayList<>(); - expected.add(new Election("", "votingpass", asset1)); - expected.add(new Election("", "votingpass1", asset2)); - expected.add(new Election("", "votingpass2", asset3)); - - assertEquals(expected, activity.loadElections(assetList)); - } - -} \ No newline at end of file diff --git a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java b/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java deleted file mode 100644 index 862df51..0000000 --- a/app/src/test/java/com/digitalvotingpass/electionchoice/ElectionTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.digitalvotingpass.electionchoice; - -import org.bitcoinj.core.Asset; -import org.bitcoinj.core.Sha256Hash; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Created by wkmeijer on 7-6-17. - */ -public class ElectionTest { - private Sha256Hash mockHash = new Sha256Hash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - - @Test - public void equalsActualEqual() throws Exception { - Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - Election e2 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - assertTrue(e1.equals(e2)); - } - - @Test - public void equalsNonEqualPlace() throws Exception { - Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - Election e2 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - assertTrue(e1.equals(e2)); - } - - @Test - public void equalsNonEqualKind() throws Exception { - Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - Election e2 = new Election("Delft", "Provincial election", new Asset("G_Delft", mockHash)); - assertFalse(e1.equals(e2)); - } - - @Test - public void equalsNonEqualAssetName() throws Exception { - Election e1 = new Election("Delft", "Municipal election", new Asset("G_Delft", mockHash)); - Election e2 = new Election("Delft", "Municipal election", new Asset("T_Delft", mockHash)); - assertFalse(e1.equals(e2)); - } - -} \ No newline at end of file From 4fc47bcdb77f51ce545b9c46c4d532ae07ae8cf5 Mon Sep 17 00:00:00 2001 From: Jonathan Raes Date: Tue, 13 Jun 2017 11:59:09 +0200 Subject: [PATCH 4/9] use snackbar, only show it when no connection avail --- .../digitalvotingpass/SplashActivity.java | 19 +++- .../com/digitalvotingpass/utilities/Util.java | 19 +++- .../res/layout/activity_splash_screen.xml | 91 ++++++++++--------- app/src/main/res/values/strings.xml | 3 + 4 files changed, 82 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java index 7e46d52..1271283 100644 --- a/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java +++ b/app/src/main/java/com/digitalvotingpass/digitalvotingpass/SplashActivity.java @@ -9,11 +9,13 @@ import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; +import android.provider.Settings; import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.support.v13.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.util.Log; +import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -100,15 +102,28 @@ public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (!Util.isOnline(getApplicationContext()) && hasFocus) { initTextHandler.removeCallbacks(initTextUpdater); - Toast.makeText(getApplicationContext(), getString(R.string.please_enable_connect_message), Toast.LENGTH_LONG).show(); currentTask.setText(getString(R.string.no_connection)); + + if (!Util.isNetEnabled(getApplicationContext())) { + View.OnClickListener inputSnackbarListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + } + }; + + Snackbar snackbar = Snackbar.make(findViewById(R.id.splash_screen_layout), getString(R.string.please_enable_connect_message), Snackbar.LENGTH_INDEFINITE); + snackbar.getView().setBackgroundColor(ContextCompat.getColor(this, R.color.redFailed)); + snackbar.setAction(R.string.go_network_settings, inputSnackbarListener); + snackbar.show(); + } } } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == REQUEST_CODE_STORAGE) { + if (requestCode == REQUEST_CODE_STORAGE) { if (grantResults.length != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED) { } else { handler.post(startBlockChain); diff --git a/app/src/main/java/com/digitalvotingpass/utilities/Util.java b/app/src/main/java/com/digitalvotingpass/utilities/Util.java index e69e3e6..5407821 100644 --- a/app/src/main/java/com/digitalvotingpass/utilities/Util.java +++ b/app/src/main/java/com/digitalvotingpass/utilities/Util.java @@ -25,6 +25,7 @@ public class Util { /** * Returns the height of the status bar in pixels + * * @param resources Resources object required to get the height attribute. * @return int */ @@ -41,7 +42,8 @@ public static int getStatusBarHeight(Resources resources) { * Sets up a top-padding for the given app bar equal to the height of the status bar. * This increases the length of the app bar so it fits nicely below the status bar. * This method also sets the status bar transparency. - * @param appBar Toolbar to set padding to + * + * @param appBar Toolbar to set padding to * @param activity Activity - current activity */ public static void setupAppBar(Toolbar appBar, Activity activity) { @@ -57,8 +59,9 @@ public static void setupAppBar(Toolbar appBar, Activity activity) { * Copies an InputStream into a File. * This is used to copy an InputStream from the assets folder to a file in the FileSystem. * Creates nay non-existant parent folders to f. + * * @param is InputStream to be copied. - * @param f File to copy data to. + * @param f File to copy data to. */ public static void copyAssetsFile(InputStream is, File f) throws IOException { OutputStream os = null; @@ -72,8 +75,7 @@ public static void copyAssetsFile(InputStream is, File f) throws IOException { final int buffer_size = 1024 * 1024; try { byte[] bytes = new byte[buffer_size]; - for (;;) - { + for (; ; ) { int count = is.read(bytes, 0, buffer_size); if (count == -1) break; @@ -91,7 +93,7 @@ public static void copyAssetsFile(InputStream is, File f) throws IOException { * This method is used for signing transaction hashes (which are in hex). */ public static byte[] hexStringToByteArray(String hStr) { - if(hStr != null) { + if (hStr != null) { int len = hStr.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { @@ -128,4 +130,11 @@ public static boolean isOnline(Context ctx) { NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); } + + public static boolean isNetEnabled(Context ctx) { + ConnectivityManager cm = + (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo netInfo = cm.getActiveNetworkInfo(); + return netInfo != null; + } } diff --git a/app/src/main/res/layout/activity_splash_screen.xml b/app/src/main/res/layout/activity_splash_screen.xml index 292d716..ef29778 100644 --- a/app/src/main/res/layout/activity_splash_screen.xml +++ b/app/src/main/res/layout/activity_splash_screen.xml @@ -1,53 +1,58 @@ - - + android:layout_width="match_parent" + android:layout_height="match_parent"> - + - + - + - - + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a0a9b82..1cc8190 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -78,6 +78,9 @@ Please enable network connection No Network + + Settings + January February From a3c0a3b8b19315bcf97c03e106d9b1fb99a2c12a Mon Sep 17 00:00:00 2001 From: Daan Middendorp Date: Tue, 13 Jun 2017 14:18:26 +0200 Subject: [PATCH 5/9] Add download playstore button readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0f393b0..de6f8a1 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ This app is intended for use at the polling station. An official scans a voter's []() + + + Android app on Google Play + + ## Getting Started Import the root folder into your IDE (tested on Android Studio), then run project. From e3e11a3735b53dbbe5493109b4a91e808bfaf4fd Mon Sep 17 00:00:00 2001 From: Daan Middendorp Date: Tue, 13 Jun 2017 14:56:38 +0200 Subject: [PATCH 6/9] fix alignment --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de6f8a1..d634290 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ The scope of this project is limited to the [voting pass](https://nl.wikipedia.o This app is intended for use at the polling station. An official scans a voter's travel document to verify and redeem the suffrage, which process is stored on the blockchain and can be verifed by anyone. After the suffrage is verified, a ballot is handed out and the voting process continues in a traditional way (by pencil and paper). -[]() - - - Android app on Google Play + + Android app on Google Play + + ## Getting Started From 5b66d777bdfaf10d403d19b042ada62f5e929ded Mon Sep 17 00:00:00 2001 From: Daan Middendorp Date: Tue, 13 Jun 2017 15:05:01 +0200 Subject: [PATCH 7/9] Create README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d634290..463bcd2 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ The scope of this project is limited to the [voting pass](https://nl.wikipedia.o This app is intended for use at the polling station. An official scans a voter's travel document to verify and redeem the suffrage, which process is stored on the blockchain and can be verifed by anyone. After the suffrage is verified, a ballot is handed out and the voting process continues in a traditional way (by pencil and paper). - - Android app on Google Play - + + Android app on Google Play + ## Getting Started @@ -50,4 +50,4 @@ This project is licensed under the LGPL License - see the [LICENSE.md](LICENSE.m We would like to give special thanks to: * Johan Pouwelse ([synctext](https://github.com/synctext)) for his guidance and blockchain expertise * Milvum ([milvum.com](https://www.milvum.com)) for the resources they provided -* Anyone who's code was used for those great building blocks \ No newline at end of file +* Anyone who's code was used for those great building blocks From acdaab67b0bc903dfb34b4c3ff6bb59fb2643fe0 Mon Sep 17 00:00:00 2001 From: Daan Middendorp Date: Tue, 13 Jun 2017 15:09:51 +0200 Subject: [PATCH 8/9] Create README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 463bcd2..8d8d966 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![platform](https://img.shields.io/badge/platform-Android-green.svg)](https://www.android.com) [![Build Status](https://travis-ci.org/digital-voting-pass/digital-voting-pass-app.svg?branch=develop)](https://travis-ci.org/digital-voting-pass/digital-voting-pass-app) + Part of a [Delft Unversity of Technology](https://www.tudelft.nl) bachelor's thesis about the digitalization of the voting pass for Dutch elections using **blockchain** and **machine readable travel documents**. @@ -11,7 +12,6 @@ The scope of this project is limited to the [voting pass](https://nl.wikipedia.o This app is intended for use at the polling station. An official scans a voter's travel document to verify and redeem the suffrage, which process is stored on the blockchain and can be verifed by anyone. After the suffrage is verified, a ballot is handed out and the voting process continues in a traditional way (by pencil and paper). - Android app on Google Play From 62a19f780191d723588df99da234601dfe0bbe25 Mon Sep 17 00:00:00 2001 From: Jonathan Raes Date: Wed, 14 Jun 2017 17:11:16 +0200 Subject: [PATCH 9/9] updated strings --- app/src/main/res/values-nl/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 848f704..4a3dd02 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -107,6 +107,9 @@ Downloaden... Initialiseren... + Activeer de internet verbinding + Geen Internet + WIFI Instellingen Initialiseren \u00A0Initialiseren. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c7fb312..f2756b0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -107,6 +107,9 @@ Downloading... Initializing... + Please enable network connection + No Network + WIFI Settings Initializing \u00A0Initializing. @@ -119,14 +122,8 @@ From %s Sent %1$d vote \n%2$s %3$s To %s - 1GoqgbPZUV2yuPZXohtAvB2NZbjcew8Rk93mMn|Government - Please enable network connection - No Network - - Settings - com.digitalvotingpass.ELECTION_OBJECT_KEY