Skip to content

Commit

Permalink
Added reports navdrawer entry and divided visibility options into sub…
Browse files Browse the repository at this point in the history
…categories as suggested by gsantner

Merge PR #110 from DfA/divide-visibility-options

Reports Navdrawer Item reworked
set context of webview in onAttach method of BrowserFragment

Merge branch 'master' of github.com:Diaspora-for-Android/diaspora-android
  • Loading branch information
vanitasvitae committed Nov 6, 2016
1 parent e6f16fc commit 8e324d8
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ protected void updateNavigationViewEntryVisibilities() {
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile());
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
navMenu.findItem(R.id.nav_stream).setVisible(true);
navMenu.findItem(R.id.nav_reports).setVisible(appSettings.isVisibleInNavReports());


// Hide whole group (for logged in use) if no pod was selected
Expand Down Expand Up @@ -1029,23 +1030,32 @@ public boolean onNavigationItemSelected(MenuItem item) {
} else {
snackbarNoInternet.show();
}
break;
}
break;

case R.id.nav_public: {
if (WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getPublicUrl());
} else {
snackbarNoInternet.show();
}
break;
}
break;

case R.id.nav_reports: {
if(WebHelper.isOnline(MainActivity.this)) {
openDiasporaUrl(urls.getReportsUrl());
} else {
snackbarNoInternet.show();
}
}
break;

case R.id.nav_exit: {
moveTaskToBack(true);
finish();
break;
}
break;

case R.id.nav_settings: {
startActivity(new Intent(this, SettingsActivity.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ public boolean isVisibleInNavContacts() {
return getBoolean(prefApp, R.string.pref_key__visibility_nav__contacts, false);
}

public boolean isVisibleInNavReports() {
return getBoolean(prefApp, R.string.pref_key__visibility_nav__reports, false);
}

public void setPrimaryColorSettings(int base, int shade) {
setInt(prefApp, R.string.pref_key__primary_color_base, base);
setInt(prefApp, R.string.pref_key__primary_color_shade, shade);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class DiasporaUrlHelper {
public static final String SUBURL_MANAGE_TAGS = "/tag_followings/manage";
public static final String SUBURL_SIGN_IN = "/users/sign_in";
public static final String SUBURL_MANAGE_CONTACTS = "/contacts";
public static final String SUBURL_REPORTS = "/reports";
public static final String URL_BLANK = "about:blank";
public static final String SUBURL_NOTIFICATIONS_ALSO_COMMENTED = "/notifications?type=also_commented";
public static final String SUBURL_NOTIFICATIONS_COMMENT_ON_POST = "/notifications?type=comment_on_post";
Expand Down Expand Up @@ -237,6 +238,16 @@ public String getStatisticsUrl() {
return getPodUrl() + SUBURL_STATISTICS;
}

/**
* Return an Url that points to the reports page of a the configured pod.
* Note: This url is only useful/visible for podmins and moderators.
*
* @return https://(pod-domain.tld)/reports
*/
public String getReportsUrl() {
return getPodUrl() + SUBURL_REPORTS;
}

/**
* Return a url that points to the sign in page of the pod.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.github.dfa.diaspora_android.web;

import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.MutableContextWrapper;
Expand Down Expand Up @@ -256,6 +257,14 @@ public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
/* Nothing to do here */
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
if(webView != null && webView.getContext() instanceof MutableContextWrapper) {
((MutableContextWrapper) webView.getContext()).setBaseContext(context);
}
}

public boolean onBackPressed() {
if (webView.canGoBack()) {
getActivity().runOnUiThread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void onClick(DialogInterface dialog, int which) {
+ System.currentTimeMillis() + ".png");
request.setDestinationUri(Uri.fromFile(destinationFile));
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);

Toast.makeText(context, context.getText(R.string.share__toast_saved_image_to_location) + " " +
destinationFile.getAbsolutePath(), Toast.LENGTH_LONG).show();
}
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/ic_report_black_48px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#000000"
android:pathData="M15.73 3H8.27L3 8.27v7.46L8.27 21h7.46L21 15.73V8.27L15.73 3zM12 17.3c-.72
0-1.3-.58-1.3-1.3 0-.72 .58 -1.3 1.3-1.3 .72 0 1.3 .58 1.3 1.3 0 .72-.58 1.3-1.3
1.3zm1-4.3h-2V7h2v6z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/main__navdrawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
android:icon="@drawable/ic_public_black_48px"
android:title="@string/nav_public_activities" />

<item
android:id="@+id/nav_reports"
android:icon="@drawable/ic_report_black_48px"
android:title="@string/nav_reports" />

<item
android:id="@+id/nav_exit"
android:icon="@drawable/ic_cancel_black_48px"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<string name="pref_key__visibility_nav__followed_tags" translatable="false">pref_key__visibility_nav__followed_tags</string>
<string name="pref_key__visibility_nav__profile" translatable="false">pref_key__visibility_nav__profile</string>
<string name="pref_key__visibility_nav__contacts" translatable="false">pref_key__visibility_nav__contacts</string>
<string name="pref_key__visibility_nav__reports" translatable="false">pref_key__visibility_nav__reports</string>

<!-- PodProfile -->
<string name="pref_key__podprofile_avatar_url" translatable="false">podUserProfile_avatar</string>
Expand Down Expand Up @@ -74,6 +75,9 @@
<string name="pref_title__sub_nav_slider">Navigation Slider</string>
<string name="pref_desc__sub_nav_slider">Control visibility of entries in the navigation drawer</string>
<string name="pref_cat__visibility_nav_items">Item visibility</string>
<string name="pref_cat__visibility_nav_items__user">User</string>
<string name="pref_cat__visibility_nav_items__general">General</string>
<string name="pref_cat__visibility_nav_items__admin">Admin</string>

<!-- Themes -->
<string name="pref_title__themes">Theme and Colors</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<string name="nav_followed_tags">Followed Tags</string>
<string name="nav_public_activities">Public activities</string>
<string name="nav_contacts" translatable="false">@string/contacts</string>
<string name="nav_reports">Reports</string>

<string name="share__share_link_as_text">Share link as text</string>
<string name="share__share_screenshot">Share screenshot of webpage</string>
Expand Down
119 changes: 69 additions & 50 deletions app/src/main/res/xml/preferences__sub_navslider_vis.xml
Original file line number Diff line number Diff line change
@@ -1,54 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:key="@string/pref_key__title__visibility_nav"
android:title="@string/pref_cat__visibility_nav_items">

<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__profile"
android:title="@string/nav_profile"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__followed_tags"
android:title="@string/nav_followed_tags"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__aspects"
android:title="@string/nav_aspects"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__contacts"
android:title="@string/nav_contacts" />
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__activities"
android:title="@string/nav_activities"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__liked"
android:title="@string/nav_liked"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__commented"
android:title="@string/nav_commented"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__mentions"
android:title="@string/nav_mentions"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__public_activities"
android:title="@string/nav_public_activities"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__exit"
android:title="@string/action_exit_app"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__help_license"
android:title="@string/nav_help_license"/>

</com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory>
<!-- User -->
<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:title="@string/pref_cat__visibility_nav_items__user">
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__profile"
android:title="@string/nav_profile"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__followed_tags"
android:title="@string/nav_followed_tags"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__aspects"
android:title="@string/nav_aspects"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__contacts"
android:title="@string/nav_contacts" />
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__activities"
android:title="@string/nav_activities"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__liked"
android:title="@string/nav_liked"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__commented"
android:title="@string/nav_commented"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__mentions"
android:title="@string/nav_mentions"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__public_activities"
android:title="@string/nav_public_activities"/>

</com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory>


<!-- General -->
<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:title="@string/pref_cat__visibility_nav_items__general">

<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__exit"
android:title="@string/action_exit_app"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="true"
android:key="@string/pref_key__visibility_nav__help_license"
android:title="@string/nav_help_license"/>

</com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory>


<!-- Admin -->
<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:title="@string/pref_cat__visibility_nav_items__admin">

<com.github.dfa.diaspora_android.ui.theme.ThemedVisibilityPreference
android:defaultValue="false"
android:key="@string/pref_key__visibility_nav__reports"
android:title="@string/nav_reports"/>

</com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory>
</PreferenceScreen>

0 comments on commit 8e324d8

Please sign in to comment.