Commit cf55b493 by 石璀亮

feat(model):add the setting function and add the model setting ui

1 parent 7779cdb5
......@@ -20,7 +20,11 @@
</intent-filter>
</activity>
<activity android:name=".SettingActivity"
android:label="@string/app_name"
android:label="@string/item_setting"
>
</activity>
<activity android:name=".ProductModelActivity"
android:label="@string/item_type"
>
</activity>
......
package com.nbbsw.cuiliang.systemsetting;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TableLayout;
......@@ -18,10 +20,116 @@ public class CommonTableActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.common_table);
Intent intent = getIntent();
generateMemTable();
String return_item = intent.getStringExtra("item");
Log.d("item", return_item);
if (return_item.equals(this.getResources().getString(R.string.item_mem))){
generateMemTable();
}
if (return_item.equals(this.getResources().getString(R.string.item_cpu))){
generateCpuTable();
}
if (return_item.equals(this.getResources().getString(R.string.item_storage))){
generateStorageTable();
}
if (return_item.equals(this.getResources().getString(R.string.item_screen))){
generateScreenTable();
}
if (return_item.equals(this.getResources().getString(R.string.item_camera))){
generateCameraTable();
}
if (return_item.equals(this.getResources().getString(R.string.item_other))){
generateOtherTable();
}
}
private void generateOtherTable() {
TableLayout mytable = (TableLayout) findViewById(R.id.common_table);
int numberOfRow = 3;
int numberOfColumn = 5;
int cellDimension = 24;
int cellPadding = 2;
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
mytable.addView(tableRow, new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
generateTextView("口", tableRow);
generateTextView("跑分", tableRow);
generateTextView("支持root", tableRow);
generateTextView("支持所有传感器", tableRow);
generateTextView("状态", tableRow);
generateCommonTable(mytable, numberOfRow, numberOfColumn, cellDimension, cellPadding, tableRow);
}
private void generateCameraTable() {
TableLayout mytable = (TableLayout) findViewById(R.id.common_table);
int numberOfRow = 3;
int numberOfColumn = 5;
int cellDimension = 24;
int cellPadding = 2;
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
mytable.addView(tableRow, new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
generateTextView("口", tableRow);
generateTextView("前摄像头像素", tableRow);
generateTextView("后摄像头像素", tableRow);
generateTextView("视频质量", tableRow);
generateTextView("状态", tableRow);
generateCommonTable(mytable, numberOfRow, numberOfColumn, cellDimension, cellPadding, tableRow);
}
private void generateScreenTable() {
TableLayout mytable = (TableLayout) findViewById(R.id.common_table);
int numberOfRow = 3;
int numberOfColumn = 5;
int cellDimension = 24;
int cellPadding = 2;
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
mytable.addView(tableRow, new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
generateTextView("口", tableRow);
generateTextView("高度", tableRow);
generateTextView("宽度", tableRow);
generateTextView("密度", tableRow);
generateTextView("状态", tableRow);
generateCommonTable(mytable, numberOfRow, numberOfColumn, cellDimension, cellPadding, tableRow);
}
private void generateStorageTable() {
TableLayout mytable = (TableLayout) findViewById(R.id.common_table);
int numberOfRow = 3;
int numberOfColumn = 3;
int cellDimension = 24;
int cellPadding = 2;
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
mytable.addView(tableRow, new TableLayout.LayoutParams((cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
generateTextView("口", tableRow);
generateTextView("内部存储", tableRow);
generateTextView("状态", tableRow);
generateCommonTable(mytable, numberOfRow, numberOfColumn, cellDimension, cellPadding, tableRow);
}
private void generateMemTable() {
TableLayout mytable = (TableLayout) findViewById(R.id.common_table);
int numberOfRow = 3;
......
......@@ -28,7 +28,7 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.fruit_item, parent, false);
.inflate(R.layout.unit_item, parent, false);
final ViewHolder holder = new ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener(){
......@@ -54,10 +54,25 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> {
return holder;
}
/**
* Handle click event.
*
* @param itemName the item name
* @param context the context
*/
public void handleClickEvent(String itemName, Context context){
Intent intent = new Intent(context, CommonTableActivity.class);
intent.putExtra("item", itemName);
context.startActivity(intent);
if (itemName.equals(context.getResources().getString(R.string.item_setting))){
Intent intent = new Intent(context, SettingActivity.class);
context.startActivity(intent);
}else if (itemName.equals(context.getResources().getString(R.string.item_type))){
Intent intent = new Intent(context, ProductModelActivity.class);
context.startActivity(intent);
}else{
Intent intent = new Intent(context, CommonTableActivity.class);
intent.putExtra("item", itemName);
context.startActivity(intent);
}
}
......
package com.nbbsw.cuiliang.systemsetting;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
/**
* Created by st on 17-7-19.
*/
public class ProductModelActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_model);
}
}
package com.nbbsw.cuiliang.systemsetting;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
/**
* Created by st on 17-7-18.
* Function: Setting For All Hardware.
*/
public class SettingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setting);
setContentView(R.layout.activity_setting);
LinearLayout setting_reset = (LinearLayout)findViewById(R.id.setting_reset);
setting_reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
settingReset();
}
});
LinearLayout setting_true = (LinearLayout)findViewById(R.id.setting_true);
setting_true.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
settingTrue();
}
});
}
private void settingTrue() {
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("警告").
setMessage(R.string.setting_true_introduce).
setIcon(R.drawable.ic_launcher).
setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Setting: Restore True Value
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Setting: Cancel
}
}).
create();
alertDialog.show();
}
private void settingReset() {
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("警告").
setMessage(R.string.setting_reset_introduce).
setIcon(R.drawable.ic_launcher).
setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Setting: Factory Default
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Setting: Cancel
}
}).
create();
alertDialog.show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/model_input_tips" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="选择其他型号" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="确定" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="重置" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="清除" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/setting_reset"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setting_reset" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setting_reset_introduce"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/setting_true"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setting_reset" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setting_true_introduce"
/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="@style/AppTheme">
</LinearLayout>
\ No newline at end of file
......@@ -12,5 +12,10 @@
<string name="item_other">其他</string>
<string name="item_type">型号</string>
<string name="item_setting">设置</string>
<string name="setting_reset">恢复出厂值</string>
<string name="setting_true">恢复真实值</string>
<string name="setting_reset_introduce">将CPU、运行内存、存储‘屏幕、摄像头、其他以及产品型号恢复到出厂值</string>
<string name="setting_true_introduce">将CPU、运行内存、存储‘屏幕、摄像头、其他以及产品型号恢复到真实值</string>
<string name="model_input_tips">请输入产品型号</string>
</resources>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!