Commit ee45c797 authored by jonasled's avatar jonasled

Merge branch 'develop'

parents f4351c9f f2e5c19d
......@@ -50,20 +50,20 @@ play {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.0'
implementation group: 'com.google.guava', name: 'guava', version: '29.0-android'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.jjoe64:graphview:4.2.2'
implementation "com.google.android.material:material:1.2.0-alpha06"
implementation "com.google.android.material:material:1.3.0-alpha02"
implementation 'commons-codec:commons-codec:1.14'
implementation 'de.taimos:totp:1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "ch.acra:acra-http:5.6.1"
implementation "ch.acra:acra-toast:5.6.1"
implementation "ch.acra:acra-mail:5.6.1"
......
......@@ -15,16 +15,16 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label,android:theme">
<activity android:name=".debug"></activity>
<activity android:name=".debugActivity"></activity>
<activity
android:name=".StorageControl"
android:name=".StorageControlActivity"
android:label="@string/title_activity_server_control"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".NodeControl"
android:name=".NodeControlActivity"
android:label="@string/title_activity_server_control"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".loginActivity">
<activity android:name=".startActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -32,18 +32,18 @@
</intent-filter>
</activity>
<activity
android:name=".settings"
android:name=".SettingsActivity"
android:label="@string/title_activity_settings" />
<activity
android:name=".ConsoleView"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullscreenTheme" />
<activity
android:name=".ServerControl"
android:name=".ServerControlActivity"
android:label="@string/title_activity_server_control"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ProxmoxConnected"
android:name=".ClusterActivity"
android:label="@string/title_activity_proxmox_connected"
android:theme="@style/AppTheme.NoActionBar" />
<activity
......@@ -51,7 +51,7 @@
android:label="@string/title_activity_new_server"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".MainActivity"
android:name=".ServerActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
......
......@@ -43,7 +43,7 @@ import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
public class ProxmoxConnected extends AppCompatActivity {
public class ClusterActivity extends AppCompatActivity {
public static boolean updateRequired = false;
int databaseID;
......@@ -65,8 +65,8 @@ public class ProxmoxConnected extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
if(loginActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_proxmox_connected);
if(startActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_cluster);
listView = findViewById(R.id.listView);
swipeRefreshLayout = findViewById(R.id.swiperefresh);
mydb = new de.jonasled.proxdroid.DBHelper(this);
......@@ -101,11 +101,11 @@ public class ProxmoxConnected extends AppCompatActivity {
listView.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {//wait for click on listView element
Intent intent = null;
if((vmctList.get(sortedKeys.get(position)).get(3).equals("lxc")) || (vmctList.get(sortedKeys.get(position)).get(3).equals("qemu"))) {
intent = new Intent(getApplicationContext(), ServerControl.class); //start the Server control activity with some parameters
intent = new Intent(getApplicationContext(), ServerControlActivity.class); //start the Server control activity with some parameters
} else if(vmctList.get(sortedKeys.get(position)).get(3).equals("node")){
intent = new Intent(getApplicationContext(), NodeControl.class); //start the Server control activity with some parameters
intent = new Intent(getApplicationContext(), NodeControlActivity.class); //start the Server control activity with some parameters
} else if(vmctList.get(sortedKeys.get(position)).get(3).equals("storage")){
intent = new Intent(getApplicationContext(), StorageControl.class); //start the Server control activity with some parameters
intent = new Intent(getApplicationContext(), StorageControlActivity.class); //start the Server control activity with some parameters
}
intent.putExtra("id", vmctList.get(sortedKeys.get(position)).get(1));//the id of the machine e.g. 100
intent.putExtra("node", vmctList.get(sortedKeys.get(position)).get(2));//the name of the node e.g. pve
......@@ -131,7 +131,7 @@ public class ProxmoxConnected extends AppCompatActivity {
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String sStackTrace = sw.toString(); // stack trace as a string
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ProxmoxConnected.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ClusterActivity.this);
dlgAlert.setMessage(sStackTrace);
dlgAlert.setTitle(R.string.errUnknown);
dlgAlert.setCancelable(false);
......@@ -163,7 +163,7 @@ public class ProxmoxConnected extends AppCompatActivity {
@Override
protected void onPreExecute() {
super.onPreExecute();
pd = ProgressDialog.show(ProxmoxConnected.this, "", getResources().getString(R.string.loading), true,//open a loading dialog
pd = ProgressDialog.show(ClusterActivity.this, "", getResources().getString(R.string.loading), true,//open a loading dialog
false);
}
......@@ -330,7 +330,7 @@ public class ProxmoxConnected extends AppCompatActivity {
} catch (SSLHandshakeException e){//handle some exceptions
e.printStackTrace();
HelperFunctions.trustCert(ProxmoxConnected.this, strings[0] + "/");
HelperFunctions.trustCert(ClusterActivity.this, strings[0] + "/");
return "";
} catch (IOException e){
e.printStackTrace();
......@@ -372,7 +372,7 @@ public class ProxmoxConnected extends AppCompatActivity {
@Override
protected void onPostExecute(String result) {
pd.dismiss();//close the loading dialog
AlertDialog.Builder dlgAlert2 = new AlertDialog.Builder(ProxmoxConnected.this);
AlertDialog.Builder dlgAlert2 = new AlertDialog.Builder(ClusterActivity.this);
if(result != ""){//if a error occurred, build the dialog for the detailed info
dlgAlert2.setMessage(result.substring(result.indexOf("|") + 1));
dlgAlert2.setTitle(R.string.detailedError);
......@@ -381,7 +381,7 @@ public class ProxmoxConnected extends AppCompatActivity {
}
if (result.startsWith("failedIO")) {//handle the exceptions from above
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ProxmoxConnected.this);
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ClusterActivity.this);
if(mPreferences.getBoolean("callIntent", false) && !HelperFunctions.lastConnectName.equals(urlString)) {
PackageManager pm = getApplicationContext().getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(mPreferences.getString("intentApp", ""));
......@@ -402,16 +402,15 @@ public class ProxmoxConnected extends AppCompatActivity {
}
else if(!mPreferences.getBoolean("callIntent", false) || HelperFunctions.lastConnectName.equals(urlString)) {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ProxmoxConnected.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ClusterActivity.this);
dlgAlert.setMessage(R.string.errNotReachable);
dlgAlert.setTitle(R.string.errNotReachableTitle);
dlgAlert.setPositiveButton(R.string.ok, (DialogInterface dialog, int which) -> finish());
dlgAlert.setNegativeButton(R.string.moreDetails, (DialogInterface dialog, int which) -> dlgAlert2.show());
dlgAlert.setNegativeButton(R.string.moreDetails, (DialogInterface dialog, int which) -> dlgAlert2.show());
dlgAlert.create().show();
}
} else if (result.startsWith("failedJSON")) {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ProxmoxConnected.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ClusterActivity.this);
dlgAlert.setMessage(R.string.errInvalidJson);
dlgAlert.setTitle(R.string.errInvalidJsonTitle);
dlgAlert.setCancelable(false);
......@@ -419,7 +418,7 @@ public class ProxmoxConnected extends AppCompatActivity {
dlgAlert.setNegativeButton(R.string.moreDetails, (DialogInterface dialog, int which) -> dlgAlert2.show());
dlgAlert.create().show();
} else if(result != "") {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ProxmoxConnected.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(ClusterActivity.this);
dlgAlert.setMessage(result);
dlgAlert.setTitle(R.string.errUnknown);
dlgAlert.setCancelable(false);
......@@ -435,7 +434,7 @@ public class ProxmoxConnected extends AppCompatActivity {
sortedKeys = new ArrayList(vmctList.keySet());//The response from proxmox is a mess, no System or whatever, so we sort the array after the key
Collections.sort(sortedKeys);
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ProxmoxConnected.this);
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ClusterActivity.this);
int lastindex = 0; //get the last container / VM in list
......@@ -532,7 +531,7 @@ public class ProxmoxConnected extends AppCompatActivity {
int[] iconsInt = Ints.toArray(icon);
String[] labelArray = label.toArray(new String[0]);//convert the List to array and show the listView
adapter = new de.jonasled.proxdroid.ClusterListAdapter(ProxmoxConnected.this, labelArray, iconsInt);
adapter = new de.jonasled.proxdroid.ClusterListAdapter(ClusterActivity.this, labelArray, iconsInt);
listView.setAdapter(adapter);
}
}
......
......@@ -47,11 +47,11 @@ public class ConsoleView extends AppCompatActivity {
ticket = getIntent().getStringExtra("ticket");//get the data, give on start of this activity
url = getIntent().getStringExtra("url");
CSRFPreventionToken = getIntent().getStringExtra("CSRFPreventionToken");
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ConsoleView.this); //get the settings
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ConsoleView.this); //get the SettingsActivity
//fullscreen the view
getSupportActionBar().hide();
if(mPreferences.getBoolean("consoleFullscreen", true)){//hide the status bar, if enabled in settings
if(mPreferences.getBoolean("consoleFullscreen", true)){//hide the status bar, if enabled in SettingsActivity
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
}
......@@ -61,13 +61,13 @@ public class ConsoleView extends AppCompatActivity {
WebChromeClientCustom mWebChromeClient = new WebChromeClientCustom();
browser.setWebChromeClient(mWebChromeClient);
browser.getSettings().setJavaScriptEnabled(true);//enable some settings in chrome WebView
browser.getSettings().setJavaScriptEnabled(true);//enable some SettingsActivity in chrome WebView
browser.getSettings().setDomStorageEnabled(true);
browser.getSettings().setUseWideViewPort(true);
browser.getSettings().setLoadWithOverviewMode(true);
browser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {//if build is debug, enabled webView remote debugging (on pc open chrome://inspect/#devices)
if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {//if build is debugActivity, enabled webView remote debugging (on pc open chrome://inspect/#devices)
WebView.setWebContentsDebuggingEnabled(true);
}
......@@ -99,7 +99,7 @@ public class ConsoleView extends AppCompatActivity {
@Override
public void onPageFinished(WebView view, String url){
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ConsoleView.this);//get the settings module
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(ConsoleView.this);//get the SettingsActivity module
if(url.contains("xterm")){//check if we have a xterm console, if yes inject custom font size via javascript
view.loadUrl("javascript: (function() {term.setOption('fontSize', " + mPreferences.getString("xtermSize", "15") + ");})()");
} else if(url.contains("novnc")){//check if console is novnc
......
......@@ -4,45 +4,32 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.Series;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base32;
import org.apache.commons.codec.binary.Hex;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidParameterSpecException;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.time.Instant;
import java.util.Random;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
......@@ -59,7 +46,7 @@ public class HelperFunctions {
public static TrustManagerFactory tmf;
public static SSLContext context;
public static HostnameVerifier hostnameVerifier;
public static String lastConnectName = ""; //we declare this variable here, becuase if we restart the ProxmoxConnected Class it will reset the variable
public static String lastConnectName = ""; //we declare this variable here, becuase if we restart the ClusterActivity Class it will reset the variable
public static String humanReadableByteCountBin(long bytes) { //Convert a byte long to a String with suitable extension
......@@ -80,24 +67,18 @@ public class HelperFunctions {
public static void formatGraph(GraphView graphView, LineGraphSeries... lineGraphSeries){
double maxX = lineGraphSeries[0].getHighestValueX();
double minX = lineGraphSeries[0].getLowestValueX();
double maxY = lineGraphSeries[0].getHighestValueY();
double minY = lineGraphSeries[0].getLowestValueY();
graphView.removeAllSeries();
for (LineGraphSeries series: lineGraphSeries) {
graphView.addSeries(series);
if(series.getHighestValueX() > maxX) maxX = series.getHighestValueX();
if(series.getLowestValueX() > minX) minX = series.getLowestValueX();
if(series.getHighestValueY() > maxY) maxY = series.getHighestValueY();
if(series.getLowestValueY() > minY) minY = series.getLowestValueY();
if(series.getHighestValueX()> maxX) maxX = series.getHighestValueX();
if(series.getLowestValueX()> minX) minX = series.getLowestValueX();
}
graphView.getViewport().setXAxisBoundsManual(true);
graphView.getViewport().setMaxX(maxX);
graphView.getViewport().setMinX(minX);
graphView.getViewport().setMaxY(maxY);
graphView.getViewport().setMinY(minY);
}
public static String totpGenerator(String secretKey) { //used to generate the TFA tokens on open connection, if TFA is enabled
......@@ -232,7 +213,7 @@ public class HelperFunctions {
/* Encrypt the message. */
Cipher cipher = null;
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, loginActivity.decryptToken);
cipher.init(Cipher.ENCRYPT_MODE, startActivity.decryptToken);
byte[] cipherText = cipher.doFinal(message.getBytes("UTF-8"));
return cipherText;
}
......@@ -243,7 +224,7 @@ public class HelperFunctions {
/* Decrypt the message, given derived encContentValues and initialization vector. */
Cipher cipher = null;
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, loginActivity.decryptToken);
cipher.init(Cipher.DECRYPT_MODE, startActivity.decryptToken);
String decryptString = new String(cipher.doFinal(cipherText), "UTF-8");
return decryptString;
}
......
......@@ -10,10 +10,7 @@ import android.os.Build;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.common.primitives.Ints;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
......@@ -23,11 +20,8 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -35,27 +29,12 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidParameterSpecException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class NewServer extends AppCompatActivity {
TextView inputName;
......@@ -77,7 +56,7 @@ public class NewServer extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(loginActivity.theme == 3) setTheme(R.style.Theme_App_black);
if(startActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_new_server);
Toolbar toolbar = findViewById(R.id.toolbar);//find the UI elements
setSupportActionBar(toolbar);
......@@ -213,7 +192,7 @@ public class NewServer extends AppCompatActivity {
}
} catch (Exception e) {
e.printStackTrace();}
Intent intent = new Intent(getApplicationContext(), de.jonasled.proxdroid.MainActivity.class); //start the main activity
Intent intent = new Intent(getApplicationContext(), ServerActivity.class); //start the main activity
finish();
startActivity(intent);
});
......
......@@ -40,7 +40,7 @@ import java.util.TimerTask;
import javax.net.ssl.HttpsURLConnection;
public class NodeControl extends AppCompatActivity {
public class NodeControlActivity extends AppCompatActivity {
String ticket;
String id;
......@@ -85,7 +85,7 @@ public class NodeControl extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(loginActivity.theme == 3) setTheme(R.style.Theme_App_black);
if(startActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_node_control);
Toolbar toolbar = findViewById(R.id.toolbar);
consoleButton = findViewById(R.id.buttonConsole);
......@@ -230,7 +230,7 @@ public class NodeControl extends AppCompatActivity {
protected void onPreExecute() {
HelperFunctions.buildKeystore();
super.onPreExecute();
pd = ProgressDialog.show(NodeControl.this, "", getResources().getString(R.string.loading), true,
pd = ProgressDialog.show(NodeControlActivity.this, "", getResources().getString(R.string.loading), true,
false); // Create and show Progress dialog
}
......@@ -271,7 +271,7 @@ public class NodeControl extends AppCompatActivity {
pd.dismiss();
if (result == "failedIO") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errNotReachable);
dlgAlert.setTitle(R.string.errNotReachableTitle);
dlgAlert.setCancelable(false);
......@@ -279,14 +279,14 @@ public class NodeControl extends AppCompatActivity {
dlgAlert.create().show();
} else if (result == "failedJSON") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errInvalidJson);
dlgAlert.setTitle(R.string.errInvalidJsonTitle);
dlgAlert.setCancelable(false);
dlgAlert.setPositiveButton(R.string.ok,(DialogInterface dialog, int which) -> finish());
dlgAlert.create().show();
}
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setTitle(R.string.notes);
dlgAlert.setMessage(description);
dlgAlert.setPositiveButton(R.string.ok, null);
......@@ -302,7 +302,7 @@ public class NodeControl extends AppCompatActivity {
protected void onPreExecute() {
HelperFunctions.buildKeystore();
super.onPreExecute();
pd = ProgressDialog.show(NodeControl.this, "", getResources().getString(R.string.loading), true,
pd = ProgressDialog.show(NodeControlActivity.this, "", getResources().getString(R.string.loading), true,
false); // Create and show Progress dialog
}
......@@ -345,7 +345,7 @@ public class NodeControl extends AppCompatActivity {
pd.dismiss();
if (result == "failedIO") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errNotReachable);
dlgAlert.setTitle(R.string.errNotReachableTitle);
dlgAlert.setCancelable(false);
......@@ -353,7 +353,7 @@ public class NodeControl extends AppCompatActivity {
dlgAlert.create().show();
} else if (result == "failedJSON") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errInvalidJson);
dlgAlert.setTitle(R.string.errInvalidJsonTitle);
dlgAlert.setCancelable(false);
......@@ -378,10 +378,10 @@ public class NodeControl extends AppCompatActivity {
@Override
protected void onPreExecute() {
HelperFunctions.buildKeystore();
NodeControl.this.runOnUiThread(() -> {
NodeControlActivity.this.runOnUiThread(() -> {
super.onPreExecute();
if(showLoading) {
pd = ProgressDialog.show(NodeControl.this, "", getResources().getString(R.string.getDataOf) + " " + node, true,
pd = ProgressDialog.show(NodeControlActivity.this, "", getResources().getString(R.string.getDataOf) + " " + node, true,
false); // Create and show Progress dialog
}
ramGraphSeries = new LineGraphSeries<>();
......@@ -501,14 +501,14 @@ public class NodeControl extends AppCompatActivity {
@Override
protected void onPostExecute(String result) {
NodeControl.this.runOnUiThread(() -> {
NodeControlActivity.this.runOnUiThread(() -> {
if (showLoading) {
pd.dismiss();
showLoading = false;
}
if (result == "failedIO") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errNotReachable);
dlgAlert.setTitle(R.string.errNotReachableTitle);
dlgAlert.setCancelable(false);
......@@ -516,7 +516,7 @@ public class NodeControl extends AppCompatActivity {
dlgAlert.create().show();
} else if (result == "failedJSON") {
timer.cancel();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errInvalidJson);
dlgAlert.setTitle(R.string.errInvalidJsonTitle);
dlgAlert.setCancelable(false);
......@@ -557,7 +557,7 @@ public class NodeControl extends AppCompatActivity {
} catch (JSONException e){
timer.cancel();
e.printStackTrace();
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControl.this);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(NodeControlActivity.this);
dlgAlert.setMessage(R.string.errInvalidJson);
dlgAlert.setTitle(R.string.errInvalidJsonTitle);
dlgAlert.setCancelable(false);
......
package de.jonasled.proxdroid;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class NonScrollListView extends ListView {
public NonScrollListView(Context context) {
super(context);
}
public NonScrollListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = View.MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, View.MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}
\ No newline at end of file
......@@ -10,21 +10,15 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.ListView;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.util.ArrayList;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
public class MainActivity extends AppCompatActivity {
public class ServerActivity extends AppCompatActivity {
private de.jonasled.proxdroid.DBHelper mydb;
ArrayList<String> databaseID;
......@@ -33,8 +27,8 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(loginActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_main);
if(startActivity.theme == 3) setTheme(R.style.Theme_App_black);
setContentView(R.layout.activity_server);
Toolbar toolbar = findViewById(R.id.toolbar);
listView = findViewById(R.id.listView);
setSupportActionBar(toolbar);
......@@ -55,7 +49,7 @@ public class MainActivity extends AppCompatActivity {
String selectedItem = databaseID.get(position);//get the ID in the database from the Server
int databaseID = Integer.parseInt(selectedItem);//parse the ID to int
Intent intent = new Intent(getApplicationContext(), ProxmoxConnected.class);//start the Proxmox connected class with the ID of the entry as parameter