-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSettingsActivity.java
153 lines (135 loc) · 5.47 KB
/
SettingsActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.example.abdullah.opencvframeget;
import android.app.ActionBar;
import android.content.Intent;
import android.provider.ContactsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
public class SettingsActivity extends AppCompatActivity implements View.OnClickListener {
TextView t1;
Switch laneswitch;
Switch vehicleswitch;
ImageView abt_us;
public static boolean lane_switch=true;
public static boolean vehicle_switch=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.distance_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
t1 = (TextView) findViewById(R.id.textView);
t1.setOnClickListener(this);
abt_us=(ImageView) findViewById(R.id.abt_us);
abt_us.setOnClickListener(this);
laneswitch = (Switch) findViewById(R.id.switchlane);
laneswitch.setChecked(lane_switch);
laneswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked)
{
laneswitch.setChecked(true);
lane_switch=true;
}
else
{
laneswitch.setChecked(false);
lane_switch=false;
}
}
});
vehicleswitch = (Switch) findViewById(R.id.switchvehicle);
vehicleswitch.setChecked(vehicle_switch);
vehicleswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked)
{
vehicleswitch.setChecked(true);
vehicle_switch=true;
}
else
{
vehicleswitch.setChecked(false);
vehicle_switch=false;
}
}
});
}
@Override
public void onClick(View v) {
if(v.getId()==abt_us.getId())
{
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_id));
// set a message
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(" Developed By: \r\n\n Syed Ali Kazim \n And \n Abdullah Akbar.\r\n \r\n All Rights Reserved.");
// Toast configuration
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
else {
Intent specifyintent = new Intent(this, Specifycontact.class);
startActivity(specifyintent);
}
// finish();
}
public void onBackPressed(){
Intent mainintent = new Intent(this, StartupActivity.class);
startActivity(mainintent);
finish();
}
/*public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main2, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_id));
// set a message
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(" Developed By: \r\n\n Syed Ali Kazim \n And \n Abdullah Akbar.\r\n \r\n All Rights Reserved.");
// Toast configuration
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
return true;
}
return super.onOptionsItemSelected(item);
}
*/
}