1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-24 21:32:07 +01:00

Hide statusbar option for mainacitvity

This commit is contained in:
Gregor Santner 2017-09-11 18:48:58 +02:00
parent 76f33a45ba
commit b4608794ab
9 changed files with 194 additions and 106 deletions

View file

@ -75,22 +75,24 @@ import com.github.dfa.diaspora_android.ui.theme.CustomFragment;
import com.github.dfa.diaspora_android.ui.theme.ThemeHelper; import com.github.dfa.diaspora_android.ui.theme.ThemeHelper;
import com.github.dfa.diaspora_android.ui.theme.ThemedActivity; import com.github.dfa.diaspora_android.ui.theme.ThemedActivity;
import com.github.dfa.diaspora_android.ui.theme.ThemedAlertDialogBuilder; import com.github.dfa.diaspora_android.ui.theme.ThemedAlertDialogBuilder;
import com.github.dfa.diaspora_android.util.ActivityUtils;
import com.github.dfa.diaspora_android.util.AndroidBug5497Workaround;
import com.github.dfa.diaspora_android.util.AppLog; import com.github.dfa.diaspora_android.util.AppLog;
import com.github.dfa.diaspora_android.util.AppSettings; import com.github.dfa.diaspora_android.util.AppSettings;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.ActivityUtils;
import com.github.dfa.diaspora_android.web.BrowserFragment; import com.github.dfa.diaspora_android.web.BrowserFragment;
import com.github.dfa.diaspora_android.web.ContextMenuWebView; import com.github.dfa.diaspora_android.web.ContextMenuWebView;
import com.github.dfa.diaspora_android.web.ProxyHandler; import com.github.dfa.diaspora_android.web.ProxyHandler;
import com.github.dfa.diaspora_android.web.WebHelper; import com.github.dfa.diaspora_android.web.WebHelper;
import com.github.dfa.diaspora_android.web.custom_tab.CustomTabActivityHelper; import com.github.dfa.diaspora_android.web.custom_tab.CustomTabActivityHelper;
import net.gsantner.opoc.util.SimpleMarkdownParser;
import java.io.IOException; import java.io.IOException;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import net.gsantner.opoc.util.SimpleMarkdownParser;
public class MainActivity extends ThemedActivity public class MainActivity extends ThemedActivity
implements NavigationView.OnNavigationItemSelectedListener, implements NavigationView.OnNavigationItemSelectedListener,
@ -116,7 +118,7 @@ public class MainActivity extends ThemedActivity
private App app; private App app;
private CustomTabActivityHelper customTabActivityHelper; private CustomTabActivityHelper customTabActivityHelper;
private AppSettings appSettings; private AppSettings _appSettings;
private DiasporaUrlHelper urls; private DiasporaUrlHelper urls;
private DiasporaUserProfile diasporaUserProfile; private DiasporaUserProfile diasporaUserProfile;
private final Handler uiHandler = new Handler(); private final Handler uiHandler = new Handler();
@ -170,15 +172,21 @@ public class MainActivity extends ThemedActivity
AppLog.v(this, "onCreate()"); AppLog.v(this, "onCreate()");
// Bind UI // Bind UI
if (AppSettings.get().isEditorStatusBarHidden()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.main__activity); setContentView(R.layout.main__activity);
ButterKnife.bind(this); ButterKnife.bind(this);
if (AppSettings.get().isEditorStatusBarHidden()) {
AndroidBug5497Workaround.assistActivity(this);
}
app = (App) getApplication(); app = (App) getApplication();
appSettings = app.getSettings(); _appSettings = app.getSettings();
diasporaUserProfile = app.getDiasporaUserProfile(); diasporaUserProfile = app.getDiasporaUserProfile();
diasporaUserProfile.setCallbackHandler(uiHandler); diasporaUserProfile.setCallbackHandler(uiHandler);
diasporaUserProfile.setListener(this); diasporaUserProfile.setListener(this);
urls = new DiasporaUrlHelper(appSettings); urls = new DiasporaUrlHelper(_appSettings);
customTabActivityHelper = new CustomTabActivityHelper(); customTabActivityHelper = new CustomTabActivityHelper();
customTabActivityHelper.setConnectionCallback(this); customTabActivityHelper.setConnectionCallback(this);
ProxyHandler.getInstance().updateProxySettings(this); ProxyHandler.getInstance().updateProxySettings(this);
@ -204,7 +212,7 @@ public class MainActivity extends ThemedActivity
} }
}); });
if (!appSettings.hasPod()) { if (!_appSettings.hasPod()) {
AppLog.d(this, "We have no pod. Show PodSelectionFragment"); AppLog.d(this, "We have no pod. Show PodSelectionFragment");
updateNavigationViewEntryVisibilities(); updateNavigationViewEntryVisibilities();
showFragment(getFragment(PodSelectionFragment.TAG)); showFragment(getFragment(PodSelectionFragment.TAG));
@ -222,7 +230,7 @@ public class MainActivity extends ThemedActivity
// Show first start dialog // Show first start dialog
try { try {
SimpleMarkdownParser mdParser = SimpleMarkdownParser.get().setDefaultSmpFilter(SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW); SimpleMarkdownParser mdParser = SimpleMarkdownParser.get().setDefaultSmpFilter(SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW);
if (appSettings.isAppFirstStart()) { if (_appSettings.isAppFirstStart()) {
mdParser.parse( mdParser.parse(
getResources().openRawResource(R.raw.license), ""); getResources().openRawResource(R.raw.license), "");
String html = mdParser.getHtml() String html = mdParser.getHtml()
@ -231,8 +239,8 @@ public class MainActivity extends ThemedActivity
+ mdParser.parse(getResources().openRawResource(R.raw.license_third_party), ""); + mdParser.parse(getResources().openRawResource(R.raw.license_third_party), "");
html = mdParser.setHtml(html).removeMultiNewlines().getHtml(); html = mdParser.setHtml(html).removeMultiNewlines().getHtml();
ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.about_activity__title_about_license, html); ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.about_activity__title_about_license, html);
appSettings.isAppCurrentVersionFirstStart(); _appSettings.isAppCurrentVersionFirstStart();
} else if (appSettings.isAppCurrentVersionFirstStart()) { } else if (_appSettings.isAppCurrentVersionFirstStart()) {
SimpleMarkdownParser smp = new SimpleMarkdownParser().parse( SimpleMarkdownParser smp = new SimpleMarkdownParser().parse(
getResources().openRawResource(R.raw.changelog), ""); getResources().openRawResource(R.raw.changelog), "");
ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.changelog, smp.getHtml()); ActivityUtils.get(this).showDialogWithHtmlTextView(R.string.changelog, smp.getHtml());
@ -361,7 +369,7 @@ public class MainActivity extends ThemedActivity
AppLog.v(this, "Fragment was not visible. Replace it."); AppLog.v(this, "Fragment was not visible. Replace it.");
fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit(); fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit();
invalidateOptionsMenu(); invalidateOptionsMenu();
if (appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide()) { if (_appSettings.isIntellihideToolbars() && fragment.isAllowedIntellihide()) {
this.enableToolbarHiding(); this.enableToolbarHiding();
} else { } else {
this.disableToolbarHiding(); this.disableToolbarHiding();
@ -390,7 +398,7 @@ public class MainActivity extends ThemedActivity
navProfilePictureArea.setOnClickListener(new View.OnClickListener() { navProfilePictureArea.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
navDrawer.closeDrawer(GravityCompat.START); navDrawer.closeDrawer(GravityCompat.START);
if (!appSettings.getProfileId().equals("")) { if (!_appSettings.getProfileId().equals("")) {
openDiasporaUrl(urls.getProfileUrl()); openDiasporaUrl(urls.getProfileUrl());
} }
} }
@ -399,13 +407,13 @@ public class MainActivity extends ThemedActivity
navheaderDescription = ButterKnife.findById(navHeader, R.id.podselection__podupti_notice); navheaderDescription = ButterKnife.findById(navHeader, R.id.podselection__podupti_notice);
navheaderImage = ButterKnife.findById(navHeader, R.id.navheader_user_image); navheaderImage = ButterKnife.findById(navHeader, R.id.navheader_user_image);
if (!appSettings.getName().equals("")) { if (!_appSettings.getName().equals("")) {
navheaderTitle.setText(appSettings.getName()); navheaderTitle.setText(_appSettings.getName());
} }
if (appSettings.getPod() != null) { if (_appSettings.getPod() != null) {
navheaderDescription.setText(appSettings.getPod().getName()); navheaderDescription.setText(_appSettings.getPod().getName());
} }
String avatarUrl = appSettings.getAvatarUrl(); String avatarUrl = _appSettings.getAvatarUrl();
if (!avatarUrl.equals("")) { if (!avatarUrl.equals("")) {
//Display app launcher icon instead of default avatar asset //Display app launcher icon instead of default avatar asset
//(Which would by the way not load because of missing pod domain prefix in the url) //(Which would by the way not load because of missing pod domain prefix in the url)
@ -433,26 +441,26 @@ public class MainActivity extends ThemedActivity
navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), true); navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), true);
// Hide by app settings // Hide by app settings
navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit()); navMenu.findItem(R.id.nav_exit).setVisible(_appSettings.isVisibleInNavExit());
navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities()); navMenu.findItem(R.id.nav_activities).setVisible(_appSettings.isVisibleInNavActivities());
navMenu.findItem(R.id.nav_aspects).setVisible(appSettings.isVisibleInNavAspects()); navMenu.findItem(R.id.nav_aspects).setVisible(_appSettings.isVisibleInNavAspects());
navMenu.findItem(R.id.nav_contacts).setVisible(appSettings.isVisibleInNavContacts()); navMenu.findItem(R.id.nav_contacts).setVisible(_appSettings.isVisibleInNavContacts());
navMenu.findItem(R.id.nav_commented).setVisible(appSettings.isVisibleInNavCommented()); navMenu.findItem(R.id.nav_commented).setVisible(_appSettings.isVisibleInNavCommented());
navMenu.findItem(R.id.nav_followed_tags).setVisible(appSettings.isVisibleInNavFollowed_tags()); navMenu.findItem(R.id.nav_followed_tags).setVisible(_appSettings.isVisibleInNavFollowed_tags());
navMenu.findItem(R.id.nav_about).setVisible(appSettings.isVisibleInNavHelp_license()); navMenu.findItem(R.id.nav_about).setVisible(_appSettings.isVisibleInNavHelp_license());
navMenu.findItem(R.id.nav_liked).setVisible(appSettings.isVisibleInNavLiked()); navMenu.findItem(R.id.nav_liked).setVisible(_appSettings.isVisibleInNavLiked());
navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions()); navMenu.findItem(R.id.nav_mentions).setVisible(_appSettings.isVisibleInNavMentions());
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile()); navMenu.findItem(R.id.nav_profile).setVisible(_appSettings.isVisibleInNavProfile());
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities()); navMenu.findItem(R.id.nav_public).setVisible(_appSettings.isVisibleInNavPublic_activities());
navMenu.findItem(R.id.nav_stream).setVisible(true); navMenu.findItem(R.id.nav_stream).setVisible(true);
navMenu.findItem(R.id.nav_statistics).setVisible(appSettings.isVisibleInNavStatistics()); navMenu.findItem(R.id.nav_statistics).setVisible(_appSettings.isVisibleInNavStatistics());
navMenu.findItem(R.id.nav_reports).setVisible(appSettings.isVisibleInNavReports()); navMenu.findItem(R.id.nav_reports).setVisible(_appSettings.isVisibleInNavReports());
navMenu.findItem(R.id.nav_toggle_desktop_page).setVisible(appSettings.isVisibleInNavToggleMobileDesktop()); navMenu.findItem(R.id.nav_toggle_desktop_page).setVisible(_appSettings.isVisibleInNavToggleMobileDesktop());
navMenu.findItem(R.id.nav_dandelion).setVisible(appSettings.isVisibleInNavDandelionAccount()); navMenu.findItem(R.id.nav_dandelion).setVisible(_appSettings.isVisibleInNavDandelionAccount());
// Hide whole group (for logged in use) if no pod was selected // Hide whole group (for logged in use) if no pod was selected
if (!appSettings.hasPod()) { if (!_appSettings.hasPod()) {
navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), false); navMenu.setGroupVisible(navMenu.findItem(R.id.nav_exit).getGroupId(), false);
} }
} }
@ -465,7 +473,7 @@ public class MainActivity extends ThemedActivity
@OnClick(R.id.main__topbar) @OnClick(R.id.main__topbar)
public void onToolBarClicked(View view) { public void onToolBarClicked(View view) {
AppLog.i(this, "onToolBarClicked()"); AppLog.i(this, "onToolBarClicked()");
if (appSettings.isTopbarStreamShortcutEnabled() && appSettings.hasPod()) { if (_appSettings.isTopbarStreamShortcutEnabled() && _appSettings.hasPod()) {
onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_stream)); onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_stream));
} }
} }
@ -512,7 +520,7 @@ public class MainActivity extends ThemedActivity
} }
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) { } else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
AppLog.v(this, "Reset pod data and show PodSelectionFragment"); AppLog.v(this, "Reset pod data and show PodSelectionFragment");
appSettings.setPod(null); _appSettings.setPod(null);
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
navheaderTitle.setText(R.string.app_name); navheaderTitle.setText(R.string.app_name);
@ -645,8 +653,11 @@ public class MainActivity extends ThemedActivity
LocalBroadcastManager.getInstance(this).registerReceiver(brSetTitle, new IntentFilter(ACTION_UPDATE_TITLE_FROM_URL)); LocalBroadcastManager.getInstance(this).registerReceiver(brSetTitle, new IntentFilter(ACTION_UPDATE_TITLE_FROM_URL));
LocalBroadcastManager.getInstance(this).registerReceiver(brOpenExternalLink, new IntentFilter(ACTION_OPEN_EXTERNAL_URL)); LocalBroadcastManager.getInstance(this).registerReceiver(brOpenExternalLink, new IntentFilter(ACTION_OPEN_EXTERNAL_URL));
invalidateOptionsMenu(); invalidateOptionsMenu();
this.appSettings = getAppSettings(); _appSettings = getAppSettings();
if (appSettings.isIntellihideToolbars()) { if (_appSettings.isRecreateMainActivity()){
recreate();
}
if (_appSettings.isIntellihideToolbars()) {
enableToolbarHiding(); enableToolbarHiding();
} else { } else {
disableToolbarHiding(); disableToolbarHiding();
@ -676,7 +687,7 @@ public class MainActivity extends ThemedActivity
///Hide bottom toolbar ///Hide bottom toolbar
toolbarBottom.setVisibility(View.GONE); toolbarBottom.setVisibility(View.GONE);
} else { } else {
getMenuInflater().inflate(appSettings.isExtendedNotificationsActivated() ? getMenuInflater().inflate(_appSettings.isExtendedNotificationsActivated() ?
R.menu.main__menu_top__notifications_dropdown : R.menu.main__menu_top, menu); R.menu.main__menu_top__notifications_dropdown : R.menu.main__menu_top, menu);
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu()); getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
@ -719,7 +730,7 @@ public class MainActivity extends ThemedActivity
AppLog.i(this, "onOptionsItemSelected()"); AppLog.i(this, "onOptionsItemSelected()");
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_notifications: { case R.id.action_notifications: {
if (appSettings.isExtendedNotificationsActivated()) { if (_appSettings.isExtendedNotificationsActivated()) {
return true; return true;
} }
//Otherwise we execute the action of action_notifications_all //Otherwise we execute the action of action_notifications_all
@ -837,7 +848,7 @@ public class MainActivity extends ThemedActivity
} }
}; };
final AlertDialog dialog = new ThemedAlertDialogBuilder(this, appSettings) final AlertDialog dialog = new ThemedAlertDialogBuilder(this, _appSettings)
.setView(layout).setTitle(R.string.search_alert_title) .setView(layout).setTitle(R.string.search_alert_title)
.setCancelable(true) .setCancelable(true)
.setPositiveButton(R.string.search_alert_tag, clickListener) .setPositiveButton(R.string.search_alert_tag, clickListener)
@ -943,7 +954,7 @@ public class MainActivity extends ThemedActivity
private void setSharedTexts(String sharedSubject, String sharedBody) { private void setSharedTexts(String sharedSubject, String sharedBody) {
AppLog.i(this, "setSharedTexts()"); AppLog.i(this, "setSharedTexts()");
String body = WebHelper.replaceUrlWithMarkdown(sharedBody); String body = WebHelper.replaceUrlWithMarkdown(sharedBody);
if (appSettings.isAppendSharedViaApp()) { if (_appSettings.isAppendSharedViaApp()) {
AppLog.v(this, "Append app reference to shared text"); AppLog.v(this, "Append app reference to shared text");
body = body + "\n\n" + getString(R.string.shared_via_app); body = body + "\n\n" + getString(R.string.shared_via_app);
} }
@ -1030,7 +1041,7 @@ public class MainActivity extends ThemedActivity
break; break;
case R.id.nav_profile: { case R.id.nav_profile: {
if (!appSettings.getProfileId().equals("")) { if (!_appSettings.getProfileId().equals("")) {
openDiasporaUrl(urls.getProfileUrl()); openDiasporaUrl(urls.getProfileUrl());
} }
} }
@ -1197,9 +1208,9 @@ public class MainActivity extends ThemedActivity
protected void applyColorToViews() { protected void applyColorToViews() {
ThemeHelper.updateToolbarColor(toolbarTop); ThemeHelper.updateToolbarColor(toolbarTop);
ThemeHelper.updateActionMenuViewColor(toolbarBottom); ThemeHelper.updateActionMenuViewColor(toolbarBottom);
navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor()); navDrawerLayout.setBackgroundColor(_appSettings.getPrimaryColor());
navProfilePictureArea.setBackgroundColor(appSettings.getPrimaryColor()); navProfilePictureArea.setBackgroundColor(_appSettings.getPrimaryColor());
if (appSettings.isAmoledColorMode()) { if (_appSettings.isAmoledColorMode()) {
navView.setItemTextColor(ColorStateList.valueOf(Color.GRAY)); navView.setItemTextColor(ColorStateList.valueOf(Color.GRAY));
navView.setItemIconTintList(ColorStateList.valueOf(Color.GRAY)); navView.setItemIconTintList(ColorStateList.valueOf(Color.GRAY));
navView.setBackgroundColor(Color.BLACK); navView.setBackgroundColor(Color.BLACK);

View file

@ -38,11 +38,6 @@ import butterknife.ButterKnife;
import uz.shift.colorpicker.LineColorPicker; import uz.shift.colorpicker.LineColorPicker;
import uz.shift.colorpicker.OnColorChangedListener; import uz.shift.colorpicker.OnColorChangedListener;
/**
* SettingsActivity
* Created by vanitas on 24.10.16.
*/
public class SettingsActivity extends ThemedActivity implements SharedPreferences.OnSharedPreferenceChangeListener { public class SettingsActivity extends ThemedActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
//Toolbar //Toolbar
@ -192,6 +187,10 @@ public class SettingsActivity extends ThemedActivity implements SharedPreference
((SettingsActivity) getActivity()).showFragment(SettingsFragmentDebugging.TAG, true); ((SettingsActivity) getActivity()).showFragment(SettingsFragmentDebugging.TAG, true);
return true; return true;
} }
/** Usability */
else if (settings.isKeyEqual(key, R.string.pref_key__is_overview_statusbar_hidden)){
AppSettings.get().setRecreateMainActivity(true);
}
/** Network */ /** Network */
else if (settings.isKeyEqual(key, R.string.pref_key__clear_cache)) { else if (settings.isKeyEqual(key, R.string.pref_key__clear_cache)) {
Intent intent = new Intent(getActivity(), MainActivity.class); Intent intent = new Intent(getActivity(), MainActivity.class);

View file

@ -0,0 +1,58 @@
package com.github.dfa.diaspora_android.util;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
// From https://stackoverflow.com/a/19494006
public class AndroidBug5497Workaround {
// For more information, see https://code.google.com/p/android/issues/detail?id=5497
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
public static void assistActivity(Activity activity) {
new AndroidBug5497Workaround(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard / 4)) {
// keyboard probably just became visible
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
// keyboard probably just became hidden
frameLayoutParams.height = usableHeightSansKeyboard;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}
}

View file

@ -26,13 +26,13 @@ import com.github.dfa.diaspora_android.data.DiasporaAspect;
import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod; import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
import com.github.dfa.diaspora_android.web.ProxyHandler; import com.github.dfa.diaspora_android.web.ProxyHandler;
import net.gsantner.opoc.util.AppSettingsBase;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.List; import java.util.List;
import net.gsantner.opoc.util.AppSettingsBase;
/** /**
* Settings * Settings
* Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of dandelion*. * Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of dandelion*.
@ -81,7 +81,7 @@ public class AppSettings extends AppSettingsBase {
} }
public void setProfileId(String profileId) { public void setProfileId(String profileId) {
setString(R.string.pref_key__podprofile_id, profileId,prefPod); setString(R.string.pref_key__podprofile_id, profileId, prefPod);
} }
public boolean isLoadImages() { public boolean isLoadImages() {
@ -103,24 +103,24 @@ public class AppSettings extends AppSettingsBase {
} }
public String getAvatarUrl() { public String getAvatarUrl() {
return getString(R.string.pref_key__podprofile_avatar_url, "",prefPod); return getString(R.string.pref_key__podprofile_avatar_url, "", prefPod);
} }
public void setAvatarUrl(String avatarUrl) { public void setAvatarUrl(String avatarUrl) {
setString(R.string.pref_key__podprofile_avatar_url, avatarUrl,prefPod); setString(R.string.pref_key__podprofile_avatar_url, avatarUrl, prefPod);
} }
public String getName() { public String getName() {
return getString(R.string.pref_key__podprofile_name, "",prefPod); return getString(R.string.pref_key__podprofile_name, "", prefPod);
} }
public void setName(String name) { public void setName(String name) {
setString(R.string.pref_key__podprofile_name, name,prefPod); setString(R.string.pref_key__podprofile_name, name, prefPod);
} }
public DiasporaPod getPod() { public DiasporaPod getPod() {
if (currentPod0Cached == null) { if (currentPod0Cached == null) {
String pref = getString(R.string.pref_key__current_pod_0, "",prefPod); String pref = getString(R.string.pref_key__current_pod_0, "", prefPod);
try { try {
currentPod0Cached = new DiasporaPod().fromJson(new JSONObject(pref)); currentPod0Cached = new DiasporaPod().fromJson(new JSONObject(pref));
@ -134,22 +134,22 @@ public class AppSettings extends AppSettingsBase {
public void setPod(DiasporaPod pod) { public void setPod(DiasporaPod pod) {
try { try {
setString(R.string.pref_key__current_pod_0, setString(R.string.pref_key__current_pod_0,
pod == null ? null : pod.toJson().toString(),prefPod); pod == null ? null : pod.toJson().toString(), prefPod);
currentPod0Cached = pod; currentPod0Cached = pod;
} catch (JSONException ignored) { } catch (JSONException ignored) {
} }
} }
public boolean hasPod() { public boolean hasPod() {
return !getString(R.string.pref_key__current_pod_0, "",prefPod).equals(""); return !getString(R.string.pref_key__current_pod_0, "", prefPod).equals("");
} }
public void setPodAspects(DiasporaAspect[] aspects) { public void setPodAspects(DiasporaAspect[] aspects) {
setStringArray(R.string.pref_key__podprofile_aspects, aspects,prefPod); setStringArray(R.string.pref_key__podprofile_aspects, aspects, prefPod);
} }
public DiasporaAspect[] getAspects() { public DiasporaAspect[] getAspects() {
String[] s = getStringArray(R.string.pref_key__podprofile_aspects,prefPod); String[] s = getStringArray(R.string.pref_key__podprofile_aspects, prefPod);
DiasporaAspect[] aspects = new DiasporaAspect[s.length]; DiasporaAspect[] aspects = new DiasporaAspect[s.length];
for (int i = 0; i < aspects.length; i++) { for (int i = 0; i < aspects.length; i++) {
aspects[i] = new DiasporaAspect(s[i]); aspects[i] = new DiasporaAspect(s[i]);
@ -158,43 +158,43 @@ public class AppSettings extends AppSettingsBase {
} }
public String[] getFollowedTags() { public String[] getFollowedTags() {
return getStringArray(R.string.pref_key__podprofile_followed_tags,prefPod); return getStringArray(R.string.pref_key__podprofile_followed_tags, prefPod);
} }
public void setFollowedTags(String[] values) { public void setFollowedTags(String[] values) {
setStringArray(R.string.pref_key__podprofile_followed_tags, values,prefPod); setStringArray(R.string.pref_key__podprofile_followed_tags, values, prefPod);
} }
public String[] getFollowedTagsFavs() { public String[] getFollowedTagsFavs() {
return getStringArray(R.string.pref_key__podprofile_followed_tags_favs,prefPod); return getStringArray(R.string.pref_key__podprofile_followed_tags_favs, prefPod);
} }
public void setFollowedTagsFavs(List<String> values) { public void setFollowedTagsFavs(List<String> values) {
setStringList(R.string.pref_key__podprofile_followed_tags_favs, values,prefPod); setStringList(R.string.pref_key__podprofile_followed_tags_favs, values, prefPod);
} }
public String[] getAspectFavs() { public String[] getAspectFavs() {
return getStringArray(R.string.pref_key__podprofile_aspects_favs,prefPod); return getStringArray(R.string.pref_key__podprofile_aspects_favs, prefPod);
} }
public void setAspectFavs(List<String> values) { public void setAspectFavs(List<String> values) {
setStringList(R.string.pref_key__podprofile_aspects_favs, values,prefPod); setStringList(R.string.pref_key__podprofile_aspects_favs, values, prefPod);
} }
public int getUnreadMessageCount() { public int getUnreadMessageCount() {
return getInt(R.string.pref_key__podprofile_unread_message_count, 0,prefPod); return getInt(R.string.pref_key__podprofile_unread_message_count, 0, prefPod);
} }
public void setUnreadMessageCount(int unreadMessageCount) { public void setUnreadMessageCount(int unreadMessageCount) {
setInt(R.string.pref_key__podprofile_unread_message_count, unreadMessageCount,prefPod); setInt(R.string.pref_key__podprofile_unread_message_count, unreadMessageCount, prefPod);
} }
public int getNotificationCount() { public int getNotificationCount() {
return getInt(R.string.pref_key__podprofile_notification_count, 0,prefPod); return getInt(R.string.pref_key__podprofile_notification_count, 0, prefPod);
} }
public void setNotificationCount(int notificationCount) { public void setNotificationCount(int notificationCount) {
setInt(R.string.pref_key__podprofile_notification_count, notificationCount,prefPod); setInt(R.string.pref_key__podprofile_notification_count, notificationCount, prefPod);
} }
public boolean isAppendSharedViaApp() { public boolean isAppendSharedViaApp() {
@ -274,7 +274,7 @@ public class AppSettings extends AppSettingsBase {
} }
public boolean isIntellihideToolbars() { public boolean isIntellihideToolbars() {
return getBool(R.string.pref_key__intellihide_toolbars, true); return getBool(R.string.pref_key__intellihide_toolbars, false);
} }
public boolean isChromeCustomTabsEnabled() { public boolean isChromeCustomTabsEnabled() {
@ -370,11 +370,11 @@ public class AppSettings extends AppSettingsBase {
} }
public long getLastVisitedPositionInStream() { public long getLastVisitedPositionInStream() {
return getLong(R.string.pref_key__podprofile_last_stream_position, -1,prefPod); return getLong(R.string.pref_key__podprofile_last_stream_position, -1, prefPod);
} }
public void setLastVisitedPositionInStream(long timestamp) { public void setLastVisitedPositionInStream(long timestamp) {
setLong(R.string.pref_key__podprofile_last_stream_position, timestamp,prefPod); setLong(R.string.pref_key__podprofile_last_stream_position, timestamp, prefPod);
} }
public void setLanguage(String value) { public void setLanguage(String value) {
@ -434,4 +434,18 @@ public class AppSettings extends AppSettingsBase {
public boolean isAdBlockEnabled() { public boolean isAdBlockEnabled() {
return getBool(R.string.pref_key__adblock_enable, true); return getBool(R.string.pref_key__adblock_enable, true);
} }
public boolean isEditorStatusBarHidden() {
return getBool(R.string.pref_key__is_overview_statusbar_hidden, false);
}
public void setRecreateMainActivity(boolean value) {
setBool(R.string.pref_key__recreate_main_activity, value);
}
public boolean isRecreateMainActivity() {
boolean value = getBool(R.string.pref_key__recreate_main_activity, false);
setRecreateMainActivity(false);
return value;
}
} }

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
</vector>

View file

@ -77,4 +77,6 @@ nachträglich erteilen. Öffne dafür: Systemeinstellungen - Apps - dandelion*.
<string name="pod_address">Pod Adresse</string> <string name="pod_address">Pod Adresse</string>
<string name="missing_value">Fehlender Wert</string> <string name="missing_value">Fehlender Wert</string>
<string name="jump_to_last_visited_timestamp_in_stream">Zuletzt besuchte Seite im Stream aufrufen?</string> <string name="jump_to_last_visited_timestamp_in_stream">Zuletzt besuchte Seite im Stream aufrufen?</string>
<string name="pref_summary__is_statusbar_hidden">Statusleiste in Hauptansicht verstecken</string>
<string name="pref_title__is_statusbar_hidden">Statusleiste verstecken</string>
</resources> </resources>

View file

@ -9,7 +9,7 @@
<string name="tor" translatable="false">Tor</string> <string name="tor" translatable="false">Tor</string>
<string name="HTTP" translatable="false">HTTP</string>
<string name="action_compose_new_post" translatable="false">@string/new_post</string> <string name="action_compose_new_post" translatable="false">@string/new_post</string>
<string name="search_alert_title" translatable="false">@string/search</string> <string name="search_alert_title" translatable="false">@string/search</string>
@ -40,10 +40,22 @@
<string name="nav_statistics" translatable="false">@string/statistics</string> <string name="nav_statistics" translatable="false">@string/statistics</string>
<string name="nav_contacts" translatable="false">@string/contacts</string> <string name="nav_contacts" translatable="false">@string/contacts</string>
<!--
Pref title/desc (refs)
-->
<string name="pref_title__chrome_custom_tabs_enabled" translatable="false">Chrome Custom Tabs</string>
<string name="pref_key__proxy_was_enabled" translatable="false">wasProxyEnabled</string>
<string name="pref_title__manage_contacts" translatable="false">@string/contacts</string>
<string name="pref_title__sub_logging" translatable="false">@string/about_activity__title_debug_info</string>
<string name="pref_desc__sub_logging" translatable="false">@string/fragment_debug__section_log</string>
<string name="pref_title__logging_enabled" translatable="false">@string/fragment_debug__section_log</string>
<string name="pref_title__logging_spam_enabled" translatable="false">@string/fragment_debug__section_log_spam</string>
<string name="pref_desc__sub_proxy" translatable="false">@string/pref_desc__http_proxy_enabled</string>
<string name="pref_cat__more" translatable="false">@string/nav_menu_more</string>
<!-- <!--
Pref keys Pref keys
--> -->
<string name="pref_cat__more" translatable="false">@string/nav_menu_more</string>
<string name="pref_key__current_pod_0" translatable="false">pref_key__current_pod_0</string> <string name="pref_key__current_pod_0" translatable="false">pref_key__current_pod_0</string>
<string name="pref_key__font_size" translatable="false">pref_key_font_size</string> <string name="pref_key__font_size" translatable="false">pref_key_font_size</string>
<string name="pref_key__language" translatable="false">pref_key__language</string> <string name="pref_key__language" translatable="false">pref_key__language</string>
@ -60,8 +72,6 @@
<string name="pref_key__topbar_stream_shortcut" translatable="false">pref_key__topbar_stream_shortcut</string> <string name="pref_key__topbar_stream_shortcut" translatable="false">pref_key__topbar_stream_shortcut</string>
<string name="pref_key__app_first_start" translatable="false">pref_key__app_first_start</string> <string name="pref_key__app_first_start" translatable="false">pref_key__app_first_start</string>
<string name="pref_key__app_first_start_current_version" translatable="false">pref_key__app_first_start_current_version</string> <string name="pref_key__app_first_start_current_version" translatable="false">pref_key__app_first_start_current_version</string>
<!-- Themes -->
<string name="pref_key__primary_color__amoled_mode" translatable="false">pref_key__primary_color__amoled_mode</string> <string name="pref_key__primary_color__amoled_mode" translatable="false">pref_key__primary_color__amoled_mode</string>
<string name="pref_key__primary_color__preference_click" translatable="false">@string/pref_key__primary_color_shade</string> <string name="pref_key__primary_color__preference_click" translatable="false">@string/pref_key__primary_color_shade</string>
<string name="pref_key__primary_color_base" translatable="false">pref_key_primary_color_base</string> <string name="pref_key__primary_color_base" translatable="false">pref_key_primary_color_base</string>
@ -69,15 +79,10 @@
<string name="pref_key__accent_color__preference_click" translatable="false">@string/pref_key__accent_color_shade</string> <string name="pref_key__accent_color__preference_click" translatable="false">@string/pref_key__accent_color_shade</string>
<string name="pref_key__accent_color_base" translatable="false">pref_key_accent_color_base</string> <string name="pref_key__accent_color_base" translatable="false">pref_key_accent_color_base</string>
<string name="pref_key__accent_color_shade" translatable="false">pref_key_accent_color_shade</string> <string name="pref_key__accent_color_shade" translatable="false">pref_key_accent_color_shade</string>
<string name="pref_key__append_shared_via_app" translatable="false">pref_key_append_shared_via_app</string> <string name="pref_key__append_shared_via_app" translatable="false">pref_key_append_shared_via_app</string>
<string name="pref_key__http_proxy_enabled" translatable="false">pref_key_proxy_enabled</string> <string name="pref_key__http_proxy_enabled" translatable="false">pref_key_proxy_enabled</string>
<string name="pref_key__http_proxy_host" translatable="false">pref_key_proxy_host</string> <string name="pref_key__http_proxy_host" translatable="false">pref_key_proxy_host</string>
<string name="pref_key__http_proxy_port" translatable="false">pref_key_proxy_port</string> <string name="pref_key__http_proxy_port" translatable="false">pref_key_proxy_port</string>
<string name="pref_key__proxy_was_enabled" translatable="false">wasProxyEnabled</string>
<!-- Navigation Slider -->
<string name="pref_key__screen_rotation" translatable="false">pref_key__screen_rotation</string> <string name="pref_key__screen_rotation" translatable="false">pref_key__screen_rotation</string>
<string name="pref_key__visibility_nav__exit" translatable="false">pref_key__visibility_navslider__exit</string> <string name="pref_key__visibility_nav__exit" translatable="false">pref_key__visibility_navslider__exit</string>
<string name="pref_key__visibility_nav__help_license" translatable="false">pref_key__visibility_nav__help_license</string> <string name="pref_key__visibility_nav__help_license" translatable="false">pref_key__visibility_nav__help_license</string>
@ -94,8 +99,6 @@
<string name="pref_key__visibility_nav__statistics" translatable="false">pref_key__visibility_nav__statistics</string> <string name="pref_key__visibility_nav__statistics" translatable="false">pref_key__visibility_nav__statistics</string>
<string name="pref_key__visibility_nav__toggle_mobile_desktop" translatable="false">pref_key__visibility_nav__toggle_mobile_desktop</string> <string name="pref_key__visibility_nav__toggle_mobile_desktop" translatable="false">pref_key__visibility_nav__toggle_mobile_desktop</string>
<string name="pref_key__visibility_nav__dandelion_account" translatable="false">pref_key__visibility_nav__dandelion_account</string> <string name="pref_key__visibility_nav__dandelion_account" translatable="false">pref_key__visibility_nav__dandelion_account</string>
<!-- PodProfile -->
<string name="pref_key__podprofile_avatar_url" translatable="false">pref_key__podprofile_avatar_url</string> <string name="pref_key__podprofile_avatar_url" translatable="false">pref_key__podprofile_avatar_url</string>
<string name="pref_key__podprofile_name" translatable="false">pref_key__podprofile_name</string> <string name="pref_key__podprofile_name" translatable="false">pref_key__podprofile_name</string>
<string name="pref_key__podprofile_id" translatable="false">pref_key__podprofile_id</string> <string name="pref_key__podprofile_id" translatable="false">pref_key__podprofile_id</string>
@ -105,26 +108,10 @@
<string name="pref_key__podprofile_followed_tags_favs" translatable="false">pref_key__podprofile_followed_tags_favs</string> <string name="pref_key__podprofile_followed_tags_favs" translatable="false">pref_key__podprofile_followed_tags_favs</string>
<string name="pref_key__podprofile_unread_message_count" translatable="false">pref_key__podprofile_unread_message_count</string> <string name="pref_key__podprofile_unread_message_count" translatable="false">pref_key__podprofile_unread_message_count</string>
<string name="pref_key__podprofile_notification_count" translatable="false">pref_key__podprofile_notification_count</string> <string name="pref_key__podprofile_notification_count" translatable="false">pref_key__podprofile_notification_count</string>
<string name="pref_key__podprofile_last_stream_position" translatable="false">pref_key__podprofile_last_stream_position</string> <string name="pref_key__podprofile_last_stream_position" translatable="false">pref_key__podprofile_last_stream_position</string> <!-- More -->
<string name="pref_title__manage_contacts" translatable="false">@string/contacts</string>
<!-- More -->
<string name="pref_key__logging_spam_enabled" translatable="false">pref_key__logging_spam_enabled</string> <string name="pref_key__logging_spam_enabled" translatable="false">pref_key__logging_spam_enabled</string>
<string name="pref_key__logging_enabled" translatable="false">pref_key__logging_enabled</string> <string name="pref_key__logging_enabled" translatable="false">pref_key__logging_enabled</string>
<string name="pref_key__wipe_settings" translatable="false">pref_key__wipe_settings</string> <string name="pref_key__wipe_settings" translatable="false">pref_key__wipe_settings</string>
<string name="pref_title__sub_logging" translatable="false">@string/about_activity__title_debug_info</string>
<string name="pref_desc__sub_logging" translatable="false">@string/fragment_debug__section_log</string>
<string name="pref_title__logging_enabled" translatable="false">@string/fragment_debug__section_log</string>
<string name="pref_title__logging_spam_enabled" translatable="false">@string/fragment_debug__section_log_spam</string>
<!-- Network -->
<string name="pref_desc__sub_proxy" translatable="false">@string/pref_desc__http_proxy_enabled</string>
<string name="HTTP" translatable="false">HTTP</string>
<string name="pref_title__chrome_custom_tabs_enabled" translatable="false">Chrome Custom Tabs</string>
<!-- Recently added - Please move to right section-->
<!-- Sorry -->
<string name="pref_key__title__appearance" translatable="false">pref_key__title__appearance</string> <string name="pref_key__title__appearance" translatable="false">pref_key__title__appearance</string>
<string name="pref_key__title__pod_settings" translatable="false">pref_key__title__pod_settings</string> <string name="pref_key__title__pod_settings" translatable="false">pref_key__title__pod_settings</string>
<string name="pref_key__title__network" translatable="false">pref_key__title__network</string> <string name="pref_key__title__network" translatable="false">pref_key__title__network</string>
@ -132,12 +119,11 @@
<string name="pref_key__title__debugging" translatable="false">pref_key__title__debugging</string> <string name="pref_key__title__debugging" translatable="false">pref_key__title__debugging</string>
<string name="pref_key__title__proxy" translatable="false">pref_key__title__proxy</string> <string name="pref_key__title__proxy" translatable="false">pref_key__title__proxy</string>
<string name="pref_key__title__themes" translatable="false">pref_key__title__themes</string> <string name="pref_key__title__themes" translatable="false">pref_key__title__themes</string>
<string name="pref_key__cat_themes" translatable="false">pref_key__cat_themes</string> <string name="pref_key__cat_themes" translatable="false">pref_key__cat_themes</string>
<string name="pref_key__cat_nav_slider" translatable="false">pref_key__cat_nav_slider</string> <string name="pref_key__cat_nav_slider" translatable="false">pref_key__cat_nav_slider</string>
<string name="pref_key__cat_proxy" translatable="false">pref_key__cat_proxy</string> <string name="pref_key__cat_proxy" translatable="false">pref_key__cat_proxy</string>
<string name="pref_key__cat_debugging" translatable="false">pref_key__cat_debugging</string> <string name="pref_key__cat_debugging" translatable="false">pref_key__cat_debugging</string>
<string name="pref_key__adblock_enable" translatable="false">pref_key__adblock_enable</string> <string name="pref_key__adblock_enable" translatable="false">pref_key__adblock_enable</string>
<string name="pref_key__is_overview_statusbar_hidden" translatable="false">pref_key__is_overview_statusbar_hidden</string>
<string name="pref_key__recreate_main_activity" translatable="false">pref_key__recreate_main_activity</string>
</resources> </resources>

View file

@ -94,4 +94,6 @@
<string name="pod_address">Pod address</string> <string name="pod_address">Pod address</string>
<string name="missing_value">Missing value</string> <string name="missing_value">Missing value</string>
<string name="jump_to_last_visited_timestamp_in_stream">Jump to last visited page in stream?</string> <string name="jump_to_last_visited_timestamp_in_stream">Jump to last visited page in stream?</string>
<string name="pref_summary__is_statusbar_hidden">Hide statusbar at main view</string>
<string name="pref_title__is_statusbar_hidden">Hide statusbar</string>
</resources> </resources>

View file

@ -43,12 +43,19 @@
android:title="@string/pref_cat__operability"> android:title="@string/pref_cat__operability">
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference <com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
android:defaultValue="true" android:defaultValue="false"
android:icon="@drawable/ic_zoom_out_map_black_24px" android:icon="@drawable/ic_zoom_out_map_black_24px"
android:key="@string/pref_key__intellihide_toolbars" android:key="@string/pref_key__intellihide_toolbars"
android:summary="@string/pref_desc__intellihide_toolbars" android:summary="@string/pref_desc__intellihide_toolbars"
android:title="@string/pref_title__intellihide_toolbars"/> android:title="@string/pref_title__intellihide_toolbars"/>
<CheckBoxPreference
android:icon="@drawable/ic_visibility_black_24dp"
android:defaultValue="false"
android:key="@string/pref_key__is_overview_statusbar_hidden"
android:summary="@string/pref_summary__is_statusbar_hidden"
android:title="@string/pref_title__is_statusbar_hidden"/>
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference <com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:icon="@drawable/ic_notifications_black_24px" android:icon="@drawable/ic_notifications_black_24px"