Compare commits
No commits in common. "master" and "1.0" have entirely different histories.
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion '26.0.2'
|
||||
buildToolsVersion "26.0.0"
|
||||
defaultConfig {
|
||||
applicationId "de.tysox.bs_elmshorn"
|
||||
minSdkVersion 16
|
||||
|
@ -2,8 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.tysox.bs_elmshorn">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
Binary file not shown.
@ -1,11 +1,7 @@
|
||||
package de.tysox.bs_elmshorn;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@ -16,18 +12,11 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static MainActivity instance;
|
||||
private int currentWeek;
|
||||
|
||||
/**
|
||||
* The {@link android.support.v4.view.PagerAdapter} that will provide
|
||||
@ -50,21 +39,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_main);
|
||||
instance = this;
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
currentWeek = calendar.get(Calendar.WEEK_OF_YEAR);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
// Create the adapter that will return a fragment for each of the three
|
||||
// primary sections of the activity.
|
||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
mViewPager = findViewById(R.id.container);
|
||||
mViewPager = (ViewPager) findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
@ -77,50 +62,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final TextView refresh = findViewById(R.id.refresh);
|
||||
final TextView left = findViewById(R.id.left);
|
||||
final TextView right = findViewById(R.id.right);
|
||||
Typeface font = Typeface.createFromAsset(getBaseContext().getAssets(), "font/fontawesome.ttf");
|
||||
refresh.setTypeface(font);
|
||||
right.setTypeface(font);
|
||||
left.setTypeface(font);
|
||||
refresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebView webView = findViewById(R.id.timetable);
|
||||
webView.reload();
|
||||
}
|
||||
});
|
||||
right.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebView webView = findViewById(R.id.timetable);
|
||||
currentWeek++;
|
||||
webView.loadUrl("https://tysox.de/webapps/timetable.php?week="+ currentWeek);
|
||||
|
||||
}
|
||||
});
|
||||
left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
WebView webView = findViewById(R.id.timetable);
|
||||
currentWeek--;
|
||||
webView.loadUrl("https://tysox.de/webapps/timetable.php?week="+ currentWeek);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -132,9 +78,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
/*if (id == R.id.action_settings) {
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@ -150,9 +97,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
final TextView refresh = MainActivity.getInstance().findViewById(R.id.refresh);
|
||||
final TextView left = MainActivity.getInstance().findViewById(R.id.left);
|
||||
final TextView right = MainActivity.getInstance().findViewById(R.id.right);
|
||||
switch (position) {
|
||||
case 0:
|
||||
Tab1 tab1 = new Tab1();
|
||||
@ -175,12 +119,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNetworkAvailable() {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( CONNECTIVITY_SERVICE );
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
|
||||
public static MainActivity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
@ -1,18 +1,13 @@
|
||||
package de.tysox.bs_elmshorn;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@ -31,71 +26,26 @@ public class Tab1 extends Fragment {
|
||||
View rootView = inflater.inflate(R.layout.tab1, container, false);
|
||||
|
||||
Handler handler = new Handler();
|
||||
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WebView webView= (WebView) MainActivity.getInstance().findViewById(R.id.timetable);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
|
||||
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
|
||||
webView.getSettings().setAppCachePath( MainActivity.getInstance().getApplicationContext().getCacheDir().getAbsolutePath() );
|
||||
webView.getSettings().setAllowFileAccess( true );
|
||||
webView.getSettings().setAppCacheEnabled( true );
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setVerticalScrollBarEnabled(false);
|
||||
webView.setHorizontalScrollBarEnabled(false);
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
|
||||
if(!MainActivity.getInstance().isNetworkAvailable()) {
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
||||
}
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
currentWeek = calendar.get(Calendar.WEEK_OF_YEAR);
|
||||
|
||||
webView.loadUrl("https://tysox.de/webapps/timetable.php?week="+ currentWeek);
|
||||
// s5 mini 119 opx 170 xperia 113
|
||||
webView.setPadding(0,0,0,0);
|
||||
webView.setInitialScale(getScale());
|
||||
webView.loadUrl("http://www.bs-elmshorn.de/Stundenplan/Schueler/"+currentWeek+"/c/c00018.htm");
|
||||
// s5 mini 119 opx 170
|
||||
webView.setInitialScale(119);
|
||||
}
|
||||
},101);
|
||||
},100);
|
||||
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private int getScale(){
|
||||
Display display = ((WindowManager) MainActivity.getInstance().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||
int width = display.getWidth();
|
||||
Double val = new Double(width)/new Double(690);
|
||||
val = val * 100d;
|
||||
return val.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final TextView refresh = MainActivity.getInstance().findViewById(R.id.refresh);
|
||||
final TextView left = MainActivity.getInstance().findViewById(R.id.left);
|
||||
final TextView right = MainActivity.getInstance().findViewById(R.id.right);
|
||||
if (isVisibleToUser) {
|
||||
try {
|
||||
refresh.setVisibility(View.VISIBLE);
|
||||
left.setVisibility(View.VISIBLE);
|
||||
right.setVisibility(View.VISIBLE);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
refresh.setVisibility(View.INVISIBLE);
|
||||
left.setVisibility(View.INVISIBLE);
|
||||
right.setVisibility(View.INVISIBLE);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by Jan on 16.09.2017.
|
||||
*/
|
||||
@ -21,30 +22,23 @@ public class Tab2 extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.tab2, container, false);
|
||||
Handler handler = new Handler();
|
||||
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WebView webView= (WebView) MainActivity.getInstance().findViewById(R.id.vt1);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
|
||||
webView.getSettings().setAppCachePath( MainActivity.getInstance().getApplicationContext().getCacheDir().getAbsolutePath() );
|
||||
webView.getSettings().setAllowFileAccess( true );
|
||||
webView.getSettings().setAppCacheEnabled( true );
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setVerticalScrollBarEnabled(false);
|
||||
webView.setHorizontalScrollBarEnabled(false);
|
||||
|
||||
if(!MainActivity.getInstance().isNetworkAvailable()) {
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
||||
}
|
||||
|
||||
|
||||
webView.loadUrl("http://www.bs-elmshorn.de/Stundenplan/DSB/f1/subst_001.htm");
|
||||
// s5 mini 100 opx 150
|
||||
webView.setInitialScale(150);
|
||||
}
|
||||
},100);
|
||||
|
||||
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
@ -20,28 +19,18 @@ public class Tab3 extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.tab3, container, false);
|
||||
Handler handler = new Handler();
|
||||
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
WebView webView= MainActivity.getInstance().findViewById(R.id.vt2);
|
||||
WebView webView= (WebView) MainActivity.getInstance().findViewById(R.id.vt2);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
|
||||
webView.getSettings().setAppCachePath( MainActivity.getInstance().getApplicationContext().getCacheDir().getAbsolutePath() );
|
||||
webView.getSettings().setAllowFileAccess( true );
|
||||
webView.getSettings().setAppCacheEnabled( true );
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setVerticalScrollBarEnabled(false);
|
||||
webView.setHorizontalScrollBarEnabled(false);
|
||||
|
||||
if(!MainActivity.getInstance().isNetworkAvailable()) {
|
||||
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
||||
}
|
||||
|
||||
webView.loadUrl("http://www.bs-elmshorn.de/Stundenplan/DSB/f1/subst_002.htm");
|
||||
// s5 mini 100 opx 150
|
||||
webView.setInitialScale(150);
|
||||
|
@ -8,14 +8,8 @@
|
||||
|
||||
<WebView
|
||||
android:id="@+id/timetable"
|
||||
android:layout_width="385dp"
|
||||
android:layout_height="576dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_width="344dp"
|
||||
android:layout_height="495dp"
|
||||
tools:layout_editor_absoluteX="8dp"
|
||||
tools:layout_editor_absoluteY="8dp" />
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -8,14 +8,8 @@
|
||||
|
||||
<WebView
|
||||
android:id="@+id/vt1"
|
||||
android:layout_width="385dp"
|
||||
android:layout_height="576dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_width="344dp"
|
||||
android:layout_height="495dp"
|
||||
tools:layout_editor_absoluteX="8dp"
|
||||
tools:layout_editor_absoluteY="8dp" />
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -6,17 +6,24 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context="de.tysox.bs_elmshorn.Tab3">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/section_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
|
||||
tools:layout_constraintLeft_creator="1"
|
||||
tools:layout_constraintTop_creator="1" />
|
||||
|
||||
<WebView
|
||||
android:id="@+id/vt2"
|
||||
android:layout_width="385dp"
|
||||
android:layout_height="576dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_width="344dp"
|
||||
android:layout_height="495dp"
|
||||
tools:layout_editor_absoluteX="8dp"
|
||||
tools:layout_editor_absoluteY="8dp" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -1,26 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="de.tysox.bs_elmshorn.MainActivity">
|
||||
<item
|
||||
android:id="@+id/refresh"
|
||||
android:actionViewClass="android.widget.TextView"
|
||||
android:title="@string/fa_refresh"
|
||||
app:showAsAction="always"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/left"
|
||||
android:actionViewClass="android.widget.TextView"
|
||||
android:title="@string/fa_left"
|
||||
app:showAsAction="always"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/right"
|
||||
android:actionViewClass="android.widget.TextView"
|
||||
android:title="@string/fa_right"
|
||||
app:showAsAction="always" />
|
||||
|
||||
|
||||
</menu>
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
@ -4,7 +4,4 @@
|
||||
<string name="tab_text_2">Vertretung 1</string>
|
||||
<string name="tab_text_3">Vertretung 2</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="fa_refresh"></string>
|
||||
<string name="fa_left"></string>
|
||||
<string name="fa_right"></string>
|
||||
</resources>
|
||||
|
@ -7,7 +7,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
Loading…
x
Reference in New Issue
Block a user