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
e74f61d6
Commit
e74f61d6
authored
Jan 22, 2017
by
Lennart Bader
Browse files
Added options: Landing Page for startup, VPlan display option, Link behavior for news
parent
67e916eb
Changes
12
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/mytfg/apps/vplan/activities/MainActivity.java
View file @
e74f61d6
package
de.mytfg.apps.vplan.activities
;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.FragmentContainer
;
import
android.support.v7.app.AppCompatActivity
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
...
...
@@ -8,9 +9,12 @@ import android.support.annotation.Nullable;
import
android.support.design.widget.NavigationView
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.DrawerLayout
;
import
android.util.Log
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
java.util.Set
;
import
de.mytfg.apps.vplan.R
;
import
de.mytfg.apps.vplan.api.MyTFGApi
;
import
de.mytfg.apps.vplan.fragments.AboutFragment
;
...
...
@@ -20,6 +24,7 @@ import de.mytfg.apps.vplan.fragments.PlanFragment;
import
de.mytfg.apps.vplan.fragments.StartFragment
;
import
de.mytfg.apps.vplan.navigation.Navigation
;
import
de.mytfg.apps.vplan.toolbar.ToolbarManager
;
import
de.mytfg.apps.vplan.tools.Settings
;
public
class
MainActivity
extends
AppCompatActivity
{
private
NavigationView
navigationView
;
...
...
@@ -92,7 +97,21 @@ public class MainActivity extends AppCompatActivity {
fragment
=
getSupportFragmentManager
().
getFragment
(
savedInstanceState
,
"fragmentInstanceSaved"
);
}
else
{
fragment
=
new
PlanFragment
();
// Read Landing Page from settings
Settings
settings
=
new
Settings
(
context
);
int
page
=
settings
.
getInt
(
"landing_page"
);
String
[]
fragmentNames
=
getResources
().
getStringArray
(
R
.
array
.
settings_opt_landing_page_fragments
);
String
fragName
=
"StartFragment"
;
if
(
page
>=
0
&&
page
<
fragmentNames
.
length
)
{
fragName
=
fragmentNames
[
page
];
}
try
{
fragName
=
"de.mytfg.apps.vplan.fragments."
+
fragName
;
Class
c
=
Class
.
forName
(
fragName
);
fragment
=
(
Fragment
)
c
.
newInstance
();
}
catch
(
Exception
ex
)
{
fragment
=
new
StartFragment
();
}
}
}
navi
.
navigate
(
fragment
,
R
.
id
.
fragment_container
);
...
...
app/src/main/java/de/mytfg/apps/vplan/adapters/NewsEntryHolder.java
View file @
e74f61d6
...
...
@@ -9,9 +9,12 @@ import android.text.Html;
import
android.view.View
;
import
android.widget.TextView
;
import
java.util.Set
;
import
de.mytfg.apps.vplan.R
;
import
de.mytfg.apps.vplan.objects.TfgNewsEntry
;
import
de.mytfg.apps.vplan.objects.VplanEntry
;
import
de.mytfg.apps.vplan.tools.Settings
;
import
static
android
.
view
.
View
.
GONE
;
...
...
@@ -38,7 +41,8 @@ public class NewsEntryHolder extends RecyclerView.ViewHolder {
date
.
setText
(
entry
.
getDateString
());
summary
.
setText
(
Html
.
fromHtml
(
entry
.
getSummary
()));
final
String
link
=
entry
.
getLink
();
if
(!
link
.
isEmpty
())
{
Settings
settings
=
new
Settings
(
context
);
if
(!
link
.
isEmpty
()
&&
settings
.
getBool
(
"news_browser"
))
{
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
...
...
app/src/main/java/de/mytfg/apps/vplan/adapters/PlanEntryHolder.java
View file @
e74f61d6
...
...
@@ -11,6 +11,7 @@ import android.widget.TextView;
import
de.mytfg.apps.vplan.R
;
import
de.mytfg.apps.vplan.objects.VplanEntry
;
import
de.mytfg.apps.vplan.tools.Settings
;
import
static
android
.
view
.
View
.
GONE
;
...
...
@@ -40,14 +41,18 @@ public class PlanEntryHolder extends RecyclerView.ViewHolder {
}
public
void
update
(
VplanEntry
planEntry
)
{
Settings
settings
=
new
Settings
(
context
);
//titleView.setText(baseObject.getName());
lesson
.
setText
(
planEntry
.
getLesson
());
plan
.
setText
(
planEntry
.
getPlan
());
String
planText
=
settings
.
getBool
(
"plan_fulltext"
)
?
planEntry
.
getPlanText
()
:
planEntry
.
getPlan
();
String
substText
=
settings
.
getBool
(
"plan_fulltext"
)
?
planEntry
.
getSubstText
()
:
planEntry
.
getSubstitution
();
plan
.
setText
(
planText
);
if
(
planEntry
.
getSubstitution
().
isEmpty
())
{
substHeader
.
setVisibility
(
GONE
);
subst
.
setVisibility
(
GONE
);
}
else
{
subst
.
setText
(
planEntry
.
getSubstitution
()
);
subst
.
setText
(
substText
);
subst
.
setVisibility
(
View
.
VISIBLE
);
substHeader
.
setVisibility
(
View
.
VISIBLE
);
}
...
...
app/src/main/java/de/mytfg/apps/vplan/fragments/SettingsFragment.java
View file @
e74f61d6
...
...
@@ -12,12 +12,17 @@ import android.support.v4.app.Fragment;
import
android.support.v7.app.AlertDialog
;
import
android.text.Html
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.CompoundButton
;
import
android.widget.Spinner
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
org.json.JSONArray
;
...
...
@@ -35,6 +40,7 @@ import de.mytfg.apps.vplan.api.ApiCallback;
import
de.mytfg.apps.vplan.api.ApiParams
;
import
de.mytfg.apps.vplan.api.MyTFGApi
;
import
de.mytfg.apps.vplan.objects.User
;
import
de.mytfg.apps.vplan.tools.Settings
;
public
class
SettingsFragment
extends
Fragment
{
private
View
view
;
...
...
@@ -95,6 +101,8 @@ public class SettingsFragment extends Fragment {
}
});
updateSettings
();
updateAdditionalClasses
();
return
view
;
...
...
@@ -267,4 +275,40 @@ public class SettingsFragment extends Fragment {
}
});
}
private
void
updateSettings
()
{
Switch
fulltext
=
(
Switch
)
view
.
findViewById
(
R
.
id
.
switch_fulltext
);
Switch
newsbrowser
=
(
Switch
)
view
.
findViewById
(
R
.
id
.
switch_news_browser
);
Spinner
landing
=
(
Spinner
)
view
.
findViewById
(
R
.
id
.
spinner_landing
);
final
Settings
settings
=
new
Settings
(
context
);
fulltext
.
setChecked
(
settings
.
getBool
(
"plan_fulltext"
));
fulltext
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
settings
.
save
(
"plan_fulltext"
,
b
);
}
});
newsbrowser
.
setChecked
(
settings
.
getBool
(
"news_browser"
));
newsbrowser
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
settings
.
save
(
"news_browser"
,
b
);
}
});
landing
.
setSelection
(
settings
.
getInt
(
"landing_page"
));
landing
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
adapterView
,
View
view
,
int
i
,
long
l
)
{
settings
.
save
(
"landing_page"
,
i
);
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
adapterView
)
{
}
});
}
}
app/src/main/java/de/mytfg/apps/vplan/tools/Settings.java
0 → 100644
View file @
e74f61d6
package
de.mytfg.apps.vplan.tools
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.util.Log
;
import
java.net.ContentHandler
;
import
java.util.Set
;
/**
* Manages storage of settings for easy access
*/
public
class
Settings
{
private
Context
context
;
private
SharedPreferences
preferences
;
public
Settings
(
Context
context
)
{
this
.
context
=
context
;
preferences
=
context
.
getSharedPreferences
(
"settings"
,
Context
.
MODE_PRIVATE
);
}
public
void
save
(
String
option
,
String
value
)
{
preferences
.
edit
()
.
putString
(
option
,
value
)
.
apply
();
}
public
void
save
(
String
option
,
boolean
value
)
{
preferences
.
edit
()
.
putBoolean
(
option
,
value
)
.
apply
();
}
public
void
save
(
String
option
,
int
value
)
{
preferences
.
edit
()
.
putInt
(
option
,
value
)
.
apply
();
Log
.
d
(
"SAVE"
,
option
+
": "
+
value
);
}
public
boolean
getBool
(
String
option
)
{
return
preferences
.
getBoolean
(
option
,
false
);
}
public
String
getString
(
String
option
)
{
return
preferences
.
getString
(
option
,
""
);
}
public
int
getInt
(
String
option
)
{
return
preferences
.
getInt
(
option
,
0
);
}
}
app/src/main/res/layout/fragment_settings.xml
View file @
e74f61d6
<android.support.v4.widget.NestedScrollView
<android.support.v4.widget.NestedScrollView
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
...
...
@@ -92,6 +92,64 @@
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:padding=
"@dimen/cardview_spacing"
android:layout_marginBottom=
"@dimen/defaultPadding"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:padding=
"@dimen/cardview_spacing"
android:background=
"@color/colorPrimaryLight"
>
<TextView
android:textSize=
"@dimen/textTitle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/settings_general_title"
android:id=
"@+id/settings_general"
/>
<ListView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</ListView>
<Switch
android:text=
"@string/settings_opt_fulltext"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"10dp"
android:id=
"@+id/switch_fulltext"
/>
<Switch
android:text=
"@string/settings_opt_newslink"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"10dp"
android:id=
"@+id/switch_news_browser"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textColor=
"@color/colorPrimaryText"
android:textSize=
"@dimen/textSmallTitle"
android:text=
"@string/settings_opt_landing_page"
/>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:entries=
"@array/settings_opt_landing_page_entries"
android:id=
"@+id/spinner_landing"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
app/src/main/res/layout/tabs.xml
View file @
e74f61d6
...
...
@@ -7,7 +7,7 @@
android:theme=
"@style/AppTheme"
android:background=
"@color/colorPrimaryDark"
app:tabTextAppearance=
"@style/AppTheme.TabTextAppearance"
app:tabTextColor=
"@color/color
Se
con
daryText
"
app:tabTextColor=
"@color/color
I
con
sDark
"
app:tabSelectedTextColor=
"@color/colorIcons"
app:tabIndicatorColor=
"@color/colorAccent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
...
...
app/src/main/res/values-de/strings.xml
View file @
e74f61d6
...
...
@@ -101,6 +101,12 @@
<string
name=
"account_accept"
>
Speichern
</string>
<string
name=
"account_discard"
>
Verwerfen
</string>
<!-- SETTING -->
<string
name=
"settings_general_title"
>
Einstellungen
</string>
<string
name=
"settings_opt_newslink"
>
News im Browser öffnen
</string>
<string
name=
"settings_opt_fulltext"
>
VPlan als Volltext anzeigen
</string>
<string
name=
"settings_opt_landing_page"
>
Standardansicht
</string>
<!-- USER -->
<string
name=
"user_rights_norights"
>
Nicht eingeloggt
</string>
...
...
app/src/main/res/values-v21/styles.xml
View file @
e74f61d6
...
...
@@ -5,6 +5,8 @@
<item
name=
"android:windowTranslucentStatus"
>
true
</item>
<item
name=
"android:colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"android:colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"android:textColorTertiary"
>
@color/colorSecondaryText
</item>
<item
name=
"android:textColorSecondary"
>
@color/colorSecondaryText
</item>
<item
name=
"android:colorAccent"
>
@color/colorAccent
</item>
<item
name=
"android:colorControlNormal"
>
@color/colorPrimaryDark
</item>
<item
name=
"android:colorControlActivated"
>
@color/colorAccent
</item>
...
...
@@ -16,4 +18,9 @@
<item
name=
"android:indeterminateTint"
>
@color/colorAccent
</item>
<item
name=
"android:progressBackgroundTint"
>
@color/colorAccent
</item>
</style>
<style
name=
"AppTheme.Switch"
parent=
"Base.Widget.AppCompat.CompoundButton.Switch"
>
<item
name=
"android:layout_marginBottom"
>
10dp
</item>
<item
name=
"android:colorControlActivated"
>
@color/colorAccent
</item>
</style>
</resources>
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
e74f61d6
...
...
@@ -5,8 +5,9 @@
<color
name=
"colorPrimaryLight"
>
#C5CAE9
</color>
<color
name=
"colorSecondaryLight"
>
#DFE2F4
</color>
<color
name=
"colorIcons"
>
#FFFFFF
</color>
<color
name=
"colorPrimaryText"
>
#212121
</color>
<color
name=
"colorSecondaryText"
>
#DDDDDD
</color>
<color
name=
"colorIconsDark"
>
#dddddd
</color>
<color
name=
"colorPrimaryText"
>
#000000
</color>
<color
name=
"colorSecondaryText"
>
#333333
</color>
<color
name=
"colorDivider"
>
#B6B6B6
</color>
<color
name=
"colorAccent"
>
#FF7400
</color>
...
...
app/src/main/res/values/strings.xml
View file @
e74f61d6
...
...
@@ -100,6 +100,22 @@
<string
name=
"account_accept"
>
OK
</string>
<string
name=
"account_discard"
>
Discard
</string>
<!-- SETTING -->
<string
name=
"settings_general_title"
>
Settings
</string>
<string
name=
"settings_opt_newslink"
>
Open News in Browser
</string>
<string
name=
"settings_opt_fulltext"
>
Show Plan as Fulltext
</string>
<string
name=
"settings_opt_landing_page"
>
Default Page
</string>
<string-array
name=
"settings_opt_landing_page_entries"
>
<item>
@string/menutitle_home
</item>
<item>
@string/menutitle_plan
</item>
<item>
@string/menutitle_about
</item>
</string-array>
<string-array
name=
"settings_opt_landing_page_fragments"
>
<item>
StartFragment
</item>
<item>
PlanFragment
</item>
<item>
AboutFragment
</item>
</string-array>
<!-- USER -->
<string
name=
"user_rights_norights"
>
Not logged in
</string>
<string
name=
"user_rights_pupil"
>
Pupil
</string>
...
...
app/src/main/res/values/styles.xml
View file @
e74f61d6
...
...
@@ -54,5 +54,4 @@
<item
name=
"android:textColor"
>
@color/colorIcons
</item>
<item
name=
"android:textAllCaps"
>
false
</item>
</style>
</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