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

Commit

Permalink
Settings button and License dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Garret Yoder committed Sep 10, 2016
1 parent 9738534 commit 43ea0b8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ ext {
configurations.all {
//noinspection GroovyAssignabilityCheck
resolutionStrategy.force "com.android.support:recyclerview-v7:${supportLibVersion}"
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
Expand Down Expand Up @@ -154,4 +155,7 @@ dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'

//License dialog
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,23 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import de.psdev.licensesdialog.LicensesDialog;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD2ClauseLicense;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
import subreddit.android.appstore.BuildConfig;
import subreddit.android.appstore.R;
import subreddit.android.appstore.util.ui.BaseActivity;

public class AboutActivity extends BaseActivity implements View.OnClickListener {
public class AboutActivity extends BaseActivity implements View.OnClickListener, NavigationView.OnNavigationItemSelectedListener {
@BindView(R.id.app_nav) NavigationView app_nav;
@BindView(R.id.contributor_nav) NavigationView contributor_nav;
@BindView(R.id.about_toolbar) Toolbar mToolbar;

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

NavigationView.OnNavigationItemSelectedListener aboutListener = new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.reportbug: {
openInChrome(BUG_URL);
break;
}
case R.id.licenses: {
//TODO: open a license dialog
break;
}
}
return false;
}
};

NavigationView.OnNavigationItemSelectedListener contributorListener = new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Expand All @@ -49,6 +37,39 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
}
};

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.reportbug: {
openInChrome(BUG_URL);
break;
}
case R.id.licenses: {
Notices notices = new Notices();
notices.addNotice(new Notice("Fastscroll","https://github.com/FutureMind/recycler-fast-scroll","Copyright 2015 Future Mind", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Glide","https://github.com/bumptech/glide",null, new BSD2ClauseLicense()));
notices.addNotice(new Notice("RxJava","https://github.com/ReactiveX/RxJava","Copyright 2013 Netflix, Inc.", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Tomorrow MVP","https://github.com/michal-luszczuk/tomorrow-mvp",null, new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("GSon","https://github.com/google/gson","Copyright 2008 Google Inc.",new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Dagger","https://github.com/square/dagger","Copyright 2012 Square, Inc.", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Butterknife","https://github.com/JakeWharton/butterknife","Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Timber","https://github.com/JakeWharton/timber","Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Flow Layout","https://github.com/blazsolar/FlowLayout","Copyright 2013 Blaž Šolar",new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("OkHttp", "http://square.github.io/okhttp/", "Copyright 2016 Square, Inc.", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Android Support Libraries", "https://github.com/android/platform_frameworks_support", null, new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("LeakCanary","https://github.com/square/leakcanary","Copyright 2015 Square, Inc.", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("License Dialog","https://github.com/PSDev/LicensesDialog","Copyright 2013-2016 Philip Schiffer", new ApacheSoftwareLicense20()));
new LicensesDialog.Builder(this)
.setNotices(notices)
.setTitle(R.string.licenses)
.build()
.show();
break;
}
}
return false;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -60,7 +81,7 @@ protected void onCreate(Bundle savedInstanceState) {
mToolbar.setNavigationOnClickListener(this);

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

contributor_nav.setNavigationItemSelectedListener(contributorListener);
}
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/res/layout/fragment_navigation_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@
<android.support.design.widget.NavigationView
android:id="@+id/navigationview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<View
android:layout_width="match_parent"
android:layout_height=".1dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@color/colorSelector"/>
android:layout_height="match_parent"
android:layout_weight="1"/>

<android.support.design.widget.NavigationView
android:id="@+id/footer_nav"
Expand Down

0 comments on commit 43ea0b8

Please sign in to comment.