Skip to content

Commit

Permalink
Migrate to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-knyazev committed Oct 12, 2022
1 parent 6d4702e commit 2099378
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 84 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

18 changes: 12 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@ android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "omega.com.omegalayoutsexample"
minSdkVersion 14
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation project(":libs")
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

implementation 'androidx.appcompat:appcompat:1.5.1'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class AutoOrientationExampleActivity extends AppCompatActivity {

public static Intent createIntent(Context context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package omega.com.omegalayoutsexample;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class PercentsExampleActivity extends AppCompatActivity {

public static Intent createIntent(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import androidx.appcompat.app.AppCompatActivity;

public class ShadowsExampleActivity extends AppCompatActivity {

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.AppCompatButton
<Button
android:id="@+id/button_percents"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Percents" />

<android.support.v7.widget.AppCompatButton
<Button
android:id="@+id/button_shadows"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shadows" />

<android.support.v7.widget.AppCompatButton
<Button
android:id="@+id/button_auto_orientation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

buildscript {

ext.supportVersion = '27.1.1'
ext.compileSdkVersion = 27
ext.targetSdkVersion = 27
ext.compileSdkVersion = 31
ext.targetSdkVersion = 31

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -22,7 +21,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Apr 06 15:15:42 MSK 2018
#Wed Oct 12 11:21:56 MSK 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
zipStoreBase=GRADLE_USER_HOME
6 changes: 3 additions & 3 deletions libs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ android {
compileSdkVersion rootProject.ext.compileSdkVersion

defaultConfig {
minSdkVersion 14
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

}

Expand All @@ -26,5 +26,5 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compileOnly "com.android.support:appcompat-v7:$supportVersion"
compileOnly 'androidx.appcompat:appcompat:1.5.1'
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.omega_r.libs.layouts;

import android.content.Context;
import android.support.v7.widget.LinearLayoutCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

public class AutoOrientationLinearLayout extends LinearLayoutCompat {
public class AutoOrientationLinearLayout extends LinearLayout {

public AutoOrientationLinearLayout(Context context) {
super(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.FrameLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.v4.view.MarginLayoutParamsCompat;
import android.support.v4.view.ViewCompat;
import androidx.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -442,10 +440,8 @@ public void fillMarginLayoutParams(View view, ViewGroup.MarginLayoutParams param
mPreservedParams.topMargin = params.topMargin;
mPreservedParams.rightMargin = params.rightMargin;
mPreservedParams.bottomMargin = params.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
mPreservedParams.setMarginStart(params.getMarginStart());
mPreservedParams.setMarginEnd(params.getMarginEnd());

if (leftMarginPercent >= 0) {
params.leftMargin = Math.round(widthHint * leftMarginPercent);
Expand All @@ -461,20 +457,17 @@ public void fillMarginLayoutParams(View view, ViewGroup.MarginLayoutParams param
}
boolean shouldResolveLayoutDirection = false;
if (startMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginStart(params,
Math.round(widthHint * startMarginPercent));
params.setMarginStart(Math.round(widthHint * startMarginPercent));
shouldResolveLayoutDirection = true;
}
if (endMarginPercent >= 0) {
MarginLayoutParamsCompat.setMarginEnd(params,
Math.round(widthHint * endMarginPercent));
params.setMarginEnd(Math.round(widthHint * endMarginPercent));
shouldResolveLayoutDirection = true;
}
if (shouldResolveLayoutDirection && (view != null)) {
// Force the resolve pass so that start / end margins are propagated to the
// matching left / right fields
MarginLayoutParamsCompat.resolveLayoutDirection(params,
ViewCompat.getLayoutDirection(view));
params.resolveLayoutDirection(view.getLayoutDirection());
}
if (DEBUG) {
Log.d(TAG, "after fillMarginLayoutParams: (" + params.width + ", " + params.height
Expand Down Expand Up @@ -502,10 +495,8 @@ public void restoreMarginLayoutParams(ViewGroup.MarginLayoutParams params) {
params.topMargin = mPreservedParams.topMargin;
params.rightMargin = mPreservedParams.rightMargin;
params.bottomMargin = mPreservedParams.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat.getMarginStart(mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat.getMarginEnd(mPreservedParams));
params.setMarginStart(mPreservedParams.getMarginStart());
params.setMarginEnd(mPreservedParams.getMarginEnd());
}

/**
Expand Down
Loading

0 comments on commit 2099378

Please sign in to comment.