From a9396c9c116d709bd66557f05a3e767ccd6ee033 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Fri, 16 Nov 2018 16:30:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=8E=D0=BD=D0=B8=D1=82-=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20(=D0=BE=D0=BD=D0=B8=20=D0=BF=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=87=D1=82=D0=BE=20=D0=BD=D0=B5=20=D0=BD=D1=83=D0=B6=D0=BD?= =?UTF-8?q?=D1=8B),=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20ActionBar=20=D0=B2=20SettingsActivity=20(=D1=81?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BC=D0=BE=D1=89=D1=8C=D1=8E=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B0=20AppCompatPreferenceActivity).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 531 -> 537 bytes app/build.gradle | 2 +- .../vrcatalog/ExampleInstrumentedTest.java | 26 ---- .../vrcatalog/SettingsActivity.java | 12 +- .../AppCompatPreferenceActivity.java | 125 ++++++++++++++++++ .../volgorobot/vrcatalog/ExampleUnitTest.java | 17 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 8 files changed, 133 insertions(+), 55 deletions(-) delete mode 100644 app/src/androidTest/java/ru/volgorobot/vrcatalog/ExampleInstrumentedTest.java create mode 100644 app/src/main/java/ru/volgorobot/vrcatalog/additional/AppCompatPreferenceActivity.java delete mode 100644 app/src/test/java/ru/volgorobot/vrcatalog/ExampleUnitTest.java diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 513b45630436762e7de8f50a7601af2a53243d4f..2f6f833776601a3c9893c6a53bcb25efc52fc661 100644 GIT binary patch delta 124 zcmV-?0E7RN1epYom;@YLk~@){hz}?)Xm4$0FJowOZ*FgMc$0$xHYW^Xb!lv5E@yIK zWNc-1aR7b*1^@s65N804UGtLG8*JGaElD)<(34969TOxD8XH1f#TivHn_oTyB{_5e e5tEDo8I;}n-&x2bg1(rm1gFo=%p7WrsSlS7BbW^urV+&2&k+IPTQ_zEp2ch ziCIlasdVxLMp>1(gkFb8S%K}}A6j3ZHUCw834@Y;Mt*LpezBoG)CB#>2NTesting documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("ru.volgorobot.vrcatalog", appContext.getPackageName()); - } -} diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/SettingsActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/SettingsActivity.java index 928ab76..d74d8a9 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/SettingsActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/SettingsActivity.java @@ -1,23 +1,19 @@ package ru.volgorobot.vrcatalog; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import android.support.v7.app.AppCompatDelegate; import android.view.Menu; import android.view.MenuItem; -import android.preference.PreferenceActivity; +import ru.volgorobot.vrcatalog.additional.AppCompatPreferenceActivity; -public class SettingsActivity extends PreferenceActivity { - - private AppCompatDelegate mDelegate; +public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.activity_settings); - //getActionBar().setDisplayHomeAsUpEnabled(true); - //getActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); } @Override diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/additional/AppCompatPreferenceActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/additional/AppCompatPreferenceActivity.java new file mode 100644 index 0000000..cfd5368 --- /dev/null +++ b/app/src/main/java/ru/volgorobot/vrcatalog/additional/AppCompatPreferenceActivity.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ru.volgorobot.vrcatalog.additional; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.widget.Toolbar; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls + * to be used with AppCompat. + * + * This technique can be used with an {@link android.app.Activity} class, not just + * {@link android.preference.PreferenceActivity}. + */ + +public abstract class AppCompatPreferenceActivity extends PreferenceActivity { + private AppCompatDelegate mDelegate; + @Override + protected void onCreate(Bundle savedInstanceState) { + getDelegate().installViewFactory(); + getDelegate().onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getDelegate().onPostCreate(savedInstanceState); + } + + public ActionBar getSupportActionBar() { + return getDelegate().getSupportActionBar(); + } + + public void setSupportActionBar(@Nullable Toolbar toolbar) { + getDelegate().setSupportActionBar(toolbar); + } + + @Override + public MenuInflater getMenuInflater() { + return getDelegate().getMenuInflater(); + } + + @Override + public void setContentView(@LayoutRes int layoutResID) { + getDelegate().setContentView(layoutResID); + } + + @Override + public void setContentView(View view) { + getDelegate().setContentView(view); + } + + @Override + public void setContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().setContentView(view, params); + } + + @Override + public void addContentView(View view, ViewGroup.LayoutParams params) { + getDelegate().addContentView(view, params); + } + + @Override + protected void onPostResume() { + super.onPostResume(); + getDelegate().onPostResume(); + } + + @Override + protected void onTitleChanged(CharSequence title, int color) { + super.onTitleChanged(title, color); + getDelegate().setTitle(title); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + getDelegate().onConfigurationChanged(newConfig); + } + + @Override + protected void onStop() { + super.onStop(); + getDelegate().onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + getDelegate().onDestroy(); + } + + public void invalidateOptionsMenu() { + getDelegate().invalidateOptionsMenu(); + } + + private AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = AppCompatDelegate.create(this, null); + } + return mDelegate; + } +} \ No newline at end of file diff --git a/app/src/test/java/ru/volgorobot/vrcatalog/ExampleUnitTest.java b/app/src/test/java/ru/volgorobot/vrcatalog/ExampleUnitTest.java deleted file mode 100644 index ac47aea..0000000 --- a/app/src/test/java/ru/volgorobot/vrcatalog/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package ru.volgorobot.vrcatalog; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 077cb2f..8d3ef8e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4b3c7b5..2b05c88 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Sep 08 16:32:20 MSK 2018 +#Fri Nov 16 14:50:11 MSK 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip