Toolbars
This commit is contained in:
parent
b4ca63a39e
commit
aa47871f5f
@ -86,7 +86,6 @@ dependencies {
|
|||||||
compile 'com.google.android.gms:play-services-ads:8.4.0'
|
compile 'com.google.android.gms:play-services-ads:8.4.0'
|
||||||
compile 'com.google.android.gms:play-services-base:8.4.0'
|
compile 'com.google.android.gms:play-services-base:8.4.0'
|
||||||
compile 'com.google.android.gms:play-services-analytics:8.4.0'
|
compile 'com.google.android.gms:play-services-analytics:8.4.0'
|
||||||
compile 'com.melnykov:floatingactionbutton:1.1.0'
|
|
||||||
compile(name: 'plotter', ext: 'aar')
|
compile(name: 'plotter', ext: 'aar')
|
||||||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
||||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||||
|
@ -31,7 +31,9 @@ import android.graphics.Color;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
@ -43,6 +45,7 @@ import android.widget.TextView;
|
|||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import org.solovyev.android.Activities;
|
import org.solovyev.android.Activities;
|
||||||
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.Views;
|
import org.solovyev.android.Views;
|
||||||
import org.solovyev.android.calculator.history.History;
|
import org.solovyev.android.calculator.history.History;
|
||||||
import org.solovyev.android.calculator.language.Language;
|
import org.solovyev.android.calculator.language.Language;
|
||||||
@ -79,6 +82,9 @@ public class ActivityUi {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Bind(R.id.toolbar)
|
@Bind(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
|
@Nullable
|
||||||
|
@Bind(R.id.fab)
|
||||||
|
FloatingActionButton fab;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private Preferences.Gui.Theme theme = Preferences.Gui.Theme.material_theme;
|
private Preferences.Gui.Theme theme = Preferences.Gui.Theme.material_theme;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -337,4 +343,14 @@ public class ActivityUi {
|
|||||||
public Tabs getTabs() {
|
public Tabs getTabs() {
|
||||||
return tabs;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void withFab(@DrawableRes int icon, @Nonnull View.OnClickListener listener) {
|
||||||
|
if (fab == null) {
|
||||||
|
Check.shouldNotHappen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fab.setVisibility(View.VISIBLE);
|
||||||
|
fab.setImageResource(icon);
|
||||||
|
fab.setOnClickListener(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.solovyev.android.calculator.functions.EditFunctionFragment;
|
|||||||
import org.solovyev.android.calculator.functions.FunctionsFragment;
|
import org.solovyev.android.calculator.functions.FunctionsFragment;
|
||||||
import org.solovyev.android.calculator.history.BaseHistoryFragment;
|
import org.solovyev.android.calculator.history.BaseHistoryFragment;
|
||||||
import org.solovyev.android.calculator.history.EditHistoryFragment;
|
import org.solovyev.android.calculator.history.EditHistoryFragment;
|
||||||
|
import org.solovyev.android.calculator.history.HistoryActivity;
|
||||||
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
||||||
import org.solovyev.android.calculator.floating.FloatingCalculatorView;
|
import org.solovyev.android.calculator.floating.FloatingCalculatorView;
|
||||||
import org.solovyev.android.calculator.operators.OperatorsFragment;
|
import org.solovyev.android.calculator.operators.OperatorsFragment;
|
||||||
@ -49,4 +50,5 @@ public interface AppComponent {
|
|||||||
void inject(FloatingCalculatorView view);
|
void inject(FloatingCalculatorView view);
|
||||||
void inject(DragButtonWizardStep fragment);
|
void inject(DragButtonWizardStep fragment);
|
||||||
void inject(BaseFragment fragment);
|
void inject(BaseFragment fragment);
|
||||||
|
void inject(HistoryActivity activity);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@ public class AdUi {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adView.resume();
|
adView.resume();
|
||||||
|
if (adFree != null) {
|
||||||
|
updateAdView();
|
||||||
|
} else {
|
||||||
checkout.loadInventory().whenLoaded(onMainThread(new Inventory.Listener() {
|
checkout.loadInventory().whenLoaded(onMainThread(new Inventory.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLoaded(@Nonnull Inventory.Products products) {
|
public void onLoaded(@Nonnull Inventory.Products products) {
|
||||||
@ -52,6 +55,7 @@ public class AdUi {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateAdView() {
|
private void updateAdView() {
|
||||||
if (adFree == null || adView == null) {
|
if (adFree == null || adView == null) {
|
||||||
|
@ -35,7 +35,6 @@ import android.view.*;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.*;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.views.llm.DividerItemDecoration;
|
import org.solovyev.android.views.llm.DividerItemDecoration;
|
||||||
@ -61,8 +60,6 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Bind(R.id.entities_fab)
|
|
||||||
public FloatingActionButton fab;
|
|
||||||
@Bind(R.id.entities_recyclerview)
|
@Bind(R.id.entities_recyclerview)
|
||||||
public RecyclerView recyclerView;
|
public RecyclerView recyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -47,7 +47,7 @@ public class FloatingCalculatorActivity extends AppCompatActivity {
|
|||||||
final String permission = getString(R.string.cpp_permission_overlay);
|
final String permission = getString(R.string.cpp_permission_overlay);
|
||||||
builder.setMessage(getString(R.string.cpp_missing_permission_msg, permission));
|
builder.setMessage(getString(R.string.cpp_missing_permission_msg, permission));
|
||||||
builder.setTitle(R.string.cpp_missing_permission_title);
|
builder.setTitle(R.string.cpp_missing_permission_title);
|
||||||
builder.setPositiveButton(R.string.ok, this);
|
builder.setPositiveButton(R.string.ok, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
package org.solovyev.android.calculator.functions;
|
package org.solovyev.android.calculator.functions;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
@ -46,6 +47,13 @@ public class FunctionsActivity extends BaseActivity {
|
|||||||
EditFunctionFragment.show(function, this);
|
EditFunctionFragment.show(function, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.withFab(R.drawable.ic_add_white_36dp, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
EditFunctionFragment.show(FunctionsActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,14 +64,6 @@ public class FunctionsFragment extends BaseEntitiesFragment<Function> {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
bus.register(this);
|
bus.register(this);
|
||||||
fab.setVisibility(View.VISIBLE);
|
|
||||||
fab.attachToRecyclerView(recyclerView);
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
EditFunctionFragment.show(getActivity());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,9 @@ package org.solovyev.android.calculator.history;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
@ -37,7 +35,6 @@ import android.view.*;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
@ -64,8 +61,6 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
Bus bus;
|
Bus bus;
|
||||||
@Bind(R.id.history_recyclerview)
|
@Bind(R.id.history_recyclerview)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
@Bind(R.id.history_fab)
|
|
||||||
FloatingActionButton fab;
|
|
||||||
private HistoryAdapter adapter;
|
private HistoryAdapter adapter;
|
||||||
|
|
||||||
protected BaseHistoryFragment(boolean recentHistory) {
|
protected BaseHistoryFragment(boolean recentHistory) {
|
||||||
@ -107,35 +102,9 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
recyclerView.addItemDecoration(new DividerItemDecoration(context, null));
|
recyclerView.addItemDecoration(new DividerItemDecoration(context, null));
|
||||||
fab.attachToRecyclerView(recyclerView);
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
showClearHistoryDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showClearHistoryDialog() {
|
|
||||||
new AlertDialog.Builder(getActivity(), App.getTheme().alertDialogTheme)
|
|
||||||
.setTitle(R.string.cpp_clear_history_title)
|
|
||||||
.setMessage(R.string.cpp_clear_history_message)
|
|
||||||
.setPositiveButton(R.string.cpp_clear_history, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (recentHistory) {
|
|
||||||
history.clearRecent();
|
|
||||||
} else {
|
|
||||||
history.clearSaved();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.c_cancel, null)
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected final void copyResult(@Nonnull HistoryState state) {
|
protected final void copyResult(@Nonnull HistoryState state) {
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
@ -12,16 +12,14 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import org.solovyev.android.calculator.AppComponent;
|
import org.solovyev.android.calculator.AppComponent;
|
||||||
import org.solovyev.android.calculator.BaseDialogFragment;
|
import org.solovyev.android.calculator.BaseDialogFragment;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.Bind;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
public class EditHistoryFragment extends BaseDialogFragment {
|
public class EditHistoryFragment extends BaseDialogFragment {
|
||||||
|
|
||||||
public static final String ARG_STATE = "state";
|
public static final String ARG_STATE = "state";
|
||||||
@ -74,14 +72,22 @@ public class EditHistoryFragment extends BaseDialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPrepareDialog(@NonNull AlertDialog.Builder builder) {
|
protected void onPrepareDialog(@NonNull AlertDialog.Builder builder) {
|
||||||
builder.setNegativeButton(R.string.c_cancel, null);
|
builder.setNegativeButton(R.string.c_cancel, null);
|
||||||
builder.setPositiveButton(R.string.c_save, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.c_save, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
final HistoryState.Builder b = HistoryState.builder(state, newState)
|
final HistoryState.Builder b = HistoryState.builder(state, newState)
|
||||||
.withComment(commentView.getText().toString());
|
.withComment(commentView.getText().toString());
|
||||||
history.updateSaved(b.build());
|
history.updateSaved(b.build());
|
||||||
|
dismiss();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super.onClick(dialog, which);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
|
@ -22,23 +22,67 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.View;
|
||||||
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.view.Tabs;
|
import org.solovyev.android.calculator.view.Tabs;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.FragmentTab.history;
|
|
||||||
import static org.solovyev.android.calculator.FragmentTab.saved_history;
|
import static org.solovyev.android.calculator.FragmentTab.saved_history;
|
||||||
|
|
||||||
public class HistoryActivity extends BaseActivity {
|
public class HistoryActivity extends BaseActivity {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
History history;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
ui.withFab(R.drawable.ic_delete_white_36dp, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final Fragment fragment = ui.getTabs().getCurrentFragment();
|
||||||
|
showClearHistoryDialog(fragment instanceof RecentHistoryFragment);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(@Nonnull AppComponent component) {
|
||||||
|
super.inject(component);
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateTabs(@Nonnull Tabs tabs) {
|
protected void populateTabs(@Nonnull Tabs tabs) {
|
||||||
super.populateTabs(tabs);
|
super.populateTabs(tabs);
|
||||||
tabs.addTab(history);
|
tabs.addTab(FragmentTab.history);
|
||||||
tabs.addTab(saved_history);
|
tabs.addTab(saved_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showClearHistoryDialog(final boolean recentHistory) {
|
||||||
|
new AlertDialog.Builder(this, App.getTheme().alertDialogTheme)
|
||||||
|
.setTitle(R.string.cpp_clear_history_title)
|
||||||
|
.setMessage(R.string.cpp_clear_history_message)
|
||||||
|
.setPositiveButton(R.string.cpp_clear_history, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (recentHistory) {
|
||||||
|
history.clearRecent();
|
||||||
|
} else {
|
||||||
|
history.clearSaved();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.c_cancel, null)
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
package org.solovyev.android.calculator.variables;
|
package org.solovyev.android.calculator.variables;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.view.Tabs;
|
import org.solovyev.android.calculator.view.Tabs;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -45,6 +47,13 @@ public class VariablesActivity extends BaseActivity {
|
|||||||
EditVariableFragment.showDialog(variable, this);
|
EditVariableFragment.showDialog(variable, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.withFab(R.drawable.ic_add_white_36dp, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
EditVariableFragment.showDialog(VariablesActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,8 +46,6 @@ import javax.inject.Inject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.FragmentTab.variables;
|
|
||||||
|
|
||||||
public class VariablesFragment extends BaseEntitiesFragment<IConstant> {
|
public class VariablesFragment extends BaseEntitiesFragment<IConstant> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -76,14 +74,6 @@ public class VariablesFragment extends BaseEntitiesFragment<IConstant> {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
bus.register(this);
|
bus.register(this);
|
||||||
fab.setVisibility(View.VISIBLE);
|
|
||||||
fab.attachToRecyclerView(recyclerView);
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
EditVariableFragment.showDialog(null, getFragmentManager());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import android.support.v4.app.FragmentPagerAdapter;
|
|||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -32,8 +33,8 @@ public class Tabs {
|
|||||||
@Bind(R.id.tabs)
|
@Bind(R.id.tabs)
|
||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
@Nullable
|
@Nullable
|
||||||
@Bind(R.id.viewpager)
|
@Bind(R.id.viewPager)
|
||||||
ViewPager viewpager;
|
ViewPager viewPager;
|
||||||
|
|
||||||
public Tabs(@Nonnull AppCompatActivity activity) {
|
public Tabs(@Nonnull AppCompatActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
@ -43,14 +44,21 @@ public class Tabs {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
ButterKnife.bind(this, activity);
|
ButterKnife.bind(this, activity);
|
||||||
|
|
||||||
if (tabLayout == null || viewpager == null) {
|
if (tabLayout == null || viewPager == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
viewpager.setAdapter(adapter);
|
final int tabs = adapter.getCount();
|
||||||
tabLayout.setupWithViewPager(viewpager);
|
if (tabs == 0) {
|
||||||
|
tabLayout.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewPager.setAdapter(adapter);
|
||||||
|
tabLayout.setTabMode(tabs > 3 ? TabLayout.MODE_SCROLLABLE : TabLayout.MODE_FIXED);
|
||||||
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
|
|
||||||
if (ViewCompat.isLaidOut(tabLayout)) {
|
if (ViewCompat.isLaidOut(tabLayout)) {
|
||||||
tabLayout.setupWithViewPager(viewpager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
} else {
|
} else {
|
||||||
final ViewTreeObserver treeObserver = Adjuster.getTreeObserver(tabLayout);
|
final ViewTreeObserver treeObserver = Adjuster.getTreeObserver(tabLayout);
|
||||||
if (treeObserver != null) {
|
if (treeObserver != null) {
|
||||||
@ -62,7 +70,7 @@ public class Tabs {
|
|||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
anotherTreeObserver.removeGlobalOnLayoutListener(this);
|
anotherTreeObserver.removeGlobalOnLayoutListener(this);
|
||||||
}
|
}
|
||||||
tabLayout.setupWithViewPager(viewpager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -87,6 +95,14 @@ public class Tabs {
|
|||||||
adapter.add(new TabFragment(fragmentClass, fragmentArgs, title));
|
adapter.add(new TabFragment(fragmentClass, fragmentArgs, title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Fragment getCurrentFragment() {
|
||||||
|
if (viewPager == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return adapter.getItem(viewPager.getCurrentItem());
|
||||||
|
}
|
||||||
|
|
||||||
private final class TabFragments extends FragmentPagerAdapter {
|
private final class TabFragments extends FragmentPagerAdapter {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
65
app/src/main/res/layout-land/activity_empty.xml
Normal file
65
app/src/main/res/layout-land/activity_empty.xml
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright 2013 serso aka se.solovyev
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
~
|
||||||
|
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
~ Contact details
|
||||||
|
~
|
||||||
|
~ Email: se.solovyev@gmail.com
|
||||||
|
~ Site: http://se.solovyev.org
|
||||||
|
-->
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/main"
|
||||||
|
style="@style/CppMain"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/viewPager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_scrollFlags="snap">
|
||||||
|
|
||||||
|
<android.support.design.widget.TabLayout
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabMaxWidth="0dp"
|
||||||
|
app:tabMode="fixed" />
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
style="@style/CppFab" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
@ -30,6 +30,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/viewPager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -43,13 +49,16 @@
|
|||||||
<android.support.design.widget.TabLayout
|
<android.support.design.widget.TabLayout
|
||||||
android:id="@+id/tabs"
|
android:id="@+id/tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabMaxWidth="0dp"
|
||||||
|
app:tabMode="fixed" />
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/viewpager"
|
android:id="@+id/fab"
|
||||||
android:layout_width="match_parent"
|
style="@style/CppFab"/>
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
@ -22,28 +22,16 @@
|
|||||||
~ Site: http://se.solovyev.org
|
~ Site: http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout a:id="@+id/main_fragment_layout"
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
|
||||||
a:id="@+id/main_fragment_layout"
|
|
||||||
style="@style/CppFragment"
|
style="@style/CppFragment"
|
||||||
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="match_parent">
|
a:layout_height="match_parent">
|
||||||
|
|
||||||
<org.solovyev.android.calculator.AdView style="@style/CppAd" />
|
<org.solovyev.android.calculator.AdView style="@style/CppAd" />
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
a:layout_width="match_parent"
|
|
||||||
a:layout_height="match_parent">
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
a:id="@+id/entities_recyclerview"
|
a:id="@+id/entities_recyclerview"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="match_parent" />
|
a:layout_height="match_parent" />
|
||||||
|
|
||||||
<com.melnykov.fab.FloatingActionButton
|
|
||||||
a:id="@+id/entities_fab"
|
|
||||||
style="@style/CppFab"
|
|
||||||
a:src="@drawable/ic_add_white_36dp"
|
|
||||||
a:visibility="gone" />
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -31,18 +31,9 @@
|
|||||||
|
|
||||||
<org.solovyev.android.calculator.AdView style="@style/CppAd" />
|
<org.solovyev.android.calculator.AdView style="@style/CppAd" />
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
a:layout_width="match_parent"
|
|
||||||
a:layout_height="match_parent">
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
a:id="@+id/history_recyclerview"
|
a:id="@+id/history_recyclerview"
|
||||||
a:layout_width="match_parent"
|
a:layout_width="match_parent"
|
||||||
a:layout_height="match_parent" />
|
a:layout_height="match_parent" />
|
||||||
|
|
||||||
<com.melnykov.fab.FloatingActionButton
|
|
||||||
a:id="@+id/history_fab"
|
|
||||||
style="@style/CppFab"
|
|
||||||
a:src="@drawable/ic_delete_white_36dp" />
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -279,9 +279,8 @@
|
|||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layout_gravity">bottom|end</item>
|
<item name="android:layout_gravity">bottom|end</item>
|
||||||
<item name="android:layout_margin">16dp</item>
|
<item name="android:layout_margin">16dp</item>
|
||||||
<item name="fab_colorNormal">?attr/cpp_fab_bg</item>
|
<item name="android:visibility">gone</item>
|
||||||
<item name="fab_colorPressed">?attr/cpp_fab_bg</item>
|
<item name="backgroundTint">?attr/cpp_fab_bg</item>
|
||||||
<item name="fab_colorRipple">?attr/colorControlHighlight</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CppListItemText">
|
<style name="CppListItemText">
|
||||||
@ -326,16 +325,14 @@
|
|||||||
<item name="android:padding">0dp</item>
|
<item name="android:padding">0dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CppActionBar" parent="@style/Widget.AppCompat.ActionBar">
|
<style name="CppToolbar" parent="@style/Widget.AppCompat.Toolbar">
|
||||||
<item name="background">@color/cpp_material_actionbar</item>
|
<item name="background">@color/cpp_material_actionbar</item>
|
||||||
<item name="android:background">@color/cpp_material_actionbar</item>
|
|
||||||
<item name="backgroundStacked">@color/cpp_material_actionbar</item>
|
<item name="backgroundStacked">@color/cpp_material_actionbar</item>
|
||||||
<item name="backgroundSplit">@color/cpp_material_actionbar</item>
|
<item name="backgroundSplit">@color/cpp_material_actionbar</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CppActionBar.Light" parent="CppActionBar">
|
<style name="CppToolbar.Light" parent="CppToolbar">
|
||||||
<item name="background">@color/cpp_material_actionbar_light</item>
|
<item name="background">@color/cpp_material_actionbar_light</item>
|
||||||
<item name="android:background">@color/cpp_material_actionbar_light</item>
|
|
||||||
<item name="backgroundStacked">@color/cpp_material_actionbar_light</item>
|
<item name="backgroundStacked">@color/cpp_material_actionbar_light</item>
|
||||||
<item name="backgroundSplit">@color/cpp_material_actionbar_light</item>
|
<item name="backgroundSplit">@color/cpp_material_actionbar_light</item>
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user