Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mytfg
mytfg-vplan-app
Commits
2a17c0b8
Commit
2a17c0b8
authored
Mar 27, 2017
by
Lennart Bader
Browse files
Added base classes for Firebase
parent
3fe317fd
Changes
13
Hide whitespace changes
Inline
Side-by-side
app/app-release.apk
View file @
2a17c0b8
No preview for this file type
app/build.gradle
View file @
2a17c0b8
...
...
@@ -7,8 +7,8 @@ android {
applicationId
"de.mytfg.apps.mytfg"
minSdkVersion
15
targetSdkVersion
25
versionCode
6
versionName
"0.5.
1
b"
versionCode
7
versionName
"0.5.
2
b"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes
{
...
...
@@ -32,4 +32,5 @@ dependencies {
compile
'com.android.support:cardview-v7:25.2.0'
compile
'com.github.amlcurran.showcaseview:library:5.4.3'
compile
'ch.acra:acra:4.7.0'
compile
'com.google.firebase:firebase-messaging:10.2.0'
}
app/src/main/AndroidManifest.xml
View file @
2a17c0b8
...
...
@@ -27,6 +27,20 @@
</intent-filter>
</activity>
<service
android:name=
".firebase.FbMessagingService"
>
<intent-filter>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
</intent-filter>
</service>
<service
android:name=
".firebase.FbInstanceIdService"
>
<intent-filter>
<action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/>
</intent-filter>
</service>
</application>
</manifest>
app/src/main/java/de/mytfg/apps/mytfg/activities/MainActivity.java
View file @
2a17c0b8
...
...
@@ -63,27 +63,27 @@ public class MainActivity extends AppCompatActivity {
default
:
return
false
;
case
R
.
id
.
mainmenu_news
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
TfgFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
mainmenu_plan
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
PlanFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
mainmenu_vrr
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
VrrFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
mainmenu_account
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
SettingsFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
mainmenu_about
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
AboutFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
mainmenu_feedback
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
FeedbackFragment
(),
R
.
id
.
fragment_container
);
return
true
;
...
...
@@ -97,11 +97,11 @@ public class MainActivity extends AppCompatActivity {
navigationView
.
inflateMenu
(
R
.
menu
.
navigation_menu
);
return
true
;
case
R
.
id
.
mainmenu_links
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
LinksFragment
(),
R
.
id
.
fragment_container
);
return
true
;
case
R
.
id
.
submenu_partners_secretary
:
navi
.
clear
();
//
navi.clear();
navi
.
navigate
(
new
OfficeFragment
(),
R
.
id
.
fragment_container
);
return
true
;
}
...
...
app/src/main/java/de/mytfg/apps/mytfg/firebase/FbApi.java
0 → 100644
View file @
2a17c0b8
package
de.mytfg.apps.mytfg.firebase
;
import
android.content.Context
;
import
org.json.JSONObject
;
import
javax.net.ssl.HttpsURLConnection
;
import
de.mytfg.apps.mytfg.api.ApiCallback
;
import
de.mytfg.apps.mytfg.api.ApiParams
;
import
de.mytfg.apps.mytfg.api.MyTFGApi
;
import
de.mytfg.apps.mytfg.api.SuccessCallback
;
/**
* Used to manage the Firebase Token and access the MyTFG API.
*/
public
class
FbApi
{
private
Context
context
;
public
FbApi
(
Context
context
)
{
this
.
context
=
context
;
}
public
void
sendFbToken
(
String
token
,
final
SuccessCallback
callback
)
{
MyTFGApi
api
=
new
MyTFGApi
(
context
);
ApiParams
params
=
new
ApiParams
();
params
.
addParam
(
"push_token"
,
token
);
params
.
addParam
(
"service"
,
"firebase"
);
api
.
addAuth
(
params
);
api
.
call
(
"api_firebase_token"
,
params
,
new
ApiCallback
()
{
@Override
public
void
callback
(
JSONObject
result
,
int
responseCode
)
{
if
(
responseCode
==
HttpsURLConnection
.
HTTP_OK
)
{
callback
.
callback
(
true
);
}
else
{
callback
.
callback
(
false
);
}
}
});
}
}
app/src/main/java/de/mytfg/apps/mytfg/firebase/FbInstanceIdService.java
0 → 100644
View file @
2a17c0b8
package
de.mytfg.apps.mytfg.firebase
;
import
android.util.Log
;
import
com.google.firebase.iid.FirebaseInstanceId
;
import
com.google.firebase.iid.FirebaseInstanceIdService
;
import
de.mytfg.apps.mytfg.api.SuccessCallback
;
public
class
FbInstanceIdService
extends
FirebaseInstanceIdService
{
@Override
public
void
onTokenRefresh
()
{
String
refreshedToken
=
FirebaseInstanceId
.
getInstance
().
getToken
();
Log
.
d
(
"FB-ID"
,
"Refreshed token: "
+
refreshedToken
);
FbApi
fbApi
=
new
FbApi
(
getApplicationContext
());
fbApi
.
sendFbToken
(
refreshedToken
,
new
SuccessCallback
()
{
@Override
public
void
callback
(
boolean
success
)
{
Log
.
d
(
"FB-ID-Server"
,
""
+
success
);
}
});
}
}
app/src/main/java/de/mytfg/apps/mytfg/firebase/FbMessagingService.java
0 → 100644
View file @
2a17c0b8
package
de.mytfg.apps.mytfg.firebase
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
public
class
FbMessagingService
extends
FirebaseMessagingService
{
}
app/src/main/java/de/mytfg/apps/mytfg/fragments/PlanFragment.java
View file @
2a17c0b8
...
...
@@ -196,7 +196,7 @@ public class PlanFragment extends AuthenticationFragment {
ViewPager
viewPager
=
(
ViewPager
)
view
.
findViewById
(
R
.
id
.
plan_pager
);
// Create Pager elements if not existent
if
(
today
==
null
||
tomorrow
==
null
)
{
if
(
today
==
null
||
tomorrow
==
null
||
true
)
{
todayPlan
=
new
Vplan
(
context
,
"today"
);
tomorrowPlan
=
new
Vplan
(
context
,
"tomorrow"
);
...
...
app/src/main/java/de/mytfg/apps/mytfg/fragments/TfgFragment.java
View file @
2a17c0b8
...
...
@@ -63,7 +63,7 @@ public class TfgFragment extends AuthenticationFragment {
super
.
onResume
();
ViewPager
viewPager
=
(
ViewPager
)
view
.
findViewById
(
R
.
id
.
tfg_pager
);
// Create Pager elements if not existent
if
(
newsLogic
==
null
||
eventsLogic
==
null
)
{
if
(
newsLogic
==
null
||
eventsLogic
==
null
||
true
)
{
news
=
new
TfgNews
(
context
);
newsLogic
=
new
NewsLogic
(
news
,
context
);
...
...
app/src/main/java/de/mytfg/apps/mytfg/navigation/Navigation.java
View file @
2a17c0b8
...
...
@@ -27,6 +27,8 @@ import de.mytfg.apps.mytfg.tools.CopyDrawableImageTransform;
public
class
Navigation
{
private
Context
context
;
private
boolean
finishOnBack
=
false
;
public
Navigation
(
Context
context
)
{
this
.
context
=
context
;
}
...
...
@@ -39,6 +41,8 @@ public class Navigation {
return;
}*/
finishOnBack
=
false
;
MyTFGApi
api
=
new
MyTFGApi
(
context
);
if
(
fragment
.
needsAuthentication
()
&&
!
api
.
isLoggedIn
())
{
navigate
(
new
LoginFragment
(),
container
);
...
...
@@ -108,7 +112,12 @@ public class Navigation {
if
(
fragmentManager
.
getBackStackEntryCount
()
>
1
)
{
fragmentManager
.
popBackStack
();
}
else
{
((
MainActivity
)
context
).
finish
();
if
(
finishOnBack
)
{
((
MainActivity
)
context
).
finish
();
}
else
{
finishOnBack
=
true
;
snackbar
(
context
.
getString
(
R
.
string
.
next_close
));
}
}
}
...
...
app/src/main/java/de/mytfg/apps/mytfg/objects/Vplan.java
View file @
2a17c0b8
...
...
@@ -151,7 +151,7 @@ public class Vplan extends MytfgObject {
timestamp
=
result
.
optLong
(
"api_time"
,
System
.
currentTimeMillis
());
loaded
=
true
;
}
catch
(
JSONException
ex
)
{
ex
.
printStackTrace
();
//
ex.printStackTrace();
return
false
;
}
return
true
;
...
...
app/src/main/res/values-de/strings.xml
View file @
2a17c0b8
...
...
@@ -8,6 +8,7 @@
<string
name=
"please_wait"
>
Bitte warten
</string>
<string
name=
"login_process"
>
Sie werden eingeloggt
…
</string>
<string
name=
"login_empty"
>
Bitte Nutzernamen und Passwort angeben.
</string>
<string
name=
"next_close"
>
Drücken Sie den Zurück-Button zum Schließen erneut
</string>
<!-- VPlan Menu -->
<string
name=
"menutitle_home"
>
Start
</string>
...
...
@@ -218,7 +219,7 @@
<string
name=
"sc_home_navi_title"
>
Navigation
</string>
<string
name=
"sc_home_navi_text"
>
Klicken Sie zum Öffnen der Navigation hier
</string>
<string
name=
"sc_home_news"
>
Aktuelles vom TFG
</string>
<string
name=
"sc_home_news_text"
>
Aktuelle
s
News vom TFG - Ankündigungen, Projekte und mehr!
</string>
<string
name=
"sc_home_news_text"
>
Aktuelle News vom TFG - Ankündigungen, Projekte und mehr!
</string>
<string
name=
"sc_home_events"
>
TFG Kalender
</string>
<string
name=
"sc_home_events_text"
>
Aktuelle Events am TFG
</string>
<string
name=
"sc_plan_today_title"
>
Aktueller Tag
</string>
...
...
app/src/main/res/values/strings.xml
View file @
2a17c0b8
...
...
@@ -8,6 +8,8 @@
<string
name=
"login_process"
>
Logging in
…
</string>
<string
name=
"login_empty"
>
Please enter username and password
</string>
<string
name=
"next_close"
>
Press back again to close the App
</string>
<!-- Main Menu -->
<string
name=
"menutitle_home"
>
Home
</string>
<string
name=
"menutitle_news"
>
News
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment