Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 43ea0b8

Browse files
author
Garret Yoder
committed
Settings button and License dialog
1 parent 9738534 commit 43ea0b8

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ ext {
9696
configurations.all {
9797
//noinspection GroovyAssignabilityCheck
9898
resolutionStrategy.force "com.android.support:recyclerview-v7:${supportLibVersion}"
99+
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
99100
}
100101
dependencies {
101102
compile fileTree(dir: 'libs', include: ['*.jar'])
@@ -154,4 +155,7 @@ dependencies {
154155
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
155156
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
156157
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
158+
159+
//License dialog
160+
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
157161
}

app/src/main/java/subreddit/android/appstore/screens/settings/AboutActivity.java

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,23 @@
1212

1313
import butterknife.BindView;
1414
import butterknife.ButterKnife;
15+
import de.psdev.licensesdialog.LicensesDialog;
16+
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
17+
import de.psdev.licensesdialog.licenses.BSD2ClauseLicense;
18+
import de.psdev.licensesdialog.model.Notice;
19+
import de.psdev.licensesdialog.model.Notices;
1520
import subreddit.android.appstore.BuildConfig;
1621
import subreddit.android.appstore.R;
1722
import subreddit.android.appstore.util.ui.BaseActivity;
1823

19-
public class AboutActivity extends BaseActivity implements View.OnClickListener {
24+
public class AboutActivity extends BaseActivity implements View.OnClickListener, NavigationView.OnNavigationItemSelectedListener {
2025
@BindView(R.id.app_nav) NavigationView app_nav;
2126
@BindView(R.id.contributor_nav) NavigationView contributor_nav;
2227
@BindView(R.id.about_toolbar) Toolbar mToolbar;
2328

2429
protected static final String REDDIT_URL = "https://www.reddit.com";
2530
protected static final String BUG_URL = "https://github.com/d4rken/reddit-android-appstore/issues";
2631

27-
NavigationView.OnNavigationItemSelectedListener aboutListener = new NavigationView.OnNavigationItemSelectedListener() {
28-
@Override
29-
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
30-
switch (item.getItemId()) {
31-
case R.id.reportbug: {
32-
openInChrome(BUG_URL);
33-
break;
34-
}
35-
case R.id.licenses: {
36-
//TODO: open a license dialog
37-
break;
38-
}
39-
}
40-
return false;
41-
}
42-
};
43-
4432
NavigationView.OnNavigationItemSelectedListener contributorListener = new NavigationView.OnNavigationItemSelectedListener() {
4533
@Override
4634
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
@@ -49,6 +37,39 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
4937
}
5038
};
5139

40+
@Override
41+
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
42+
switch (item.getItemId()) {
43+
case R.id.reportbug: {
44+
openInChrome(BUG_URL);
45+
break;
46+
}
47+
case R.id.licenses: {
48+
Notices notices = new Notices();
49+
notices.addNotice(new Notice("Fastscroll","https://github.com/FutureMind/recycler-fast-scroll","Copyright 2015 Future Mind", new ApacheSoftwareLicense20()));
50+
notices.addNotice(new Notice("Glide","https://github.com/bumptech/glide",null, new BSD2ClauseLicense()));
51+
notices.addNotice(new Notice("RxJava","https://github.com/ReactiveX/RxJava","Copyright 2013 Netflix, Inc.", new ApacheSoftwareLicense20()));
52+
notices.addNotice(new Notice("Tomorrow MVP","https://github.com/michal-luszczuk/tomorrow-mvp",null, new ApacheSoftwareLicense20()));
53+
notices.addNotice(new Notice("GSon","https://github.com/google/gson","Copyright 2008 Google Inc.",new ApacheSoftwareLicense20()));
54+
notices.addNotice(new Notice("Dagger","https://github.com/square/dagger","Copyright 2012 Square, Inc.", new ApacheSoftwareLicense20()));
55+
notices.addNotice(new Notice("Butterknife","https://github.com/JakeWharton/butterknife","Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
56+
notices.addNotice(new Notice("Timber","https://github.com/JakeWharton/timber","Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
57+
notices.addNotice(new Notice("Flow Layout","https://github.com/blazsolar/FlowLayout","Copyright 2013 Blaž Šolar",new ApacheSoftwareLicense20()));
58+
notices.addNotice(new Notice("OkHttp", "http://square.github.io/okhttp/", "Copyright 2016 Square, Inc.", new ApacheSoftwareLicense20()));
59+
notices.addNotice(new Notice("Android Support Libraries", "https://github.com/android/platform_frameworks_support", null, new ApacheSoftwareLicense20()));
60+
notices.addNotice(new Notice("LeakCanary","https://github.com/square/leakcanary","Copyright 2015 Square, Inc.", new ApacheSoftwareLicense20()));
61+
notices.addNotice(new Notice("License Dialog","https://github.com/PSDev/LicensesDialog","Copyright 2013-2016 Philip Schiffer", new ApacheSoftwareLicense20()));
62+
new LicensesDialog.Builder(this)
63+
.setNotices(notices)
64+
.setTitle(R.string.licenses)
65+
.build()
66+
.show();
67+
break;
68+
}
69+
}
70+
return false;
71+
}
72+
5273
@Override
5374
protected void onCreate(Bundle savedInstanceState) {
5475
super.onCreate(savedInstanceState);
@@ -60,7 +81,7 @@ protected void onCreate(Bundle savedInstanceState) {
6081
mToolbar.setNavigationOnClickListener(this);
6182

6283
app_nav.getMenu().findItem(0).setTitle(getResources().getString(R.string.version) + " " + BuildConfig.VERSION_NAME);
63-
app_nav.setNavigationItemSelectedListener(aboutListener);
84+
app_nav.setNavigationItemSelectedListener(this);
6485

6586
contributor_nav.setNavigationItemSelectedListener(contributorListener);
6687
}

app/src/main/res/layout/fragment_navigation_layout.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@
5757
<android.support.design.widget.NavigationView
5858
android:id="@+id/navigationview"
5959
android:layout_width="match_parent"
60-
android:layout_height="match_parent"/>
61-
62-
<View
63-
android:layout_width="match_parent"
64-
android:layout_height=".1dp"
65-
android:layout_marginLeft="8dp"
66-
android:layout_marginRight="8dp"
67-
android:background="@color/colorSelector"/>
60+
android:layout_height="match_parent"
61+
android:layout_weight="1"/>
6862

6963
<android.support.design.widget.NavigationView
7064
android:id="@+id/footer_nav"

0 commit comments

Comments
 (0)