Skip to content
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
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}
19 changes: 19 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# 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.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
13 changes: 9 additions & 4 deletions slideDateTimePicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 30
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 30
}

buildTypes {
Expand All @@ -15,8 +15,13 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
compile 'com.android.support:support-v4:23.1.1'
implementation 'androidx.appcompat:appcompat:1.3.0'
}
10 changes: 1 addition & 9 deletions slideDateTimePicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.jjobes.slidedatetimepicker" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />

</manifest>
<manifest package="com.github.jjobes.slidedatetimepicker" />
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.github.jjobes.slidedatetimepicker;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.DatePicker;
import android.widget.TimePicker;

import androidx.viewpager.widget.ViewPager;

/**
* A custom {@link android.support.v4.view.ViewPager} implementation that corrects
* A custom {@link ViewPager} implementation that corrects
* the height of the ViewPager and also dispatches touch events to either the ViewPager
* or the date or time picker depending on the direction of the swipe.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;
import android.widget.DatePicker.OnDateChangedListener;

import androidx.fragment.app.Fragment;

/**
* The fragment for the first page in the ViewPager that holds
Expand All @@ -21,60 +21,28 @@
*/
public class DateFragment extends Fragment
{
/**
* Used to communicate back to the parent fragment as the user
* is changing the date spinners so we can dynamically update
* the tab text.
*/
public interface DateChangedListener
{
void onDateChanged(int year, int month, int day);
}
public static final String DATE_FRAGMENT_KEY = "100";

private DateChangedListener mCallback;
private CustomDatePicker mDatePicker;

public DateFragment()
{
// Required empty public constructor for fragment.
}

/**
* Cast the reference to {@link SlideDateTimeDialogFragment}
* to a {@link DateChangedListener}.
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

try
{
mCallback = (DateChangedListener) getTargetFragment();
}
catch (ClassCastException e)
{
throw new ClassCastException("Calling fragment must implement " +
"DateFragment.DateChangedListener interface");
}
}

/**
* Return an instance of DateFragment with its bundle filled with the
* constructor arguments. The values in the bundle are retrieved in
* {@link #onCreateView()} below to properly initialize the DatePicker.
*
* @param theme
* @param year
* @param month
* @param day
* @param minDate
* @param maxDate
* @return an instance of DateFragment
* {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} below to properly initialize the DatePicker.
*/
public static final DateFragment newInstance(int theme, int year, int month,
int day, Date minDate, Date maxDate)
{
public static DateFragment newInstance(
int theme,
int year,
int month,
int day,
Date minDate,
Date maxDate
) {
DateFragment f = new DateFragment();

Bundle b = new Bundle();
Expand All @@ -93,9 +61,12 @@ public static final DateFragment newInstance(int theme, int year, int month,
* Create and return the user interface view for this fragment.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState
) {
assert getArguments() != null;
int theme = getArguments().getInt("theme");
int initialYear = getArguments().getInt("year");
int initialMonth = getArguments().getInt("month");
Expand All @@ -112,8 +83,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Context contextThemeWrapper = new ContextThemeWrapper(
getActivity(),
theme == SlideDateTimePicker.HOLO_DARK ?
android.R.style.Theme_Holo :
android.R.style.Theme_Holo_Light);
android.R.style.Theme_Holo :
android.R.style.Theme_Holo_Light);

LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

Expand All @@ -123,18 +94,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// block keyboard popping up on touch
mDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
mDatePicker.init(
initialYear,
initialMonth,
initialDay,
new OnDateChangedListener() {

@Override
public void onDateChanged(DatePicker view, int year,
int monthOfYear, int dayOfMonth)
{
mCallback.onDateChanged(year, monthOfYear, dayOfMonth);
}
});
initialYear,
initialMonth,
initialDay,
(view, year, monthOfYear, dayOfMonth) -> {
Bundle result = new Bundle();
result.putInt("year", year);
result.putInt("monthOfYear", monthOfYear);
result.putInt("dayOfMonth", dayOfMonth);
getParentFragmentManager().setFragmentResult(DATE_FRAGMENT_KEY, result);
});

if (minDate != null)
mDatePicker.setMinDate(minDate.getTime());
Expand All @@ -144,4 +113,4 @@ public void onDateChanged(DatePicker view, int year,

return v;
}
}
}
Loading