Добавил сохранение пути к серверу.
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
|
||||
@ -560,7 +560,6 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
spiInsFormulation = findViewById(R.id.spiInsFormulation); // формуляция(УМО, КЭ, др.)
|
||||
guiTable.add(spiInsFormulation, "insecticide_formulation_id");
|
||||
((selectDB)spiInsFormulation).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
@ -582,7 +581,6 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
spiInsDiluted = findViewById(R.id.spiInsDiluted); // Коммерческий припарат разбавлен?
|
||||
guiTable.add(spiInsDiluted, "insecticide_diluted_id");
|
||||
((selectDB)spiInsDiluted).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package kz.istt.locust;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
@ -9,6 +11,7 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
/*import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpVersion;
|
||||
@ -68,8 +71,8 @@ import tctable.TCTable;
|
||||
* */
|
||||
public class MySynchronizationOld
|
||||
{
|
||||
//public static String URL="https://ccalm.org";
|
||||
public static String URL="http://192.168.200.100:8080";
|
||||
public static String URL="https://ccalm.org";
|
||||
//public static String URL="http://192.168.200.100:8080";
|
||||
|
||||
private Context _context; //От какого контекста показывать алерты
|
||||
//private boolean _showAlert; //Показывать ли окно подождите пожалуйста (его нельзя создавать если в сервисе)
|
||||
@ -121,6 +124,7 @@ public class MySynchronizationOld
|
||||
MySynchronizationOld(Context context)
|
||||
{
|
||||
_context = context;
|
||||
loadURL();
|
||||
|
||||
String appPath = _context.getApplicationContext().getFilesDir().getAbsolutePath();
|
||||
//Thread for downloading from Internet
|
||||
@ -128,6 +132,16 @@ public class MySynchronizationOld
|
||||
myThread.start(); //Стартуем поток
|
||||
}
|
||||
|
||||
//Download setup from local storage
|
||||
public void loadURL()
|
||||
{
|
||||
String URL = MySynchronizationOld.URL;
|
||||
SharedPreferences prefs = _context.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
URL = prefs.getString("URL", "");
|
||||
if(URLUtil.isValidUrl(URL))
|
||||
MySynchronizationOld.URL = URL;
|
||||
}
|
||||
|
||||
/*public static HttpClient getTestHttpClient() {
|
||||
try {
|
||||
SSLContextBuilder builder = new SSLContextBuilder();
|
||||
|
||||
@ -12,13 +12,18 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.vision.Frame;
|
||||
import com.google.android.gms.vision.barcode.Barcode;
|
||||
@ -54,6 +59,7 @@ public class SetupActivity extends Activity {
|
||||
public Button btnAr = null;
|
||||
public Button btnQR = null;
|
||||
public Button btnDeleteAllData = null;
|
||||
public EditText edtURL = null;
|
||||
public CheckBox cbIdentifyCountryRegion = null;
|
||||
public CheckBox cbShowAdvancedSettings = null;
|
||||
|
||||
@ -310,6 +316,27 @@ public class SetupActivity extends Activity {
|
||||
cbShowAdvancedSettings = (CheckBox) findViewById(R.id.cbShowAdvancedSettings);
|
||||
cbShowAdvancedSettings.setOnClickListener(oclShowAdvancedSettings);
|
||||
|
||||
edtURL = (EditText) findViewById(R.id.edtURL);
|
||||
edtURL.setText(MySynchronizationOld.URL);
|
||||
|
||||
edtURL.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (URLUtil.isValidUrl(editable.toString())) {
|
||||
SharedPreferences prefs = SetupActivity.this.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString("URL", editable.toString());
|
||||
editor.apply(); // or editor.commit(); if you want to save synchronously
|
||||
MySynchronizationOld.URL = editable.toString();
|
||||
} else {
|
||||
Toast.makeText(SetupActivity.this, "Invalid URL", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Button delete all data
|
||||
OnClickListener oclDeleteAllData = new OnClickListener()
|
||||
|
||||
@ -244,7 +244,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:id="@+id/edtCalibrWidthCard0"
|
||||
android:id="@+id/edtURL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
||||
Reference in New Issue
Block a user