Начал делать дни синхронизации
This commit is contained in:
@ -73,6 +73,7 @@ public class MySynchronizationOld
|
||||
{
|
||||
public static String URL="https://ccalm.org";
|
||||
//public static String URL="http://192.168.200.100:8080";
|
||||
public static int SyncDays=30;
|
||||
|
||||
private Context _context; //От какого контекста показывать алерты
|
||||
//private boolean _showAlert; //Показывать ли окно подождите пожалуйста (его нельзя создавать если в сервисе)
|
||||
@ -138,6 +139,7 @@ public class MySynchronizationOld
|
||||
String URL = MySynchronizationOld.URL;
|
||||
SharedPreferences prefs = _context.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
URL = prefs.getString("URL", "");
|
||||
MySynchronizationOld.SyncDays = prefs.getInt("SynDays", MySynchronizationOld.SyncDays);
|
||||
if(URLUtil.isValidUrl(URL))
|
||||
MySynchronizationOld.URL = URL;
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ public class SetupActivity extends Activity {
|
||||
public Button btnQR = null;
|
||||
public Button btnDeleteAllData = null;
|
||||
public EditText edtURL = null;
|
||||
public EditText edtSyncDays = null;
|
||||
public CheckBox cbIdentifyCountryRegion = null;
|
||||
public CheckBox cbShowAdvancedSettings = null;
|
||||
|
||||
@ -102,6 +103,9 @@ public class SetupActivity extends Activity {
|
||||
//Загрузка сохранёного языка
|
||||
Tools.loadLocale(this);
|
||||
|
||||
//Прячу всё что должно быть спрятано
|
||||
((LinearLayout)findViewById(R.id.llShowAdvancedSettings)).setVisibility(View.GONE);
|
||||
|
||||
tvSynchronization = (TextView)findViewById(R.id.tvSynchronization);
|
||||
|
||||
//Кнопочка синхронизировать
|
||||
@ -338,6 +342,28 @@ public class SetupActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
edtSyncDays = (EditText) findViewById(R.id.edtSyncDays);
|
||||
edtSyncDays.setText(MySynchronizationOld.SyncDays);
|
||||
|
||||
edtSyncDays.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) {
|
||||
try {
|
||||
MySynchronizationOld.SyncDays=Integer.parseInt(edtSyncDays.toString());
|
||||
SharedPreferences prefs = SetupActivity.this.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putInt("SyncDays", MySynchronizationOld.SyncDays);
|
||||
editor.apply(); // or editor.commit(); if you want to save synchronously
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(SetupActivity.this, "Invalid integer", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Button delete all data
|
||||
OnClickListener oclDeleteAllData = new OnClickListener()
|
||||
{
|
||||
|
||||
@ -225,34 +225,45 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/Show_advanced_settings"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llShowAdvancedSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/URL_path_to_the_server"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
</LinearLayout>
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edtURL"
|
||||
android:hint="@string/URL_path_to_the_server"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:importantForAutofill="no"
|
||||
android:autofillHints=""
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textUri" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edtSyncDays"
|
||||
android:hint="@string/Days_of_synchronization"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberDecimal" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -263,9 +274,9 @@
|
||||
android:id="@+id/btnDeleteAllData"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:minWidth="190dp"
|
||||
android:minHeight="40dp"
|
||||
android:layout_margin="2dp"
|
||||
android:text="@string/Delete_all_data" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -336,4 +336,6 @@
|
||||
<string name="Commercial_product_diluted">Ticarət məhsulu seyreltilirmi?</string>
|
||||
<string name="Working_fluid_dilution_ratio">İşçi mayenin seyreltmə nisbəti</string>
|
||||
<string name="Show_advanced_settings">Qabaqcıl parametrləri göstərin</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
@ -446,6 +446,7 @@
|
||||
<string name="Human_Health_and_Environment_HH_Env_Monitoring_Form">Мониторинг здоровья человека и окружающей среды</string>
|
||||
<string name="URL_path_to_the_server">URL путь к серверу</string>
|
||||
<string name="Do_you_really_want_to_delete_all_data_from_the_app">Вы действительно хотите удалить все данные из приложения?</string>
|
||||
<string name="Days_of_synchronization">Дней синхронизации</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
@ -447,7 +447,7 @@
|
||||
<string name="URL_path_to_the_server">URL path to the server</string>
|
||||
|
||||
<string name="Do_you_really_want_to_delete_all_data_from_the_app">Do you really want to delete all data from the app?</string>
|
||||
|
||||
<string name="Days_of_synchronization">Days of synchronization</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user