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
0e8f6c1d
Commit
0e8f6c1d
authored
Jan 23, 2017
by
Lennart Bader
Browse files
Added more positioning options to CustomViewTarget and added resource strings for showcases
parent
79916cc1
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/mytfg/apps/vplan/fragments/PlanFragment.java
View file @
0e8f6c1d
...
...
@@ -220,19 +220,19 @@ public class PlanFragment extends Fragment {
private
void
showcase
()
{
ShowCaseManager
scm
=
new
ShowCaseManager
(
getContext
());
ToolbarManager
tbm
=
((
MainActivity
)
getActivity
()).
getToolbarManager
();
// scm.show(this, R.id.fab ,"SEARCH", "Such du Spacko!");
ToolbarManager
tbm
=
((
MainActivity
)
getActivity
()).
getToolbarManager
();
Target
tab1
=
new
CustomViewTarget
(
tbm
.
getTabs
(),
0.25
f
,
0.5
f
,
getActivity
()
);
Target
tab2
=
new
CustomViewTarget
(
tbm
.
getTabs
(),
0.75
f
,
0.5
f
,
getActivity
()
);
Target
tab1
=
new
CustomViewTarget
(
tbm
.
getTabs
(),
0.25
,
0.5
);
Target
tab2
=
new
CustomViewTarget
(
tbm
.
getTabs
(),
0.75
,
0.5
);
Target
fab
=
new
ViewTarget
(
R
.
id
.
fab
,
getActivity
());
Target
menu
=
new
CustomViewTarget
(
tbm
.
getToolbar
(),
200
,
0
,
CustomViewTarget
.
Type
.
ABS_MID_R
);
scm
.
createChain
(
this
)
.
add
(
tab1
,
"HEUTE"
,
"Plan für heute"
)
.
add
(
tab2
,
"Morgen"
,
"Plan für morgen"
)
.
add
(
fab
,
"Suche"
,
"Nach Fächern etc suchen"
,
true
)
.
add
(
tab1
,
R
.
string
.
sc_plan_today_title
,
R
.
string
.
sc_plan_today_text
)
.
add
(
tab2
,
R
.
string
.
sc_plan_next_title
,
R
.
string
.
sc_plan_next_text
)
.
add
(
menu
,
R
.
string
.
sc_plan_menu_title
,
R
.
string
.
sc_plan_menu_text
)
.
add
(
fab
,
R
.
string
.
sc_plan_search_title
,
R
.
string
.
sc_plan_search_text
,
true
)
.
showChain
();
}
...
...
app/src/main/java/de/mytfg/apps/vplan/fragments/StartFragment.java
View file @
0e8f6c1d
...
...
@@ -5,6 +5,7 @@ import android.net.Uri;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.TabLayout
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.TextViewCompat
;
import
android.support.v7.widget.CardView
;
...
...
@@ -34,6 +35,7 @@ import de.mytfg.apps.vplan.objects.TfgNewsEntry;
import
de.mytfg.apps.vplan.objects.User
;
import
de.mytfg.apps.vplan.objects.Vplan
;
import
de.mytfg.apps.vplan.toolbar.ToolbarManager
;
import
de.mytfg.apps.vplan.tools.CustomViewTarget
;
import
de.mytfg.apps.vplan.tools.ItemOffsetDecoration
;
import
de.mytfg.apps.vplan.tools.ShowCaseManager
;
...
...
@@ -74,6 +76,12 @@ public class StartFragment extends Fragment {
this
.
displayNews
();
ShowCaseManager
scm
=
new
ShowCaseManager
(
context
);
View
toolbar
=
((
MainActivity
)
getActivity
()).
getToolbarManager
().
getToolbar
();
scm
.
createChain
(
this
)
.
add
(
new
CustomViewTarget
(
toolbar
,
50
,
0
,
CustomViewTarget
.
Type
.
ABS_MID_L
),
R
.
string
.
sc_home_navi_title
,
R
.
string
.
sc_home_navi_text
)
.
showChain
();
return
view
;
}
...
...
app/src/main/java/de/mytfg/apps/vplan/toolbar/ToolbarManager.java
View file @
0e8f6c1d
...
...
@@ -214,4 +214,8 @@ public class ToolbarManager {
drawerLayout
.
addDrawerListener
(
actionBarDrawerToggle
);
actionBarDrawerToggle
.
syncState
();
}
public
Toolbar
getToolbar
()
{
return
this
.
toolbar
;
}
}
app/src/main/java/de/mytfg/apps/vplan/tools/CustomViewTarget.java
View file @
0e8f6c1d
...
...
@@ -13,48 +13,113 @@ import com.github.amlcurran.showcaseview.targets.Target;
*/
public
class
CustomViewTarget
implements
Target
{
public
enum
Type
{
ABS_B_R
,
// Pos from bottom right
ABS_B_L
,
// Pos from bottom left
ABS_T_R
,
// Pos from top right
ABS_T_L
,
// Pos from top left
ABS_MID_L
,
// Pos from Mid Left
ABS_MID_R
,
// Pos from Mid right
ABS_MID_T
,
// Pos from Mid top
ABS_MID_B
,
// Pos from Mid bottom
ABS_MID
,
// Pos from mid
PERC
// Pos from top left (perc)
}
private
final
View
mView
;
private
Type
type
=
Type
.
ABS_MID
;
private
int
xval
;
private
int
yval
;
private
double
percX
;
private
double
percY
;
private
int
offsetX
;
private
int
offsetY
;
private
float
percX
;
private
float
percY
;
private
boolean
perc
;
public
CustomViewTarget
(
View
view
)
{
mView
=
view
;
}
public
CustomViewTarget
(
int
viewId
,
int
offsetX
,
int
offsetY
,
Activity
activity
)
{
this
.
offsetX
=
offsetX
;
this
.
offsetY
=
offsetY
;
mView
=
activity
.
findViewById
(
viewId
);
public
CustomViewTarget
(
int
viewId
,
int
xval
,
int
yval
,
Activity
activity
,
Type
type
)
{
this
(
activity
.
findViewById
(
viewId
),
xval
,
yval
,
type
);
}
public
CustomViewTarget
(
View
view
,
int
xval
,
int
yval
,
Type
type
)
{
mView
=
view
;
this
.
xval
=
xval
;
this
.
yval
=
yval
;
this
.
type
=
type
;
}
public
CustomViewTarget
(
View
view
,
float
percX
,
float
percY
,
Activity
activity
)
{
public
CustomViewTarget
(
View
view
,
double
percX
,
double
percY
)
{
mView
=
view
;
this
.
percX
=
percX
;
this
.
percY
=
percY
;
perc
=
true
;
this
.
type
=
Type
.
PERC
;
}
@Override
public
Point
getPoint
()
{
int
[]
location
=
new
int
[
2
];
mView
.
getLocationInWindow
(
location
);
if
(
perc
)
{
int
midX
=
mView
.
getWidth
()
/
2
;
int
midY
=
mView
.
getHeight
()
/
2
;
int
posX
=
(
int
)
(
percX
*
mView
.
getWidth
());
int
posY
=
(
int
)
(
percY
*
mView
.
getHeight
());
this
.
offsetX
=
posX
-
midX
;
this
.
offsetY
=
posY
-
midY
;
Log
.
d
(
"MX"
,
""
+
midX
);
Log
.
d
(
"OX"
,
""
+
offsetX
);
Log
.
d
(
"PX"
,
""
+
percX
);
// Position of the (corner of the) view
int
posX
=
location
[
0
];
int
posY
=
location
[
1
];
int
x
;
int
y
;
int
midX
=
mView
.
getWidth
()
/
2
;
int
midY
=
mView
.
getHeight
()
/
2
;
switch
(
type
)
{
case
PERC:
x
=
posX
+
(
int
)
(
percX
*
mView
.
getWidth
());
y
=
posY
+
(
int
)
(
percY
*
mView
.
getHeight
());
break
;
case
ABS_MID:
x
=
posX
+
midX
+
xval
;
y
=
posY
+
midY
+
yval
;
break
;
case
ABS_T_L:
x
=
posX
+
xval
;
y
=
posY
+
yval
;
break
;
case
ABS_B_L:
x
=
posX
+
xval
;
y
=
posY
+
mView
.
getHeight
()
-
yval
;
break
;
case
ABS_B_R:
x
=
posX
+
mView
.
getWidth
()
-
xval
;
y
=
posY
+
mView
.
getHeight
()
-
yval
;
break
;
case
ABS_T_R:
x
=
posX
+
mView
.
getWidth
()
-
xval
;
y
=
posY
+
yval
;
break
;
case
ABS_MID_B:
x
=
posX
+
midX
;
y
=
posY
+
mView
.
getHeight
()
-
yval
;
break
;
case
ABS_MID_T:
x
=
posX
+
midX
;
y
=
posY
+
yval
;
break
;
case
ABS_MID_L:
x
=
posX
+
xval
;
y
=
posY
+
midY
;
break
;
case
ABS_MID_R:
x
=
posX
+
mView
.
getWidth
()
-
xval
;
y
=
posY
+
midY
;
break
;
default
:
x
=
midX
;
y
=
midY
;
break
;
}
int
x
=
location
[
0
]
+
mView
.
getWidth
()
/
2
+
offsetX
;
int
y
=
location
[
1
]
+
mView
.
getHeight
()
/
2
+
offsetY
;
return
new
Point
(
x
,
y
);
}
}
app/src/main/java/de/mytfg/apps/vplan/tools/ShowCaseManager.java
View file @
0e8f6c1d
...
...
@@ -2,6 +2,7 @@ package de.mytfg.apps.vplan.tools;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.support.annotation.StringRes
;
import
android.support.v4.app.Fragment
;
import
android.util.Log
;
import
android.view.View
;
...
...
@@ -42,21 +43,21 @@ public class ShowCaseManager {
preferences
=
context
.
getSharedPreferences
(
"showcase"
,
Context
.
MODE_PRIVATE
);
}
public
void
clear
(
String
fragment
)
{
public
void
clear
(
Fragment
fragment
)
{
preferences
.
edit
()
.
remove
(
fragment
)
.
remove
(
fragment
.
getClass
().
toString
()
)
.
apply
();
}
public
void
setDone
(
String
fragment
)
{
public
void
setDone
(
Fragment
fragment
)
{
preferences
.
edit
()
.
putBoolean
(
fragment
,
true
)
.
putBoolean
(
fragment
.
getClass
().
toString
()
,
true
)
.
apply
();
}
public
boolean
isDone
(
String
fragment
)
{
return
preferences
.
getBoolean
(
fragment
,
false
);
public
boolean
isDone
(
Fragment
fragment
)
{
return
preferences
.
getBoolean
(
fragment
.
getClass
().
toString
()
,
false
);
}
public
void
show
(
Fragment
fragment
,
int
viewId
,
String
title
,
String
text
)
{
...
...
@@ -66,7 +67,7 @@ public class ShowCaseManager {
public
void
show
(
Fragment
fragment
,
Target
target
,
String
title
,
String
text
)
{
if
(
isDone
(
fragment
.
getClass
().
toString
()
))
{
if
(
isDone
(
fragment
))
{
return
;
}
...
...
@@ -92,10 +93,7 @@ public class ShowCaseManager {
this
.
fragment
=
fragment
;
this
.
chain
=
new
LinkedList
<>();
if
(
showcaseView
!=
null
)
{
Log
.
d
(
"SC"
,
"Already there"
);
showcaseView
.
hide
();
}
else
{
Log
.
d
(
"SC"
,
"null (nothing shown)"
);
}
return
this
;
}
...
...
@@ -104,6 +102,14 @@ public class ShowCaseManager {
return
add
(
target
,
title
,
text
,
false
);
}
public
ShowCaseManager
add
(
Target
target
,
@StringRes
int
title
,
@StringRes
int
text
)
{
return
add
(
target
,
title
,
text
,
false
);
}
public
ShowCaseManager
add
(
Target
target
,
@StringRes
int
title
,
@StringRes
int
text
,
boolean
buttonLeft
)
{
return
add
(
target
,
context
.
getString
(
title
),
context
.
getString
(
text
),
buttonLeft
);
}
public
ShowCaseManager
add
(
Target
target
,
String
title
,
String
text
,
boolean
buttonLeft
)
{
ChainElement
elem
=
new
ChainElement
();
elem
.
fragment
=
fragment
;
...
...
@@ -116,7 +122,7 @@ public class ShowCaseManager {
}
public
void
showChain
()
{
if
(
isDone
(
fragment
.
getClass
().
toString
()
))
{
if
(
isDone
(
fragment
))
{
return
;
}
...
...
@@ -186,6 +192,8 @@ public class ShowCaseManager {
showcaseView
.
setContentTitle
(
elem
.
title
);
showcaseView
.
setContentText
(
elem
.
text
);
}
else
{
// Do not repeat the tutorial for this fragment
setDone
(
fragment
);
showcaseView
.
hide
();
}
}
...
...
app/src/main/res/values-de/strings.xml
View file @
0e8f6c1d
...
...
@@ -125,4 +125,20 @@
Der Quellcode kann auf Github eingesehen werden.
Die kommerzielle Verbreitung dieser App ist untersagt.
</string>
<!-- SHOWCASE -->
<string
name=
"hide_showcase"
>
Fertig
</string>
<string
name=
"next_showcase"
>
Weiter
</string>
<!-- SHOWCASE TEXTS & TITLES -->
<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_plan_today_title"
>
Aktueller Tag
</string>
<string
name=
"sc_plan_today_text"
>
Plan für den aktuellen Schultag
</string>
<string
name=
"sc_plan_next_title"
>
Nächster Tag
</string>
<string
name=
"sc_plan_next_text"
>
Plan für den nächsten Schultag
</string>
<string
name=
"sc_plan_menu_title"
>
Weitere Informationen
</string>
<string
name=
"sc_plan_menu_text"
>
Erhalten Sie Informationen über abwesende Lehrer, Mitteilungen und den Zeitpunkt der letzten Aktualisierung
</string>
<string
name=
"sc_plan_search_title"
>
Suche
</string>
<string
name=
"sc_plan_search_text"
>
Suchen Sie ach Klassen, Lehrern, Fächern, Stunden, Räumen und mehr
</string>
</resources>
app/src/main/res/values/strings.xml
View file @
0e8f6c1d
...
...
@@ -133,4 +133,16 @@
<!-- SHOWCASE -->
<string
name=
"hide_showcase"
>
Hide
</string>
<string
name=
"next_showcase"
>
Next
</string>
<!-- SHOWCASE TEXTS & TITLES -->
<string
name=
"sc_home_navi_title"
>
Navigation
</string>
<string
name=
"sc_home_navi_text"
>
Click here to open the navigation
</string>
<string
name=
"sc_plan_today_title"
>
Current Day
</string>
<string
name=
"sc_plan_today_text"
>
The plan for the current day
</string>
<string
name=
"sc_plan_next_title"
>
Next Day
</string>
<string
name=
"sc_plan_next_text"
>
The plan for the next day
</string>
<string
name=
"sc_plan_menu_title"
>
More information
</string>
<string
name=
"sc_plan_menu_text"
>
Use these options to see more information like absent teachers, messages and the time of the last update
</string>
<string
name=
"sc_plan_search_title"
>
Search
</string>
<string
name=
"sc_plan_search_text"
>
You can search for classes, teachers, subjects, rooms and more
</string>
</resources>
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