Make the layout modes options

Split layout on phones is for the power user, made some small fixes to make it "usable" on phones.
multisite
Floens 9 years ago
parent 7014fc6a8b
commit 4e1d61fbf4
  1. 3
      Clover/app/src/main/java/org/floens/chan/Chan.java
  2. 22
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  3. 30
      Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java
  4. 4
      Clover/app/src/main/java/org/floens/chan/ui/controller/AdvancedSettingsController.java
  5. 39
      Clover/app/src/main/java/org/floens/chan/ui/controller/MainSettingsController.java
  6. 6
      Clover/app/src/main/java/org/floens/chan/ui/layout/PopupControllerContainer.java
  7. 3
      Clover/app/src/main/java/org/floens/chan/ui/layout/SplitNavigationControllerLayout.java
  8. 5
      Clover/app/src/main/res/values/strings.xml

@ -22,7 +22,6 @@ import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.StrictMode; import android.os.StrictMode;
import android.webkit.WebView;
import com.android.volley.RequestQueue; import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.ImageLoader;
@ -149,7 +148,7 @@ public class Chan extends Application {
//noinspection PointlessBooleanExpression //noinspection PointlessBooleanExpression
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true); // WebView.setWebContentsDebuggingEnabled(true);
} }
} }
} }

@ -68,9 +68,27 @@ public class ChanSettings {
} }
} }
public enum LayoutMode implements OptionSettingItem {
AUTO("auto"),
PHONE("phone"),
SPLIT("split");
String name;
LayoutMode(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
}
private static Proxy proxy; private static Proxy proxy;
private static final StringSetting theme; private static final StringSetting theme;
public static final OptionsSetting<LayoutMode> layoutMode;
public static final StringSetting fontSize; public static final StringSetting fontSize;
public static final BooleanSetting fontCondensed; public static final BooleanSetting fontCondensed;
public static final BooleanSetting openLinkConfirmation; public static final BooleanSetting openLinkConfirmation;
@ -94,7 +112,6 @@ public class ChanSettings {
public static final BooleanSetting saveOriginalFilename; public static final BooleanSetting saveOriginalFilename;
public static final BooleanSetting shareUrl; public static final BooleanSetting shareUrl;
public static final BooleanSetting networkHttps; public static final BooleanSetting networkHttps;
public static final BooleanSetting forcePhoneLayout;
public static final BooleanSetting enableReplyFab; public static final BooleanSetting enableReplyFab;
public static final BooleanSetting anonymize; public static final BooleanSetting anonymize;
public static final BooleanSetting anonymizeIds; public static final BooleanSetting anonymizeIds;
@ -156,6 +173,8 @@ public class ChanSettings {
theme = new StringSetting(p, "preference_theme", "light"); theme = new StringSetting(p, "preference_theme", "light");
layoutMode = new OptionsSetting<>(p, "preference_layout_mode", LayoutMode.values(), LayoutMode.AUTO);
boolean tablet = AndroidUtils.getRes().getBoolean(R.bool.is_tablet); boolean tablet = AndroidUtils.getRes().getBoolean(R.bool.is_tablet);
fontSize = new StringSetting(p, "preference_font", tablet ? "16" : "14"); fontSize = new StringSetting(p, "preference_font", tablet ? "16" : "14");
@ -181,7 +200,6 @@ public class ChanSettings {
saveOriginalFilename = new BooleanSetting(p, "preference_image_save_original", false); saveOriginalFilename = new BooleanSetting(p, "preference_image_save_original", false);
shareUrl = new BooleanSetting(p, "preference_image_share_url", false); shareUrl = new BooleanSetting(p, "preference_image_share_url", false);
networkHttps = new BooleanSetting(p, "preference_network_https", true); networkHttps = new BooleanSetting(p, "preference_network_https", true);
forcePhoneLayout = new BooleanSetting(p, "preference_force_phone_layout", false);
enableReplyFab = new BooleanSetting(p, "preference_enable_reply_fab", true); enableReplyFab = new BooleanSetting(p, "preference_enable_reply_fab", true);
anonymize = new BooleanSetting(p, "preference_anonymize", false); anonymize = new BooleanSetting(p, "preference_anonymize", false);
anonymizeIds = new BooleanSetting(p, "preference_anonymize_ids", false); anonymizeIds = new BooleanSetting(p, "preference_anonymize_ids", false);

@ -97,17 +97,29 @@ public class StartActivity extends AppCompatActivity implements NfcAdapter.Creat
StyledToolbarNavigationController toolbarNavigationController = new StyledToolbarNavigationController(this); StyledToolbarNavigationController toolbarNavigationController = new StyledToolbarNavigationController(this);
if (AndroidUtils.isTablet(this) && !ChanSettings.forcePhoneLayout.get()) { ChanSettings.LayoutMode layoutMode = ChanSettings.layoutMode.get();
SplitNavigationController splitNavigationController = new SplitNavigationController(this); if (layoutMode == ChanSettings.LayoutMode.AUTO) {
splitNavigationController.setEmptyView((ViewGroup) LayoutInflater.from(this).inflate(R.layout.layout_split_empty, null)); if (AndroidUtils.isTablet(this)) {
layoutMode = ChanSettings.LayoutMode.SPLIT;
} else {
layoutMode = ChanSettings.LayoutMode.PHONE;
}
}
drawerController.setChildController(splitNavigationController); switch (layoutMode) {
case SPLIT:
SplitNavigationController splitNavigationController = new SplitNavigationController(this);
splitNavigationController.setEmptyView((ViewGroup) LayoutInflater.from(this).inflate(R.layout.layout_split_empty, null));
splitNavigationController.setLeftController(toolbarNavigationController); drawerController.setChildController(splitNavigationController);
mainNavigationController = toolbarNavigationController;
} else { splitNavigationController.setLeftController(toolbarNavigationController);
drawerController.setChildController(toolbarNavigationController); mainNavigationController = toolbarNavigationController;
mainNavigationController = toolbarNavigationController; break;
case PHONE:
drawerController.setChildController(toolbarNavigationController);
mainNavigationController = toolbarNavigationController;
break;
} }
browseController = new BrowseController(this); browseController = new BrowseController(this);

@ -46,7 +46,6 @@ public class AdvancedSettingsController extends SettingsController {
private boolean needRestart; private boolean needRestart;
private LinkSettingView saveLocation; private LinkSettingView saveLocation;
private SettingView newCaptcha; private SettingView newCaptcha;
private SettingView forcePhoneLayoutSetting;
private SettingView enableReplyFab; private SettingView enableReplyFab;
private SettingView neverHideToolbar; private SettingView neverHideToolbar;
private SettingView controllersSwipeable; private SettingView controllersSwipeable;
@ -84,7 +83,7 @@ public class AdvancedSettingsController extends SettingsController {
public void onPreferenceChange(SettingView item) { public void onPreferenceChange(SettingView item) {
super.onPreferenceChange(item); super.onPreferenceChange(item);
if (item == forcePhoneLayoutSetting || item == enableReplyFab || item == newCaptcha || item == neverHideToolbar || item == controllersSwipeable) { if (item == enableReplyFab || item == newCaptcha || item == neverHideToolbar || item == controllersSwipeable) {
needRestart = true; needRestart = true;
} else { } else {
EventBus.getDefault().post(new RefreshUIMessage("postui")); EventBus.getDefault().post(new RefreshUIMessage("postui"));
@ -120,7 +119,6 @@ public class AdvancedSettingsController extends SettingsController {
controllersSwipeable = settings.add(new BooleanSettingView(this, ChanSettings.controllerSwipeable, R.string.setting_controller_swipeable, 0)); controllersSwipeable = settings.add(new BooleanSettingView(this, ChanSettings.controllerSwipeable, R.string.setting_controller_swipeable, 0));
settings.add(new BooleanSettingView(this, ChanSettings.shareUrl, R.string.setting_share_url, R.string.setting_share_url_description)); settings.add(new BooleanSettingView(this, ChanSettings.shareUrl, R.string.setting_share_url, R.string.setting_share_url_description));
settings.add(new BooleanSettingView(this, ChanSettings.networkHttps, R.string.setting_network_https, R.string.setting_network_https_description)); settings.add(new BooleanSettingView(this, ChanSettings.networkHttps, R.string.setting_network_https, R.string.setting_network_https_description));
forcePhoneLayoutSetting = settings.add(new BooleanSettingView(this, ChanSettings.forcePhoneLayout, R.string.setting_force_phone_layout, 0));
enableReplyFab = settings.add(new BooleanSettingView(this, ChanSettings.enableReplyFab, R.string.setting_enable_reply_fab, R.string.setting_enable_reply_fab_description)); enableReplyFab = settings.add(new BooleanSettingView(this, ChanSettings.enableReplyFab, R.string.setting_enable_reply_fab, R.string.setting_enable_reply_fab_description));
settings.add(new BooleanSettingView(this, ChanSettings.anonymize, R.string.setting_anonymize, 0)); settings.add(new BooleanSettingView(this, ChanSettings.anonymize, R.string.setting_anonymize, 0));
settings.add(new BooleanSettingView(this, ChanSettings.anonymizeIds, R.string.setting_anonymize_ids, 0)); settings.add(new BooleanSettingView(this, ChanSettings.anonymizeIds, R.string.setting_anonymize_ids, 0));

@ -31,6 +31,7 @@ import android.widget.Toast;
import org.floens.chan.Chan; import org.floens.chan.Chan;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.core.settings.ChanSettings; import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.activity.StartActivity;
import org.floens.chan.ui.helper.HintPopup; import org.floens.chan.ui.helper.HintPopup;
import org.floens.chan.ui.helper.RefreshUIMessage; import org.floens.chan.ui.helper.RefreshUIMessage;
import org.floens.chan.ui.settings.BooleanSettingView; import org.floens.chan.ui.settings.BooleanSettingView;
@ -64,10 +65,13 @@ public class MainSettingsController extends SettingsController implements Toolba
private int clickCount; private int clickCount;
private SettingView developerView; private SettingView developerView;
private SettingView fontView; private SettingView fontView;
private SettingView layoutModeView;
private SettingView fontCondensed; private SettingView fontCondensed;
private SettingView gridColumnsView; private SettingView gridColumnsView;
private ToolbarMenuItem overflow; private ToolbarMenuItem overflow;
private ChanSettings.LayoutMode previousLayoutMode;
private PopupWindow advancedSettingsHint; private PopupWindow advancedSettingsHint;
public MainSettingsController(Context context) { public MainSettingsController(Context context) {
@ -87,6 +91,8 @@ public class MainSettingsController extends SettingsController implements Toolba
view = inflateRes(R.layout.settings_layout); view = inflateRes(R.layout.settings_layout);
content = (LinearLayout) view.findViewById(R.id.scrollview_content); content = (LinearLayout) view.findViewById(R.id.scrollview_content);
previousLayoutMode = ChanSettings.layoutMode.get();
populatePreferences(); populatePreferences();
onWatchEnabledChanged(ChanSettings.watchEnabled.get()); onWatchEnabledChanged(ChanSettings.watchEnabled.get());
@ -117,6 +123,15 @@ public class MainSettingsController extends SettingsController implements Toolba
} }
} }
@Override
public void onDestroy() {
super.onDestroy();
if (previousLayoutMode != ChanSettings.layoutMode.get()) {
((StartActivity) context).restart();
}
}
@Override @Override
public void onMenuItemClicked(ToolbarMenuItem item) { public void onMenuItemClicked(ToolbarMenuItem item) {
} }
@ -179,6 +194,26 @@ public class MainSettingsController extends SettingsController implements Toolba
} }
})); }));
List<ListSettingView.Item> layoutModes = new ArrayList<>();
for (ChanSettings.LayoutMode mode : ChanSettings.LayoutMode.values()) {
int name = 0;
switch (mode) {
case AUTO:
name = R.string.setting_layout_mode_auto;
break;
case PHONE:
name = R.string.setting_layout_mode_phone;
break;
case SPLIT:
name = R.string.setting_layout_mode_split;
break;
}
layoutModes.add(new ListSettingView.Item<>(getString(name), mode));
}
layoutModeView = new ListSettingView<>(this, ChanSettings.layoutMode, R.string.setting_layout_mode, layoutModes);
appearance.add(layoutModeView);
List<ListSettingView.Item> fontSizes = new ArrayList<>(); List<ListSettingView.Item> fontSizes = new ArrayList<>();
for (int size = 10; size <= 19; size++) { for (int size = 10; size <= 19; size++) {
String name = size + (String.valueOf(size).equals(ChanSettings.fontSize.getDefault()) ? " " + getString(R.string.setting_font_size_default) : ""); String name = size + (String.valueOf(size).equals(ChanSettings.fontSize.getDefault()) ? " " + getString(R.string.setting_font_size_default) : "");
@ -225,8 +260,8 @@ public class MainSettingsController extends SettingsController implements Toolba
break; break;
} }
imageAutoLoadTypes.add(new ListSettingView.Item<ChanSettings.MediaAutoLoadMode>(getString(name), mode)); imageAutoLoadTypes.add(new ListSettingView.Item<>(getString(name), mode));
videoAutoLoadTypes.add(new ListSettingView.Item<ChanSettings.MediaAutoLoadMode>(getString(name), mode)); videoAutoLoadTypes.add(new ListSettingView.Item<>(getString(name), mode));
} }
imageAutoLoadView = new ListSettingView<>(this, ChanSettings.imageAutoLoadNetwork, R.string.setting_image_auto_load, imageAutoLoadTypes); imageAutoLoadView = new ListSettingView<>(this, ChanSettings.imageAutoLoadNetwork, R.string.setting_image_auto_load, imageAutoLoadTypes);

@ -45,6 +45,12 @@ public class PopupControllerContainer extends FrameLayout {
FrameLayout.LayoutParams child = (LayoutParams) getChildAt(0).getLayoutParams(); FrameLayout.LayoutParams child = (LayoutParams) getChildAt(0).getLayoutParams();
if (widthMode == MeasureSpec.EXACTLY && widthSize < dp(600)) {
child.width = widthSize;
} else {
child.width = dp(600);
}
if (heightMode == MeasureSpec.EXACTLY && heightSize < dp(600)) { if (heightMode == MeasureSpec.EXACTLY && heightSize < dp(600)) {
child.height = heightSize; child.height = heightSize;
} else { } else {

@ -84,7 +84,8 @@ public class SplitNavigationControllerLayout extends LinearLayout {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
int leftWidth = Math.max(minimumLeftWidth, (int) (widthSize * ratio)); int minWidth = Math.min(minimumLeftWidth, widthSize / 2);
int leftWidth = Math.max(minWidth, (int) (widthSize * ratio));
int rightWidth = widthSize - dividerWidth - leftWidth; int rightWidth = widthSize - dividerWidth - leftWidth;
leftView.getLayoutParams().width = leftWidth; leftView.getLayoutParams().width = leftWidth;
rightView.getLayoutParams().width = rightWidth; rightView.getLayoutParams().width = rightWidth;

@ -355,6 +355,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="setting_theme">Theme</string> <string name="setting_theme">Theme</string>
<string name="setting_theme_explanation">Swipe to change the theme.\nTap the toolbar to change its color.\n</string> <string name="setting_theme_explanation">Swipe to change the theme.\nTap the toolbar to change its color.\n</string>
<string name="setting_theme_accent">Click here to change the FAB color</string> <string name="setting_theme_accent">Click here to change the FAB color</string>
<string name="setting_layout_mode">Layout mode</string>
<string name="setting_layout_mode_auto">Auto</string>
<string name="setting_layout_mode_phone">Phone layout</string>
<string name="setting_layout_mode_split">Split mode</string>
<string name="setting_font_size">Font size</string> <string name="setting_font_size">Font size</string>
<string name="setting_font_size_default">(default)</string> <string name="setting_font_size_default">(default)</string>
<string name="setting_font_condensed">Use condensed font</string> <string name="setting_font_condensed">Use condensed font</string>
@ -400,7 +404,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="setting_share_url_description">Share the url to the image instead of the image itself</string> <string name="setting_share_url_description">Share the url to the image instead of the image itself</string>
<string name="setting_network_https">Use HTTPS</string> <string name="setting_network_https">Use HTTPS</string>
<string name="setting_network_https_description">Use HTTPS for all network requests</string> <string name="setting_network_https_description">Use HTTPS for all network requests</string>
<string name="setting_force_phone_layout">Force phone layout</string>
<string name="setting_enable_reply_fab">Enable the reply FAB</string> <string name="setting_enable_reply_fab">Enable the reply FAB</string>
<string name="setting_enable_reply_fab_description">Disabling replaces it with a menu option</string> <string name="setting_enable_reply_fab_description">Disabling replaces it with a menu option</string>
<string name="setting_anonymize">Make everyone Anonymous</string> <string name="setting_anonymize">Make everyone Anonymous</string>

Loading…
Cancel
Save