mirror of https://github.com/kurisufriend/Clover
commit
0365cafaa9
@ -0,0 +1,79 @@ |
||||
/* |
||||
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||
* Copyright (C) 2014 Floens |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.floens.chan.ui.controller; |
||||
|
||||
import android.content.Context; |
||||
import android.view.View; |
||||
import android.widget.FrameLayout; |
||||
|
||||
import org.floens.chan.R; |
||||
import org.floens.chan.controller.Controller; |
||||
import org.floens.chan.controller.ControllerLogic; |
||||
import org.floens.chan.controller.NavigationController; |
||||
|
||||
public class PopupController extends Controller implements View.OnClickListener { |
||||
private FrameLayout topView; |
||||
private FrameLayout container; |
||||
|
||||
private NavigationController childController; |
||||
|
||||
public PopupController(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
|
||||
view = inflateRes(R.layout.layout_controller_popup); |
||||
topView = (FrameLayout) view.findViewById(R.id.top_view); |
||||
topView.setOnClickListener(this); |
||||
container = (FrameLayout) view.findViewById(R.id.container); |
||||
} |
||||
|
||||
@Override |
||||
public void onDestroy() { |
||||
super.onDestroy(); |
||||
|
||||
if (childController != null) { |
||||
childController.onDestroy(); |
||||
} |
||||
} |
||||
|
||||
public void setChildController(NavigationController childController) { |
||||
childController.parentController = this; |
||||
ControllerLogic.transition(this.childController, childController, true, true, container); |
||||
this.childController = childController; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onBack() { |
||||
return childController != null && childController.onBack(); |
||||
} |
||||
|
||||
@Override |
||||
public void onClick(View v) { |
||||
dismiss(); |
||||
} |
||||
|
||||
public void dismiss() { |
||||
if (presentingController instanceof SplitNavigationController) { |
||||
((SplitNavigationController) presentingController).popAll(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,100 @@ |
||||
/* |
||||
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||
* Copyright (C) 2014 Floens |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.floens.chan.ui.controller; |
||||
|
||||
import android.content.Context; |
||||
import android.view.ViewGroup; |
||||
|
||||
import org.floens.chan.R; |
||||
import org.floens.chan.controller.Controller; |
||||
import org.floens.chan.controller.ControllerTransition; |
||||
import org.floens.chan.ui.theme.ThemeHelper; |
||||
import org.floens.chan.ui.toolbar.Toolbar; |
||||
|
||||
public class StyledToolbarNavigationController extends ToolbarNavigationController { |
||||
public StyledToolbarNavigationController(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
|
||||
view = inflateRes(R.layout.controller_navigation_toolbar); |
||||
container = (ViewGroup) view.findViewById(R.id.container); |
||||
toolbar = (Toolbar) view.findViewById(R.id.toolbar); |
||||
toolbar.setBackgroundColor(ThemeHelper.getInstance().getTheme().primaryColor.color); |
||||
toolbar.setCallback(this); |
||||
} |
||||
|
||||
@Override |
||||
public void transition(Controller from, Controller to, boolean pushing, ControllerTransition controllerTransition) { |
||||
super.transition(from, to, pushing, controllerTransition); |
||||
|
||||
if (to != null) { |
||||
DrawerController drawerController = getDrawerController(); |
||||
if (drawerController != null) { |
||||
drawerController.setDrawerEnabled(to.navigationItem.hasDrawer); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean onBack() { |
||||
if (super.onBack()) { |
||||
return true; |
||||
} else if (parentController instanceof PopupController && controllerList.size() == 1) { |
||||
((PopupController) parentController).dismiss(); |
||||
return true; |
||||
} else if (navigationController instanceof SplitNavigationController && controllerList.size() == 1) { |
||||
SplitNavigationController splitNavigationController = (SplitNavigationController) navigationController; |
||||
if (splitNavigationController.rightController == this) { |
||||
splitNavigationController.setRightController(null); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onMenuOrBackClicked(boolean isArrow) { |
||||
if (isArrow) { |
||||
onBack(); |
||||
} else { |
||||
DrawerController drawerController = getDrawerController(); |
||||
if (drawerController != null) { |
||||
drawerController.onMenuClicked(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private DrawerController getDrawerController() { |
||||
if (parentController instanceof DrawerController) { |
||||
return (DrawerController) parentController; |
||||
} else if (navigationController instanceof SplitNavigationController) { |
||||
SplitNavigationController splitNavigationController = (SplitNavigationController) navigationController; |
||||
if (splitNavigationController.parentController instanceof DrawerController) { |
||||
return (DrawerController) splitNavigationController.parentController; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,103 @@ |
||||
/* |
||||
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||
* Copyright (C) 2014 Floens |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.floens.chan.ui.controller; |
||||
|
||||
import android.content.Context; |
||||
import android.widget.FrameLayout; |
||||
|
||||
import org.floens.chan.R; |
||||
import org.floens.chan.controller.Controller; |
||||
import org.floens.chan.controller.ControllerTransition; |
||||
import org.floens.chan.controller.NavigationController; |
||||
import org.floens.chan.ui.toolbar.Toolbar; |
||||
|
||||
public abstract class ToolbarNavigationController extends NavigationController implements Toolbar.ToolbarCallback { |
||||
protected Toolbar toolbar; |
||||
|
||||
public ToolbarNavigationController(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public Toolbar getToolbar() { |
||||
return toolbar; |
||||
} |
||||
|
||||
public void showSearch() { |
||||
toolbar.openSearch(); |
||||
} |
||||
|
||||
@Override |
||||
public void transition(Controller from, Controller to, boolean pushing, ControllerTransition controllerTransition) { |
||||
super.transition(from, to, pushing, controllerTransition); |
||||
|
||||
if (to != null) { |
||||
toolbar.setNavigationItem(controllerTransition != null, pushing, to.navigationItem); |
||||
updateToolbarCollapse(to, controllerTransition != null); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onMenuOrBackClicked(boolean isArrow) { |
||||
} |
||||
|
||||
@Override |
||||
public boolean onBack() { |
||||
return toolbar.closeSearch() || super.onBack(); |
||||
} |
||||
|
||||
@Override |
||||
public String getSearchHint() { |
||||
return context.getString(R.string.search_hint); |
||||
} |
||||
|
||||
@Override |
||||
public void onSearchVisibilityChanged(boolean visible) { |
||||
Controller top = getTop(); |
||||
if (top instanceof ToolbarSearchCallback) { |
||||
((ToolbarSearchCallback) top).onSearchVisibilityChanged(visible); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onSearchEntered(String entered) { |
||||
Controller top = getTop(); |
||||
if (top instanceof ToolbarSearchCallback) { |
||||
((ToolbarSearchCallback) top).onSearchEntered(entered); |
||||
} |
||||
} |
||||
|
||||
protected void updateToolbarCollapse(Controller controller, boolean animate) { |
||||
if (!controller.navigationItem.collapseToolbar) { |
||||
FrameLayout.LayoutParams toViewParams = (FrameLayout.LayoutParams) controller.view.getLayoutParams(); |
||||
toViewParams.topMargin = toolbar.getToolbarHeight(); |
||||
controller.view.setLayoutParams(toViewParams); |
||||
} |
||||
|
||||
toolbar.processScrollCollapse(Toolbar.TOOLBAR_COLLAPSE_SHOW, animate); |
||||
} |
||||
|
||||
public interface ToolbarSearchCallback { |
||||
void onSearchVisibilityChanged(boolean visible); |
||||
|
||||
void onSearchEntered(String entered); |
||||
} |
||||
|
||||
public interface ToolbarMenuCallback { |
||||
void onMenuOrBackClicked(boolean isArrow); |
||||
} |
||||
} |
@ -0,0 +1,49 @@ |
||||
/* |
||||
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||
* Copyright (C) 2014 Floens |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.floens.chan.ui.layout; |
||||
|
||||
import android.content.Context; |
||||
import android.util.AttributeSet; |
||||
import android.widget.LinearLayout; |
||||
|
||||
import static org.floens.chan.utils.AndroidUtils.dp; |
||||
|
||||
public class PostRepliesContainer extends LinearLayout { |
||||
public PostRepliesContainer(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public PostRepliesContainer(Context context, AttributeSet attrs) { |
||||
super(context, attrs); |
||||
} |
||||
|
||||
public PostRepliesContainer(Context context, AttributeSet attrs, int defStyleAttr) { |
||||
super(context, attrs, defStyleAttr); |
||||
} |
||||
|
||||
@Override |
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
||||
int maxWidth = dp(600); |
||||
|
||||
if (MeasureSpec.getSize(widthMeasureSpec) > maxWidth) { |
||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.getMode(widthMeasureSpec)); |
||||
} |
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Clover - 4chan browser https://github.com/Floens/Clover/ |
||||
Copyright (C) 2014 Floens |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<org.floens.chan.ui.view.TouchBlockingFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="?backcolor"> |
||||
|
||||
<org.floens.chan.ui.toolbar.Toolbar |
||||
android:id="@+id/toolbar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="@dimen/toolbar_height" /> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
|
||||
</org.floens.chan.ui.view.TouchBlockingFrameLayout> |
@ -0,0 +1,32 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Clover - 4chan browser https://github.com/Floens/Clover/ |
||||
Copyright (C) 2014 Floens |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<FrameLayout |
||||
android:id="@+id/top_view" |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="#88000000"> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/container" |
||||
android:layout_width="600dp" |
||||
android:layout_height="600dp" |
||||
android:layout_gravity="center" |
||||
android:background="@drawable/dialog_full_light"/> |
||||
|
||||
</FrameLayout> |
@ -0,0 +1,32 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Clover - 4chan browser https://github.com/Floens/Clover/ |
||||
Copyright (C) 2014 Floens |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<FrameLayout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="?backcolor"> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center" |
||||
android:text="@string/thread_empty_select" |
||||
android:textColor="?text_color_secondary" |
||||
android:textSize="16sp"/> |
||||
|
||||
</FrameLayout> |
Loading…
Reference in new issue