Use toolbar instead of action bar in main activity
This commit is contained in:
parent
e30e8ca2fe
commit
96b4290260
@ -63,6 +63,7 @@ dependencies {
|
||||
compile 'org.solovyev:common-msg:1.0.7'
|
||||
compile 'com.android.support:support-v4:23.1.1'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'com.android.support:cardview-v7:23.1.1'
|
||||
compile 'com.android.support:design:23.1.1'
|
||||
compile('ch.acra:acra:4.7.0') {
|
||||
exclude group: 'org.json'
|
||||
|
@ -12,7 +12,6 @@ print 'Screenshot will be located in ' + outFolder + ' with name ' + outFilename
|
||||
apk = '/home/serso/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp/2012.11.25/calculatorpp.apk'
|
||||
package = 'org.solovyev.android.calculator'
|
||||
activity = 'org.solovyev.android.calculator.CalculatorActivity'
|
||||
mobileActivity = 'org.solovyev.android.calculator.CalculatorActivityMobile'
|
||||
operatorsActivity = 'org.solovyev.android.calculator.math.edit.CalculatorOperatorsActivity'
|
||||
deviceName = 'emulator-5580'
|
||||
|
||||
@ -56,18 +55,6 @@ if device:
|
||||
#outFilename = outFilename + '_' + str(time.time())
|
||||
takeScreenshot(outFolder, outFilename + '_operators');
|
||||
|
||||
runComponent = package + '/' + mobileActivity
|
||||
|
||||
print 'Starting activity ' + runComponent + '...'
|
||||
device.startActivity(component=runComponent)
|
||||
|
||||
# sleep while application will be loaded
|
||||
MonkeyRunner.sleep(4);
|
||||
|
||||
print 'Taking screenshot...'
|
||||
#outFilename = outFilename + '_' + str(time.time())
|
||||
takeScreenshot(outFolder, outFilename + '_mobile');
|
||||
|
||||
print '#########'
|
||||
print 'Finished!'
|
||||
print '#########'
|
||||
|
@ -56,13 +56,6 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name=".CalculatorActivityMobile"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:label="@string/c_app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name=".preferences.PreferencesActivity"
|
||||
android:label="@string/c_app_settings" />
|
||||
|
@ -22,26 +22,28 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.*;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import org.solovyev.android.Activities;
|
||||
import org.solovyev.android.Android;
|
||||
import org.solovyev.android.calculator.converter.ConverterFragment;
|
||||
import org.solovyev.android.calculator.history.History;
|
||||
import org.solovyev.android.calculator.keyboard.PartialKeyboardUi;
|
||||
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||
import org.solovyev.android.fragments.FragmentUtils;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.wizard.Wizard;
|
||||
import org.solovyev.android.wizard.Wizards;
|
||||
@ -51,14 +53,14 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
|
||||
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.preventScreenFromFading;
|
||||
import static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes;
|
||||
import static org.solovyev.android.wizard.WizardUi.*;
|
||||
|
||||
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, Toolbar.OnMenuItemClickListener {
|
||||
|
||||
@Nonnull
|
||||
public static final String TAG = CalculatorActivity.class.getSimpleName();
|
||||
@ -77,6 +79,10 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
@Nullable
|
||||
@Bind(R.id.partial_keyboard)
|
||||
View partialKeyboard;
|
||||
@Bind(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@Bind(R.id.editor)
|
||||
FrameLayout editor;
|
||||
private boolean useBackAsPrev;
|
||||
|
||||
public CalculatorActivity() {
|
||||
@ -154,36 +160,37 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
ui.setLayoutId(R.layout.main_calculator);
|
||||
ui.setLayoutId(R.layout.activity_main);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && hasPermanentMenuKey())) {
|
||||
actionBar.hide();
|
||||
} else {
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
}
|
||||
ButterKnife.bind(this);
|
||||
|
||||
FragmentUtils.createFragment(this, EditorFragment.class, R.id.editor, "editor");
|
||||
FragmentUtils.createFragment(this, DisplayFragment.class, R.id.display, "display");
|
||||
FragmentUtils.createFragment(this, KeyboardFragment.class, R.id.keyboard, "keyboard");
|
||||
if (savedInstanceState == null) {
|
||||
final FragmentManager fm = getSupportFragmentManager();
|
||||
final FragmentTransaction t = fm.beginTransaction();
|
||||
t.add(R.id.editor, new EditorFragment(), "editor");
|
||||
t.add(R.id.display, new DisplayFragment(), "display");
|
||||
t.add(R.id.keyboard, new KeyboardFragment(), "keyboard");
|
||||
t.commit();
|
||||
}
|
||||
|
||||
if (partialKeyboard != null) {
|
||||
partialKeyboardUi.onCreateView(this, partialKeyboard);
|
||||
}
|
||||
|
||||
this.useBackAsPrev = Preferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
toolbar.inflateMenu(R.menu.main);
|
||||
toolbar.setOnMenuItemClickListener(this);
|
||||
|
||||
useBackAsPrev = Preferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
if (savedInstanceState == null) {
|
||||
firstTimeInit(preferences, this);
|
||||
}
|
||||
|
||||
toggleOrientationChange(preferences);
|
||||
toggleOrientationChange();
|
||||
prepareCardAndToolbar();
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
preferredPreferences.check(this, false);
|
||||
|
||||
if (App.isMonkeyRunner(this)) {
|
||||
@ -199,11 +206,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
private boolean hasPermanentMenuKey() {
|
||||
return ViewConfiguration.get(this).hasPermanentMenuKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
@ -255,16 +257,60 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
}
|
||||
|
||||
if (Preferences.Gui.autoOrientation.getKey().equals(key)) {
|
||||
toggleOrientationChange(preferences);
|
||||
toggleOrientationChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
|
||||
private void toggleOrientationChange() {
|
||||
if (Preferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_settings:
|
||||
launcher.showSettings();
|
||||
return true;
|
||||
case R.id.menu_history:
|
||||
launcher.showHistory();
|
||||
return true;
|
||||
case R.id.menu_plotter:
|
||||
Locator.getInstance().getPlotter().plot();
|
||||
return true;
|
||||
case R.id.menu_conversion_tool:
|
||||
ConverterFragment.show(this);
|
||||
return true;
|
||||
case R.id.menu_about:
|
||||
launcher.showAbout();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void prepareCardAndToolbar() {
|
||||
if (!(editor instanceof CardView)) {
|
||||
return;
|
||||
}
|
||||
final CardView card = (CardView) editor;
|
||||
final Resources resources = getResources();
|
||||
final int cardTopMargin = resources.getDimensionPixelSize(R.dimen.cpp_card_margin);
|
||||
final int preLollipopCardTopPadding = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? card.getPaddingTop() : 0;
|
||||
|
||||
{
|
||||
final ViewGroup.LayoutParams lp = toolbar.getLayoutParams();
|
||||
lp.height += cardTopMargin + preLollipopCardTopPadding;
|
||||
toolbar.setLayoutParams(lp);
|
||||
// center icons in toolbar
|
||||
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + cardTopMargin / 2 + preLollipopCardTopPadding, toolbar.getPaddingRight(), toolbar.getPaddingBottom() + cardTopMargin / 2);
|
||||
}
|
||||
final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) card.getLayoutParams();
|
||||
final int actionWidth = resources.getDimensionPixelSize(R.dimen.abc_action_button_min_width_overflow_material) + 2 * resources.getDimensionPixelSize(R.dimen.abc_action_bar_overflow_padding_start_material);
|
||||
lp.leftMargin = actionWidth + 2 * toolbar.getPaddingLeft();
|
||||
lp.rightMargin = actionWidth + 2 * toolbar.getPaddingRight();
|
||||
card.setLayoutParams(lp);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 11/25/12
|
||||
* Time: 2:34 PM
|
||||
*/
|
||||
public class CalculatorActivityMobile extends CalculatorActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
Preferences.Gui.layout.putPreference(prefs, Preferences.Gui.Layout.main_calculator_mobile);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (!App.isMonkeyRunner(this)) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
}
|
@ -22,17 +22,10 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.solovyev.android.calculator.converter.ConverterFragment;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@ -43,10 +36,6 @@ public class EditorFragment extends BaseFragment {
|
||||
|
||||
@Inject
|
||||
Editor editor;
|
||||
@Inject
|
||||
SharedPreferences preferences;
|
||||
@Inject
|
||||
ActivityLauncher launcher;
|
||||
@Bind(R.id.calculator_editor)
|
||||
EditorView editorView;
|
||||
|
||||
@ -54,12 +43,6 @@ public class EditorFragment extends BaseFragment {
|
||||
super(R.layout.cpp_app_editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(@Nonnull AppComponent component) {
|
||||
super.inject(component);
|
||||
@ -79,31 +62,4 @@ public class EditorFragment extends BaseFragment {
|
||||
editor.clearView(editorView);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_settings:
|
||||
launcher.showSettings();
|
||||
return true;
|
||||
case R.id.menu_history:
|
||||
launcher.showHistory();
|
||||
return true;
|
||||
case R.id.menu_plotter:
|
||||
Locator.getInstance().getPlotter().plot();
|
||||
return true;
|
||||
case R.id.menu_conversion_tool:
|
||||
ConverterFragment.show(getActivity());
|
||||
return true;
|
||||
case R.id.menu_about:
|
||||
launcher.showAbout();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -288,20 +288,22 @@ public final class Preferences {
|
||||
|
||||
public enum Theme {
|
||||
|
||||
default_theme(R.style.Cpp_Theme_Gray),
|
||||
violet_theme(R.style.Cpp_Theme_Violet),
|
||||
light_blue_theme(R.style.Cpp_Theme_Blue),
|
||||
metro_blue_theme(R.style.Cpp_Theme_Metro_Blue),
|
||||
metro_purple_theme(R.style.Cpp_Theme_Metro_Purple),
|
||||
metro_green_theme(R.style.Cpp_Theme_Metro_Green),
|
||||
material_theme(R.style.Cpp_Theme_Material),
|
||||
material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Wizard_Light, R.style.Cpp_Theme_Material_Light_Dialog, R.style.Cpp_Theme_Material_Light_Dialog_Alert);
|
||||
default_theme(R.style.Cpp_Theme_Gray, R.style.Cpp_Theme_Gray_NoActionBar),
|
||||
violet_theme(R.style.Cpp_Theme_Violet, R.style.Cpp_Theme_Violet_NoActionBar),
|
||||
light_blue_theme(R.style.Cpp_Theme_Blue, R.style.Cpp_Theme_Blue_NoActionBar),
|
||||
metro_blue_theme(R.style.Cpp_Theme_Metro_Blue, R.style.Cpp_Theme_Metro_Blue_NoActionBar),
|
||||
metro_purple_theme(R.style.Cpp_Theme_Metro_Purple, R.style.Cpp_Theme_Metro_Purple_NoActionBar),
|
||||
metro_green_theme(R.style.Cpp_Theme_Metro_Green, R.style.Cpp_Theme_Metro_Green_NoActionBar),
|
||||
material_theme(R.style.Cpp_Theme_Material, R.style.Cpp_Theme_Material_NoActionBar),
|
||||
material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Material_Light_NoActionBar, R.style.Cpp_Theme_Wizard_Light, R.style.Cpp_Theme_Material_Light_Dialog, R.style.Cpp_Theme_Material_Light_Dialog_Alert);
|
||||
|
||||
private static final SparseArray<TextColor> textColors = new SparseArray<>();
|
||||
|
||||
@StyleRes
|
||||
public final int theme;
|
||||
@StyleRes
|
||||
public final int mainTheme;
|
||||
@StyleRes
|
||||
public final int wizardTheme;
|
||||
@StyleRes
|
||||
public final int dialogTheme;
|
||||
@ -309,12 +311,13 @@ public final class Preferences {
|
||||
public final int alertDialogTheme;
|
||||
public final boolean light;
|
||||
|
||||
Theme(@StyleRes int theme) {
|
||||
this(theme, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Material_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert);
|
||||
Theme(@StyleRes int theme, int mainTheme) {
|
||||
this(theme, mainTheme, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Material_Dialog, R.style.Cpp_Theme_Material_Dialog_Alert);
|
||||
}
|
||||
|
||||
Theme(@StyleRes int theme, @StyleRes int wizardTheme, @StyleRes int dialogTheme, @StyleRes int alertDialogTheme) {
|
||||
Theme(@StyleRes int theme, int mainTheme, @StyleRes int wizardTheme, @StyleRes int dialogTheme, @StyleRes int alertDialogTheme) {
|
||||
this.theme = theme;
|
||||
this.mainTheme = mainTheme;
|
||||
this.wizardTheme = wizardTheme;
|
||||
this.dialogTheme = dialogTheme;
|
||||
this.alertDialogTheme = alertDialogTheme;
|
||||
@ -322,6 +325,9 @@ public final class Preferences {
|
||||
}
|
||||
|
||||
public int getThemeFor(@Nullable Context context) {
|
||||
if (context instanceof CalculatorActivity) {
|
||||
return wizardTheme;
|
||||
}
|
||||
if (context instanceof WizardActivity) {
|
||||
return wizardTheme;
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package org.solovyev.android.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/25/12
|
||||
* Time: 9:29 PM
|
||||
*/
|
||||
public class FragmentUtils {
|
||||
|
||||
public static void createFragment(@Nonnull FragmentActivity activity,
|
||||
@Nonnull Class<? extends Fragment> fragmentClass,
|
||||
int parentViewId,
|
||||
@Nonnull String tag) {
|
||||
createFragment(activity, fragmentClass, parentViewId, tag, null);
|
||||
}
|
||||
|
||||
public static void createFragment(@Nonnull FragmentActivity activity,
|
||||
@Nonnull Class<? extends Fragment> fragmentClass,
|
||||
int parentViewId,
|
||||
@Nonnull String tag,
|
||||
@Nullable Bundle args) {
|
||||
final FragmentManager fm = activity.getSupportFragmentManager();
|
||||
|
||||
Fragment messagesFragment = fm.findFragmentByTag(tag);
|
||||
|
||||
final FragmentTransaction ft = fm.beginTransaction();
|
||||
try {
|
||||
if (messagesFragment == null) {
|
||||
messagesFragment = Fragment.instantiate(activity, fragmentClass.getName(), args);
|
||||
ft.add(parentViewId, messagesFragment, tag);
|
||||
} else {
|
||||
if (messagesFragment.isDetached()) {
|
||||
ft.attach(messagesFragment);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ft.commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -26,12 +26,7 @@
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
a:id="@+id/editor"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp"
|
||||
a:layout_weight="2"
|
||||
a:orientation="horizontal" />
|
||||
<include layout="@layout/activity_main_editor_with_toolbar"/>
|
||||
|
||||
<LinearLayout
|
||||
a:id="@+id/partial_keyboard"
|
@ -23,19 +23,14 @@
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/main"
|
||||
style="@style/CppMain"
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
a:id="@+id/editor"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp"
|
||||
a:layout_weight="2"
|
||||
a:orientation="horizontal" />
|
||||
<include layout="@layout/activity_main_editor_with_toolbar"/>
|
||||
|
||||
<LinearLayout
|
||||
a:id="@+id/partial_keyboard"
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp"
|
||||
a:layout_weight="2">
|
||||
|
||||
<FrameLayout
|
||||
a:id="@+id/editor"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent" />
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
a:id="@+id/toolbar"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="?actionBarSize"
|
||||
a:layout_gravity="top|right" />
|
||||
</FrameLayout>
|
@ -21,21 +21,11 @@
|
||||
~ Email: se.solovyev@gmail.com
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
<org.solovyev.android.calculator.EditorView a:id="@+id/calculator_editor"
|
||||
style="@style/CppText.Editor"
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/main_fragment_layout"
|
||||
style="@style/CppFragment"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:padding="@dimen/cpp_editor_padding">
|
||||
|
||||
<org.solovyev.android.calculator.EditorView
|
||||
a:id="@+id/calculator_editor"
|
||||
style="@style/CppText.Editor"
|
||||
a:hint="@string/c_calc_editor_hint"
|
||||
a:scrollbars="vertical"
|
||||
a:singleLine="false"
|
||||
a:textIsSelectable="true" />
|
||||
|
||||
</LinearLayout>
|
||||
a:hint="@string/c_calc_editor_hint"
|
||||
a:padding="@dimen/cpp_editor_padding"
|
||||
a:scrollbars="vertical"
|
||||
a:singleLine="false"
|
||||
a:textIsSelectable="true" />
|
@ -33,5 +33,6 @@
|
||||
|
||||
<attr name="cpp_text_color" format="reference" />
|
||||
<attr name="cpp_text_color_error" format="reference" />
|
||||
<attr name="cpp_card_style" format="reference" />
|
||||
|
||||
</resources>
|
||||
|
@ -44,4 +44,5 @@
|
||||
<dimen name="cpp_image_button_size">30dp</dimen>
|
||||
<dimen name="cpp_image_button_padding">5dp</dimen>
|
||||
<dimen name="cpp_dialog_width_max">400dp</dimen>
|
||||
<dimen name="cpp_card_margin">4dp</dimen>
|
||||
</resources>
|
@ -59,8 +59,8 @@
|
||||
<style name="CppText.Editor">
|
||||
<item name="android:text">""</item>
|
||||
<item name="android:gravity">left|top</item>
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:textSize">@dimen/cpp_editor_text_size</item>
|
||||
<item name="android:textColor">?attr/cpp_text_color</item>
|
||||
<item name="android:inputType">textMultiLine|textNoSuggestions</item>
|
||||
|
@ -22,6 +22,11 @@
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="Cpp.Theme.NoActionBar" parent="@style/Cpp.Theme">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme" parent="@style/Theme.AppCompat">
|
||||
<item name="colorPrimary">@color/cpp_metro_button</item>
|
||||
<item name="colorPrimaryDark">@color/cpp_metro_button_dark</item>
|
||||
@ -36,6 +41,7 @@
|
||||
<item name="cpp_fab_bg">@color/grey_900</item>
|
||||
<item name="cpp_text_color">@color/cpp_text</item>
|
||||
<item name="cpp_text_color_error">@color/cpp_text_error</item>
|
||||
<item name="cpp_card_style">@style/CardView.Dark</item>
|
||||
|
||||
<item name="android:listDivider">@drawable/divider_dark</item>
|
||||
</style>
|
||||
@ -94,6 +100,7 @@
|
||||
<item name="cpp_fab_bg">@color/cpp_material_light</item>
|
||||
<item name="cpp_text_color">@color/cpp_text_inverse</item>
|
||||
<item name="cpp_text_color_error">@color/cpp_text_inverse_error</item>
|
||||
<item name="cpp_card_style">@style/CardView.Light</item>
|
||||
|
||||
<item name="android:listDivider">@drawable/divider</item>
|
||||
</style>
|
||||
|
@ -59,6 +59,11 @@
|
||||
<item name="android:textSize">@dimen/cpp_widget_keyboard_button_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Material.NoActionBar" parent="Cpp.Theme.Material">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Material" parent="Cpp.Theme">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Material.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Material.Digit</item>
|
||||
|
@ -59,6 +59,11 @@
|
||||
<item name="android:textSize">@dimen/cpp_widget_keyboard_button_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Material.Light.NoActionBar" parent="Cpp.Theme.Material.Light">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Material.Light" parent="Cpp.Theme.Light">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Material.Light.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Material.Light.Digit</item>
|
||||
|
@ -65,12 +65,15 @@
|
||||
<item name="android:padding">@dimen/cpp_keyboard_simple_image_button_padding</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Blue.NoActionBar" parent="Cpp.Theme.Metro.Blue">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Blue" parent="Cpp.Theme">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Metro.Blue.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Metro.Blue.Control</item>
|
||||
<item name="cpp_button_style_control_image">
|
||||
@style/CppKeyboardButton.Metro.Blue.Control.Image
|
||||
</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Metro.Blue.Control.Image</item>
|
||||
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Metro.Blue.Operation</item>
|
||||
</style>
|
||||
|
||||
|
@ -26,6 +26,11 @@
|
||||
<item name="android:background">@drawable/metro_button_green</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Green.NoActionBar" parent="Cpp.Theme.Metro.Green">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Green" parent="Cpp.Theme.Metro.Blue">
|
||||
<item name="cpp_button_style_operation">@style/metro_green_operation_button_style</item>
|
||||
</style>
|
||||
|
@ -26,6 +26,11 @@
|
||||
<item name="android:background">@drawable/metro_button_purple</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Purple.NoActionBar" parent="Cpp.Theme.Metro.Purple">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Metro.Purple" parent="Cpp.Theme.Metro.Blue">
|
||||
<item name="cpp_button_style_operation">@style/metro_purple_operation_button_style</item>
|
||||
</style>
|
||||
|
@ -36,11 +36,15 @@
|
||||
|
||||
<style name="CppKeyboardButton.Blue.Control.Image" parent="CppKeyboardButton.Blue.Control"/>
|
||||
|
||||
<style name="Cpp.Theme.Blue.NoActionBar" parent="Cpp.Theme.Blue">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Blue" parent="Cpp.Theme">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Blue.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Blue.Control</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Blue.Control.Image
|
||||
</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Blue.Control.Image</item>
|
||||
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Blue.Operation</item>
|
||||
</style>
|
||||
|
||||
|
@ -36,19 +36,22 @@
|
||||
|
||||
<style name="CppKeyboardButton.Gray.Control.Image" parent="CppKeyboardButton.Gray.Control"/>
|
||||
|
||||
<style name="Cpp.Theme.Gray.NoActionBar" parent="Cpp.Theme.Gray">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Gray" parent="Cpp.Theme">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Gray.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Gray.Control</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Gray.Control.Image
|
||||
</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Gray.Control.Image</item>
|
||||
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Gray.Operation</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Dialog.Gray" parent="Cpp.Theme.Dialog">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Gray.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Gray.Control</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Gray.Control.Image
|
||||
</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Gray.Control.Image</item>
|
||||
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Gray.Operation</item>
|
||||
</style>
|
||||
|
||||
|
@ -36,11 +36,15 @@
|
||||
|
||||
<style name="CppKeyboardButton.Violet.Control.Image" parent="CppKeyboardButton.Violet.Control"/>
|
||||
|
||||
<style name="Cpp.Theme.Violet.NoActionBar" parent="Cpp.Theme.Violet">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Violet" parent="Cpp.Theme">
|
||||
<item name="cpp_button_style_digit">@style/CppKeyboardButton.Violet.Digit</item>
|
||||
<item name="cpp_button_style_control">@style/CppKeyboardButton.Violet.Control</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Violet.Control.Image
|
||||
</item>
|
||||
<item name="cpp_button_style_control_image">@style/CppKeyboardButton.Violet.Control.Image</item>
|
||||
<item name="cpp_button_style_operation">@style/CppKeyboardButton.Violet.Operation</item>
|
||||
</style>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user