Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs and update the source code #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 29

defaultConfig {
applicationId "com.github.glomadrian.materialanimatedswitch.sample"
minSdkVersion 9
targetSdkVersion 22
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -20,7 +19,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project (':materialanimatedswitch')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation project (':materialanimatedswitch')
}

This file was deleted.

31 changes: 14 additions & 17 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.glomadrian.materialanimatedswitch.sample"
>
package="com.github.glomadrian.materialanimatedswitch.sample">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.github.glomadrian.materialanimatedswitch.sample;

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

import androidx.appcompat.app.AppCompatActivity;

import com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch;

public class MainActivity extends AppCompatActivity {
Expand All @@ -15,23 +17,25 @@ public class MainActivity extends AppCompatActivity {
private MaterialAnimatedSwitch materialAnimatedSwitch4;
private MaterialAnimatedSwitch masterSwitch;

@Override protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainView = findViewById(R.id.main);
materialAnimatedSwitch = (MaterialAnimatedSwitch) findViewById(R.id.pin);
materialAnimatedSwitch2 = (MaterialAnimatedSwitch) findViewById(R.id.pin2);
materialAnimatedSwitch3 = (MaterialAnimatedSwitch) findViewById(R.id.pin3);
materialAnimatedSwitch4 = (MaterialAnimatedSwitch) findViewById(R.id.pin4);
masterSwitch = (MaterialAnimatedSwitch) findViewById(R.id.masterSwitch);
materialAnimatedSwitch = findViewById(R.id.pin);
materialAnimatedSwitch2 = findViewById(R.id.pin2);
materialAnimatedSwitch3 = findViewById(R.id.pin3);
materialAnimatedSwitch4 = findViewById(R.id.pin4);
masterSwitch = findViewById(R.id.masterSwitch);

materialAnimatedSwitch.setOnCheckedChangeListener(
new MaterialAnimatedSwitch.OnCheckedChangeListener() {
@Override public void onCheckedChanged(boolean isChecked) {
Toast.makeText(MainActivity.this, materialAnimatedSwitch.isChecked() + "",
Toast.LENGTH_SHORT).show();
materialAnimatedSwitch2.toggle();
}
});
new MaterialAnimatedSwitch.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(boolean isChecked) {
Toast.makeText(MainActivity.this, materialAnimatedSwitch.isChecked() + "",
Toast.LENGTH_SHORT).show();
materialAnimatedSwitch2.toggle();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Utils {
*/
public static int dpToPx(float dp, Resources resources) {
float px =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
return (int) px;
}
}
134 changes: 64 additions & 70 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,87 +1,81 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4285F4"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#4285F4"
>
<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/masterSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
app:base_release_color="@color/md_teal_900"
app:base_press_color="@color/md_teal_50"
app:ball_release_color="@color/md_teal_500"
app:ball_press_color="@color/md_white_1000"
app:icon_release="@drawable/ic_radio_button_off_white_36dp"
app:icon_press="@drawable/ic_radio_button_on_teal_500_36dp"
/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="4"
android:orientation="vertical"
android:layout_centerInParent="true"
>

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
/>
tools:context=".MainActivity">

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:layout_marginTop="20dp"
android:id="@+id/pin2"
android:id="@+id/masterSwitch"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
app:base_release_color="@color/md_green_900"
app:base_press_color="@color/md_green_50"
app:ball_release_color="@color/md_green_500"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
app:ball_press_color="@color/md_white_1000"
app:icon_release="@drawable/shield_with_sword_64"
app:icon_press="@drawable/sword_in_vertical_position_64"
/>
app:ball_release_color="@color/md_teal_500"
app:base_press_color="@color/md_teal_50"
app:base_release_color="@color/md_teal_900"
app:icon_press="@drawable/ic_radio_button_on_teal_500_36dp"
app:icon_release="@drawable/ic_radio_button_off_white_36dp" />

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin3"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
app:base_release_color="@color/md_deep_purple_900"
app:base_press_color="@color/md_deep_purple_50"
app:ball_release_color="@color/md_deep_purple_500"
app:ball_press_color="@color/md_white_1000"
app:icon_release="@drawable/ic_create_white_36dp"
app:icon_press="@drawable/ic_delete_deep_purple_500_36dp"
/>
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:weightSum="4">

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin4"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
app:base_release_color="@color/md_deep_orange_900"
app:base_press_color="@color/md_deep_orange_50"
app:ball_release_color="@color/md_deep_orange_500"
app:ball_press_color="@color/md_white_1000"
app:icon_release="@drawable/ic_play_arrow_white_36dp"
app:icon_press="@drawable/ic_stop_deep_orange_500_36dp"
/>
</LinearLayout>
<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
app:ball_press_color="@color/md_white_1000"
app:ball_release_color="@color/md_green_500"
app:base_press_color="@color/md_green_50"
app:base_release_color="@color/md_green_900"
app:icon_press="@drawable/sword_in_vertical_position_64"
app:icon_release="@drawable/shield_with_sword_64" />

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
app:ball_press_color="@color/md_white_1000"
app:ball_release_color="@color/md_deep_purple_500"
app:base_press_color="@color/md_deep_purple_50"
app:base_release_color="@color/md_deep_purple_900"
app:icon_press="@drawable/ic_delete_deep_purple_500_36dp"
app:icon_release="@drawable/ic_create_white_36dp" />

<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/pin4"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
app:ball_press_color="@color/md_white_1000"
app:ball_release_color="@color/md_deep_orange_500"
app:base_press_color="@color/md_deep_orange_50"
app:base_release_color="@color/md_deep_orange_900"
app:icon_press="@drawable/ic_stop_deep_orange_500_36dp"
app:icon_release="@drawable/ic_play_arrow_white_36dp" />
</LinearLayout>

</RelativeLayout>
9 changes: 5 additions & 4 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
Loading