You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.3 KiB
140 lines
4.3 KiB
package ru.defend.defdevteam.tstu;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ArrayAdapter;
|
|
import android.widget.CheckBox;
|
|
import android.widget.EditText;
|
|
import android.widget.ImageView;
|
|
import android.widget.ListView;
|
|
import android.widget.TextView;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
private EditText login, password;
|
|
public ImageView logo;
|
|
private SharedPreferences sPref;
|
|
final String LOGIN = "login";
|
|
final String PASSWORD = "password";
|
|
final String CHECK = "check";
|
|
public CheckBox check;
|
|
static public List<MainActivity.groupList> subs;
|
|
|
|
|
|
|
|
public void authButtonOnClick(View v){
|
|
if(check.isChecked()){
|
|
saveForms();
|
|
}
|
|
Intent WebA = new Intent(this, WebActivity.class);
|
|
WebA.putExtra("login", login.getText().toString());
|
|
WebA.putExtra("pass", password.getText().toString());
|
|
startActivity(WebA);
|
|
//onFeedReaderComplete();
|
|
}
|
|
|
|
//TODO: Проверка авторизации здеся, хотя как ее тут пилить, когда ее нету лооол!
|
|
void saveForms() {
|
|
sPref = getPreferences(MODE_PRIVATE);
|
|
SharedPreferences.Editor ed = sPref.edit();
|
|
ed.putString(LOGIN, login.getText().toString());
|
|
ed.putString(PASSWORD, password.getText().toString());
|
|
ed.putBoolean(CHECK, check.isChecked());
|
|
ed.apply();
|
|
}
|
|
|
|
void loadForms() {
|
|
sPref = getPreferences(MODE_PRIVATE);
|
|
login.setText(sPref.getString(LOGIN, ""));
|
|
password.setText(sPref.getString(PASSWORD, ""));
|
|
check.setChecked(sPref.getBoolean(CHECK, false));
|
|
}
|
|
|
|
public void updateForms(View v){
|
|
if(!check.isChecked()) {
|
|
password.setText("");
|
|
saveForms();
|
|
}
|
|
else {
|
|
saveForms();
|
|
}
|
|
}
|
|
|
|
|
|
public class subsAdapter extends ArrayAdapter<groupList> {
|
|
public subsAdapter(Context context) {
|
|
super(context, android.R.layout.simple_list_item_multiple_choice, subs);
|
|
}
|
|
|
|
@Override
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
groupList group = getItem(position);
|
|
|
|
if(convertView == null){
|
|
convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_multiple_choice, null);
|
|
}
|
|
((TextView) convertView.findViewById(android.R.id.text1)).setText(group.name);
|
|
return convertView;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public class groupList {
|
|
public String name, rate;
|
|
public groupList(String name, String rate){
|
|
this.name = name;
|
|
this.rate = rate;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.main);
|
|
login = (EditText) findViewById(R.id.editLogin);
|
|
password = (EditText) findViewById(R.id.passEdit);
|
|
check = (CheckBox) findViewById(R.id.save);
|
|
loadForms();
|
|
//TODO: убрать потом
|
|
subs = new ArrayList<groupList>();
|
|
subs.add(new groupList("test","test"));
|
|
subs.add(new groupList("test","test"));
|
|
subs.add(new groupList("test","test"));
|
|
subs.add(new groupList("test","test"));
|
|
setContentView(R.layout.subscriptions);
|
|
ArrayAdapter<groupList> subsL = new subsAdapter(this);
|
|
ListView subsList = (ListView) findViewById(R.id.subsList);
|
|
subsList.setAdapter(subsL);
|
|
}
|
|
|
|
@Override
|
|
protected void onResume() {
|
|
super.onResume();
|
|
Intent intent = getIntent();
|
|
if (!(intent.getStringExtra("error") == null)) {
|
|
Log.i("TESTINGG", intent.getStringExtra("error"));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
if(check.isChecked()) saveForms();
|
|
}
|
|
|
|
public void OnSubsListClick(View v) {
|
|
|
|
}
|
|
}
|
|
|