Skip to content

Commit

Permalink
Added device check on first app start;
Browse files Browse the repository at this point in the history
Trying to fix the cpu temp check
  • Loading branch information
shmutalov committed Oct 25, 2020
1 parent 0d95eae commit f64fb53
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 16 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "29.0.2"

compileOptions {
Expand All @@ -13,9 +13,9 @@ android {
defaultConfig {
applicationId "shmutalov.verusminer9000"
minSdkVersion 23
targetSdkVersion 28 // to avoid an error 13 when running exe in assets folder (sdk 29 gives the error)
targetSdkVersion 30 // to avoid an error 13 when running exe in assets folder (sdk 29 gives the error)
versionCode 7
versionName "0.0.4"
versionName "0.0.5"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/shmutalov/verusminer9000/AboutFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,

Button btnDonateXLA = view.findViewById(R.id.btnDonateVRSC);
btnDonateXLA.setOnClickListener(view12 -> {
Utils.copyToClipboard("VRSC Donation Address", Utils.VERUS_DONATION_ADDRESS);
Utils.copyToClipboard(MainActivity.getContextOfApplication(),"VRSC Donation Address", Utils.VERUS_DONATION_ADDRESS);
Toast.makeText(getContext(), R.string.donationadressverus_copied, Toast.LENGTH_SHORT).show();
});

Expand Down Expand Up @@ -150,7 +150,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,

Button btnDebugInfo = view.findViewById(R.id.btnDebugInfo);
btnDebugInfo.setOnClickListener(view1 -> {
Utils.copyToClipboard("Verus Miner 9000 Debug Info", sDebugInfo);
Utils.copyToClipboard(MainActivity.getContextOfApplication(),"Verus Miner 9000 Debug Info", sDebugInfo);
Toast.makeText(getContext(), getResources().getString(R.string.debuginfo_copied), Toast.LENGTH_SHORT).show();
});

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/shmutalov/verusminer9000/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ static float getCPUTempFromFile(String sFile) {
if (line != null) {
output = Float.parseFloat(line);

if (output > 1000.0f && Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
//if (output > 1000.0f && Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
if (output > 1000.0f) {
output /= 1000.0f;
}

Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/shmutalov/verusminer9000/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,14 @@ static void showPopup(View view, LayoutInflater inflater, View popupView) {
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);

// dismiss the popup window when touched
popupView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
popupWindow.dismiss();
return true;
}
popupView.setOnTouchListener((v, event) -> {
popupWindow.dismiss();
return true;
});
}

static void copyToClipboard(String label, String text) {
ClipboardManager clipboard = (ClipboardManager) MainActivity.getContextOfApplication().getSystemService(Context.CLIPBOARD_SERVICE);
static void copyToClipboard(Context context, String label, String text) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(label, text);
clipboard.setPrimaryClip(clip);
}
Expand All @@ -124,7 +121,7 @@ static String pasteFromClipboard(Context appContext) {

// If it does contain data
assert clipboard != null;
if (!(clipboard.hasPrimaryClip())) {
if (!clipboard.hasPrimaryClip()) {
// Ignore
} else if (!(Objects.requireNonNull(clipboard.getPrimaryClipDescription()).hasMimeType(MIMETYPE_TEXT_PLAIN))) {
// Ignore, since the clipboard has data but it is not plain text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,27 @@
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.content.res.ResourcesCompat;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;

import shmutalov.verusminer9000.miner.AbstractMiningService;
import shmutalov.verusminer9000.miner.VerusBinMiningService;

public class WizardHomeActivity extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -31,10 +44,55 @@ public void onCreate(Bundle savedInstanceState) {
return;
}

setContentView(R.layout.fragment_wizard_home);
// check, if our device is supported
String abi = Tools.getABI();
VerusBinMiningService miner = new VerusBinMiningService();
boolean isSupported = Arrays.asList(miner.getSupportedArchitectures()).contains(abi);
if (isSupported) {
setContentView(R.layout.fragment_wizard_home);
} else {
setContentView(R.layout.fragment_wizard_platform_not_supported);
}

View view = findViewById(android.R.id.content).getRootView();

if (!isSupported) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(BuildConfig.BUILD_TIME);
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm a", Locale.ENGLISH);
String build_time_debug = formatter.format(calendar.getTime());

StringBuilder cpuinfo = new StringBuilder(Config.read("CPUINFO").trim());
if(cpuinfo.length() == 0) {
try {
Map<String, String> m = Tools.getCPUInfo();

cpuinfo = new StringBuilder("ABI: " + Tools.getABI() + "\n");
for (Map.Entry<String, String> pair : m.entrySet()) {
cpuinfo.append(pair.getKey()).append(": ").append(pair.getValue()).append("\n");
}
} catch (Exception e) {
cpuinfo = new StringBuilder();
}

Config.write("CPUINFO", cpuinfo.toString().trim());
}

String sDebugInfo = "Version Code: " + BuildConfig.VERSION_CODE + "\n" +
"Version Name: " + BuildConfig.VERSION_NAME + "\n" +
"Build Time: " + build_time_debug + "\n\n" +
"Device Name: " + Tools.getDeviceName(view.getContext()) + "\n" +
"CPU Info: " + cpuinfo;

Button btnDebugInfo = view.findViewById(R.id.btnDebugInfo);
btnDebugInfo.setOnClickListener(view1 -> {
Utils.copyToClipboard(view.getContext(),"Verus Miner 9000 Debug Info", sDebugInfo);
Toast.makeText(view.getContext(), view.getResources().getString(R.string.debuginfo_copied), Toast.LENGTH_SHORT).show();
});

return;
}

String sDisclaimerText = getResources().getString(R.string.disclaimer_agreement);
String sDiclaimer = getResources().getString(R.string.disclaimer);

Expand Down
74 changes: 74 additions & 0 deletions app/src/main/res/layout/fragment_wizard_platform_not_supported.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="35dp"
android:layout_marginEnd="35dp"
android:background="@color/bg_body"
android:weightSum="80">

<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="20"/>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/bg_body">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="VERUS MINER"
android:gravity="center"
android:textSize="30sp"
android:textStyle="bold"
android:textColor="@color/txt_headline"/>

<ImageView
android:id="@+id/splashscreen"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher"/>

</LinearLayout>

<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="5" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/architecture_not_supported"
android:textColor="@color/c_red"
android:textStyle="bold"
android:textAlignment="center"
android:textSize="20sp" />

<Button
android:id="@+id/btnDebugInfo"
android:layout_width="140dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:backgroundTint="@color/bg_lighter"
android:insetLeft="2dp"
android:insetRight="2dp"
android:text="@string/debuginfo"
android:textSize="14sp"
android:textColor="@color/txt_button_filled"
android:textAllCaps="false"
app:cornerRadius="5dp"
app:iconPadding="0dp"
app:icon="@drawable/ic_copy"
app:iconTint="@color/btn_icon_default"/>
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<string name="passwordhint">Worker password</string>
<string name="workernamehint">Worker name</string>
<string name="landingpage_headline">Start mining on your mobile device safely and efficiently</string>
<string name="architecture_not_supported">Your architecture is not supported</string>
<string name="landingpage_introduction">Verus Miner 9000 provides useful information about your mining activities and prevents your device from overheating.</string>
<string name="createaddress">Create your wallet</string>
<string name="disclaimer_agreement">By using this application, you confirm your knowledge and acceptance of the Disclaimer</string>
Expand Down

0 comments on commit f64fb53

Please sign in to comment.