mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 00:26:45 -06:00
Merge branch 'grid-marks'
# Conflicts: # app/src/main/java/io/github/wulkanowy/activity/main/Login.java # app/src/main/java/io/github/wulkanowy/activity/main/MainActivity.java
This commit is contained in:
commit
a5ad57cfde
@ -36,5 +36,8 @@ dependencies {
|
||||
compile 'com.android.support:design:25.3.1'
|
||||
compile 'com.android.support:support-vector-drawable:25.3.1'
|
||||
compile 'com.android.support:support-v4:25.3.1'
|
||||
compile 'com.android.support:recyclerview-v7:25.3.1'
|
||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.github.wulkanowy">
|
||||
package="io.github.wulkanowy"
|
||||
android:installLocation="internalOnly">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
@ -11,11 +12,12 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@android:style/Theme.DeviceDefault">
|
||||
android:theme="@style/Theme.AppCompat">
|
||||
<activity
|
||||
android:name=".activity.started.StartedActivity"
|
||||
android:noHistory="true"
|
||||
android:theme="@style/NoActionBar">
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
android:configChanges="orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -24,11 +26,12 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:label="@string/login_title" />
|
||||
android:label="@string/login_title"
|
||||
android:configChanges="orientation|screenSize"/>
|
||||
<activity
|
||||
android:name=".activity.dashboard.DashboardActivity"
|
||||
android:label="@string/title_activity_dashboard"
|
||||
android:theme="@style/Theme.AppCompat" />
|
||||
android:configChanges="orientation|screenSize"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -18,7 +18,7 @@ import io.github.wulkanowy.activity.dashboard.marks.MarksFragment;
|
||||
public class DashboardActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
MarksFragment marksFragment = new MarksFragment();
|
||||
MarksFragment marksFragment;
|
||||
AttendanceFragment attendanceFragment = new AttendanceFragment();
|
||||
BoardFragment boardFragment = new BoardFragment();
|
||||
LessonplanFragment lessonplanFragment = new LessonplanFragment();
|
||||
@ -68,6 +68,8 @@ public class DashboardActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dashboard);
|
||||
|
||||
marksFragment = new MarksFragment();
|
||||
|
||||
setTitle(R.string.title_dashboard);
|
||||
|
||||
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
|
||||
|
@ -0,0 +1,61 @@
|
||||
package io.github.wulkanowy.activity.dashboard.marks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private ArrayList<String> lista;
|
||||
|
||||
public ImageAdapter(Context context, ArrayList<String> lista) {
|
||||
this.lista = lista;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_layout, viewGroup, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ImageAdapter.ViewHolder viewHolder, int i) {
|
||||
|
||||
viewHolder.tv_android.setText(lista.get(i));
|
||||
Picasso.with(context)
|
||||
.load(R.drawable.sample_0)
|
||||
.resize(240,120)
|
||||
.noFade()
|
||||
.into(viewHolder.img_android);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return lista.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
private TextView tv_android;
|
||||
private ImageView img_android;
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
tv_android = (TextView)view.findViewById(R.id.tv_android);
|
||||
img_android = (ImageView) view.findViewById(R.id.img_android);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,38 @@
|
||||
package io.github.wulkanowy.activity.dashboard.marks;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
public class MarksFragment extends Fragment {
|
||||
|
||||
|
||||
ArrayList<String> subject = new ArrayList<>();
|
||||
View view;
|
||||
|
||||
public MarksFragment() {
|
||||
}
|
||||
|
||||
@ -19,7 +40,120 @@ public class MarksFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_marks, container, false);
|
||||
|
||||
view = inflater.inflate(R.layout.fragment_marks, container, false);
|
||||
if (subject.size() == 0) {
|
||||
|
||||
new MarksModel(container.getContext()).execute();
|
||||
}
|
||||
else if (subject.size() > 1) {
|
||||
|
||||
createGrid();
|
||||
view.findViewById(R.id.loadingPanel).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void createGrid(){
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.card_recycler_view);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(view.getContext(),2);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
ImageAdapter adapter = new ImageAdapter(view.getContext(),subject);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
public class MarksModel extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private Context mContext;
|
||||
private Map<String, String> loginCookies;
|
||||
|
||||
MarksModel(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
String cookiesPath = mContext.getFilesDir().getPath() + "/cookies.txt";
|
||||
|
||||
try {
|
||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cookiesPath));
|
||||
loginCookies = (Map<String, String>) ois.readObject();
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e){
|
||||
e.toString();
|
||||
}
|
||||
|
||||
// get link to uonetplus-opiekun.vulcan.net.pl module
|
||||
String startPageUrl = "https://uonetplus.vulcan.net.pl/powiatjaroslawski/Start.mvc/Index";
|
||||
try {
|
||||
Document startPage = Jsoup.connect(startPageUrl)
|
||||
.followRedirects(true)
|
||||
.cookies(loginCookies)
|
||||
.get();
|
||||
Elements studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a");
|
||||
String uonetPlusOpiekunUrl = studentTileLink.attr("href");
|
||||
|
||||
// get context module cookie
|
||||
Connection.Response res = Jsoup.connect(uonetPlusOpiekunUrl)
|
||||
.followRedirects(true)
|
||||
.cookies(loginCookies)
|
||||
.execute();
|
||||
loginCookies = res.cookies();
|
||||
|
||||
//get subject name
|
||||
String subjectPageurl = "https://uonetplus-opiekun.vulcan.net.pl/powiatjaroslawski/005791/Oceny/Wszystkie?details=1";
|
||||
Document subjectPage = Jsoup.connect(subjectPageurl)
|
||||
.cookies(loginCookies)
|
||||
.get();
|
||||
Elements subjectTile = subjectPage.select(".ocenyZwykle-table > tbody > tr");
|
||||
for (Element titlelement : subjectTile){
|
||||
subject.add(titlelement.select("td:nth-child(1)").text());
|
||||
}
|
||||
|
||||
// get marks view
|
||||
String marksPageUrl = "https://uonetplus-opiekun.vulcan.net.pl/powiatjaroslawski/005791/Oceny/Wszystkie?details=2";
|
||||
Document marksPage = Jsoup.connect(marksPageUrl)
|
||||
.cookies(loginCookies)
|
||||
.get();
|
||||
Elements marksRows = marksPage.select(".ocenySzczegoly-table > tbody > tr");
|
||||
for (Element element : marksRows) {
|
||||
System.out.println("----------");
|
||||
System.out.println("Subject" + element.select("td:nth-child(1)").text());
|
||||
System.out.println("Grade: " + element.select("td:nth-child(2)").text());
|
||||
System.out.println("Description: " + element.select("td:nth-child(3)").text());
|
||||
System.out.println("Weight: " + element.select("td:nth-child(4)").text());
|
||||
System.out.println("Date: " + element.select("td:nth-child(5)").text());
|
||||
System.out.println("Teacher: " + element.select("td:nth-child(6)").text());
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
|
||||
Set<String> hs = new HashSet<>();
|
||||
hs.addAll(subject);
|
||||
subject.clear();
|
||||
subject.addAll(hs);
|
||||
|
||||
createGrid();
|
||||
|
||||
view.findViewById(R.id.loadingPanel).setVisibility(View.GONE);
|
||||
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
200
app/src/main/java/io/github/wulkanowy/activity/main/Login.java
Normal file
200
app/src/main/java/io/github/wulkanowy/activity/main/Login.java
Normal file
@ -0,0 +1,200 @@
|
||||
package io.github.wulkanowy.activity.main;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.activity.dashboard.DashboardActivity;
|
||||
|
||||
public class Login extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
String email;
|
||||
String password;
|
||||
String county;
|
||||
|
||||
int check;
|
||||
|
||||
Map<String, String> loginCookies;
|
||||
|
||||
Activity activity;
|
||||
String userMesage;
|
||||
|
||||
String urlForStepOne;
|
||||
String urlForStepTwo;
|
||||
String urlForStepThree;
|
||||
|
||||
ProgressDialog progress;
|
||||
|
||||
public Login(String emailT, String passwordT, String countyT, Activity mainAC, int check) {
|
||||
|
||||
activity = mainAC;
|
||||
progress = new ProgressDialog(activity);
|
||||
this.check = check;
|
||||
|
||||
|
||||
if (countyT.equals("Debug")) {
|
||||
urlForStepOne = activity.getString(R.string.urlStepOneDebug);
|
||||
urlForStepTwo = activity.getString(R.string.urlStepTwoDebug);
|
||||
urlForStepThree = activity.getString(R.string.urlStepThreeDebug);
|
||||
county = activity.getString(R.string.countyDebug);
|
||||
email = emailT;
|
||||
password = passwordT;
|
||||
} else {
|
||||
urlForStepOne = activity.getString(R.string.urlStepOneRelease);
|
||||
urlForStepTwo = activity.getString(R.string.urlStepTwoRelease);
|
||||
urlForStepThree = activity.getString(R.string.urlStepThreeRelease);
|
||||
county = countyT;
|
||||
email = emailT;
|
||||
password = passwordT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
|
||||
progress.setTitle(activity.getText(R.string.login_title));
|
||||
progress.setMessage(activity.getText(R.string.please_wait));
|
||||
progress.setCancelable(false);
|
||||
progress.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
try {
|
||||
if (!stepOne()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Document certificate = stepTwo();
|
||||
|
||||
Connection.Response step3 = stepThree(certificate);
|
||||
Document dashboardHtml = step3.parse();
|
||||
|
||||
String helloText = dashboardHtml.getElementsByClass("welcome").text();
|
||||
|
||||
if (helloText.equals("Dzień dobry!")) {
|
||||
String cookiesPath = activity.getFilesDir().getPath() + "/cookies.txt";
|
||||
FileOutputStream out = new FileOutputStream(cookiesPath);
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(out);
|
||||
outputStream.writeObject(loginCookies);
|
||||
outputStream.flush();
|
||||
|
||||
userMesage = activity.getString(R.string.login_accepted);
|
||||
} else {
|
||||
userMesage = activity.getString(R.string.login_denied);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
userMesage = e.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean stepOne() throws IOException {
|
||||
Connection.Response initial = Jsoup
|
||||
.connect(urlForStepOne)
|
||||
.data("LoginName", email)
|
||||
.data("Password", password)
|
||||
.method(Connection.Method.POST)
|
||||
.execute();
|
||||
|
||||
loginCookies = initial.cookies();
|
||||
|
||||
CheckPass checkPass = new CheckPass(initial);
|
||||
userMesage = checkPass.start();
|
||||
|
||||
return userMesage.isEmpty();
|
||||
}
|
||||
|
||||
private Document stepTwo() throws IOException {
|
||||
urlForStepTwo = urlForStepTwo.replace("{locationID}", county);
|
||||
|
||||
return Jsoup.connect(urlForStepTwo)
|
||||
.cookies(loginCookies)
|
||||
.get();
|
||||
}
|
||||
|
||||
private Connection.Response stepThree(Document certificate) throws IOException {
|
||||
Elements wresultsInput = certificate.select("input[name=wresult]");
|
||||
String wresults = wresultsInput.attr("value");
|
||||
|
||||
Elements waInput = certificate.select("input[name=wa]");
|
||||
String wa = waInput.attr("value");
|
||||
|
||||
urlForStepThree = urlForStepThree.replace("{locationID}", county);
|
||||
|
||||
Connection.Response res = Jsoup.connect(urlForStepThree)
|
||||
.data("wa", wa)
|
||||
.data("wresult", wresults)
|
||||
.cookies(loginCookies)
|
||||
.followRedirects(true)
|
||||
.method(Connection.Method.POST)
|
||||
.execute();
|
||||
|
||||
loginCookies = res.cookies();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
progress.dismiss();
|
||||
if (!userMesage.isEmpty()) {
|
||||
Toast.makeText(activity, userMesage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
if (userMesage.equals(activity.getString(R.string.login_accepted))) {
|
||||
if (check == 0) {
|
||||
if (createAccount()) {
|
||||
Intent intent = new Intent(activity, DashboardActivity.class);
|
||||
activity.startActivity(intent);
|
||||
} else if (!createAccount()) {
|
||||
Toast.makeText(activity, "Konto już istnieje", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(activity, DashboardActivity.class);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
} else if (check == 1) {
|
||||
Intent intent = new Intent(activity, DashboardActivity.class);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean createAccount() {
|
||||
|
||||
SharedPreferences sharedPreferences = activity.getSharedPreferences("io.github.wulkanowy", Context.MODE_PRIVATE);
|
||||
if (!sharedPreferences.contains(email)) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("wulkanowy",email);
|
||||
editor.putString(email,email);
|
||||
editor.putString("sandi" + email,password);
|
||||
editor.putString("county" + email,county);
|
||||
editor.commit();
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("wulkanowy",email);
|
||||
editor.commit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package io.github.wulkanowy.activity.main;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
@ -14,7 +14,11 @@ import java.util.LinkedHashMap;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
String password;
|
||||
String email;
|
||||
String county;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -49,9 +53,9 @@ public class MainActivity extends Activity {
|
||||
EditText adressEmail = (EditText)findViewById(R.id.emailText);
|
||||
EditText passwordText = (EditText)findViewById(R.id.passwordText);
|
||||
EditText countyText = (EditText)findViewById(R.id.countyText);
|
||||
String password = passwordText.getText().toString();
|
||||
String email = adressEmail.getText().toString();
|
||||
String county = countyText.getText().toString();
|
||||
password = passwordText.getText().toString();
|
||||
email = adressEmail.getText().toString();
|
||||
county = countyText.getText().toString();
|
||||
|
||||
String[] keys = this.getResources().getStringArray(R.array.counties);
|
||||
String[] values = this.getResources().getStringArray(R.array.counties_values);
|
||||
@ -65,10 +69,12 @@ public class MainActivity extends Activity {
|
||||
county = map.get(county);
|
||||
}
|
||||
|
||||
if (!email.isEmpty() && !password.isEmpty() && !county.isEmpty()){
|
||||
new LoginTask(this).execute(email, password, county);
|
||||
} else {
|
||||
if (!email.isEmpty() || !password.isEmpty() || !county.isEmpty()){
|
||||
new Login(email, password, county, this, 0).execute();
|
||||
}
|
||||
else if (password.isEmpty() || email.isEmpty() || county.isEmpty()) {
|
||||
Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,34 @@
|
||||
package io.github.wulkanowy.activity.started;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import io.github.wulkanowy.activity.dashboard.DashboardActivity;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.activity.main.Login;
|
||||
import io.github.wulkanowy.activity.main.MainActivity;
|
||||
|
||||
public class LoadingTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
Context activity;
|
||||
Activity activity;
|
||||
boolean isOnline;
|
||||
String idAccount;
|
||||
String email;
|
||||
String password;
|
||||
String county;
|
||||
|
||||
LoadingTask(Context main) {
|
||||
final boolean SAVE_DATA = true;
|
||||
|
||||
LoadingTask(Activity main) {
|
||||
activity = main;
|
||||
}
|
||||
|
||||
@ -23,15 +39,63 @@ public class LoadingTask extends AsyncTask<Void, Void, Void> {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
isOnline = isOnline();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
|
||||
/* Intent intent = new Intent(activity,MainActivity.class);
|
||||
activity.startActivity(intent); */
|
||||
if (isOnline) {
|
||||
SharedPreferences sharedPreferences = activity.getSharedPreferences("io.github.wulkanowy", Context.MODE_PRIVATE);
|
||||
|
||||
Intent intent = new Intent(activity,MainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
if (SAVE_DATA) {
|
||||
|
||||
if (sharedPreferences.contains("wulkanowy")) {
|
||||
|
||||
idAccount = sharedPreferences.getString("wulkanowy", "");
|
||||
email = sharedPreferences.getString(idAccount, "");
|
||||
password = sharedPreferences.getString("sandi" + email, "");
|
||||
county = sharedPreferences.getString("county" + email, "");
|
||||
|
||||
if (!email.isEmpty() || !password.isEmpty() || !county.isEmpty()) {
|
||||
new Login(email, password, county, activity, 1).execute();
|
||||
} else if (password.isEmpty() || email.isEmpty() || county.isEmpty()) {
|
||||
Toast.makeText(activity, R.string.data_text, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
|
||||
Toast.makeText(activity,"Brak połączenia z internetem",Toast.LENGTH_SHORT ).show();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
try {
|
||||
int timeoutMs = 1500;
|
||||
Socket sock = new Socket();
|
||||
SocketAddress sockaddr = new InetSocketAddress("8.8.8.8", 53);
|
||||
|
||||
sock.connect(sockaddr, timeoutMs);
|
||||
sock.close();
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package io.github.wulkanowy.activity.started;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
public class StartedActivity extends Activity {
|
||||
public class StartedActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
BIN
app/src/main/res/drawable/sample_0.png
Normal file
BIN
app/src/main/res/drawable/sample_0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
@ -11,9 +11,12 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
|
@ -1,4 +1,4 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -9,4 +9,4 @@
|
||||
android:layout_height="match_parent"
|
||||
android:text="Fragment Frekwencja" />
|
||||
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -11,4 +11,4 @@
|
||||
android:text="Fragment Dashboard" />
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -9,4 +9,4 @@
|
||||
android:layout_height="match_parent"
|
||||
android:text="Fragment Plan lekcji" />
|
||||
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -1,17 +1,25 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="io.github.wulkanowy.activity.dashboard.marks.MarksFragment">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/card_recycler_view"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<TextView
|
||||
<RelativeLayout
|
||||
android:id="@+id/loadingPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Fragment Oceny" />
|
||||
android:gravity="center" >
|
||||
|
||||
<ExpandableListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
26
app/src/main/res/layout/row_layout.xml
Normal file
26
app/src/main/res/layout/row_layout.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?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="wrap_content"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_marginLeft="1dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/img_android"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_android"
|
||||
android:gravity="center"
|
||||
android:textColor="#000000"
|
||||
android:background="#FFFFFF"
|
||||
android:textStyle="bold"
|
||||
android:lines="2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
@ -2,5 +2,4 @@
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
|
@ -1,5 +1,3 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user