From 866672eb47a0b2ef9fcba17120e898672ad3b514 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Sat, 22 Oct 2016 19:21:26 +0200 Subject: [PATCH 1/2] Show Tor preset in Pod selection ; Themed BadgeDrawable ; Update TR, Pods ; Show Stream option after login --- app/src/main/AndroidManifest.xml | 2 + .../activity/MainActivity.java | 22 ++- .../diaspora_android/data/AppSettings.java | 6 +- .../fragment/PodSelectionFragment.java | 2 +- .../diaspora_android/ui/BadgeDrawable.java | 4 +- .../ui/PodSelectionDialog.java | 40 +++++- .../main/res/layout/podselection__dialog.xml | 18 +++ app/src/main/res/raw/podlist.json | 128 ++++++++++-------- .../res/values-de/strings-preferences.xml | 3 + app/src/main/res/values-de/strings.xml | 7 + .../res/values-fr/strings-preferences.xml | 2 + app/src/main/res/values-fr/strings.xml | 7 + app/src/main/res/values/strings.xml | 1 + 13 files changed, 176 insertions(+), 66 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1c0486e4..b4d7d10c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -245,6 +245,8 @@ + + diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 786e98eb..4b3c36f6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -60,6 +60,7 @@ import android.widget.Toast; import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.data.AppSettings; +import com.github.dfa.diaspora_android.data.DiasporaPodList; import com.github.dfa.diaspora_android.data.PodUserProfile; import com.github.dfa.diaspora_android.fragment.BrowserFragment; import com.github.dfa.diaspora_android.fragment.CustomFragment; @@ -71,6 +72,7 @@ import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver; import com.github.dfa.diaspora_android.receiver.UpdateTitleReceiver; import com.github.dfa.diaspora_android.ui.BadgeDrawable; import com.github.dfa.diaspora_android.ui.IntellihideToolbarActivityListener; +import com.github.dfa.diaspora_android.ui.PodSelectionDialog; import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.CustomTabHelpers.CustomTabActivityHelper; import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; @@ -85,7 +87,8 @@ public class MainActivity extends ThemedActivity implements NavigationView.OnNavigationItemSelectedListener, WebUserProfileChangedListener, CustomTabActivityHelper.ConnectionCallback, - IntellihideToolbarActivityListener { + IntellihideToolbarActivityListener, + PodSelectionDialog.PodSelectionDialogResultListener{ public static final int REQUEST_CODE_ASK_PERMISSIONS = 123; @@ -370,6 +373,11 @@ public class MainActivity extends ThemedActivity protected void updateNavigationViewEntryVisibilities() { Menu navMenu = navView.getMenu(); + + // Initially show all items visible when logged in + navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), true); + + // Hide by app settings navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit()); navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities()); navMenu.findItem(R.id.nav_aspects).setVisible(appSettings.isVisibleInNavAspects()); @@ -380,8 +388,10 @@ public class MainActivity extends ThemedActivity navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions()); 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); - // Top bar + + // Hide whole group (for logged in use) if no pod was selected if (!appSettings.hasPod()) { navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), false); } @@ -921,6 +931,14 @@ public class MainActivity extends ThemedActivity } } + @Override + public void onPodSelectionDialogResult(DiasporaPodList.DiasporaPod pod, boolean accepted) { + if(accepted) { + invalidateOptionsMenu(); + navheaderDescription.setText(pod.getName()); + } + } + @Override public void onCustomTabsDisconnected() { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java index ab9fbb73..bc724cd8 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/data/AppSettings.java @@ -275,8 +275,8 @@ public class AppSettings { return getInt(prefApp, R.string.pref_key__http_proxy_port, 0); } catch(Exception _anything){ //TODO: Backward Compatibility for older versions. REMOVE after App v1.7.0 - setInt(prefApp, R.string.pref_key__http_proxy_port, 0); - return 0; + String str = getString(prefApp, R.string.pref_key__http_proxy_port, "0"); + return Integer.parseInt(str); } } @@ -341,7 +341,7 @@ public class AppSettings { } public boolean isVisibleInNavProfile() { - return getBoolean(prefApp, R.string.pref_key__visibility_nav__profile, false); + return getBoolean(prefApp, R.string.pref_key__visibility_nav__profile, true); } public void setPrimaryColorSettings(int base, int shade) { diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java index c131c03d..1bdd4621 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java @@ -251,7 +251,7 @@ public class PodSelectionFragment extends CustomFragment implements SearchView.O MainActivity mainActivity = (MainActivity) getActivity(); DiasporaUrlHelper urlHelper = new DiasporaUrlHelper(appSettings); - mainActivity.invalidateOptionsMenu(); + mainActivity.onPodSelectionDialogResult(pod, accepted); mainActivity.openDiasporaUrl(urlHelper.getSignInUrl()); } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java index 370b822f..cc585aea 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java @@ -31,6 +31,7 @@ import android.graphics.drawable.LayerDrawable; import android.support.v4.content.ContextCompat; import com.github.dfa.diaspora_android.R; +import com.github.dfa.diaspora_android.data.AppSettings; public class BadgeDrawable extends Drawable { // Source: http://mobikul.com/adding-badge-count-on-menu-items-like-cart-notification-etc/ @@ -47,8 +48,9 @@ public class BadgeDrawable extends Drawable { public BadgeDrawable(Context context) { float textSize = context.getResources().getDimension(R.dimen.textsize_badge_count); + AppSettings settings = new AppSettings(context); badgeBackground = new Paint(); - badgeBackground.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.md_deep_orange_650)); + badgeBackground.setColor(settings.getAccentColor()); badgeBackground.setAntiAlias(true); badgeBackground.setStyle(Paint.Style.FILL); badgeStroke = new Paint(); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java index 80f0d3f8..65cae8cb 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/PodSelectionDialog.java @@ -10,14 +10,18 @@ import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; +import android.widget.CheckBox; import android.widget.EditText; import android.widget.RadioGroup; import android.widget.Spinner; import android.widget.TextView; +import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.R; +import com.github.dfa.diaspora_android.data.AppSettings; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod.DiasporaPodUrl; +import com.github.dfa.diaspora_android.util.ProxyHandler; import org.json.JSONException; @@ -73,15 +77,23 @@ public class PodSelectionDialog extends AppCompatDialogFragment { @BindView(R.id.podselection__dialog__spinner_profile) Spinner spinnerProfile; + @BindView(R.id.podselection__dialog__check_torpreset) + CheckBox checkboxTorPreset; + + @BindView(R.id.podselection__dialog__text_torpreset) + TextView textTorPreset; + private PodSelectionDialogResultListener resultListener; private View root; private DiasporaPod pod = new DiasporaPod(); + private App app; @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); + app = (App) getActivity().getApplication(); // Bind UI root = inflater.inflate(R.layout.podselection__dialog, null); @@ -101,7 +113,6 @@ public class PodSelectionDialog extends AppCompatDialogFragment { spinnerProfile.setAdapter(spinnerAdapter); } - builder.setView(root); return builder.create(); } @@ -122,6 +133,18 @@ public class PodSelectionDialog extends AppCompatDialogFragment { editPodAddress.setText(url1.getHost()); radiogrpProtocol.check(url1.getProtocol().equals("https") ? R.id.podselection__dialog__radio_https : R.id.podselection__dialog__radio_http); + + // Tor + boolean isOnionUrl = url1.getHost().endsWith(".onion"); + setUiVisible(textTorPreset, isOnionUrl); + setUiVisible(checkboxTorPreset, isOnionUrl); + checkboxTorPreset.setChecked(isOnionUrl); + } + + public void setUiVisible(View view, boolean visible) { + if (view != null) { + view.setVisibility(visible ? View.VISIBLE : View.GONE); + } } @@ -142,11 +165,22 @@ public class PodSelectionDialog extends AppCompatDialogFragment { pod.setName(editPodName.getText().toString()); pod.getPodUrls().clear(); pod.getPodUrls().add(podUrl); + + // Load Tor preset + if(pod.getPodUrl().getHost().endsWith(".onion") && checkboxTorPreset.isChecked()){ + AppSettings settings = app.getSettings(); + settings.setProxyHttpEnabled(true); + settings.setProxyWasEnabled(false); + settings.setProxyHttpPort(8118); + settings.setProxyHttpHost("127.0.0.1"); + ProxyHandler.getInstance().updateProxySettings(getContext()); + } + getDialog().dismiss(); - publishResult(POSITIVE_PRESSED); + publishResult(true); } else { getDialog().cancel(); - publishResult(POSITIVE_PRESSED); + publishResult(false); } } diff --git a/app/src/main/res/layout/podselection__dialog.xml b/app/src/main/res/layout/podselection__dialog.xml index 1d8e5dbb..cd81055f 100644 --- a/app/src/main/res/layout/podselection__dialog.xml +++ b/app/src/main/res/layout/podselection__dialog.xml @@ -95,6 +95,24 @@ android:text="https" /> + + + + Sichtbarkeit der Einträge Farbschema + Einstellungen des Farbdesigns Primärfarbe Färbung der Werkzeugleisten Akzentfarbe Färbung der Details + Erweiterte Benachrichtigungen + Erweitere die Benachrichtigungsglocke um ein Ausklappmenü mit verschiedenen Benachrichtigungskategorien Schriftgröße diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 26f4a5c3..7c2de065 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -20,6 +20,13 @@ Öffentliche Aktivitäten Suchen + Alle Benachrichtigungen + Auch kommentiert + Einen Beitrag kommentiert + Gefällt + Erwähnt + Weitergesagt + Angefangen zu teilen Pod auswählen Pod-Adresse eingeben diff --git a/app/src/main/res/values-fr/strings-preferences.xml b/app/src/main/res/values-fr/strings-preferences.xml index e18c4637..18fd4a2d 100644 --- a/app/src/main/res/values-fr/strings-preferences.xml +++ b/app/src/main/res/values-fr/strings-preferences.xml @@ -23,6 +23,8 @@ Couleur secondaire Couleur de la barre de progression + Notifications étendues + Étendre la cloche de notifications avec un menu déroulant qui affiche les catégories de notification Taille de la police diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 110db457..07b65d19 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -21,6 +21,12 @@ Rechercher Toutes les notifications + Aussi commenté + Commentaires sur posts + Aimés + Mentionnés + Repartagés + A commencé à partager Selectionnez un Pod Entrez le nom de domaine du pod @@ -67,6 +73,7 @@ Vous devez autoriser \"Modifier ou supprimer le contenu de la carte Sd \" pour sauvegarder/téléverser les images. Ensuite, vous devriez fermer l\'application ou redémarrer votre téléphone. Si vous n\'avez pas autorisé l\'accès à l\'espace de stockage mais que vous souhaitez sauvegarder des images ultérieurement, vous pouvez donner la permission plus tard. Veuillez ouvrir : Paramètres - applications - Diaspora. Dans la section Autorisations, vous pouvez autoriser \"Modifier ou supprimer le contenu de la carte Sd \". Permission refusée. Permission accordée. Veuillez réessayer. + Pod personnalisé Nom du Pod Protocole Adresse du Pod diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cbd47143..576e6e77 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ Mentions Public Search + Tor All Notifications From 6e7ae16e333abfc495dc17873d2aeeb8cd111147 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Sat, 22 Oct 2016 20:10:48 +0200 Subject: [PATCH 2/2] #85 --- .../webview/DiasporaStreamWebChromeClient.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java b/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java index 1efaadb9..759fc317 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/webview/DiasporaStreamWebChromeClient.java @@ -39,14 +39,13 @@ public class DiasporaStreamWebChromeClient extends FileUploadWebChromeClient { @Override public void onProgressChanged(WebView wv, int progress) { super.onProgressChanged(wv, progress); - if (progress > 10 && progress <= 60) { + WebHelper.optimizeMobileSiteLayout(wv); + + if (progress > 0 && progress <= 85) { WebHelper.getUserProfile(wv); - WebHelper.optimizeMobileSiteLayout(wv); } if (progress > 60) { - WebHelper.optimizeMobileSiteLayout(wv); - String textToBeShared = sharedTextCallback.getSharedText(); if (textToBeShared != null) { AppLog.d(this, "Share text into webView");