1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-22 04:12:08 +01:00

Added reports navdrawer entry and divided visibility options into subcategories 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
This commit is contained in:
vanitasvitae 2016-11-06 20:36:43 +01:00
parent e6f16fce50
commit 8e324d8f2b
10 changed files with 130 additions and 51 deletions

View file

@ -399,6 +399,7 @@ public class MainActivity extends ThemedActivity
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
@ -1029,8 +1030,8 @@ public class MainActivity extends ThemedActivity
} else {
snackbarNoInternet.show();
}
break;
}
break;
case R.id.nav_public: {
if (WebHelper.isOnline(MainActivity.this)) {
@ -1038,14 +1039,23 @@ public class MainActivity extends ThemedActivity
} 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));

View file

@ -394,6 +394,10 @@ public class AppSettings {
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);

View file

@ -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";
@ -237,6 +238,16 @@ public class DiasporaUrlHelper {
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.
*

View file

@ -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;
@ -256,6 +257,14 @@ public class BrowserFragment extends ThemedFragment {
/* 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() {

View file

@ -114,6 +114,7 @@ public class ContextMenuWebView extends NestedWebView {
+ 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();
}

View file

@ -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>

View file

@ -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"

View file

@ -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>
@ -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>

View file

@ -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>

View file

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- User -->
<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:key="@string/pref_key__title__visibility_nav"
android:title="@string/pref_cat__visibility_nav_items">
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"
@ -41,6 +40,14 @@
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"
@ -51,4 +58,16 @@
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>