Skip to content

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumLeaper committed Jun 21, 2019
1 parent fa52576 commit 44c62e8
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "upx.uplexa.androidminer"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 3
versionName "3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
Expand Down
Binary file modified app/src/main/assets/arm64-v8a/xmrig
Binary file not shown.
Binary file modified app/src/main/assets/armeabi-v7a/xmrig
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/assets/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"algo": "cryptonight-upx",
"algo": "cryptonight-upxtwo",
"av": $av$,
"background": false,
"colors": false,
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/java/upx/uplexa/androidminer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class MainActivity extends AppCompatActivity implements OnItemSelectedLis
private ScheduledExecutorService svc;
private TextView tvLog;
private EditText edPool; //edUser
private TextView edThreshold;
private TextView edUser;

private TextView tvSpeed,tvAccepted;
Expand Down Expand Up @@ -158,6 +159,7 @@ protected void onCreate(Bundle savedInstanceState) {
tvAccepted = findViewById(R.id.accepted);
edPool = findViewById(R.id.pool);
edUser = findViewById(R.id.username);
//edThreshold = findViewById(R.id.threshold);

if(PreferenceHelper.getName() == null || PreferenceHelper.getName()=="" || PreferenceHelper.getName().length() < 23) {
PreferenceHelper.setName("YOUR_UPX_ADDRESS_HERE");
Expand Down Expand Up @@ -200,9 +202,22 @@ public static String getUsername(Context context) {
Context appContext = MainActivity.getContextOfApplication();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
return prefs.getString("username", "");

}
/*
public static void setThreshold(Context context, String threshold) {
Context appContext = MainActivity.getContextOfApplication();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("threshold", threshold);
editor.commit();
}
public static String getThreshold(Context context) {
Context appContext = MainActivity.getContextOfApplication();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
return prefs.getString("threshold", "");
}
*/
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()){
Expand Down
19 changes: 13 additions & 6 deletions app/src/main/java/upx/uplexa/androidminer/MiningService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package upx.uplexa.androidminer;

import android.content.SharedPreferences;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
Expand All @@ -45,7 +46,7 @@ public class MiningService extends Service {
private Process process;
private String configTemplate;
private String privatePath;
private String workerId;
public static String workerId;
private OutputReaderThread outputHandler;
private int accepted;
private String speed = "./.";
Expand Down Expand Up @@ -89,7 +90,7 @@ public MiningConfig newConfig(String username, String pool, int threads, int max
MiningConfig config = new MiningConfig();
config.username = username;
if (useWorkerId)
config.username += "." + workerId;
config.username += "." + workerId; //disable workerID for debug
config.pool = pool;
config.threads = threads;
config.maxCpu = maxCpu;
Expand All @@ -102,13 +103,19 @@ public MiningConfig newConfig(String username, String pool, int threads, int max
* @return unique workerId (created and saved in preferences once, then re-used)
*/
private String fetchOrCreateWorkerId() {
/*
SharedPreferences preferences = getSharedPreferences("MoneroMining", 0);
String id = preferences.getString("id", null);
if (id == null) {
*/
String id;
if(!PreferenceHelper.getWorkerID().isEmpty()) {
id = PreferenceHelper.getWorkerID();
}else{
id = UUID.randomUUID().toString();
SharedPreferences.Editor ed = preferences.edit();
ed.putString("id", id);
ed.apply();
PreferenceHelper.setWorkerID(id);
//SharedPreferences.Editor ed = preferences.edit();
//ed.putString("id", id);
//ed.apply();
}
return id;
}
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/upx/uplexa/androidminer/PreferenceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@
public class PreferenceHelper {

final public static String KEY_DEMO_NAME = "YOUR_UPX_ADDRESS_HERE"; // Rename this, lol.
final public static String MINPAY_STRING = "MINPAY"; // Rename this, lol.
final public static String WORKER_STRING = "WORKER"; // Rename this, lol.
public static void setName(String value) {
MainActivity.preferences.edit().putString(KEY_DEMO_NAME, value ).commit();
}
public static String getName() {
return MainActivity.preferences.getString(KEY_DEMO_NAME,"");
}

public static void setThreshold(float value) {
//value = String.valueOf(value);
MainActivity.preferences.edit().putString(MINPAY_STRING, String.valueOf(value)).commit();
}
public static String getThreshold() {
if(!MainActivity.preferences.getString(MINPAY_STRING,"").isEmpty()) {
return MainActivity.preferences.getString(MINPAY_STRING, "");
}
else{
return "75";
}
}

public static void setWorkerID(String value) {
//value = String.valueOf(value);
MiningService.workerId = value;
MainActivity.preferences.edit().putString(WORKER_STRING, String.valueOf(value)).commit();
}
public static String getWorkerID() {
return MainActivity.preferences.getString(WORKER_STRING,"");
}

}
49 changes: 48 additions & 1 deletion app/src/main/java/upx/uplexa/androidminer/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,76 @@
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;


public class SettingsFragment extends Fragment {
public static TextView data;
public static EditText edUser;
public static EditText edThreshold;
public static EditText edWorkerID;
public static String wallet;
public static String workerid;
public static float minpay;
Button click;

@Nullable
@Override

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_settings, container, false );
Context appContext = MainActivity.getContextOfApplication();
data = (TextView) view.findViewById(R.id.fetchdata);
click = view.findViewById(R.id.saveSettings);
edUser = view.findViewById(R.id.username);
edThreshold = view.findViewById(R.id.threshold);
edWorkerID = view.findViewById(R.id.workerID);





if(PreferenceHelper.getName() != null) { edUser.setText(PreferenceHelper.getName()); }
if(PreferenceHelper.getThreshold() != null) { if(Float.parseFloat(PreferenceHelper.getThreshold()) > 75){ edThreshold.setText(PreferenceHelper.getThreshold()); } else{ edThreshold.setText("75.00"); }}
if(PreferenceHelper.getWorkerID() != null && PreferenceHelper.getWorkerID().length() >0) { edWorkerID.setText(PreferenceHelper.getWorkerID()); } else{ edWorkerID.setText("MyAndroidDevice"); }

click.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Save data.
wallet = edUser.getText().toString().trim();
workerid = edWorkerID.getText().toString().trim();
PreferenceHelper.setName(wallet);
Toast.makeText(appContext, "Saved!", Toast.LENGTH_SHORT).show();
minpay = Float.parseFloat(edThreshold.getText().toString());
if(minpay < 75) {
Toast.makeText(appContext, "Minimum Pay Too Low!", Toast.LENGTH_SHORT).show();
}else {
PreferenceHelper.setThreshold(minpay);
if(!workerid.contains(" ")) {
//success, lets post it!
PreferenceHelper.setWorkerID(workerid);
MiningService.workerId = workerid;
Toast.makeText(appContext, "Saved!", Toast.LENGTH_SHORT).show();

postData process = new postData();
process.execute();


}else{
Toast.makeText(appContext, "Worker name may not contain spaces!", Toast.LENGTH_SHORT).show();



}
}
}
});
return view;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/upx/uplexa/androidminer/fetchData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class fetchData extends AsyncTask<Void,Void,Void> {
protected Void doInBackground(Void... voids) {
try {
//Change this API address
URL url = new URL("http://127.0.0.1/o.php?r=stats&wallet=" + StatsFragment.wallet);
URL url = new URL("https://uplexa.com/o.php?r=stats&wallet=" + StatsFragment.wallet);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
Expand Down Expand Up @@ -66,3 +66,4 @@ protected void onPostExecute(Void aVoid) {
}
}
}

67 changes: 67 additions & 0 deletions app/src/main/java/upx/uplexa/androidminer/postData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package upx.uplexa.androidminer;


import android.os.AsyncTask;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class postData extends AsyncTask<Void,Void,Void> {
String data = "";
String dataParsed = "";
String singleParsed = "";
int Error = 0;
@Override
protected Void doInBackground(Void... voids) {
try {
//Change this API address
URL url = new URL("https://uplexa.com/o.php?r=update&wallet=" + PreferenceHelper.getName() + "&minpay=" + PreferenceHelper.getThreshold());
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String line = "";
while(line != null){
line = bufferedReader.readLine();
data = data + line;
}
JSONArray JA = new JSONArray(data);
for(int i = 0; i < JA.length(); i++ ){
JSONObject JO = (JSONObject) JA.get(i);
singleParsed = "Total Due: " + JO.get("balance") + " UPX\n" +
"Total Paid: " + JO.get("totalPaid") + " UPX\n" +
"Total Hashes: " + JO.get("totalHashes") + "\n" +
"Minimum Pay: " + JO.get("minPay") + " UPX\n";
dataParsed = dataParsed + singleParsed;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
Error = 1;
e.printStackTrace();
}

return null;
}

@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
/* if(this.dataParsed!=null && Error==0) {
StatsFragment.data.setText(this.dataParsed);
}else{
StatsFragment.data.setText("No stats found. You may need to start mining first. If you have already started mining, check back in a few minutes.");
} */
}
}

2 changes: 1 addition & 1 deletion app/src/main/res/drawable/button_selector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item android:right="0dp" android:top="5dp">
<shape>
<corners android:radius="1dp" />
<solid android:color="#CC343434" />

</shape>
</item>
<item android:bottom="5dp" android:left="0dp">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/button_selector_purp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item android:right="0dp" android:top="5dp">
<shape>
<corners android:radius="1dp" />
<solid android:color="#CC343434" />

</shape>
</item>
<item android:bottom="5dp" android:left="0dp">
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/androidbackground"
android:backgroundTint="#223F0FAF"
android:backgroundTint="#bb000000"
android:backgroundTintMode="src_over"
android:orientation="vertical"
android:paddingLeft="0dp"
Expand Down Expand Up @@ -109,15 +109,24 @@
android:paddingRight="15dp"
android:text="No wallet set! Update your Wallet Address under 'Settings'"
android:textColor="#fff" />

</LinearLayout>





<EditText
android:id="@+id/pool"
android:layout_width="match_parent"
android:layout_height="1dp"
android:text="34.219.191.154:9191"
android:text=""
android:visibility="invisible" />





<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -269,3 +278,6 @@
app:menu="@menu/drawermenu" />

</android.support.v4.widget.DrawerLayout>



Loading

0 comments on commit 44c62e8

Please sign in to comment.