Adding delete relation/communication feature
[iot2.git] / others / lede-gui / src / main / java / com / example / lede2 / AddRelationActivity.java
diff --git a/others/lede-gui/src/main/java/com/example/lede2/AddRelationActivity.java b/others/lede-gui/src/main/java/com/example/lede2/AddRelationActivity.java
deleted file mode 100644 (file)
index da54025..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.example.lede2;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class AddRelationActivity extends AppCompatActivity implements View.OnClickListener,View.OnFocusChangeListener {
-
-    Button doneButton;
-    TextView databaseInfo;
-    private SSH_MySQL ssh;//Connection object between Android & Host
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_add_relation);
-
-        doneButton = (Button) findViewById(R.id.doneButton);
-        databaseInfo = (EditText)findViewById(R.id.textInfoComm);
-
-        doneButton.setOnClickListener(this);
-        databaseInfo.setOnFocusChangeListener(this);
-        ssh = new SSH_MySQL();
-        // Set config text from file for device
-        try {
-            InputStream is = getAssets().open(MainActivity.DEF_ADD_DEVICE_COMM_FILE);
-            int size = is.available();
-            byte[] buffer = new byte[size];
-            is.read(buffer);
-            is.close();
-            String text = new String(buffer);
-            databaseInfo.setGravity(Gravity.LEFT);
-            databaseInfo.setText(text);
-            Log.d("LOADINGFILE", "Add comm info file is already loaded!");
-        } catch (IOException ex) {
-            Log.d("LOADINGFILE", "Add comm info file is NOT loaded!");
-            ex.printStackTrace();
-        }
-    }
-
-    @Override
-    public void onClick(View v) {
-        if(v == doneButton){
-            // 1) Create a new file and insert the configuration
-            // 2) Run iotinstaller code for communication/relation installation
-            // 3) Remove the existing config file
-            ssh.execute("echo \"" + databaseInfo.getText().toString() + "\" >> " +
-                    MainActivity.DEF_MYSQL_CONFIG_FILE + ";" +
-                    MainActivity.DEF_INSTALL_RELATION_CMD + " " + MainActivity.DEF_MYSQL_CONFIG_FILE + ";" +
-                    "rm -rf " + MainActivity.DEF_MYSQL_CONFIG_FILE);
-            finish();
-        }
-    }
-
-    @Override
-    public void onFocusChange(View view, boolean hasFocus) {
-        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
-        if (hasFocus) {
-            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
-        } else {
-            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
-        }
-    }
-
-}