Revive the project
This commit is contained in:
parent
22448df392
commit
1fc9ffef3a
@ -21,25 +21,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'maven'
|
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion versions.sdk.compile
|
compileSdk versions.sdk.compile
|
||||||
buildToolsVersion versions.sdk.buildTools
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.solovyev.android.calculator"
|
applicationId "org.solovyev.android.calculator"
|
||||||
minSdkVersion versions.sdk.min
|
minSdkVersion versions.sdk.min
|
||||||
targetSdkVersion versions.sdk.target
|
targetSdkVersion versions.sdk.target
|
||||||
versionCode 157
|
versionCode 157
|
||||||
versionName '2.2.7'
|
versionName '2.2.7'
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
dataBinding true
|
||||||
|
viewBinding true
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.cfg'
|
||||||
zipAlignEnabled true
|
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
@ -49,72 +52,70 @@ android {
|
|||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lintOptions {
|
namespace 'org.solovyev.android.calculator'
|
||||||
|
lint {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
|
disable 'ContentDescription', 'IconLauncherShape'
|
||||||
warning 'MissingTranslation'
|
warning 'MissingTranslation'
|
||||||
disable 'ContentDescription'
|
|
||||||
// floating icon is semi-transparent
|
|
||||||
disable 'IconLauncherShape'
|
|
||||||
}
|
}
|
||||||
compileOptions {
|
testOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
unitTests {
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
includeAndroidResources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
java {
|
||||||
javaCompileOptions {
|
toolchain {
|
||||||
annotationProcessorOptions {
|
languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
arguments = ['library': 'true']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.android.support:support-v4:${versions.supportLib}"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
|
||||||
implementation "com.android.support:appcompat-v7:${versions.supportLib}"
|
|
||||||
implementation "com.android.support:design:${versions.supportLib}"
|
implementation "androidx.viewpager:viewpager:1.1.0-alpha01"
|
||||||
|
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||||
|
implementation 'com.google.android.material:material:1.9.0'
|
||||||
|
|
||||||
implementation ':measure:'
|
implementation ':measure:'
|
||||||
implementation ':square-otto:1.3.9-SNAPSHOT'
|
implementation ':square-otto:1.3.9-SNAPSHOT'
|
||||||
annotationProcessor ':square-otto:1.3.9-SNAPSHOT'
|
kapt ':square-otto:1.3.9-SNAPSHOT'
|
||||||
annotationProcessor ':square-otto-compiler:1.3.9-SNAPSHOT'
|
kapt ':square-otto-compiler:1.3.9-SNAPSHOT'
|
||||||
annotationProcessor 'com.squareup:javapoet:1.9.0'
|
kapt 'com.squareup:javapoet:1.9.0'
|
||||||
|
implementation project(':plotter:lib')
|
||||||
implementation project(':dragbutton')
|
implementation project(':dragbutton')
|
||||||
implementation(project(':jscl')) {
|
implementation(project(':jscl')) {
|
||||||
exclude(module: 'xercesImpl')
|
exclude(module: 'xercesImpl')
|
||||||
}
|
}
|
||||||
implementation 'org.solovyev.android:checkout:1.2.1'
|
implementation 'org.solovyev.android:checkout:1.3.0'
|
||||||
implementation 'org.solovyev.android:material:0.1.4@aar'
|
implementation "com.google.android.gms:play-services-ads:22.2.0"
|
||||||
implementation "com.google.android.gms:play-services-ads:${versions.gpsLib}"
|
|
||||||
implementation "com.google.android.gms:play-services-base:${versions.gpsLib}"
|
implementation "com.google.android.gms:play-services-base:${versions.gpsLib}"
|
||||||
implementation "com.google.android.gms:play-services-analytics:${versions.gpsLib}"
|
implementation "com.google.android.gms:play-services-analytics:18.0.3"
|
||||||
implementation(name: 'plotter', ext: 'aar')
|
implementation 'com.google.guava:guava:32.1.2-android'
|
||||||
implementation 'com.google.guava:guava:20.0'
|
implementation('org.simpleframework:simple-xml:2.7.1') {
|
||||||
implementation('org.simpleframework:simple-xml:2.6.1') {
|
|
||||||
exclude(module: 'stax')
|
exclude(module: 'stax')
|
||||||
exclude(module: 'stax-api')
|
exclude(module: 'stax-api')
|
||||||
exclude(module: 'xpp3')
|
exclude(module: 'xpp3')
|
||||||
}
|
}
|
||||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
|
||||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
|
||||||
|
|
||||||
implementation 'com.google.dagger:dagger:2.0.2'
|
implementation 'com.google.dagger:dagger:2.0.2'
|
||||||
annotationProcessor "com.google.dagger:dagger-compiler:2.0.2"
|
kapt "com.google.dagger:dagger-compiler:2.0.2"
|
||||||
implementation 'javax.annotation:jsr250-api:1.0'
|
implementation 'javax.annotation:javax.annotation-api:1.3.2'
|
||||||
|
kapt "javax.annotation:javax.annotation-api:1.3.2"
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'net.sf.opencsv:opencsv:2.0'
|
testImplementation 'net.sf.opencsv:opencsv:2.0'
|
||||||
testImplementation 'org.mockito:mockito-core:2.7.6'
|
testImplementation 'org.mockito:mockito-core:5.3.1'
|
||||||
testImplementation 'org.robolectric:robolectric:3.5.1'
|
testImplementation 'org.robolectric:robolectric:4.10.3'
|
||||||
testImplementation 'org.mockito:mockito-all:1.9.5'
|
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
|
||||||
testImplementation 'org.skyscreamer:jsonassert:1.2.3'
|
|
||||||
testImplementation(name: 'org.apache.http.legacy', ext: 'jar')
|
testImplementation(name: 'org.apache.http.legacy', ext: 'jar')
|
||||||
|
|
||||||
androidTestImplementation "com.android.support:support-annotations:${versions.supportLib}"
|
androidTestImplementation 'androidx.annotation:annotation:1.7.0'
|
||||||
androidTestImplementation'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation'com.android.support.test:rules:1.0.2'
|
androidTestImplementation 'androidx.test:rules:1.5.0'
|
||||||
androidTestImplementation'org.hamcrest:hamcrest-library:1.3'
|
androidTestImplementation'org.hamcrest:hamcrest-library:1.3'
|
||||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
|
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
|
||||||
// use version of jsr305 provided by Checkout
|
// use version of jsr305 provided by Checkout
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
||||||
})}
|
})}
|
||||||
@ -122,6 +123,7 @@ dependencies {
|
|||||||
tasks.withType(Test) {
|
tasks.withType(Test) {
|
||||||
scanForTestClasses = false
|
scanForTestClasses = false
|
||||||
include "**/*Test.class"
|
include "**/*Test.class"
|
||||||
|
exclude "**/*BaseCalculatorTest*"
|
||||||
exclude "**/*AndroidCalculatorEditorViewTest*"
|
exclude "**/*AndroidCalculatorEditorViewTest*"
|
||||||
exclude "**/*CalculatorWizardActivityTest*"
|
exclude "**/*CalculatorWizardActivityTest*"
|
||||||
exclude "**/*OnScreenCalculatorWizardStepTest*"
|
exclude "**/*OnScreenCalculatorWizardStepTest*"
|
||||||
@ -130,6 +132,7 @@ tasks.withType(Test) {
|
|||||||
exclude "**/*AngleUnitsButtonTest*"
|
exclude "**/*AngleUnitsButtonTest*"
|
||||||
exclude "**/*NumeralBasesButtonTest*"
|
exclude "**/*NumeralBasesButtonTest*"
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
task androidJavadocs(type: Javadoc) {
|
task androidJavadocs(type: Javadoc) {
|
||||||
source = android.sourceSets.main.java.srcDirs
|
source = android.sourceSets.main.java.srcDirs
|
||||||
@ -213,3 +216,4 @@ uploadArchives {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Binary file not shown.
@ -27,16 +27,16 @@ package net.slideshare.mobile.test.util;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.support.test.espresso.UiController;
|
import androidx.test.espresso.UiController;
|
||||||
import android.support.test.espresso.ViewAction;
|
import androidx.test.espresso.ViewAction;
|
||||||
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
|
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
|
||||||
import android.support.test.runner.lifecycle.Stage;
|
import androidx.test.runner.lifecycle.Stage;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.isRoot;
|
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Espresso ViewAction that changes the orientation of the screen
|
* An Espresso ViewAction that changes the orientation of the screen
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import static android.support.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
|
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
|
||||||
import static android.support.test.espresso.action.ViewActions.clearText;
|
import static androidx.test.espresso.action.ViewActions.clearText;
|
||||||
import static android.support.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static android.support.test.espresso.matcher.RootMatchers.isPlatformPopup;
|
import static androidx.test.espresso.matcher.RootMatchers.isPlatformPopup;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
import android.support.test.rule.ActivityTestRule;
|
import androidx.test.rule.ActivityTestRule;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.solovyev.android.calculator.plot;
|
package org.solovyev.android.calculator.plot;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.test.espresso.action.ViewActions;
|
import androidx.test.espresso.action.ViewActions;
|
||||||
import android.support.test.rule.ActivityTestRule;
|
import androidx.test.rule.ActivityTestRule;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
@ -14,14 +14,14 @@ import org.solovyev.android.calculator.R;
|
|||||||
import org.solovyev.android.calculator.functions.CppFunction;
|
import org.solovyev.android.calculator.functions.CppFunction;
|
||||||
import org.solovyev.android.calculator.functions.FunctionParamsView;
|
import org.solovyev.android.calculator.functions.FunctionParamsView;
|
||||||
|
|
||||||
import static android.support.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static android.support.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView;
|
import static androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.hasFocus;
|
import static androidx.test.espresso.matcher.ViewMatchers.hasFocus;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
|
import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@ -6,15 +6,15 @@ import org.solovyev.android.calculator.R;
|
|||||||
import org.solovyev.android.calculator.functions.CppFunction;
|
import org.solovyev.android.calculator.functions.CppFunction;
|
||||||
import org.solovyev.android.calculator.functions.FunctionParamsView;
|
import org.solovyev.android.calculator.functions.FunctionParamsView;
|
||||||
|
|
||||||
import static android.support.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static android.support.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static android.support.test.espresso.action.ViewActions.typeTextIntoFocusedView;
|
import static androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView;
|
||||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.hasFocus;
|
import static androidx.test.espresso.matcher.ViewMatchers.hasFocus;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
|
import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
package org.solovyev.android.calculator.wizard;
|
package org.solovyev.android.calculator.wizard;
|
||||||
|
|
||||||
import android.support.test.rule.ActivityTestRule;
|
import androidx.test.rule.ActivityTestRule;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import static android.support.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static android.support.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static android.support.test.espresso.action.ViewActions.swipeLeft;
|
import static androidx.test.espresso.action.ViewActions.swipeLeft;
|
||||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
|
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
||||||
import static net.slideshare.mobile.test.util.OrientationChangeAction.orientationLandscape;
|
import static net.slideshare.mobile.test.util.OrientationChangeAction.orientationLandscape;
|
||||||
import static net.slideshare.mobile.test.util.OrientationChangeAction.orientationPortrait;
|
import static net.slideshare.mobile.test.util.OrientationChangeAction.orientationPortrait;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="org.solovyev.android.calculator"
|
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
@ -31,7 +30,12 @@
|
|||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version" />
|
android:value="@integer/google_play_services_version" />
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||||
|
android:value="ca-app-pub-9736972200639245~6870320906"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
android:exported="true"
|
||||||
android:name=".CalculatorActivity"
|
android:name=".CalculatorActivity"
|
||||||
android:clearTaskOnLaunch="true"
|
android:clearTaskOnLaunch="true"
|
||||||
android:label="@string/cpp_app_name"
|
android:label="@string/cpp_app_name"
|
||||||
@ -55,6 +59,7 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
android:exported="false"
|
||||||
android:name=".preferences.PreferencesActivity"
|
android:name=".preferences.PreferencesActivity"
|
||||||
android:label="@string/cpp_settings">
|
android:label="@string/cpp_settings">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -120,6 +125,7 @@
|
|||||||
android:theme="@style/Cpp.Theme.Dialog" />
|
android:theme="@style/Cpp.Theme.Dialog" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
android:exported="false"
|
||||||
android:name=".plot.PlotActivity"
|
android:name=".plot.PlotActivity"
|
||||||
android:label="@string/cpp_plotter">
|
android:label="@string/cpp_plotter">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -128,6 +134,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
android:exported="false"
|
||||||
android:name=".wizard.WizardActivity"
|
android:name=".wizard.WizardActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/Cpp.Theme.Wizard">
|
android:theme="@style/Cpp.Theme.Wizard">
|
||||||
@ -144,6 +151,7 @@
|
|||||||
<!-- ONSCREEN CONFIG -->
|
<!-- ONSCREEN CONFIG -->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
android:exported="true"
|
||||||
android:name=".floating.FloatingCalculatorActivity"
|
android:name=".floating.FloatingCalculatorActivity"
|
||||||
android:icon="@drawable/ic_launcher_window"
|
android:icon="@drawable/ic_launcher_window"
|
||||||
android:label="@string/cpp_app_name_on_screen"
|
android:label="@string/cpp_app_name_on_screen"
|
||||||
@ -176,6 +184,7 @@
|
|||||||
<!-- WIDGET CONFIG -->
|
<!-- WIDGET CONFIG -->
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
|
android:exported="true"
|
||||||
android:name=".widget.CalculatorWidget"
|
android:name=".widget.CalculatorWidget"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/cpp_app_name">
|
android:label="@string/cpp_app_name">
|
||||||
@ -201,17 +210,9 @@
|
|||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
|
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
|
||||||
android:theme="@android:style/Theme.Translucent" />
|
android:theme="@android:style/Theme.Translucent" />
|
||||||
|
|
||||||
<!-- ACRA CONFIG -->
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name="org.acra.CrashReportDialog"
|
|
||||||
android:excludeFromRecents="true"
|
|
||||||
android:finishOnTaskLaunch="true"
|
|
||||||
android:launchMode="singleInstance"
|
|
||||||
android:theme="@android:style/Theme.Dialog" />
|
|
||||||
|
|
||||||
<!-- Google Analytics -->
|
<!-- Google Analytics -->
|
||||||
<receiver
|
<receiver
|
||||||
|
android:exported="true"
|
||||||
tools:ignore="ExportedReceiver"
|
tools:ignore="ExportedReceiver"
|
||||||
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
|
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
|
||||||
android:enabled="true">
|
android:enabled="true">
|
||||||
@ -220,14 +221,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
|
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
|
||||||
<receiver
|
|
||||||
tools:ignore="ExportedReceiver"
|
|
||||||
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
|
|
||||||
android:enabled="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
<service
|
<service
|
||||||
android:name="com.google.android.gms.analytics.AnalyticsService"
|
android:name="com.google.android.gms.analytics.AnalyticsService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -26,14 +26,14 @@ import android.graphics.Paint.Style;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.view.MotionEventCompat;
|
import androidx.core.view.MotionEventCompat;
|
||||||
import android.support.v4.view.ViewConfigurationCompat;
|
import androidx.core.view.ViewConfigurationCompat;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
|
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
package com.viewpagerindicator;
|
package com.viewpagerindicator;
|
||||||
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A PageIndicator is responsible to show an visual indicator on the total views
|
* A PageIndicator is responsible to show an visual indicator on the total views
|
||||||
|
@ -42,7 +42,8 @@ public final class Check {
|
|||||||
private static boolean isJunit() {
|
private static boolean isJunit() {
|
||||||
final StackTraceElement[] stackTrace = currentThread().getStackTrace();
|
final StackTraceElement[] stackTrace = currentThread().getStackTrace();
|
||||||
for (StackTraceElement element : stackTrace) {
|
for (StackTraceElement element : stackTrace) {
|
||||||
if (element.getClassName().startsWith("org.junit.")) {
|
String className = element.getClassName();
|
||||||
|
if (className.startsWith("org.junit.") || className.startsWith("org.robolectric.")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import android.app.Application;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
import jscl.math.Generic;
|
import jscl.math.Generic;
|
||||||
|
@ -9,10 +9,12 @@ import android.view.Gravity;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import com.google.android.gms.ads.AdListener;
|
import com.google.android.gms.ads.AdListener;
|
||||||
import com.google.android.gms.ads.AdRequest;
|
import com.google.android.gms.ads.AdRequest;
|
||||||
import com.google.android.gms.ads.AdSize;
|
import com.google.android.gms.ads.AdSize;
|
||||||
|
|
||||||
|
import com.google.android.gms.ads.LoadAdError;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -81,11 +83,6 @@ public class AdView extends FrameLayout {
|
|||||||
admobView.setAdListener(admobListener);
|
admobView.setAdListener(admobListener);
|
||||||
|
|
||||||
final AdRequest.Builder b = new AdRequest.Builder();
|
final AdRequest.Builder b = new AdRequest.Builder();
|
||||||
b.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
// LG Nexus 5
|
|
||||||
b.addTestDevice("B80E676D60CE6FDBE1B84A55464E3FE1");
|
|
||||||
}
|
|
||||||
admobView.loadAd(b.build());
|
admobView.loadAd(b.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +124,7 @@ public class AdView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAdFailedToLoad(int errorCode) {
|
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
|
||||||
if (adView != null) {
|
if (adView != null) {
|
||||||
adView.hide();
|
adView.hide();
|
||||||
adView = null;
|
adView = null;
|
||||||
|
@ -36,13 +36,8 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v7.view.ContextThemeWrapper;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
@ -54,6 +49,11 @@ import android.view.ViewGroup;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.floating.FloatingCalculatorService;
|
import org.solovyev.android.calculator.floating.FloatingCalculatorService;
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ public final class App {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static <T> ArrayAdapter<T> makeSimpleSpinnerAdapter(@NonNull Context context) {
|
public static <T> ArrayAdapter<T> makeSimpleSpinnerAdapter(@NonNull Context context) {
|
||||||
return new ArrayAdapter<>(context, R.layout.support_simple_spinner_dropdown_item);
|
return new ArrayAdapter<>(context, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ViewProcessor<V> {
|
public interface ViewProcessor<V> {
|
||||||
|
@ -7,12 +7,12 @@ import android.graphics.Typeface;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.GeneratedHandlerFinder;
|
|
||||||
|
|
||||||
|
import com.squareup.otto.GeneratedHandlerFinder;
|
||||||
import org.solovyev.android.calculator.language.Languages;
|
import org.solovyev.android.calculator.language.Languages;
|
||||||
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||||
import org.solovyev.android.checkout.Billing;
|
import org.solovyev.android.checkout.Billing;
|
||||||
|
@ -10,14 +10,6 @@ import android.app.Activity;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.LayoutRes;
|
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
import android.support.design.widget.AppBarLayout;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -25,6 +17,14 @@ import android.view.ViewGroup;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.ga.Ga;
|
import org.solovyev.android.calculator.ga.Ga;
|
||||||
import org.solovyev.android.calculator.language.Language;
|
import org.solovyev.android.calculator.language.Language;
|
||||||
@ -36,8 +36,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public abstract class BaseActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
@ -58,13 +56,10 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
|
|||||||
Lazy<Ga> ga;
|
Lazy<Ga> ga;
|
||||||
@Inject
|
@Inject
|
||||||
Typeface typeface;
|
Typeface typeface;
|
||||||
@BindView(R.id.main)
|
|
||||||
ViewGroup mainView;
|
ViewGroup mainView;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.toolbar)
|
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.fab)
|
|
||||||
FloatingActionButton 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;
|
||||||
@ -159,12 +154,16 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
|
|||||||
|
|
||||||
private void createView() {
|
private void createView() {
|
||||||
setContentView(layoutId);
|
setContentView(layoutId);
|
||||||
|
View contentView = findViewById(android.R.id.content);
|
||||||
|
mainView = contentView.findViewById(R.id.main);
|
||||||
|
toolbar = contentView.findViewById(R.id.toolbar);
|
||||||
|
fab = contentView.findViewById(R.id.fab);
|
||||||
|
bindViews(contentView);
|
||||||
// title must be updated as if a non-system language is used the value from AndroidManifest
|
// title must be updated as if a non-system language is used the value from AndroidManifest
|
||||||
// might be cached
|
// might be cached
|
||||||
if (titleId != 0) {
|
if (titleId != 0) {
|
||||||
setTitle(titleId);
|
setTitle(titleId);
|
||||||
}
|
}
|
||||||
ButterKnife.bind(this, this);
|
|
||||||
|
|
||||||
fixFonts(mainView, typeface);
|
fixFonts(mainView, typeface);
|
||||||
initToolbar();
|
initToolbar();
|
||||||
@ -172,6 +171,8 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
|
|||||||
tabs.onCreate();
|
tabs.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void bindViews(@Nonnull View contentView) {}
|
||||||
|
|
||||||
private void initToolbar() {
|
private void initToolbar() {
|
||||||
if (toolbar == null) {
|
if (toolbar == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -5,19 +5,19 @@ import android.content.DialogInterface;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import com.google.android.gms.analytics.HitBuilders;
|
import com.google.android.gms.analytics.HitBuilders;
|
||||||
import com.google.android.gms.analytics.Tracker;
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import org.solovyev.android.calculator.ga.Ga;
|
import org.solovyev.android.calculator.ga.Ga;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -3,11 +3,11 @@ package org.solovyev.android.calculator;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.LayoutRes;
|
import androidx.annotation.LayoutRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import org.solovyev.android.calculator.ads.AdUi;
|
import org.solovyev.android.calculator.ads.AdUi;
|
||||||
import org.solovyev.android.plotter.Check;
|
import org.solovyev.android.plotter.Check;
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -25,11 +25,9 @@ package org.solovyev.android.calculator;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.v4.app.FragmentManager;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import androidx.core.view.GravityCompat;
|
||||||
import android.support.v4.view.GravityCompat;
|
|
||||||
import android.support.v7.widget.PopupMenu;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
@ -38,10 +36,12 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import butterknife.BindView;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import jscl.AngleUnit;
|
import jscl.AngleUnit;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
import org.solovyev.android.calculator.converter.ConverterFragment;
|
import org.solovyev.android.calculator.converter.ConverterFragment;
|
||||||
|
import org.solovyev.android.calculator.databinding.ActivityMainBinding;
|
||||||
import org.solovyev.android.calculator.history.History;
|
import org.solovyev.android.calculator.history.History;
|
||||||
import org.solovyev.android.calculator.keyboard.PartialKeyboardUi;
|
import org.solovyev.android.calculator.keyboard.PartialKeyboardUi;
|
||||||
import org.solovyev.android.widget.menu.CustomPopupMenu;
|
import org.solovyev.android.widget.menu.CustomPopupMenu;
|
||||||
@ -65,11 +65,8 @@ public class CalculatorActivity extends BaseActivity implements View.OnClickList
|
|||||||
@Inject
|
@Inject
|
||||||
StartupHelper startupHelper;
|
StartupHelper startupHelper;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.partial_keyboard)
|
|
||||||
View partialKeyboard;
|
View partialKeyboard;
|
||||||
@BindView(R.id.editor)
|
|
||||||
FrameLayout editor;
|
FrameLayout editor;
|
||||||
@BindView(R.id.main_menu)
|
|
||||||
View mainMenuButton;
|
View mainMenuButton;
|
||||||
private boolean useBackAsPrevious;
|
private boolean useBackAsPrevious;
|
||||||
|
|
||||||
@ -77,6 +74,14 @@ public class CalculatorActivity extends BaseActivity implements View.OnClickList
|
|||||||
super(R.layout.activity_main, R.string.cpp_app_name);
|
super(R.layout.activity_main, R.string.cpp_app_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindViews(@Nonnull View contentView) {
|
||||||
|
ActivityMainBinding binding = ActivityMainBinding.bind(contentView.findViewById(R.id.main));
|
||||||
|
partialKeyboard = binding.partialKeyboard;
|
||||||
|
editor = binding.editorContainer.editor;
|
||||||
|
mainMenuButton = binding.editorContainer.mainMenu;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -149,10 +154,8 @@ public class CalculatorActivity extends BaseActivity implements View.OnClickList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
if (v.getId() == R.id.main_menu) {
|
||||||
case R.id.main_menu:
|
|
||||||
mainMenu.toggle();
|
mainMenu.toggle();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +174,7 @@ public class CalculatorActivity extends BaseActivity implements View.OnClickList
|
|||||||
|
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
if (popup == null) {
|
if (popup == null) {
|
||||||
popup = new CustomPopupMenu(CalculatorActivity.this, mainMenuButton, GravityCompat.END, R.attr.actionOverflowMenuStyle, 0);
|
popup = new CustomPopupMenu(CalculatorActivity.this, mainMenuButton, GravityCompat.END, android.R.attr.actionOverflowMenuStyle, 0);
|
||||||
popup.inflate(R.menu.main);
|
popup.inflate(R.menu.main);
|
||||||
popup.setOnMenuItemClickListener(this);
|
popup.setOnMenuItemClickListener(this);
|
||||||
popup.setKeepOnSubMenu(true);
|
popup.setKeepOnSubMenu(true);
|
||||||
@ -227,43 +230,43 @@ public class CalculatorActivity extends BaseActivity implements View.OnClickList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.id.menu_settings:
|
if (itemId == R.id.menu_settings) {
|
||||||
launcher.showSettings();
|
launcher.showSettings();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_history:
|
} else if (itemId == R.id.menu_history) {
|
||||||
launcher.showHistory();
|
launcher.showHistory();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_plotter:
|
} else if (itemId == R.id.menu_plotter) {
|
||||||
launcher.showPlotter();
|
launcher.showPlotter();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_conversion_tool:
|
} else if (itemId == R.id.menu_conversion_tool) {
|
||||||
ConverterFragment.show(CalculatorActivity.this);
|
ConverterFragment.show(CalculatorActivity.this);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_about:
|
} else if (itemId == R.id.menu_about) {
|
||||||
launcher.showAbout();
|
launcher.showAbout();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_mode_engineer:
|
} else if (itemId == R.id.menu_mode_engineer) {
|
||||||
Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.engineer);
|
Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.engineer);
|
||||||
restartIfModeChanged();
|
restartIfModeChanged();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_mode_simple:
|
} else if (itemId == R.id.menu_mode_simple) {
|
||||||
Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.simple);
|
Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.simple);
|
||||||
restartIfModeChanged();
|
restartIfModeChanged();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_au_deg:
|
} else if (itemId == R.id.menu_au_deg) {
|
||||||
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.deg);
|
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.deg);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_au_rad:
|
} else if (itemId == R.id.menu_au_rad) {
|
||||||
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.rad);
|
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.rad);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_nb_bin:
|
} else if (itemId == R.id.menu_nb_bin) {
|
||||||
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.bin);
|
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.bin);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_nb_dec:
|
} else if (itemId == R.id.menu_nb_dec) {
|
||||||
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.dec);
|
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.dec);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_nb_hex:
|
} else if (itemId == R.id.menu_nb_hex) {
|
||||||
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.hex);
|
Engine.Preferences.numeralBase.putPreference(preferences, NumeralBase.hex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TimingLogger;
|
import android.util.TimingLogger;
|
||||||
|
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.ClipboardManager;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -32,31 +33,30 @@ import javax.inject.Singleton;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class Clipboard {
|
public class Clipboard {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final ClipboardManager clipboard;
|
private final ClipboardManager clipboard;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Inject
|
@Inject
|
||||||
public Clipboard(@Nonnull Application application) {
|
public Clipboard(@Nonnull Application application) {
|
||||||
clipboard = (ClipboardManager) application.getSystemService(Context.CLIPBOARD_SERVICE);
|
clipboard = (ClipboardManager) application.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getText() {
|
public String getText() {
|
||||||
if (clipboard.hasText()) {
|
ClipData primaryClip = clipboard.getPrimaryClip();
|
||||||
return String.valueOf(clipboard.getText());
|
if (primaryClip != null && primaryClip.getItemCount() > 0) {
|
||||||
|
final CharSequence text = primaryClip.getItemAt(0).getText();
|
||||||
|
return text != null ? text.toString() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(@Nonnull CharSequence text) {
|
public void setText(@Nonnull CharSequence text) {
|
||||||
clipboard.setText(text);
|
clipboard.setPrimaryClip(ClipData.newPlainText("", text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(@Nonnull String text) {
|
public void setText(@Nonnull String text) {
|
||||||
clipboard.setText(text);
|
setText((CharSequence) text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -25,14 +25,12 @@ package org.solovyev.android.calculator;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
import jscl.math.Generic;
|
import jscl.math.Generic;
|
||||||
@ -63,19 +61,17 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ConversionMenuItem getByTitle(int title) {
|
public static ConversionMenuItem getByTitle(int title) {
|
||||||
switch (title) {
|
if (title == R.string.convert_to_bin) {
|
||||||
case R.string.convert_to_bin:
|
|
||||||
return to_bin;
|
return to_bin;
|
||||||
case R.string.convert_to_dec:
|
} else if (title == R.string.convert_to_dec) {
|
||||||
return to_dec;
|
return to_dec;
|
||||||
case R.string.convert_to_hex:
|
} else if (title == R.string.convert_to_hex) {
|
||||||
return to_hex;
|
return to_hex;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindView(R.id.calculator_display)
|
|
||||||
DisplayView displayView;
|
DisplayView displayView;
|
||||||
@Inject
|
@Inject
|
||||||
SharedPreferences preferences;
|
SharedPreferences preferences;
|
||||||
@ -106,7 +102,7 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
ButterKnife.bind(this, view);
|
displayView = view.findViewById(R.id.calculator_display);
|
||||||
display.setView(displayView);
|
display.setView(displayView);
|
||||||
displayView.setOnClickListener(this);
|
displayView.setOnClickListener(this);
|
||||||
return view;
|
return view;
|
||||||
@ -181,13 +177,11 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
|||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
final DisplayState state = display.getState();
|
final DisplayState state = display.getState();
|
||||||
final Generic result = state.getResult();
|
final Generic result = state.getResult();
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.string.cpp_copy:
|
if (itemId == R.string.cpp_copy) {
|
||||||
display.copy();
|
display.copy();
|
||||||
return true;
|
return true;
|
||||||
case R.string.convert_to_bin:
|
} else if (itemId == R.string.convert_to_bin || itemId == R.string.convert_to_dec || itemId == R.string.convert_to_hex) {
|
||||||
case R.string.convert_to_dec:
|
|
||||||
case R.string.convert_to_hex:
|
|
||||||
final ConversionMenuItem menuItem = ConversionMenuItem.getByTitle(item.getItemId());
|
final ConversionMenuItem menuItem = ConversionMenuItem.getByTitle(item.getItemId());
|
||||||
if (menuItem == null) {
|
if (menuItem == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -196,15 +190,14 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
|||||||
calculator.convert(state, menuItem.toNumeralBase);
|
calculator.convert(state, menuItem.toNumeralBase);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.string.c_convert:
|
} else if (itemId == R.string.c_convert) {
|
||||||
ConverterFragment.show(getActivity(), getValue(result));
|
ConverterFragment.show(getActivity(), getValue(result));
|
||||||
return true;
|
return true;
|
||||||
case R.string.c_plot:
|
} else if (itemId == R.string.c_plot) {
|
||||||
launcher.plot(result);
|
launcher.plot(result);
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double getValue(@Nullable Generic result) {
|
private static double getValue(@Nullable Generic result) {
|
||||||
|
@ -28,8 +28,8 @@ import static android.util.TypedValue.applyDimension;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
@ -27,8 +27,8 @@ import static java.lang.Math.min;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
@ -173,12 +173,13 @@ public class Editor {
|
|||||||
state = newState;
|
state = newState;
|
||||||
|
|
||||||
cancelAsyncHighlightText();
|
cancelAsyncHighlightText();
|
||||||
highlighterTask = new AsyncHighlighter(oldState, newState, force, textProcessor);
|
AsyncHighlighter newHighlighterTask = new AsyncHighlighter(oldState, newState, force, textProcessor);
|
||||||
if (highlighterTask.shouldAsync()) {
|
highlighterTask = newHighlighterTask;
|
||||||
highlighterTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
if (newHighlighterTask.shouldAsync()) {
|
||||||
|
newHighlighterTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
highlighterTask.onPostExecute(newState);
|
newHighlighterTask.onPostExecute(newState);
|
||||||
Check.isNull(highlighterTask);
|
Check.isNull(highlighterTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,17 +26,15 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import org.solovyev.android.calculator.databinding.CppAppEditorBinding;
|
||||||
|
|
||||||
public class EditorFragment extends BaseFragment {
|
public class EditorFragment extends BaseFragment {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Editor editor;
|
Editor editor;
|
||||||
@BindView(R.id.calculator_editor)
|
|
||||||
EditorView editorView;
|
EditorView editorView;
|
||||||
|
|
||||||
public EditorFragment() {
|
public EditorFragment() {
|
||||||
@ -52,7 +50,8 @@ public class EditorFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
CppAppEditorBinding binding = CppAppEditorBinding.bind(view);
|
||||||
|
editorView = binding.calculatorEditor;
|
||||||
editor.setView(editorView);
|
editor.setView(editorView);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -174,47 +174,34 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
|
|||||||
if (user.isVibrateOnKeypress()) {
|
if (user.isVibrateOnKeypress()) {
|
||||||
v.performHapticFeedback(KEYBOARD_TAP, FLAG_IGNORE_GLOBAL_SETTING | FLAG_IGNORE_VIEW_SETTING);
|
v.performHapticFeedback(KEYBOARD_TAP, FLAG_IGNORE_GLOBAL_SETTING | FLAG_IGNORE_VIEW_SETTING);
|
||||||
}
|
}
|
||||||
switch (v.getId()) {
|
int id = v.getId();
|
||||||
case R.id.cpp_kb_button_divide:
|
if (id == R.id.cpp_kb_button_divide) {
|
||||||
user.insertOperator('/');
|
user.insertOperator('/');
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_plus) {
|
||||||
case R.id.cpp_kb_button_plus:
|
|
||||||
user.insertOperator('+');
|
user.insertOperator('+');
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_minus) {
|
||||||
case R.id.cpp_kb_button_minus:
|
|
||||||
user.insertOperator('-');
|
user.insertOperator('-');
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_multiply) {
|
||||||
case R.id.cpp_kb_button_multiply:
|
|
||||||
user.insertOperator("×");
|
user.insertOperator("×");
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_functions_constants) {
|
||||||
case R.id.cpp_kb_button_functions_constants:
|
|
||||||
user.showFunctionsConstants(v);
|
user.showFunctionsConstants(v);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_functions) {
|
||||||
case R.id.cpp_kb_button_functions:
|
|
||||||
user.showFunctions(v);
|
user.showFunctions(v);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_constants) {
|
||||||
case R.id.cpp_kb_button_constants:
|
|
||||||
user.showConstants(v);
|
user.showConstants(v);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_space) {
|
||||||
case R.id.cpp_kb_button_space:
|
|
||||||
user.insertText(" ", 0);
|
user.insertText(" ", 0);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_keyboard) {
|
||||||
case R.id.cpp_kb_button_keyboard:
|
|
||||||
user.showIme();
|
user.showIme();
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_clear) {
|
||||||
case R.id.cpp_kb_button_clear:
|
|
||||||
user.getEditor().setText("");
|
user.getEditor().setText("");
|
||||||
user.getEditor().setSelection(0);
|
user.getEditor().setSelection(0);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_brackets) {
|
||||||
case R.id.cpp_kb_button_brackets:
|
|
||||||
user.insertText("()", -1);
|
user.insertText("()", -1);
|
||||||
break;
|
} else if (id == R.id.cpp_kb_button_close) {
|
||||||
case R.id.cpp_kb_button_close:
|
|
||||||
user.done();
|
user.done();
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
onDefaultClick(v);
|
onDefaultClick(v);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
user.getEditor().requestFocus();
|
user.getEditor().requestFocus();
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.v4.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.solovyev.android.calculator.about.AboutFragment;
|
import org.solovyev.android.calculator.about.AboutFragment;
|
||||||
import org.solovyev.android.calculator.about.ReleaseNotesFragment;
|
import org.solovyev.android.calculator.about.ReleaseNotesFragment;
|
||||||
import org.solovyev.android.calculator.functions.FunctionsFragment;
|
import org.solovyev.android.calculator.functions.FunctionsFragment;
|
||||||
|
@ -25,7 +25,7 @@ package org.solovyev.android.calculator;
|
|||||||
import static org.solovyev.android.calculator.Engine.Preferences.numeralBase;
|
import static org.solovyev.android.calculator.Engine.Preferences.numeralBase;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -22,12 +22,10 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.keyboard.KeyboardUi;
|
import org.solovyev.android.calculator.keyboard.KeyboardUi;
|
||||||
|
|
||||||
@ -36,8 +34,6 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class KeyboardFragment extends BaseFragment {
|
public class KeyboardFragment extends BaseFragment {
|
||||||
|
|
||||||
@Inject
|
|
||||||
SharedPreferences preferences;
|
|
||||||
@Inject
|
@Inject
|
||||||
KeyboardUi keyboardUi;
|
KeyboardUi keyboardUi;
|
||||||
|
|
||||||
@ -54,7 +50,6 @@ public class KeyboardFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
Check.isNotNull(view);
|
Check.isNotNull(view);
|
||||||
keyboardUi.onCreateView(getActivity(), view);
|
keyboardUi.onCreateView(getActivity(), view);
|
||||||
return view;
|
return view;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
import android.support.annotation.LayoutRes;
|
import androidx.annotation.LayoutRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.annotation.StyleRes;
|
import androidx.annotation.StyleRes;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jscl.math.function.IConstant;
|
import jscl.math.function.IConstant;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -2,9 +2,9 @@ package org.solovyev.android.calculator;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class RemovalConfirmationDialog {
|
public class RemovalConfirmationDialog {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -6,9 +6,9 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v7.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
import org.solovyev.android.calculator.wizard.CalculatorWizards;
|
||||||
import org.solovyev.android.wizard.Wizard;
|
import org.solovyev.android.wizard.Wizard;
|
||||||
import org.solovyev.android.wizard.Wizards;
|
import org.solovyev.android.wizard.Wizards;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
|
@ -50,7 +50,17 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PreparedExpression processWithDepth(@Nonnull String s, int depth, @Nonnull List<IConstant> undefinedVars, @Nonnull Engine engine) throws ParseException {
|
private static PreparedExpression processWithDepth(@Nonnull String s, int depth, @Nonnull List<IConstant> undefinedVars, @Nonnull Engine engine) throws ParseException {
|
||||||
return replaceVariables(processExpression(s, engine).toString(), depth, undefinedVars, engine);
|
return replaceVariables(processExpression(removeWhitespaces(s), engine).toString(), depth, undefinedVars, engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String removeWhitespaces(String s) {
|
||||||
|
final StringBuilder res = new StringBuilder(s.length());
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
char c = s.charAt(i);
|
||||||
|
if (Character.isWhitespace(c)) continue;
|
||||||
|
res.append(c);
|
||||||
|
}
|
||||||
|
return res.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.prefs.BooleanPreference;
|
import org.solovyev.android.prefs.BooleanPreference;
|
||||||
import org.solovyev.android.prefs.IntegerPreference;
|
import org.solovyev.android.prefs.IntegerPreference;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.buttons.CppButton;
|
import org.solovyev.android.calculator.buttons.CppButton;
|
||||||
@ -40,7 +40,9 @@ public final class WidgetReceiver extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyboard == null || history == null) {
|
||||||
cast(context).getComponent().inject(this);
|
cast(context).getComponent().inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
final int buttonId = intent.getIntExtra(ACTION_BUTTON_ID_EXTRA, 0);
|
final int buttonId = intent.getIntExtra(ACTION_BUTTON_ID_EXTRA, 0);
|
||||||
final CppButton button = CppButton.getById(buttonId);
|
final CppButton button = CppButton.getById(buttonId);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
package org.solovyev.android.calculator.about;
|
package org.solovyev.android.calculator.about;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
|
@ -29,24 +29,19 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseFragment;
|
import org.solovyev.android.calculator.BaseFragment;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentAboutBinding;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static org.solovyev.common.text.Strings.isEmpty;
|
import static org.solovyev.common.text.Strings.isEmpty;
|
||||||
|
|
||||||
public class AboutFragment extends BaseFragment {
|
public class AboutFragment extends BaseFragment {
|
||||||
|
|
||||||
@BindView(R.id.about_image)
|
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
@BindView(R.id.about_text)
|
|
||||||
TextView textView;
|
TextView textView;
|
||||||
@BindView(R.id.about_translators_label)
|
|
||||||
TextView translatorsLabel;
|
TextView translatorsLabel;
|
||||||
@BindView(R.id.about_translators)
|
|
||||||
TextView translatorsView;
|
TextView translatorsView;
|
||||||
|
|
||||||
public AboutFragment() {
|
public AboutFragment() {
|
||||||
@ -56,7 +51,11 @@ public class AboutFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
final FragmentAboutBinding binding = FragmentAboutBinding.bind(view);
|
||||||
|
imageView = binding.aboutImage;
|
||||||
|
textView = binding.aboutText;
|
||||||
|
translatorsLabel = binding.aboutTranslatorsLabel;
|
||||||
|
translatorsView = binding.aboutTranslators;
|
||||||
if (App.getTheme().light) {
|
if (App.getTheme().light) {
|
||||||
imageView.setImageResource(R.drawable.logo_wizard_light);
|
imageView.setImageResource(R.drawable.logo_wizard_light);
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,13 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import org.solovyev.android.calculator.BaseFragment;
|
import org.solovyev.android.calculator.BaseFragment;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentReleaseNotesBinding;
|
||||||
import org.solovyev.android.calculator.release.ReleaseNotes;
|
import org.solovyev.android.calculator.release.ReleaseNotes;
|
||||||
|
|
||||||
public class ReleaseNotesFragment extends BaseFragment {
|
public class ReleaseNotesFragment extends BaseFragment {
|
||||||
|
|
||||||
@BindView(R.id.releasenotes_text)
|
|
||||||
TextView text;
|
TextView text;
|
||||||
|
|
||||||
public ReleaseNotesFragment() {
|
public ReleaseNotesFragment() {
|
||||||
@ -47,7 +45,8 @@ public class ReleaseNotesFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
final FragmentReleaseNotesBinding binding = FragmentReleaseNotesBinding.bind(view);
|
||||||
|
text = binding.releasenotesText;
|
||||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
text.setText(Html.fromHtml(ReleaseNotes.getReleaseNotes(getActivity())));
|
text.setText(Html.fromHtml(ReleaseNotes.getReleaseNotes(getActivity())));
|
||||||
return view;
|
return view;
|
||||||
|
@ -4,7 +4,7 @@ import static org.solovyev.android.checkout.ProductTypes.IN_APP;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.AdView;
|
import org.solovyev.android.calculator.AdView;
|
||||||
@ -16,8 +16,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
public class AdUi {
|
public class AdUi {
|
||||||
|
|
||||||
@ -26,7 +24,6 @@ public class AdUi {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final Handler handler;
|
private final Handler handler;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_ad)
|
|
||||||
AdView adView;
|
AdView adView;
|
||||||
@Nullable
|
@Nullable
|
||||||
private Boolean adFree = null;
|
private Boolean adFree = null;
|
||||||
@ -92,7 +89,7 @@ public class AdUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onCreateView(@NonNull View view) {
|
public void onCreateView(@NonNull View view) {
|
||||||
ButterKnife.bind(this, view);
|
adView = view.findViewById(R.id.cpp_ad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator.calculations;
|
package org.solovyev.android.calculator.calculations;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.DisplayState;
|
import org.solovyev.android.calculator.DisplayState;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator.calculations;
|
package org.solovyev.android.calculator.calculations;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.DisplayState;
|
import org.solovyev.android.calculator.DisplayState;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator.calculations;
|
package org.solovyev.android.calculator.calculations;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.DisplayState;
|
import org.solovyev.android.calculator.DisplayState;
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import javax.measure.unit.Unit;
|
||||||
import jscl.JsclMathEngine;
|
import jscl.JsclMathEngine;
|
||||||
import midpcalc.Real;
|
import midpcalc.Real;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.measure.unit.Unit;
|
|
||||||
|
|
||||||
final class Converter {
|
final class Converter {
|
||||||
static int unitName(@Nonnull Unit unit, @Nonnull UnitDimension dimension) {
|
static int unitName(@Nonnull Unit unit, @Nonnull UnitDimension dimension) {
|
||||||
|
@ -6,11 +6,8 @@ import android.content.DialogInterface;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -29,6 +26,9 @@ import android.widget.Spinner;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.AppComponent;
|
import org.solovyev.android.calculator.AppComponent;
|
||||||
import org.solovyev.android.calculator.AppModule;
|
import org.solovyev.android.calculator.AppModule;
|
||||||
@ -38,6 +38,7 @@ import org.solovyev.android.calculator.Editor;
|
|||||||
import org.solovyev.android.calculator.Keyboard;
|
import org.solovyev.android.calculator.Keyboard;
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.CppUnitConverterBinding;
|
||||||
import org.solovyev.android.calculator.keyboard.FloatingKeyboard;
|
import org.solovyev.android.calculator.keyboard.FloatingKeyboard;
|
||||||
import org.solovyev.android.calculator.keyboard.FloatingKeyboardWindow;
|
import org.solovyev.android.calculator.keyboard.FloatingKeyboardWindow;
|
||||||
import org.solovyev.android.calculator.keyboard.FloatingNumberKeyboard;
|
import org.solovyev.android.calculator.keyboard.FloatingNumberKeyboard;
|
||||||
@ -48,9 +49,6 @@ import org.solovyev.android.calculator.view.EditTextCompat;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.UiPreferences.Converter.lastDimension;
|
import static org.solovyev.android.calculator.UiPreferences.Converter.lastDimension;
|
||||||
import static org.solovyev.android.calculator.UiPreferences.Converter.lastUnitsFrom;
|
import static org.solovyev.android.calculator.UiPreferences.Converter.lastUnitsFrom;
|
||||||
import static org.solovyev.android.calculator.UiPreferences.Converter.lastUnitsTo;
|
import static org.solovyev.android.calculator.UiPreferences.Converter.lastUnitsTo;
|
||||||
@ -77,21 +75,13 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
SharedPreferences uiPreferences;
|
SharedPreferences uiPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
Editor editor;
|
Editor editor;
|
||||||
@BindView(R.id.converter_dimensions_spinner)
|
|
||||||
Spinner dimensionsSpinner;
|
Spinner dimensionsSpinner;
|
||||||
@BindView(R.id.converter_spinner_from)
|
|
||||||
Spinner spinnerFrom;
|
Spinner spinnerFrom;
|
||||||
@BindView(R.id.converter_label_from)
|
|
||||||
TextInputLayout labelFrom;
|
TextInputLayout labelFrom;
|
||||||
@BindView(R.id.converter_edittext_from)
|
|
||||||
EditTextCompat editTextFrom;
|
EditTextCompat editTextFrom;
|
||||||
@BindView(R.id.converter_spinner_to)
|
|
||||||
Spinner spinnerTo;
|
Spinner spinnerTo;
|
||||||
@BindView(R.id.converter_label_to)
|
|
||||||
TextInputLayout labelTo;
|
TextInputLayout labelTo;
|
||||||
@BindView(R.id.converter_edittext_to)
|
|
||||||
EditText editTextTo;
|
EditText editTextTo;
|
||||||
@BindView(R.id.converter_swap_button)
|
|
||||||
ImageButton swapButton;
|
ImageButton swapButton;
|
||||||
private ArrayAdapter<Named<ConvertibleDimension>> dimensionsAdapter;
|
private ArrayAdapter<Named<ConvertibleDimension>> dimensionsAdapter;
|
||||||
private ArrayAdapter<Named<Convertible>> adapterFrom;
|
private ArrayAdapter<Named<Convertible>> adapterFrom;
|
||||||
@ -139,9 +129,15 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater,
|
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.cpp_unit_converter, null);
|
final CppUnitConverterBinding binding = CppUnitConverterBinding.inflate(inflater, null, false);
|
||||||
ButterKnife.bind(this, view);
|
dimensionsSpinner = binding.converterDimensionsSpinner;
|
||||||
|
spinnerFrom = binding.converterSpinnerFrom;
|
||||||
|
labelFrom = binding.converterLabelFrom;
|
||||||
|
editTextFrom = binding.converterEdittextFrom;
|
||||||
|
spinnerTo = binding.converterSpinnerTo;
|
||||||
|
labelTo = binding.converterLabelTo;
|
||||||
|
editTextTo = binding.converterEdittextTo;
|
||||||
|
swapButton = binding.converterSwapButton;
|
||||||
dimensionsAdapter = App.makeSimpleSpinnerAdapter(context);
|
dimensionsAdapter = App.makeSimpleSpinnerAdapter(context);
|
||||||
for (ConvertibleDimension dimension : UnitDimension.values()) {
|
for (ConvertibleDimension dimension : UnitDimension.values()) {
|
||||||
dimensionsAdapter.add(dimension.named(context));
|
dimensionsAdapter.add(dimension.named(context));
|
||||||
@ -177,7 +173,7 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
pendingToSelection = savedInstanceState.getInt(STATE_SELECTION_TO, NONE);
|
pendingToSelection = savedInstanceState.getInt(STATE_SELECTION_TO, NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -203,16 +199,13 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
switch (parent.getId()) {
|
int parentId = parent.getId();
|
||||||
case R.id.converter_dimensions_spinner:
|
if (parentId == R.id.converter_dimensions_spinner) {
|
||||||
onDimensionChanged(dimensionsAdapter.getItem(position).item);
|
onDimensionChanged(dimensionsAdapter.getItem(position).item);
|
||||||
break;
|
} else if (parentId == R.id.converter_spinner_from) {
|
||||||
case R.id.converter_spinner_from:
|
|
||||||
onUnitFromChanged(adapterFrom.getItem(position).item);
|
onUnitFromChanged(adapterFrom.getItem(position).item);
|
||||||
break;
|
} else if (parentId == R.id.converter_spinner_to) {
|
||||||
case R.id.converter_spinner_to:
|
|
||||||
convert();
|
convert();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,15 +292,13 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
switch (v.getId()) {
|
if (v.getId() == R.id.converter_edittext_from) {
|
||||||
case R.id.converter_edittext_from:
|
|
||||||
if (!hasFocus) {
|
if (!hasFocus) {
|
||||||
convert();
|
convert();
|
||||||
} else {
|
} else {
|
||||||
clearError(labelFrom);
|
clearError(labelFrom);
|
||||||
showKeyboard();
|
showKeyboard();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,31 +337,26 @@ public class ConverterFragment extends BaseDialogFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
switch (v.getId()) {
|
if (v.getId() == R.id.converter_edittext_from) {
|
||||||
case R.id.converter_edittext_from:
|
|
||||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
App.hideIme(editTextFrom);
|
App.hideIme(editTextFrom);
|
||||||
convert();
|
convert();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
int id = v.getId();
|
||||||
case R.id.converter_swap_button:
|
if (id == R.id.converter_swap_button) {
|
||||||
keyboardWindow.hide();
|
keyboardWindow.hide();
|
||||||
swap();
|
swap();
|
||||||
break;
|
} else if (id == R.id.converter_edittext_from) {
|
||||||
case R.id.converter_edittext_from:
|
|
||||||
showKeyboard();
|
showKeyboard();
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
super.onClick(v);
|
super.onClick(v);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import javax.measure.unit.Unit;
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
|
|
||||||
import jscl.JsclMathEngine;
|
import jscl.JsclMathEngine;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.measure.unit.Unit;
|
|
||||||
|
|
||||||
final class UnitConvertible implements Convertible {
|
final class UnitConvertible implements Convertible {
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.solovyev.android.calculator.converter;
|
package org.solovyev.android.calculator.converter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.Named;
|
import org.solovyev.android.calculator.Named;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
@ -25,11 +25,11 @@ package org.solovyev.android.calculator.entities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import android.support.v7.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
@ -45,6 +45,8 @@ import org.solovyev.android.calculator.BaseFragment;
|
|||||||
import org.solovyev.android.calculator.CalculatorActivity;
|
import org.solovyev.android.calculator.CalculatorActivity;
|
||||||
import org.solovyev.android.calculator.Keyboard;
|
import org.solovyev.android.calculator.Keyboard;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentEntitiesBinding;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentEntitiesItemBinding;
|
||||||
import org.solovyev.common.math.MathEntity;
|
import org.solovyev.common.math.MathEntity;
|
||||||
import org.solovyev.common.text.Strings;
|
import org.solovyev.common.text.Strings;
|
||||||
|
|
||||||
@ -57,8 +59,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFragment {
|
public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFragment {
|
||||||
@ -71,7 +71,6 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@BindView(R.id.entities_recyclerview)
|
|
||||||
public RecyclerView recyclerView;
|
public RecyclerView recyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
Keyboard keyboard;
|
Keyboard keyboard;
|
||||||
@ -96,7 +95,8 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
final FragmentEntitiesBinding binding = FragmentEntitiesBinding.bind(view);
|
||||||
|
recyclerView = binding.entitiesRecyclerview;
|
||||||
final Context context = inflater.getContext();
|
final Context context = inflater.getContext();
|
||||||
adapter = new EntitiesAdapter(context, TextUtils.isEmpty(category) ? getEntities() : getEntities(category));
|
adapter = new EntitiesAdapter(context, TextUtils.isEmpty(category) ? getEntities() : getEntities(category));
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
|
||||||
@ -204,19 +204,18 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
|
|||||||
protected abstract boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull E entity);
|
protected abstract boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull E entity);
|
||||||
|
|
||||||
public class EntityViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener {
|
public class EntityViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener {
|
||||||
@BindView(R.id.entity_text)
|
|
||||||
TextView textView;
|
TextView textView;
|
||||||
@BindView(R.id.entity_description)
|
|
||||||
TextView descriptionView;
|
TextView descriptionView;
|
||||||
@Nullable
|
@Nullable
|
||||||
private E entity;
|
private E entity;
|
||||||
|
|
||||||
public EntityViewHolder(@Nonnull View view) {
|
public EntityViewHolder(@Nonnull FragmentEntitiesItemBinding binding) {
|
||||||
super(view);
|
super(binding.getRoot());
|
||||||
BaseActivity.fixFonts(itemView, typeface);
|
BaseActivity.fixFonts(itemView, typeface);
|
||||||
ButterKnife.bind(this, view);
|
textView = binding.entityText;
|
||||||
view.setOnClickListener(this);
|
descriptionView = binding.entityDescription;
|
||||||
view.setOnCreateContextMenuListener(this);
|
itemView.setOnClickListener(this);
|
||||||
|
itemView.setOnCreateContextMenuListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(@Nonnull E entity) {
|
public void bind(@Nonnull E entity) {
|
||||||
@ -266,7 +265,7 @@ public abstract class BaseEntitiesFragment<E extends MathEntity> extends BaseFra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public EntityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
return new EntityViewHolder(inflater.inflate(R.layout.fragment_entities_item, parent, false));
|
return new EntityViewHolder(FragmentEntitiesItemBinding.inflate(inflater, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,8 +25,8 @@ package org.solovyev.android.calculator.entities;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator.entities;
|
package org.solovyev.android.calculator.entities;
|
||||||
|
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import org.solovyev.common.math.MathEntity;
|
import org.solovyev.common.math.MathEntity;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.solovyev.android.calculator.entities;
|
package org.solovyev.android.calculator.entities;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.common.math.MathEntity;
|
import org.solovyev.common.math.MathEntity;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package org.solovyev.android.calculator.errors;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentManager;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.support.v7.app.AlertDialog;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.*;
|
import org.solovyev.android.calculator.*;
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.UiPreferences;
|
import org.solovyev.android.calculator.UiPreferences;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
|
@ -27,11 +27,11 @@ import android.content.DialogInterface;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseDialogFragment;
|
import org.solovyev.android.calculator.BaseDialogFragment;
|
||||||
|
@ -29,7 +29,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
@ -177,7 +177,7 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi
|
|||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
|
|
||||||
final Intent intent = createShowWindowIntent(this);
|
final Intent intent = createShowWindowIntent(this);
|
||||||
builder.setContentIntent(PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
|
builder.setContentIntent(PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
|
||||||
|
|
||||||
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
nm.notify(NOTIFICATION_ID, builder.build());
|
nm.notify(NOTIFICATION_ID, builder.build());
|
||||||
|
@ -32,7 +32,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@ -209,7 +209,7 @@ public class FloatingCalculatorView {
|
|||||||
y = in.readInt();
|
y = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@android.support.annotation.Nullable
|
@androidx.annotation.Nullable
|
||||||
public static State fromPrefs(@NonNull SharedPreferences prefs) {
|
public static State fromPrefs(@NonNull SharedPreferences prefs) {
|
||||||
if(!prefs.contains("width")) {
|
if(!prefs.contains("width")) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -27,10 +27,8 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.LayoutRes;
|
import androidx.annotation.LayoutRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
@ -44,6 +42,8 @@ import android.view.ViewParent;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.AppComponent;
|
import org.solovyev.android.calculator.AppComponent;
|
||||||
import org.solovyev.android.calculator.BaseDialogFragment;
|
import org.solovyev.android.calculator.BaseDialogFragment;
|
||||||
@ -69,8 +69,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import jscl.math.function.IConstant;
|
import jscl.math.function.IConstant;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.functions.CppFunction.NO_ID;
|
import static org.solovyev.android.calculator.functions.CppFunction.NO_ID;
|
||||||
@ -86,20 +84,12 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
private final FloatingKeyboardWindow keyboardWindow = new FloatingKeyboardWindow(null);
|
private final FloatingKeyboardWindow keyboardWindow = new FloatingKeyboardWindow(null);
|
||||||
@NonNull
|
@NonNull
|
||||||
private final KeyboardUser keyboardUser = new KeyboardUser();
|
private final KeyboardUser keyboardUser = new KeyboardUser();
|
||||||
@BindView(R.id.function_params)
|
public FunctionParamsView paramsView;
|
||||||
public
|
public TextInputLayout nameLabel;
|
||||||
FunctionParamsView paramsView;
|
|
||||||
@BindView(R.id.function_name_label)
|
|
||||||
TextInputLayout nameLabel;
|
|
||||||
@BindView(R.id.function_name)
|
|
||||||
public EditText nameView;
|
public EditText nameView;
|
||||||
@BindView(R.id.function_body_label)
|
|
||||||
public TextInputLayout bodyLabel;
|
public TextInputLayout bodyLabel;
|
||||||
@BindView(R.id.function_body)
|
|
||||||
public EditTextCompat bodyView;
|
public EditTextCompat bodyView;
|
||||||
@BindView(R.id.function_description_label)
|
|
||||||
public TextInputLayout descriptionLabel;
|
public TextInputLayout descriptionLabel;
|
||||||
@BindView(R.id.function_description)
|
|
||||||
public EditText descriptionView;
|
public EditText descriptionView;
|
||||||
@Inject
|
@Inject
|
||||||
Calculator calculator;
|
Calculator calculator;
|
||||||
@ -181,15 +171,13 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int id = v.getId();
|
final int id = v.getId();
|
||||||
switch (id) {
|
if (id == R.id.function_name) {
|
||||||
case R.id.function_name:
|
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
clearError(nameLabel);
|
clearError(nameLabel);
|
||||||
} else {
|
} else {
|
||||||
validateName();
|
validateName();
|
||||||
}
|
}
|
||||||
break;
|
} else if (id == R.id.function_body) {
|
||||||
case R.id.function_body:
|
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
clearError(bodyLabel);
|
clearError(bodyLabel);
|
||||||
showKeyboard();
|
showKeyboard();
|
||||||
@ -197,7 +185,6 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
keyboardWindow.hide();
|
keyboardWindow.hide();
|
||||||
validateBody();
|
validateBody();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,13 +206,10 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
if (v.getId() == R.id.function_body) {
|
||||||
case R.id.function_body:
|
|
||||||
showKeyboard();
|
showKeyboard();
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
super.onClick(v);
|
super.onClick(v);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +332,13 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(layout, null);
|
final View view = inflater.inflate(layout, null);
|
||||||
ButterKnife.bind(this, view);
|
paramsView = view.findViewById(R.id.function_params);
|
||||||
|
nameLabel = view.findViewById(R.id.function_name_label);
|
||||||
|
nameView = view.findViewById(R.id.function_name);
|
||||||
|
bodyLabel = view.findViewById(R.id.function_body_label);
|
||||||
|
bodyView = view.findViewById(R.id.function_body);
|
||||||
|
descriptionLabel = view.findViewById(R.id.function_description_label);
|
||||||
|
descriptionView = view.findViewById(R.id.function_description);
|
||||||
|
|
||||||
if (savedInstanceState == null && function != null) {
|
if (savedInstanceState == null && function != null) {
|
||||||
paramsView.addParams(function.getParameters());
|
paramsView.addParams(function.getParameters());
|
||||||
|
@ -2,7 +2,7 @@ package org.solovyev.android.calculator.functions;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import jscl.math.function.CustomFunction;
|
import jscl.math.function.CustomFunction;
|
||||||
import jscl.math.function.IFunction;
|
import jscl.math.function.IFunction;
|
||||||
|
@ -4,10 +4,10 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
import jscl.math.function.Function;
|
import jscl.math.function.Function;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.functions;
|
package org.solovyev.android.calculator.functions;
|
||||||
|
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.entities.Category;
|
import org.solovyev.android.calculator.entities.Category;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.functions;
|
package org.solovyev.android.calculator.functions;
|
||||||
|
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.Preferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
@ -33,8 +34,7 @@ import android.content.res.Resources;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@ -132,7 +132,7 @@ public class FunctionParamsView extends LinearLayout {
|
|||||||
addButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
addButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
addButton.setPadding(imageButtonPadding, imageButtonPadding, imageButtonPadding, imageButtonPadding);
|
addButton.setPadding(imageButtonPadding, imageButtonPadding, imageButtonPadding, imageButtonPadding);
|
||||||
final TypedValue value = new TypedValue();
|
final TypedValue value = new TypedValue();
|
||||||
if (getContext().getTheme().resolveAttribute(R.attr.selectableItemBackgroundBorderless, value, true)) {
|
if (getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.selectableItemBackgroundBorderless, value, true)) {
|
||||||
addButton.setBackgroundResource(value.resourceId);
|
addButton.setBackgroundResource(value.resourceId);
|
||||||
}
|
}
|
||||||
return addButton;
|
return addButton;
|
||||||
|
@ -24,7 +24,7 @@ package org.solovyev.android.calculator.functions;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
|
@ -24,9 +24,9 @@ package org.solovyev.android.calculator.functions;
|
|||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
import jscl.math.function.Function;
|
import jscl.math.function.Function;
|
||||||
@ -79,17 +79,17 @@ public class FunctionsFragment extends BaseEntitiesFragment<Function> {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull final Function function) {
|
protected boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull final Function function) {
|
||||||
final FragmentActivity activity = getActivity();
|
final FragmentActivity activity = getActivity();
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.string.c_use:
|
if (itemId == R.string.c_use) {
|
||||||
onClick(function);
|
onClick(function);
|
||||||
return true;
|
return true;
|
||||||
case R.string.cpp_edit:
|
} else if (itemId == R.string.cpp_edit) {
|
||||||
if (function instanceof IFunction) {
|
if (function instanceof IFunction) {
|
||||||
EditFunctionFragment.show(CppFunction.builder((IFunction) function).build(),
|
EditFunctionFragment.show(CppFunction.builder((IFunction) function).build(),
|
||||||
activity.getSupportFragmentManager());
|
activity.getSupportFragmentManager());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.string.cpp_delete:
|
} else if (itemId == R.string.cpp_delete) {
|
||||||
RemovalConfirmationDialog.showForFunction(getActivity(), function.getName(), new DialogInterface.OnClickListener() {
|
RemovalConfirmationDialog.showForFunction(getActivity(), function.getName(), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -24,7 +24,7 @@ package org.solovyev.android.calculator.functions;
|
|||||||
|
|
||||||
import static android.text.TextUtils.isEmpty;
|
import static android.text.TextUtils.isEmpty;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.simpleframework.xml.Serializer;
|
import org.simpleframework.xml.Serializer;
|
||||||
import org.simpleframework.xml.core.Persister;
|
import org.simpleframework.xml.core.Persister;
|
||||||
|
@ -29,11 +29,7 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v7.widget.DividerItemDecoration;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.text.ClipboardManager;
|
import android.text.ClipboardManager;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
@ -43,6 +39,10 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
@ -53,6 +53,8 @@ import org.solovyev.android.calculator.BaseFragment;
|
|||||||
import org.solovyev.android.calculator.CalculatorActivity;
|
import org.solovyev.android.calculator.CalculatorActivity;
|
||||||
import org.solovyev.android.calculator.Editor;
|
import org.solovyev.android.calculator.Editor;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentHistoryBinding;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentHistoryItemBinding;
|
||||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||||
import org.solovyev.common.text.Strings;
|
import org.solovyev.common.text.Strings;
|
||||||
|
|
||||||
@ -62,8 +64,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
public abstract class BaseHistoryFragment extends BaseFragment {
|
public abstract class BaseHistoryFragment extends BaseFragment {
|
||||||
private final boolean recentHistory;
|
private final boolean recentHistory;
|
||||||
@ -75,7 +75,6 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
Bus bus;
|
Bus bus;
|
||||||
@Inject
|
@Inject
|
||||||
Typeface typeface;
|
Typeface typeface;
|
||||||
@BindView(R.id.history_recyclerview)
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
private HistoryAdapter adapter;
|
private HistoryAdapter adapter;
|
||||||
|
|
||||||
@ -111,7 +110,8 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
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);
|
||||||
ButterKnife.bind(this, view);
|
FragmentHistoryBinding binding = FragmentHistoryBinding.bind(view);
|
||||||
|
recyclerView = binding.historyRecyclerview;
|
||||||
final Context context = inflater.getContext();
|
final Context context = inflater.getContext();
|
||||||
adapter = new HistoryAdapter(context);
|
adapter = new HistoryAdapter(context);
|
||||||
bus.register(adapter);
|
bus.register(adapter);
|
||||||
@ -156,21 +156,20 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
public class HistoryViewHolder extends RecyclerView.ViewHolder implements View.OnCreateContextMenuListener, View.OnClickListener, MenuItem.OnMenuItemClickListener {
|
public class HistoryViewHolder extends RecyclerView.ViewHolder implements View.OnCreateContextMenuListener, View.OnClickListener, MenuItem.OnMenuItemClickListener {
|
||||||
|
|
||||||
private static final int DATETIME_FORMAT = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_TIME;
|
private static final int DATETIME_FORMAT = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_TIME;
|
||||||
@BindView(R.id.history_item_value)
|
|
||||||
TextView valueView;
|
TextView valueView;
|
||||||
@BindView(R.id.history_item_comment)
|
|
||||||
TextView commentView;
|
TextView commentView;
|
||||||
@BindView(R.id.history_item_time)
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
@Nullable
|
@Nullable
|
||||||
private HistoryState state;
|
private HistoryState state;
|
||||||
|
|
||||||
public HistoryViewHolder(View view) {
|
public HistoryViewHolder(@NonNull FragmentHistoryItemBinding binding) {
|
||||||
super(view);
|
super(binding.getRoot());
|
||||||
BaseActivity.fixFonts(view, typeface);
|
BaseActivity.fixFonts(binding.getRoot(), typeface);
|
||||||
ButterKnife.bind(this, view);
|
valueView = binding.historyItemValue;
|
||||||
view.setOnCreateContextMenuListener(this);
|
commentView = binding.historyItemComment;
|
||||||
view.setOnClickListener(this);
|
timeView = binding.historyItemTime;
|
||||||
|
itemView.setOnCreateContextMenuListener(this);
|
||||||
|
itemView.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind(@Nonnull HistoryState state) {
|
void bind(@Nonnull HistoryState state) {
|
||||||
@ -217,23 +216,23 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
Check.isNotNull(state);
|
Check.isNotNull(state);
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.string.c_use:
|
if (itemId == R.string.c_use) {
|
||||||
useState(state);
|
useState(state);
|
||||||
return true;
|
return true;
|
||||||
case R.string.c_copy_expression:
|
} else if (itemId == R.string.c_copy_expression) {
|
||||||
copyExpression(state);
|
copyExpression(state);
|
||||||
return true;
|
return true;
|
||||||
case R.string.c_copy_result:
|
} else if (itemId == R.string.c_copy_result) {
|
||||||
copyResult(state);
|
copyResult(state);
|
||||||
return true;
|
return true;
|
||||||
case R.string.cpp_edit:
|
} else if (itemId == R.string.cpp_edit) {
|
||||||
EditHistoryFragment.show(state, false, getFragmentManager());
|
EditHistoryFragment.show(state, false, getParentFragmentManager());
|
||||||
return true;
|
return true;
|
||||||
case R.string.c_save:
|
} else if (itemId == R.string.c_save) {
|
||||||
EditHistoryFragment.show(state, true, getFragmentManager());
|
EditHistoryFragment.show(state, true, getParentFragmentManager());
|
||||||
return true;
|
return true;
|
||||||
case R.string.cpp_delete:
|
} else if (itemId == R.string.cpp_delete) {
|
||||||
history.removeSaved(state);
|
history.removeSaved(state);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -262,7 +261,7 @@ public abstract class BaseHistoryFragment extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
return new HistoryViewHolder(inflater.inflate(R.layout.fragment_history_item, parent, false));
|
return new HistoryViewHolder(FragmentHistoryItemBinding.inflate(inflater, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,22 +4,21 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.view.LayoutInflater;
|
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.BindView;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import butterknife.ButterKnife;
|
import androidx.fragment.app.FragmentManager;
|
||||||
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 org.solovyev.android.calculator.databinding.FragmentHistoryEditBinding;
|
||||||
|
|
||||||
public class EditHistoryFragment extends BaseDialogFragment {
|
public class EditHistoryFragment extends BaseDialogFragment {
|
||||||
|
|
||||||
@ -33,10 +32,7 @@ public class EditHistoryFragment extends BaseDialogFragment {
|
|||||||
|
|
||||||
boolean newState;
|
boolean newState;
|
||||||
|
|
||||||
@BindView(R.id.history_expression)
|
|
||||||
TextView expressionView;
|
TextView expressionView;
|
||||||
|
|
||||||
@BindView(R.id.history_comment)
|
|
||||||
EditText commentView;
|
EditText commentView;
|
||||||
|
|
||||||
public static void show(@NonNull HistoryState state, boolean newState, @NonNull FragmentManager fm) {
|
public static void show(@NonNull HistoryState state, boolean newState, @NonNull FragmentManager fm) {
|
||||||
@ -95,12 +91,13 @@ public class EditHistoryFragment extends BaseDialogFragment {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
protected View onCreateDialogView(@NonNull Context context, @NonNull LayoutInflater inflater, @Nullable Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_history_edit, null);
|
final FragmentHistoryEditBinding binding = FragmentHistoryEditBinding.inflate(inflater, null, false);
|
||||||
ButterKnife.bind(this, view);
|
expressionView = binding.historyExpression;
|
||||||
|
commentView = binding.historyComment;
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
expressionView.setText(BaseHistoryFragment.getHistoryText(state));
|
expressionView.setText(BaseHistoryFragment.getHistoryText(state));
|
||||||
commentView.setText(state.getComment());
|
commentView.setText(state.getComment());
|
||||||
}
|
}
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import static android.text.TextUtils.isEmpty;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
@ -25,11 +25,11 @@ package org.solovyev.android.calculator.history;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.AppComponent;
|
import org.solovyev.android.calculator.AppComponent;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
|
@ -2,7 +2,7 @@ package org.solovyev.android.calculator.history;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
package org.solovyev.android.calculator.jscl;
|
package org.solovyev.android.calculator.jscl;
|
||||||
|
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import jscl.MathEngine;
|
import jscl.MathEngine;
|
||||||
import jscl.math.Generic;
|
import jscl.math.Generic;
|
||||||
import jscl.text.ParseException;
|
import jscl.text.ParseException;
|
||||||
|
@ -2,7 +2,7 @@ package org.solovyev.android.calculator.json;
|
|||||||
|
|
||||||
import static android.text.TextUtils.isEmpty;
|
import static android.text.TextUtils.isEmpty;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -3,10 +3,10 @@ package org.solovyev.android.calculator.keyboard;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import android.support.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import android.support.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -11,8 +11,8 @@ import android.app.Activity;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
@ -2,7 +2,7 @@ package org.solovyev.android.calculator.keyboard;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import android.app.Dialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.keyboard;
|
package org.solovyev.android.calculator.keyboard;
|
||||||
|
|
||||||
import android.support.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -93,11 +93,11 @@ public class FloatingNumberKeyboard extends BaseFloatingKeyboard {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final EditText editor = getUser().getEditor();
|
final EditText editor = getUser().getEditor();
|
||||||
switch (v.getId()) {
|
int id = v.getId();
|
||||||
case R.id.cpp_kb_button_clear:
|
if (id == R.id.cpp_kb_button_clear) {
|
||||||
editor.setText("");
|
editor.setText("");
|
||||||
return;
|
return;
|
||||||
case R.id.cpp_kb_button_close:
|
} else if (id == R.id.cpp_kb_button_close) {
|
||||||
getUser().done();
|
getUser().done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package org.solovyev.android.calculator.keyboard;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
@ -24,25 +22,15 @@ import static org.solovyev.android.views.dragbutton.DragDirection.*;
|
|||||||
|
|
||||||
public class KeyboardUi extends BaseKeyboardUi {
|
public class KeyboardUi extends BaseKeyboardUi {
|
||||||
|
|
||||||
@BindView(R.id.cpp_button_0)
|
|
||||||
public DirectionDragButton button0;
|
public DirectionDragButton button0;
|
||||||
@BindView(R.id.cpp_button_1)
|
|
||||||
public DirectionDragButton button1;
|
public DirectionDragButton button1;
|
||||||
@BindView(R.id.cpp_button_2)
|
|
||||||
public DirectionDragButton button2;
|
public DirectionDragButton button2;
|
||||||
@BindView(R.id.cpp_button_3)
|
|
||||||
public DirectionDragButton button3;
|
public DirectionDragButton button3;
|
||||||
@BindView(R.id.cpp_button_4)
|
|
||||||
public DirectionDragButton button4;
|
public DirectionDragButton button4;
|
||||||
@BindView(R.id.cpp_button_5)
|
|
||||||
public DirectionDragButton button5;
|
public DirectionDragButton button5;
|
||||||
@BindView(R.id.cpp_button_6)
|
|
||||||
public DirectionDragButton button6;
|
public DirectionDragButton button6;
|
||||||
@BindView(R.id.cpp_button_7)
|
|
||||||
public DirectionDragButton button7;
|
public DirectionDragButton button7;
|
||||||
@BindView(R.id.cpp_button_8)
|
|
||||||
public DirectionDragButton button8;
|
public DirectionDragButton button8;
|
||||||
@BindView(R.id.cpp_button_9)
|
|
||||||
public DirectionDragButton button9;
|
public DirectionDragButton button9;
|
||||||
@Inject
|
@Inject
|
||||||
Engine engine;
|
Engine engine;
|
||||||
@ -52,35 +40,22 @@ public class KeyboardUi extends BaseKeyboardUi {
|
|||||||
Bus bus;
|
Bus bus;
|
||||||
@Inject
|
@Inject
|
||||||
PartialKeyboardUi partialUi;
|
PartialKeyboardUi partialUi;
|
||||||
@BindView(R.id.cpp_button_vars)
|
|
||||||
DirectionDragButton variablesButton;
|
DirectionDragButton variablesButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_operators)
|
|
||||||
DirectionDragButton operatorsButton;
|
DirectionDragButton operatorsButton;
|
||||||
@BindView(R.id.cpp_button_functions)
|
|
||||||
DirectionDragButton functionsButton;
|
DirectionDragButton functionsButton;
|
||||||
@BindView(R.id.cpp_button_history)
|
|
||||||
DirectionDragButton historyButton;
|
DirectionDragButton historyButton;
|
||||||
@BindView(R.id.cpp_button_multiplication)
|
|
||||||
DirectionDragButton multiplicationButton;
|
DirectionDragButton multiplicationButton;
|
||||||
@BindView(R.id.cpp_button_plus)
|
|
||||||
DirectionDragButton plusButton;
|
DirectionDragButton plusButton;
|
||||||
@BindView(R.id.cpp_button_subtraction)
|
|
||||||
DirectionDragButton subtractionButton;
|
DirectionDragButton subtractionButton;
|
||||||
@BindView(R.id.cpp_button_division)
|
|
||||||
DirectionDragButton divisionButton;
|
DirectionDragButton divisionButton;
|
||||||
@BindView(R.id.cpp_button_period)
|
|
||||||
DirectionDragButton periodButton;
|
DirectionDragButton periodButton;
|
||||||
@BindView(R.id.cpp_button_round_brackets)
|
|
||||||
DirectionDragButton bracketsButton;
|
DirectionDragButton bracketsButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_like)
|
|
||||||
DirectionDragButton likeButton;
|
DirectionDragButton likeButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_percent)
|
|
||||||
DirectionDragButton percentButton;
|
DirectionDragButton percentButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_memory)
|
|
||||||
DirectionDragButton memoryButton;
|
DirectionDragButton memoryButton;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -101,7 +76,30 @@ public class KeyboardUi extends BaseKeyboardUi {
|
|||||||
public void onCreateView(@Nonnull Activity activity, @Nonnull View view) {
|
public void onCreateView(@Nonnull Activity activity, @Nonnull View view) {
|
||||||
super.onCreateView(activity, view);
|
super.onCreateView(activity, view);
|
||||||
partialUi.onCreateView(activity, view);
|
partialUi.onCreateView(activity, view);
|
||||||
ButterKnife.bind(this, view);
|
button0 = view.findViewById(R.id.cpp_button_0);
|
||||||
|
button1 = view.findViewById(R.id.cpp_button_1);
|
||||||
|
button2 = view.findViewById(R.id.cpp_button_2);
|
||||||
|
button3 = view.findViewById(R.id.cpp_button_3);
|
||||||
|
button4 = view.findViewById(R.id.cpp_button_4);
|
||||||
|
button5 = view.findViewById(R.id.cpp_button_5);
|
||||||
|
button6 = view.findViewById(R.id.cpp_button_6);
|
||||||
|
button7 = view.findViewById(R.id.cpp_button_7);
|
||||||
|
button8 = view.findViewById(R.id.cpp_button_8);
|
||||||
|
button9 = view.findViewById(R.id.cpp_button_9);
|
||||||
|
|
||||||
|
variablesButton = view.findViewById(R.id.cpp_button_vars);
|
||||||
|
operatorsButton = view.findViewById(R.id.cpp_button_operators);
|
||||||
|
functionsButton = view.findViewById(R.id.cpp_button_functions);
|
||||||
|
historyButton = view.findViewById(R.id.cpp_button_history);
|
||||||
|
multiplicationButton = view.findViewById(R.id.cpp_button_multiplication);
|
||||||
|
plusButton = view.findViewById(R.id.cpp_button_plus);
|
||||||
|
subtractionButton = view.findViewById(R.id.cpp_button_subtraction);
|
||||||
|
divisionButton = view.findViewById(R.id.cpp_button_division);
|
||||||
|
periodButton = view.findViewById(R.id.cpp_button_period);
|
||||||
|
bracketsButton = view.findViewById(R.id.cpp_button_round_brackets);
|
||||||
|
likeButton = view.findViewById(R.id.cpp_button_like);
|
||||||
|
percentButton = view.findViewById(R.id.cpp_button_percent);
|
||||||
|
memoryButton = view.findViewById(R.id.cpp_button_memory);
|
||||||
|
|
||||||
prepareButton(variablesButton);
|
prepareButton(variablesButton);
|
||||||
prepareButton(operatorsButton);
|
prepareButton(operatorsButton);
|
||||||
|
@ -3,8 +3,8 @@ package org.solovyev.android.calculator.keyboard;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
@ -14,28 +14,20 @@ import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.Preferences.Gui.vibrateOnKeypress;
|
import static org.solovyev.android.calculator.Preferences.Gui.vibrateOnKeypress;
|
||||||
import static org.solovyev.android.views.dragbutton.DragDirection.down;
|
import static org.solovyev.android.views.dragbutton.DragDirection.down;
|
||||||
|
|
||||||
public class PartialKeyboardUi extends BaseKeyboardUi {
|
public class PartialKeyboardUi extends BaseKeyboardUi {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_right)
|
|
||||||
DirectionDragButton rightButton;
|
DirectionDragButton rightButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_left)
|
|
||||||
DirectionDragButton leftButton;
|
DirectionDragButton leftButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_clear)
|
|
||||||
DirectionDragButton clearButton;
|
DirectionDragButton clearButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_erase)
|
|
||||||
DirectionDragButton eraseButton;
|
DirectionDragButton eraseButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.cpp_button_equals)
|
|
||||||
DirectionDragButton equalsButton;
|
DirectionDragButton equalsButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
EditorLongClickEraser longClickEraser;
|
EditorLongClickEraser longClickEraser;
|
||||||
@ -48,7 +40,11 @@ public class PartialKeyboardUi extends BaseKeyboardUi {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateView(@Nonnull Activity activity, @Nonnull View view) {
|
public void onCreateView(@Nonnull Activity activity, @Nonnull View view) {
|
||||||
super.onCreateView(activity, view);
|
super.onCreateView(activity, view);
|
||||||
ButterKnife.bind(this, view);
|
rightButton = view.findViewById(R.id.cpp_button_right);
|
||||||
|
leftButton = view.findViewById(R.id.cpp_button_left);
|
||||||
|
clearButton = view.findViewById(R.id.cpp_button_clear);
|
||||||
|
eraseButton = view.findViewById(R.id.cpp_button_erase);
|
||||||
|
equalsButton = view.findViewById(R.id.cpp_button_equals);
|
||||||
prepareButton(rightButton);
|
prepareButton(rightButton);
|
||||||
prepareButton(leftButton);
|
prepareButton(leftButton);
|
||||||
prepareButton(equalsButton);
|
prepareButton(equalsButton);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.language;
|
package org.solovyev.android.calculator.language;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.preferences.PreferenceEntry;
|
import org.solovyev.android.calculator.preferences.PreferenceEntry;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.math;
|
package org.solovyev.android.calculator.math;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jscl.JsclMathEngine;
|
import jscl.JsclMathEngine;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
import jscl.math.function.Constants;
|
import jscl.math.function.Constants;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.solovyev.android.calculator.memory;
|
package org.solovyev.android.calculator.memory;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.operators;
|
package org.solovyev.android.calculator.operators;
|
||||||
|
|
||||||
import android.support.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import jscl.math.operator.*;
|
import jscl.math.operator.*;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.entities.Category;
|
import org.solovyev.android.calculator.entities.Category;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
package org.solovyev.android.calculator.operators;
|
package org.solovyev.android.calculator.operators;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.operators;
|
package org.solovyev.android.calculator.operators;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import jscl.math.operator.Operator;
|
import jscl.math.operator.Operator;
|
||||||
@ -78,8 +78,7 @@ public class OperatorsFragment extends BaseEntitiesFragment<Operator> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull Operator operator) {
|
protected boolean onMenuItemClicked(@Nonnull MenuItem item, @Nonnull Operator operator) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == R.string.c_use) {
|
||||||
case R.string.c_use:
|
|
||||||
onClick(operator);
|
onClick(operator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.operators;
|
package org.solovyev.android.calculator.operators;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jscl.JsclMathEngine;
|
import jscl.JsclMathEngine;
|
||||||
import jscl.math.operator.Operator;
|
import jscl.math.operator.Operator;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.operators;
|
package org.solovyev.android.calculator.operators;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jscl.JsclMathEngine;
|
import jscl.JsclMathEngine;
|
||||||
import jscl.math.operator.Operator;
|
import jscl.math.operator.Operator;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package org.solovyev.android.calculator.plot;
|
package org.solovyev.android.calculator.plot;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentManager;
|
import androidx.core.content.ContextCompat;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import org.solovyev.android.calculator.AppComponent;
|
import org.solovyev.android.calculator.AppComponent;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.BaseFragment;
|
import org.solovyev.android.calculator.BaseFragment;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.databinding.FragmentPlotBinding;
|
||||||
import org.solovyev.android.plotter.Dimensions;
|
import org.solovyev.android.plotter.Dimensions;
|
||||||
import org.solovyev.android.plotter.PlotData;
|
import org.solovyev.android.plotter.PlotData;
|
||||||
import org.solovyev.android.plotter.PlotViewFrame;
|
import org.solovyev.android.plotter.PlotViewFrame;
|
||||||
@ -21,8 +22,6 @@ import org.solovyev.android.plotter.Plotter;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
public class PlotActivity extends BaseActivity {
|
public class PlotActivity extends BaseActivity {
|
||||||
|
|
||||||
@ -32,7 +31,6 @@ public class PlotActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Plotter plotter;
|
Plotter plotter;
|
||||||
@BindView(R.id.plot_view_frame)
|
|
||||||
PlotViewFrame plotView;
|
PlotViewFrame plotView;
|
||||||
|
|
||||||
public MyFragment() {
|
public MyFragment() {
|
||||||
@ -49,7 +47,8 @@ public class PlotActivity extends BaseActivity {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
ButterKnife.bind(this, view);
|
final FragmentPlotBinding binding = FragmentPlotBinding.bind(view);
|
||||||
|
plotView = binding.plotViewFrame;
|
||||||
|
|
||||||
final PlotData pd = plotter.getPlotData();
|
final PlotData pd = plotter.getPlotData();
|
||||||
pd.axisStyle.backgroundColor = ContextCompat.getColor(getActivity(), R.color.cpp_bg);
|
pd.axisStyle.backgroundColor = ContextCompat.getColor(getActivity(), R.color.cpp_bg);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user