From 7303a62c63e7f80eb632472fdb2aaa73a4d957a4 Mon Sep 17 00:00:00 2001 From: Mas7erMind Date: Thu, 18 Feb 2021 09:27:15 -0500 Subject: [PATCH 01/25] - Implement ACRA for debug information - Fix Locale crash with stats --- app/build.gradle | 10 ++++-- app/src/main/AndroidManifest.xml | 1 + .../androidminer/BaseActivity.java | 12 +++++++ .../androidminer/MainActivity.java | 4 +++ .../androidminer/MobileMinerApplication.java | 31 +++++++++++++++++++ .../androidminer/StatsFragment.java | 10 +++--- .../androidminer/api/providers/ScalaPool.java | 2 +- 7 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/io/scalaproject/androidminer/MobileMinerApplication.java diff --git a/app/build.gradle b/app/build.gradle index 944e94d5..21a30c35 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,10 +12,10 @@ android { defaultConfig { applicationId "io.scalaproject.androidminer" - minSdkVersion 19 + minSdkVersion 22 targetSdkVersion 28 // keep version 28 to avoid an error 13 when running exe in assets folder (sdk 29 gives the error) - versionCode 10 - versionName "2.0.0" + versionCode 11 + versionName "2.0.1" buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -43,4 +43,8 @@ dependencies { implementation 'com.github.anastr:speedviewlib:1.5.2' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10' implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' + + def acraVersion = '5.7.0' + implementation "ch.acra:acra-core:$acraVersion" + implementation "ch.acra:acra-mail:$acraVersion" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ecebb6de..f5a8c253 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ 1 ? p[1] : "kH/s"); TextView tvPoolMiners = view.findViewById(R.id.miners); - tvPoolMiners.setText(String.format("%,d", Integer.parseInt(d.pool.miners))); + tvPoolMiners.setText(String.format(Locale.getDefault(), "%,d", Integer.parseInt(d.pool.miners))); LinearLayout llPoolBlocks = view.findViewById(R.id.llBlocksPool); llPoolBlocks.setVisibility(pi.getPoolType() == 2 || pi.getPoolType() == 0 ? View.GONE : View.VISIBLE); @@ -128,7 +130,7 @@ private static void updateFields(ProviderData d, View view) { tvPoolLastBlock.setText(d.pool.lastBlockTime.isEmpty() ? "n/a" : d.pool.lastBlockTime); TextView tvPoolLBlocks = view.findViewById(R.id.blockspool); - tvPoolLBlocks.setText(d.pool.blocks.isEmpty() ? "n/a" : String.format("%,d", Integer.parseInt(d.pool.blocks))); + tvPoolLBlocks.setText(d.pool.blocks.isEmpty() ? "n/a" : String.format(Locale.getDefault(), "%,d", Integer.parseInt(d.pool.blocks))); // Address @@ -161,7 +163,7 @@ private static void updateFields(ProviderData d, View view) { tvAddressSubmittedHash.setText(pi.getPoolType() == 1 || pi.getPoolType() == 2 ? view.getResources().getString(R.string.submitted_shares) : view.getResources().getString(R.string.submitted_hashes)); TextView tvAddressBlocks = view.findViewById(R.id.blocksminedminer); - tvAddressBlocks.setText(d.miner.shares.isEmpty() ? "n/a" : String.format("%,d", Integer.parseInt(d.miner.shares))); + tvAddressBlocks.setText(d.miner.shares.isEmpty() ? "n/a" : String.format(Locale.getDefault(), "%,d", Long.parseLong(d.miner.shares))); String sBalance = d.miner.balance.replace("XLA", "").trim(); TextView tvBalance = view.findViewById(R.id.balance); diff --git a/app/src/main/java/io/scalaproject/androidminer/api/providers/ScalaPool.java b/app/src/main/java/io/scalaproject/androidminer/api/providers/ScalaPool.java index 36d3b9e7..7b73907c 100644 --- a/app/src/main/java/io/scalaproject/androidminer/api/providers/ScalaPool.java +++ b/app/src/main/java/io/scalaproject/androidminer/api/providers/ScalaPool.java @@ -89,7 +89,7 @@ protected void onBackgroundFetchData() { mBlockData.coin.symbol = joStatsConfig.optString("symbol").toUpperCase(); mBlockData.coin.denominationUnit = tryParseLong(joStatsConfig.optString("denominationUnit"), 1L); - mBlockData.pool.lastBlockTime = pTime.format(new Date(joStatsPoolStats.optLong("lastblock_timestamp") * 1000)); + mBlockData.pool.lastBlockTime = pTime.format(new Date(joStatsPoolStats.optLong("lastBlockFound"))); mBlockData.pool.lastRewardAmount = parseCurrency(joStatsPoolStats.optString("lastblock_lastReward", "0"), mBlockData.coin.units, mBlockData.coin.denominationUnit, mBlockData.coin.symbol); mBlockData.pool.hashrate = getReadableHashRateString(joStatsPool.optLong("hashrate")); mBlockData.pool.blocks = joStatsPoolStats.optString("blocksFound", "0"); From 40d0ff74c177acaf3a213dc85594005a56d1128f Mon Sep 17 00:00:00 2001 From: Mas7erMind Date: Thu, 18 Feb 2021 10:30:53 -0500 Subject: [PATCH 02/25] Add Send Debug Information settings --- .../androidminer/BaseActivity.java | 12 ------ .../io/scalaproject/androidminer/Config.java | 1 + .../androidminer/MainActivity.java | 27 ++++---------- .../androidminer/SettingsFragment.java | 10 ++++- app/src/main/res/layout/fragment_settings.xml | 37 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/io/scalaproject/androidminer/BaseActivity.java b/app/src/main/java/io/scalaproject/androidminer/BaseActivity.java index a94830e0..9e8d9596 100644 --- a/app/src/main/java/io/scalaproject/androidminer/BaseActivity.java +++ b/app/src/main/java/io/scalaproject/androidminer/BaseActivity.java @@ -57,18 +57,6 @@ public void uncaughtException(@NotNull Thread paramThread, @NotNull Throwable pa }); } - public void handleUncaughtException (Thread thread, Throwable e) - { - e.printStackTrace(); // not all Android versions will print the stack trace automatically - - /*Intent intent = new Intent (); - intent.setAction ("com.mydomain.SEND_LOG"); // see step 5. - intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application - startActivity (intent); - - System.exit(1); // kill off the crashed app*/ - } - public void showProgressDialog(int msgId) { showProgressDialog(msgId, 250); // don't show dialog for fast operations } diff --git a/app/src/main/java/io/scalaproject/androidminer/Config.java b/app/src/main/java/io/scalaproject/androidminer/Config.java index c4856219..29be48fd 100644 --- a/app/src/main/java/io/scalaproject/androidminer/Config.java +++ b/app/src/main/java/io/scalaproject/androidminer/Config.java @@ -28,6 +28,7 @@ public class Config { public final static String CONFIG_TEMPERATURE_UNIT = "temperature_unit"; public final static String CONFIG_TEMPERATURE_SENSOR_SHOW_WARNING = "temp_sensor_warning"; public final static String CONFIG_HASHRATE_REFRESH_DELAY = "hashrate_refresh_delay"; + public final static String CONFIG_SEND_DEBUG_INFO = "send_debug_info"; public final static int DefaultRefreshDelay = 30; // In seconds diff --git a/app/src/main/java/io/scalaproject/androidminer/MainActivity.java b/app/src/main/java/io/scalaproject/androidminer/MainActivity.java index 4d426939..87c01266 100644 --- a/app/src/main/java/io/scalaproject/androidminer/MainActivity.java +++ b/app/src/main/java/io/scalaproject/androidminer/MainActivity.java @@ -123,6 +123,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import org.acra.ACRA; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -350,21 +351,6 @@ public void onButtonOptions(int type) { SharedPreferences preferences = getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE); Config.initialize(preferences); - // Open Settings the first time the app is launched - /*String minersaddress = Config.read("address"); - - if (minersaddress.equals("") || minersaddress.isEmpty()) { - navigationView.getMenu().getItem(2).setChecked(true); - - SettingsFragment fragment = (SettingsFragment) getSupportFragmentManager().findFragmentByTag("settings_fragment"); - if(fragment != null) { - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment,"settings_fragment").commit(); - } - else { - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment(),"settings_fragment").commit(); - } - }*/ - pullToRefreshHr = findViewById(R.id.pullToRefreshHr); pullToRefreshHr.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override @@ -1401,6 +1387,9 @@ public void loadSettings() { bIsCelsius = Config.read(Config.CONFIG_TEMPERATURE_UNIT, "C").equals("C"); tvCPUTemperatureUnit.setText(bIsCelsius ? getString(R.string.celsius) : getString(R.string.fahrenheit)); tvBatteryTemperatureUnit.setText(bIsCelsius ? getString(R.string.celsius) : getString(R.string.fahrenheit)); + + // Disable ACRA Debug Reporting + ACRA.getErrorReporter().setEnabled(Config.read(Config.CONFIG_SEND_DEBUG_INFO, "0").equals("1")); } private void showDisclaimerTemperatureSensors() { @@ -1436,15 +1425,15 @@ public void onClick(DialogInterface dialog, int id) { private void startMining() { if (binder == null) return; - // cause a crash... - //String sCrashString = null; - //Log.e("MyApp", sCrashString.toString() ); - if (!Config.read("init").equals("1")) { setStatusText(getString(R.string.save_settings_first)); return; } + // Cause a crash to test ACRA + //String sCrashString = null; + //Log.e("ACRA Test", sCrashString.toString() ); + String password = Config.read("workername"); String address = Config.read("address"); diff --git a/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java b/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java index fc8b4dec..23c5a539 100644 --- a/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java +++ b/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java @@ -61,7 +61,7 @@ public class SettingsFragment extends Fragment { private SeekBar sbCPUTemp, sbBatteryTemp, sbCooldown, sbCores; private TextView tvCPUMaxTemp, tvBatteryMaxTemp, tvCooldown, tvCPUTempUnit, tvBatteryTempUnit, tvRefreshHashrateDelay; - private Switch swDisableTempControl, swPauseOnBattery, swKeepScreenOnWhenMining; + private Switch swDisableTempControl, swPauseOnBattery, swKeepScreenOnWhenMining, swSendDebugInformation; private ImageView ivDecreaseRefreshHashrateDelay, ivIncreaseRefreshHashrateDelay; private MaterialButtonToggleGroup tgTemperatureUnit; @@ -134,6 +134,7 @@ public void onClick(View v) { swPauseOnBattery = view.findViewById(R.id.chkPauseOnBattery); swKeepScreenOnWhenMining = view.findViewById(R.id.chkKeepScreenOnWhenMining); swDisableTempControl = view.findViewById(R.id.chkAmaycOff); + swSendDebugInformation = view.findViewById(R.id.chkSendDebugInformation); tgTemperatureUnit = view.findViewById(R.id.tgTemperatureUnit); tgTemperatureUnit.addOnButtonCheckedListener(new MaterialButtonToggleGroup.OnButtonCheckedListener() { @@ -222,6 +223,11 @@ public void onButtonChecked(MaterialButtonToggleGroup group, int checkedId, bool swKeepScreenOnWhenMining.setChecked(true); } + boolean checkSendDebugInformation = Config.read(Config.CONFIG_SEND_DEBUG_INFO).equals("1"); + if(checkSendDebugInformation) { + swSendDebugInformation.setChecked(true); + } + if (!Config.read("address").isEmpty()) { edAddress.setText(Config.read("address")); } @@ -527,6 +533,8 @@ private void saveSettings() { Config.write(Config.CONFIG_TEMPERATURE_UNIT, tgTemperatureUnit.getCheckedButtonId() == R.id.btnFarehnheit ? "F" : "C"); + Config.write(Config.CONFIG_SEND_DEBUG_INFO, swSendDebugInformation.isChecked() ? "1" : "0"); + Config.write("init", "1"); Utils.showToast(getContext(), "Settings Saved.", Toast.LENGTH_SHORT); diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 73cb5975..9d4348ec 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -837,6 +837,43 @@ android:layout_height="0.7dp" android:background="@color/txt_inactive"/> + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0a2e81b8..125bd056 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -232,4 +232,5 @@ Hashrate Refresh Delay AMAYC temperature check: Too hot AMAYC temperature check: OK + Send Debug Information \ No newline at end of file From 616750fe6b5b8e5b1468553cf4a50360de32ea3d Mon Sep 17 00:00:00 2001 From: Mas7erMind Date: Thu, 18 Feb 2021 10:46:28 -0500 Subject: [PATCH 03/25] Add Send Debug Information helper --- .../androidminer/SettingsFragment.java | 10 ++++++ app/src/main/res/layout/fragment_settings.xml | 19 +++++++++- .../layout/helper_send_debug_information.xml | 35 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/helper_send_debug_information.xml diff --git a/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java b/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java index 23c5a539..4a788627 100644 --- a/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java +++ b/app/src/main/java/io/scalaproject/androidminer/SettingsFragment.java @@ -450,6 +450,16 @@ public void onClick(View v) { } }); + Button btnSendDebugInformationHelp = view.findViewById(R.id.btnSendDebugInformationHelp); + btnSendDebugInformationHelp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // inflate the layout of the popup window + View popupView = inflater.inflate(R.layout.helper_send_debug_information, null); + Utils.showPopup(v, inflater, popupView); + } + }); + return view; } diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 9d4348ec..e8410fcd 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -644,7 +644,7 @@ android:id="@+id/btnAmaycWarning" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginStart="25dp" + android:layout_marginStart="10dp" android:layout_gravity="center_vertical" app:backgroundTint="@android:color/transparent" app:cornerRadius="5dp" @@ -773,6 +773,7 @@ +