增加 设置功能
parent
c2b4aa59e7
commit
2bd638e0ab
Binary file not shown.
@ -1,17 +1,44 @@
|
|||||||
package com.example.writeepc;
|
package com.example.writeepc;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
|
import com.example.writeepc.databinding.SettingsActivityBinding;
|
||||||
|
import com.example.writeepc.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
private Spinner powerBinding;
|
||||||
|
private Spinner powerTrace;
|
||||||
|
private EditText settingIp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
SettingsActivityBinding binding =
|
||||||
|
DataBindingUtil.setContentView(this, R.layout.settings_activity);
|
||||||
|
powerBinding = binding.selectPowerBinding;
|
||||||
|
powerTrace = binding.selectPowerTrace;
|
||||||
|
settingIp = binding.settingIp;
|
||||||
|
String bindingPower = SharedPreferencesUtils.getstring("powerBinding", "22");
|
||||||
|
String tracePower = SharedPreferencesUtils.getstring("powerTrace", "22");
|
||||||
|
List<String> powerList = Arrays.asList(getResources().getStringArray(R.array.power));
|
||||||
|
powerBinding.setSelection(powerList.indexOf(bindingPower));
|
||||||
|
powerTrace.setSelection(powerList.indexOf(tracePower));
|
||||||
|
settingIp.setText(SharedPreferencesUtils.getstring("ip", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveInfo(View view) {
|
||||||
|
SharedPreferencesUtils.putstring("powerBinding", powerBinding.getSelectedItem().toString());
|
||||||
|
SharedPreferencesUtils.putstring("powerTrace", powerTrace.getSelectedItem().toString());
|
||||||
|
SharedPreferencesUtils.putstring("ip", settingIp.getText().toString());
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,74 +1,111 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<data>
|
||||||
|
|
||||||
style="@style/info_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="55dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="#6750A4"
|
|
||||||
android:letterSpacing="1"
|
|
||||||
android:text="设置"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:textSize="22sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="20dp"
|
android:orientation="vertical"
|
||||||
|
tools:context=".SettingsActivity">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/info_text"
|
|
||||||
android:layout_width="110dp"
|
|
||||||
android:layout_height="45dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="绑定功率:" />
|
|
||||||
|
|
||||||
<Spinner
|
style="@style/info_text"
|
||||||
android:id="@+id/select_power_binding"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="#6750A4"
|
||||||
|
android:letterSpacing="1"
|
||||||
|
android:text="设置"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp"
|
android:layout_height="45dp"
|
||||||
android:layout_gravity="center"
|
android:layout_marginTop="20dp"
|
||||||
android:entries="@array/power"
|
|
||||||
android:textAlignment="center"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="45dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
|
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/info_text"
|
style="@style/info_text"
|
||||||
android:layout_width="110dp"
|
android:layout_width="110dp"
|
||||||
android:layout_height="45dp"
|
android:layout_height="45dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:text="追溯功率:" />
|
android:text="绑定功率:" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/select_power_"
|
android:id="@+id/select_power_binding"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:entries="@array/power"
|
||||||
|
android:textAlignment="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp"
|
android:layout_height="45dp"
|
||||||
android:layout_gravity="center"
|
android:layout_marginTop="20dp"
|
||||||
android:entries="@array/power"
|
|
||||||
android:textAlignment="center"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
style="@style/button_style"
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="追溯功率:" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/select_power_trace"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:entries="@array/power"
|
||||||
|
android:textAlignment="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/info_text"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="请求地址:" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/setting_ip"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:entries="@array/power"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:lines="1"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:onClick="setPower"
|
android:layout_weight="1"/>
|
||||||
android:text="设置功率" />
|
|
||||||
</LinearLayout>
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:onClick="saveInfo"
|
||||||
|
android:text="保存并退出" />
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
Loading…
Reference in New Issue