mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-04 08:00:14 -04:00
Update Gradle to latest
This commit is contained in:
15
DoNExt/.idea/misc.xml
generated
15
DoNExt/.idea/misc.xml
generated
@@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<entry_points version="2.0" />
|
|
||||||
</component>
|
|
||||||
<component name="NullableNotNullManager">
|
<component name="NullableNotNullManager">
|
||||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
@@ -27,17 +24,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<OptionsSetting value="true" id="Add" />
|
|
||||||
<OptionsSetting value="true" id="Remove" />
|
|
||||||
<OptionsSetting value="true" id="Checkout" />
|
|
||||||
<OptionsSetting value="true" id="Update" />
|
|
||||||
<OptionsSetting value="true" id="Status" />
|
|
||||||
<OptionsSetting value="true" id="Edit" />
|
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
Binary file not shown.
@@ -1,15 +1,15 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 25
|
compileSdkVersion 26
|
||||||
buildToolsVersion '25.0.2'
|
buildToolsVersion '26.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.wismna.geoffroy.donext"
|
applicationId "com.wismna.geoffroy.donext"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 25
|
targetSdkVersion 26
|
||||||
versionCode 22
|
versionCode 23
|
||||||
versionName "1.4.7"
|
versionName "1.4.8"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -21,12 +21,13 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||||
compile 'com.android.support:design:25.3.1'
|
compile 'com.android.support:design:26.1.0'
|
||||||
compile 'com.android.support:support-v4:25.3.1'
|
compile 'com.android.support:support-v4:26.1.0'
|
||||||
compile 'com.android.support:percent:25.3.1'
|
compile 'com.android.support:percent:26.1.0'
|
||||||
compile 'com.android.support:recyclerview-v7:25.3.1'
|
compile 'com.android.support:recyclerview-v7:26.1.0'
|
||||||
compile 'com.google.android.gms:play-services-ads:10.2.1'
|
compile 'com.google.android.gms:play-services-ads:11.6.2'
|
||||||
compile 'net.danlew:android.joda:2.9.7'
|
compile 'net.danlew:android.joda:2.9.7'
|
||||||
|
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<?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"
|
||||||
package="com.wismna.geoffroy.donext">
|
package="com.wismna.geoffroy.donext">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".DoNext"
|
android:name=".DoNext"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -9,7 +10,10 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<meta-data android:name="android.max_aspect" android:value="2.1" />
|
<meta-data
|
||||||
|
android:name="android.max_aspect"
|
||||||
|
android:value="2.1" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.MainActivity"
|
android:name=".activities.MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@@ -18,6 +22,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
@@ -54,6 +59,7 @@
|
|||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".activities.MainActivity" />
|
android:value=".activities.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".activities.HistoryActivity" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@@ -2,132 +2,30 @@ package com.wismna.geoffroy.donext.activities;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import com.wismna.geoffroy.donext.R;
|
import com.wismna.geoffroy.donext.R;
|
||||||
import com.wismna.geoffroy.donext.adapters.SmartFragmentStatePagerAdapter;
|
import com.wismna.geoffroy.donext.fragments.MainFragment;
|
||||||
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
|
|
||||||
import com.wismna.geoffroy.donext.dao.Task;
|
|
||||||
import com.wismna.geoffroy.donext.dao.TaskList;
|
|
||||||
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
|
||||||
import com.wismna.geoffroy.donext.fragments.TaskFormDialogFragment;
|
import com.wismna.geoffroy.donext.fragments.TaskFormDialogFragment;
|
||||||
import com.wismna.geoffroy.donext.fragments.TasksFragment;
|
import com.wismna.geoffroy.donext.fragments.TasksFragment;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements TasksFragment.TaskChangedAdapter {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link android.support.v4.view.PagerAdapter} that will provide
|
* Main Activity class
|
||||||
* fragments for each of the sections. We use a
|
|
||||||
* {@link FragmentPagerAdapter} derivative, which will keep every
|
|
||||||
* loaded fragment in memory. If this becomes too memory intensive, it
|
|
||||||
* may be best to switch to a
|
|
||||||
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
|
|
||||||
*/
|
*/
|
||||||
private SectionsPagerAdapter mSectionsPagerAdapter;
|
public class MainActivity extends AppCompatActivity {
|
||||||
/**
|
|
||||||
* The {@link ViewPager} that will host the section contents.
|
|
||||||
*/
|
|
||||||
private ViewPager mViewPager;
|
|
||||||
private TabLayout tabLayout;
|
|
||||||
private List<TaskList> taskLists;
|
|
||||||
private boolean mIsLargeLayout;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
mIsLargeLayout = getResources().getBoolean(R.bool.large_layout);
|
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
// Create the adapter that will return a fragment for each of the three
|
|
||||||
// primary sections of the activity.
|
|
||||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
|
||||||
|
|
||||||
SharedPreferences sharedPref =
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
|
||||||
|
|
||||||
// Access database to retrieve Tabs
|
|
||||||
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(this)) {
|
|
||||||
taskLists = taskListDataAccess.getAllTaskLists();
|
|
||||||
mSectionsPagerAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
if (taskLists.size() == 0) {
|
|
||||||
Intent intent = new Intent(this, TaskListActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
// Set up the ViewPager with the sections adapter.
|
|
||||||
mViewPager = (ViewPager) findViewById(R.id.container);
|
|
||||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
|
||||||
// Open last opened tab
|
|
||||||
int lastOpenedList = sharedPref.getInt("last_opened_tab", 0);
|
|
||||||
mViewPager.setCurrentItem(lastOpenedList);
|
|
||||||
|
|
||||||
if (!mIsLargeLayout) {
|
|
||||||
tabLayout = (TabLayout) findViewById(R.id.tabs);
|
|
||||||
tabLayout.setupWithViewPager(mViewPager);
|
|
||||||
|
|
||||||
// Handles scroll detection (only available for SDK version >=23)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
toggleTabLayoutArrows(tabLayout.getScrollX());
|
|
||||||
//tabLayout.setScrollIndicators(TabLayout.SCROLL_INDICATOR_LEFT | TabLayout.SCROLL_INDICATOR_RIGHT);
|
|
||||||
tabLayout.setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
|
||||||
toggleTabLayoutArrows(scrollX);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ListView listView = (ListView) findViewById(R.id.list);
|
|
||||||
//listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, taskLists));
|
|
||||||
listView.setAdapter(new ArrayAdapter<>(this, R.layout.list_tasklist_item, taskLists));
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
mViewPager.setCurrentItem(position);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
// No tabs exist yet, nothing to save
|
|
||||||
if (mViewPager == null) return;
|
|
||||||
// Otherwise, save currently opened tab
|
|
||||||
SharedPreferences sharedPref =
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
|
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
|
||||||
editor.putInt("last_opened_tab", mViewPager.getCurrentItem());
|
|
||||||
editor.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,46 +57,6 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
|||||||
return id == R.id.action_settings || super.onOptionsItemSelected(item);
|
return id == R.id.action_settings || super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTaskListChanged(Task task, int tabPosition) {
|
|
||||||
TaskRecyclerViewAdapter destinationTaskAdapter = getSpecificTabAdapter(tabPosition);
|
|
||||||
if (destinationTaskAdapter != null) destinationTaskAdapter.add(task, destinationTaskAdapter.getItemCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when user clicks on the New Task floating button */
|
|
||||||
public void onNewTaskClick(View view) {
|
|
||||||
int currentTabPosition = mViewPager.getCurrentItem();
|
|
||||||
TaskFormDialogFragment taskDialogFragment = TaskFormDialogFragment.newInstance(null,
|
|
||||||
mSectionsPagerAdapter.getAllItems(),
|
|
||||||
(TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(currentTabPosition));
|
|
||||||
|
|
||||||
// Set some configuration values for the tab
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt("list", currentTabPosition);
|
|
||||||
args.putBoolean("today", sharedPref.getBoolean("pref_conf_today_enable", false));
|
|
||||||
args.putBoolean("neutral", false);
|
|
||||||
args.putString("button_positive", getString(R.string.new_task_save));
|
|
||||||
args.putString("button_negative", getString(R.string.new_task_cancel));
|
|
||||||
args.putString("button_neutral", getString(R.string.new_task_delete));
|
|
||||||
taskDialogFragment.setArguments(args);
|
|
||||||
|
|
||||||
String title = getString(R.string.action_new_task);
|
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
||||||
if (mIsLargeLayout)
|
|
||||||
taskDialogFragment.show(fragmentManager, title);
|
|
||||||
else {
|
|
||||||
// The device is smaller, so show the fragment fullscreen
|
|
||||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
|
||||||
// For a little polish, specify a transition animation
|
|
||||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
|
||||||
// To make it fullscreen, use the 'content' root view as the container
|
|
||||||
// for the fragment, which is always the root view for the activity
|
|
||||||
transaction.add(android.R.id.content, taskDialogFragment, title)
|
|
||||||
.addToBackStack(null).commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called when the user clicks on the Today List button */
|
/** Called when the user clicks on the Today List button */
|
||||||
public void showTodayList(MenuItem item) {
|
public void showTodayList(MenuItem item) {
|
||||||
Intent intent = new Intent(this, TodayActivity.class);
|
Intent intent = new Intent(this, TodayActivity.class);
|
||||||
@@ -215,7 +73,9 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
|||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
// Update the ViewPagerAdapter to refresh all tabs
|
// Update the ViewPagerAdapter to refresh all tabs
|
||||||
mSectionsPagerAdapter.notifyDataSetChanged();
|
MainFragment fragment = getMainFragment();
|
||||||
|
fragment.getViewPager().getAdapter().notifyDataSetChanged();
|
||||||
|
//mSectionsPagerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when the user clicks the Edit Lists button */
|
/** Called when the user clicks the Edit Lists button */
|
||||||
@@ -224,6 +84,12 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when the user clicks the History button*/
|
||||||
|
public void openHistory(MenuItem item) {
|
||||||
|
MainFragment fragment = getMainFragment();
|
||||||
|
fragment.toggleHistory();
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when the user clicks the Settings button */
|
/** Called when the user clicks the Settings button */
|
||||||
public void openSettings(MenuItem menuItem) {
|
public void openSettings(MenuItem menuItem) {
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
@@ -236,70 +102,46 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskRecyclerViewAdapter getSpecificTabAdapter(int position) {
|
/** Called when user clicks on the New Task floating button */
|
||||||
TasksFragment taskFragment = (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(position);
|
public void onNewTaskClick(View view) {
|
||||||
if (taskFragment == null) return null;
|
|
||||||
View view = taskFragment.getView();
|
|
||||||
if (view == null) return null;
|
|
||||||
RecyclerView recyclerView = ((RecyclerView) view.findViewById(R.id.task_list_view));
|
|
||||||
if (recyclerView == null) return null;
|
|
||||||
return (TaskRecyclerViewAdapter) recyclerView.getAdapter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Toggles scrolling arrows visibility */
|
MainFragment fragment = getMainFragment();
|
||||||
private void toggleTabLayoutArrows(int scrollX){
|
ViewPager viewPager = fragment.getViewPager();
|
||||||
// Hide left arrow when scrolled to the left
|
int currentTabPosition = viewPager.getCurrentItem();
|
||||||
View leftArrow = findViewById(R.id.left_arrow);
|
MainFragment.SectionsPagerAdapter pagerAdapter = (MainFragment.SectionsPagerAdapter) viewPager.getAdapter();
|
||||||
if (leftArrow != null) {
|
TaskFormDialogFragment taskDialogFragment = TaskFormDialogFragment.newInstance(null,
|
||||||
if (scrollX <= 1) leftArrow.setVisibility(View.INVISIBLE);
|
pagerAdapter.getAllItems(),
|
||||||
else leftArrow.setVisibility(View.VISIBLE);
|
(TasksFragment) pagerAdapter.getRegisteredFragment(currentTabPosition));
|
||||||
}
|
|
||||||
// Hide right arrow when scrolled to the right
|
// Set some configuration values for the tab
|
||||||
View rightArrow = findViewById(R.id.right_arrow);
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
if (rightArrow != null) {
|
Bundle args = new Bundle();
|
||||||
Point size = new Point();
|
args.putInt("list", currentTabPosition);
|
||||||
getWindowManager().getDefaultDisplay().getSize(size);
|
args.putBoolean("today", sharedPref.getBoolean("pref_conf_today_enable", false));
|
||||||
if (scrollX == tabLayout.getChildAt(0).getMeasuredWidth() - tabLayout.getMeasuredWidth())
|
args.putBoolean("neutral", false);
|
||||||
rightArrow.setVisibility(View.INVISIBLE);
|
args.putString("button_positive", getString(R.string.new_task_save));
|
||||||
else rightArrow.setVisibility(View.VISIBLE);
|
args.putString("button_negative", getString(R.string.new_task_cancel));
|
||||||
|
args.putString("button_neutral", getString(R.string.new_task_delete));
|
||||||
|
taskDialogFragment.setArguments(args);
|
||||||
|
|
||||||
|
String title = getString(R.string.action_new_task);
|
||||||
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
if (!getResources().getBoolean(R.bool.large_layout))
|
||||||
|
taskDialogFragment.show(fragmentManager, title);
|
||||||
|
else {
|
||||||
|
// The device is smaller, so show the fragment fullscreen
|
||||||
|
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||||
|
// For a little polish, specify a transition animation
|
||||||
|
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
||||||
|
// To make it fullscreen, use the 'content' root view as the container
|
||||||
|
// for the fragment, which is always the root view for the activity
|
||||||
|
transaction.add(android.R.id.content, taskDialogFragment, title)
|
||||||
|
.addToBackStack(null).commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private MainFragment getMainFragment(){
|
||||||
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
* one of the sections/tabs/pages.
|
return (MainFragment)manager.findFragmentById(R.id.fragment_main);
|
||||||
*/
|
|
||||||
public class SectionsPagerAdapter extends SmartFragmentStatePagerAdapter {
|
|
||||||
|
|
||||||
SectionsPagerAdapter(FragmentManager fm) {
|
|
||||||
super(fm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Fragment getItem(int position) {
|
|
||||||
// getItem is called to instantiate the fragment for the given page.
|
|
||||||
// Return a PlaceholderFragment (defined as a static inner class below).
|
|
||||||
TaskList taskList = taskLists.get(position);
|
|
||||||
return TasksFragment.newTaskListInstance(taskList.getId(), MainActivity.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
if (taskLists != null) {
|
|
||||||
// Show the task lists
|
|
||||||
return taskLists.size();
|
|
||||||
}
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getPageTitle(int position) {
|
|
||||||
if (taskLists == null) return "N/A";
|
|
||||||
return taskLists.get(position).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TaskList> getAllItems(){
|
|
||||||
return taskLists;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,5 +11,4 @@ public class TaskListActivity extends AppCompatActivity{
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_tasklists);
|
setContentView(R.layout.activity_tasklists);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -113,11 +113,12 @@ public class TaskDataAccess implements AutoCloseable {
|
|||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Task> getAllTasksFromList(long id) {
|
public List<Task> getAllTasksFromList(long id, boolean isHistory) {
|
||||||
|
int history = isHistory ? 1 : 0;
|
||||||
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
|
||||||
DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
DatabaseHelper.TASKS_COLUMN_LIST + " = " + id +
|
||||||
" AND " + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
|
" AND (" + DatabaseHelper.TASKS_COLUMN_DONE + " = " + history +
|
||||||
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0,
|
(isHistory ? " OR " : " AND ") + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + history + ")",
|
||||||
null, null, null,
|
null, null, null,
|
||||||
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
|
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
|
||||||
return getTasksFromCursor(cursor);
|
return getTasksFromCursor(cursor);
|
||||||
|
@@ -164,7 +164,7 @@ public abstract class DynamicDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
/** Sets the title of the Fragment from the Tag */
|
/** Sets the title of the Fragment from the Tag */
|
||||||
private Toolbar setToolbarTitle(View view) {
|
private Toolbar setToolbarTitle(View view) {
|
||||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.dialog_toolbar);
|
Toolbar toolbar = view.findViewById(R.id.dialog_toolbar);
|
||||||
toolbar.setTitle(getTag());
|
toolbar.setTitle(getTag());
|
||||||
return toolbar;
|
return toolbar;
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ public abstract class DynamicDialogFragment extends DialogFragment {
|
|||||||
// Ensure that the content view is set
|
// Ensure that the content view is set
|
||||||
if (mContentLayoutId == 0) return;
|
if (mContentLayoutId == 0) return;
|
||||||
// Insert the content view
|
// Insert the content view
|
||||||
FrameLayout content = (FrameLayout) view.findViewById(R.id.dynamic_fragment_content);
|
FrameLayout content = view.findViewById(R.id.dynamic_fragment_content);
|
||||||
content.addView(inflater.inflate(mContentLayoutId, (ViewGroup) view.getParent()));
|
content.addView(inflater.inflate(mContentLayoutId, (ViewGroup) view.getParent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,234 @@
|
|||||||
|
package com.wismna.geoffroy.donext.fragments;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
import com.wismna.geoffroy.donext.activities.TaskListActivity;
|
||||||
|
import com.wismna.geoffroy.donext.adapters.SmartFragmentStatePagerAdapter;
|
||||||
|
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
|
||||||
|
import com.wismna.geoffroy.donext.dao.Task;
|
||||||
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
|
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fragment that will handle the main display
|
||||||
|
*/
|
||||||
|
public class MainFragment extends Fragment implements TasksFragment.TaskChangedAdapter {
|
||||||
|
|
||||||
|
private View mView;
|
||||||
|
private ViewPager mViewPager;
|
||||||
|
private SectionsPagerAdapter mSectionsPagerAdapter;
|
||||||
|
private TabLayout tabLayout;
|
||||||
|
private List<TaskList> taskLists;
|
||||||
|
private boolean isHistory = false;
|
||||||
|
|
||||||
|
public MainFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this factory method to create a new instance of
|
||||||
|
* this fragment using the provided parameters.
|
||||||
|
*
|
||||||
|
* @param isHistory Will this fragment show the task history?
|
||||||
|
* @return A new instance of fragment MainFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static MainFragment newInstance(boolean isHistory) {
|
||||||
|
MainFragment fragment = new MainFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("history", isHistory);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewPager getViewPager() {
|
||||||
|
return mViewPager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleHistory() {
|
||||||
|
isHistory = !isHistory;
|
||||||
|
mSectionsPagerAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (getArguments() != null) {
|
||||||
|
isHistory = getArguments().getBoolean("history");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
mView = inflater.inflate(R.layout.fragment_main, container, false);
|
||||||
|
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||||
|
Toolbar toolbar = mView.findViewById(R.id.toolbar);
|
||||||
|
activity.setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
// Create the adapter that will return a fragment for each of the three
|
||||||
|
// primary sections of the activity.
|
||||||
|
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
|
||||||
|
|
||||||
|
SharedPreferences sharedPref =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
|
// Access database to retrieve Tabs
|
||||||
|
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(activity)) {
|
||||||
|
taskLists = taskListDataAccess.getAllTaskLists();
|
||||||
|
mSectionsPagerAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
if (taskLists.size() == 0) {
|
||||||
|
Intent intent = new Intent(getContext(), TaskListActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Set up the ViewPager with the sections adapter.
|
||||||
|
mViewPager = mView.findViewById(R.id.container);
|
||||||
|
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||||
|
// Open last opened tab
|
||||||
|
int lastOpenedList = sharedPref.getInt("last_opened_tab", 0);
|
||||||
|
mViewPager.setCurrentItem(lastOpenedList);
|
||||||
|
|
||||||
|
if (!getResources().getBoolean(R.bool.large_layout)) {
|
||||||
|
tabLayout = mView.findViewById(R.id.tabs);
|
||||||
|
tabLayout.setupWithViewPager(mViewPager);
|
||||||
|
|
||||||
|
// Handles scroll detection (only available for SDK version >=23)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
toggleTabLayoutArrows(tabLayout.getScrollX());
|
||||||
|
//tabLayout.setScrollIndicators(TabLayout.SCROLL_INDICATOR_LEFT | TabLayout.SCROLL_INDICATOR_RIGHT);
|
||||||
|
tabLayout.setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
||||||
|
toggleTabLayoutArrows(scrollX);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ListView listView = mView.findViewById(R.id.list);
|
||||||
|
//listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, taskLists));
|
||||||
|
listView.setAdapter(new ArrayAdapter<>(activity, R.layout.list_tasklist_item, taskLists));
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
mViewPager.setCurrentItem(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
// No tabs exist yet, nothing to save
|
||||||
|
if (mViewPager == null) return;
|
||||||
|
// Otherwise, save currently opened tab
|
||||||
|
SharedPreferences sharedPref =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
|
editor.putInt("last_opened_tab", mViewPager.getCurrentItem());
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTaskListChanged(Task task, int tabPosition) {
|
||||||
|
TaskRecyclerViewAdapter destinationTaskAdapter = getSpecificTabAdapter(tabPosition);
|
||||||
|
if (destinationTaskAdapter != null) destinationTaskAdapter.add(task, destinationTaskAdapter.getItemCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private TaskRecyclerViewAdapter getSpecificTabAdapter(int position) {
|
||||||
|
TasksFragment taskFragment = (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(position);
|
||||||
|
if (taskFragment == null) return null;
|
||||||
|
View view = taskFragment.getView();
|
||||||
|
if (view == null) return null;
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.task_list_view);
|
||||||
|
if (recyclerView == null) return null;
|
||||||
|
return (TaskRecyclerViewAdapter) recyclerView.getAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toggles scrolling arrows visibility */
|
||||||
|
private void toggleTabLayoutArrows(int scrollX){
|
||||||
|
// Hide left arrow when scrolled to the left
|
||||||
|
View leftArrow = mView.findViewById(R.id.left_arrow);
|
||||||
|
if (leftArrow != null) {
|
||||||
|
if (scrollX <= 1) leftArrow.setVisibility(View.INVISIBLE);
|
||||||
|
else leftArrow.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
// Hide right arrow when scrolled to the right
|
||||||
|
View rightArrow = mView.findViewById(R.id.right_arrow);
|
||||||
|
if (rightArrow != null) {
|
||||||
|
Point size = new Point();
|
||||||
|
getActivity().getWindowManager().getDefaultDisplay().getSize(size);
|
||||||
|
if (scrollX == tabLayout.getChildAt(0).getMeasuredWidth() - tabLayout.getMeasuredWidth())
|
||||||
|
rightArrow.setVisibility(View.INVISIBLE);
|
||||||
|
else rightArrow.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
|
||||||
|
* one of the sections/tabs/pages.
|
||||||
|
*/
|
||||||
|
public class SectionsPagerAdapter extends SmartFragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
SectionsPagerAdapter(FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
// getItem is called to instantiate the fragment for the given page.
|
||||||
|
// Return a PlaceholderFragment (defined as a static inner class below).
|
||||||
|
TaskList taskList = taskLists.get(position);
|
||||||
|
return TasksFragment.newTaskListInstance(taskList.getId(), isHistory, MainFragment.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
if (taskLists != null) {
|
||||||
|
// Show the task lists
|
||||||
|
return taskLists.size();
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
if (taskLists == null) return "N/A";
|
||||||
|
return taskLists.get(position).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TaskList> getAllItems(){
|
||||||
|
return taskLists;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -73,7 +73,7 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPositiveButtonClick(View view) {
|
protected void onPositiveButtonClick(View view) {
|
||||||
if (view == null) return;
|
if (view == null) return;
|
||||||
EditText titleText = (EditText) view.findViewById(R.id.new_task_name);
|
EditText titleText = view.findViewById(R.id.new_task_name);
|
||||||
// handle confirmation button click hereEditText titleText = (EditText) d.findViewById(R.id.new_task_name);
|
// handle confirmation button click hereEditText titleText = (EditText) d.findViewById(R.id.new_task_name);
|
||||||
if (titleText.getText().toString().matches(""))
|
if (titleText.getText().toString().matches(""))
|
||||||
titleText.setError(getResources().getString(R.string.new_task_name_error));
|
titleText.setError(getResources().getString(R.string.new_task_name_error));
|
||||||
|
@@ -59,11 +59,11 @@ public class TaskListsFragment extends Fragment implements
|
|||||||
|
|
||||||
mView = inflater.inflate(R.layout.fragment_tasklists, container, false);
|
mView = inflater.inflate(R.layout.fragment_tasklists, container, false);
|
||||||
|
|
||||||
Button createTaskListButton = (Button) mView.findViewById(R.id.new_task_list_button);
|
Button createTaskListButton = mView.findViewById(R.id.new_task_list_button);
|
||||||
createTaskListButton.setOnClickListener(new View.OnClickListener() {
|
createTaskListButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
EditText editText = (EditText) mView.findViewById(R.id.new_task_list_name);
|
EditText editText = mView.findViewById(R.id.new_task_list_name);
|
||||||
String text = editText.getText().toString();
|
String text = editText.getText().toString();
|
||||||
if (text.matches("")) {
|
if (text.matches("")) {
|
||||||
editText.setError(getResources().getString(R.string.task_list_new_list_error));
|
editText.setError(getResources().getString(R.string.task_list_new_list_error));
|
||||||
@@ -97,7 +97,7 @@ public class TaskListsFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toggleVisibleCreateNewTaskListLayout(View view) {
|
private void toggleVisibleCreateNewTaskListLayout(View view) {
|
||||||
LinearLayout layout = (LinearLayout) view.findViewById(R.id.new_task_list_layout);
|
LinearLayout layout = view.findViewById(R.id.new_task_list_layout);
|
||||||
int taskListCount = taskListRecyclerViewAdapter.getItemCount();
|
int taskListCount = taskListRecyclerViewAdapter.getItemCount();
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "5");
|
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "5");
|
||||||
@@ -134,7 +134,7 @@ public class TaskListsFragment extends Fragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onConfirmDialogClick(DialogFragment dialog, ConfirmDialogFragment.ButtonEvent event) {
|
public void onConfirmDialogClick(DialogFragment dialog, ConfirmDialogFragment.ButtonEvent event) {
|
||||||
// Handle never ask again checkbox
|
// Handle never ask again checkbox
|
||||||
CheckBox neverAskAgainCheckBox = (CheckBox) dialog.getDialog().findViewById(R.id.task_confirmation_never);
|
CheckBox neverAskAgainCheckBox = dialog.getDialog().findViewById(R.id.task_confirmation_never);
|
||||||
if (neverAskAgainCheckBox.isChecked()) {
|
if (neverAskAgainCheckBox.isChecked()) {
|
||||||
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
@@ -195,7 +195,7 @@ public class TaskListsFragment extends Fragment implements
|
|||||||
|
|
||||||
// Set the adapter
|
// Set the adapter
|
||||||
Context context = mView.getContext();
|
Context context = mView.getContext();
|
||||||
RecyclerView recyclerView = (RecyclerView) mView.findViewById(R.id.task_lists_view);
|
RecyclerView recyclerView = mView.findViewById(R.id.task_lists_view);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
recyclerView.setAdapter(taskListRecyclerViewAdapter);
|
recyclerView.setAdapter(taskListRecyclerViewAdapter);
|
||||||
|
|
||||||
|
@@ -26,7 +26,6 @@ import android.widget.Spinner;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.wismna.geoffroy.donext.R;
|
import com.wismna.geoffroy.donext.R;
|
||||||
import com.wismna.geoffroy.donext.activities.MainActivity;
|
|
||||||
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
|
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
|
||||||
import com.wismna.geoffroy.donext.dao.Task;
|
import com.wismna.geoffroy.donext.dao.Task;
|
||||||
import com.wismna.geoffroy.donext.dao.TaskList;
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
@@ -49,13 +48,14 @@ public class TasksFragment extends Fragment implements
|
|||||||
ConfirmDialogFragment.ConfirmDialogListener,
|
ConfirmDialogFragment.ConfirmDialogListener,
|
||||||
TaskTouchHelper.TaskTouchHelperAdapter{
|
TaskTouchHelper.TaskTouchHelperAdapter{
|
||||||
|
|
||||||
public interface TaskChangedAdapter {
|
interface TaskChangedAdapter {
|
||||||
void onTaskListChanged(Task task, int tabPosition);
|
void onTaskListChanged(Task task, int tabPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TASK_LIST_ID = "task_list_id";
|
private static final String TASK_LIST_ID = "task_list_id";
|
||||||
private long taskListId = -1;
|
private long taskListId = -1;
|
||||||
private boolean isTodayView = true;
|
private boolean isTodayView = true;
|
||||||
|
private boolean isHistory = false;
|
||||||
private TaskRecyclerViewAdapter taskRecyclerViewAdapter;
|
private TaskRecyclerViewAdapter taskRecyclerViewAdapter;
|
||||||
private View view;
|
private View view;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
@@ -69,10 +69,12 @@ public class TasksFragment extends Fragment implements
|
|||||||
public TasksFragment() {
|
public TasksFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TasksFragment newTaskListInstance(long taskListId, TaskChangedAdapter taskChangedAdapter) {
|
public static TasksFragment newTaskListInstance(long taskListId, boolean isHistory,
|
||||||
|
TaskChangedAdapter taskChangedAdapter) {
|
||||||
TasksFragment fragment = new TasksFragment();
|
TasksFragment fragment = new TasksFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong(TASK_LIST_ID, taskListId);
|
args.putLong(TASK_LIST_ID, taskListId);
|
||||||
|
args.putBoolean("history", isHistory);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.mAdapter = taskChangedAdapter;
|
fragment.mAdapter = taskChangedAdapter;
|
||||||
fragment.isTodayView = false;
|
fragment.isTodayView = false;
|
||||||
@@ -86,6 +88,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
taskListId = getArguments().getLong(TASK_LIST_ID);
|
taskListId = getArguments().getLong(TASK_LIST_ID);
|
||||||
|
isHistory = getArguments().getBoolean("history");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +99,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
final Context context = view.getContext();
|
final Context context = view.getContext();
|
||||||
|
|
||||||
// Set the Recycler view
|
// Set the Recycler view
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.task_list_view);
|
recyclerView = view.findViewById(R.id.task_list_view);
|
||||||
recyclerView.setLayoutManager(new NoScrollingLayoutManager(context));
|
recyclerView.setLayoutManager(new NoScrollingLayoutManager(context));
|
||||||
|
|
||||||
// Set RecyclerView Adapter
|
// Set RecyclerView Adapter
|
||||||
@@ -105,7 +108,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
// Get all tasks
|
// Get all tasks
|
||||||
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext())) {
|
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext())) {
|
||||||
taskRecyclerViewAdapter = new TaskRecyclerViewAdapter(
|
taskRecyclerViewAdapter = new TaskRecyclerViewAdapter(
|
||||||
isTodayView? taskDataAccess.getTodayTasks() : taskDataAccess.getAllTasksFromList(taskListId),
|
isTodayView? taskDataAccess.getTodayTasks() : taskDataAccess.getAllTasksFromList(taskListId, isHistory),
|
||||||
Integer.valueOf(sharedPref.getString("pref_conf_task_layout", "1")), isTodayView);
|
Integer.valueOf(sharedPref.getString("pref_conf_task_layout", "1")), isTodayView);
|
||||||
}
|
}
|
||||||
recyclerView.setAdapter(taskRecyclerViewAdapter);
|
recyclerView.setAdapter(taskRecyclerViewAdapter);
|
||||||
@@ -134,11 +137,11 @@ public class TasksFragment extends Fragment implements
|
|||||||
args.putString("button_neutral", getString(R.string.new_task_delete));
|
args.putString("button_neutral", getString(R.string.new_task_delete));
|
||||||
|
|
||||||
// Set current tab value to new task dialog
|
// Set current tab value to new task dialog
|
||||||
ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.container);
|
ViewPager viewPager = getActivity().findViewById(R.id.container);
|
||||||
List<TaskList> taskLists;
|
List<TaskList> taskLists;
|
||||||
Task task = taskRecyclerViewAdapter.getItem(position);
|
Task task = taskRecyclerViewAdapter.getItem(position);
|
||||||
if (viewPager != null) {
|
if (viewPager != null) {
|
||||||
taskLists = ((MainActivity.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems();
|
taskLists = ((MainFragment.SectionsPagerAdapter) viewPager.getAdapter()).getAllItems();
|
||||||
args.putInt("list", viewPager.getCurrentItem());
|
args.putInt("list", viewPager.getCurrentItem());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -188,14 +191,14 @@ public class TasksFragment extends Fragment implements
|
|||||||
|
|
||||||
// Update total cycle count
|
// Update total cycle count
|
||||||
int totalCycles = taskRecyclerViewAdapter.getCycleCount();
|
int totalCycles = taskRecyclerViewAdapter.getCycleCount();
|
||||||
TextView totalCyclesView = (TextView) view.findViewById(R.id.total_task_cycles);
|
TextView totalCyclesView = view.findViewById(R.id.total_task_cycles);
|
||||||
if (totalCycles != 0)
|
if (totalCycles != 0)
|
||||||
totalCyclesView.setText(resources.getQuantityString(R.plurals.task_total_cycles, totalCycles, totalCycles));
|
totalCyclesView.setText(resources.getQuantityString(R.plurals.task_total_cycles, totalCycles, totalCycles));
|
||||||
else totalCyclesView.setText("");
|
else totalCyclesView.setText("");
|
||||||
|
|
||||||
// Update total tasks
|
// Update total tasks
|
||||||
int totalTasks = taskRecyclerViewAdapter.getItemCount();
|
int totalTasks = taskRecyclerViewAdapter.getItemCount();
|
||||||
TextView totalTasksView = (TextView) view.findViewById(R.id.total_task_count);
|
TextView totalTasksView = view.findViewById(R.id.total_task_count);
|
||||||
View noMoreTasks = view.findViewById(R.id.no_more_tasks);
|
View noMoreTasks = view.findViewById(R.id.no_more_tasks);
|
||||||
if (totalTasks == 0) {
|
if (totalTasks == 0) {
|
||||||
noMoreTasks.setVisibility(View.VISIBLE);
|
noMoreTasks.setVisibility(View.VISIBLE);
|
||||||
@@ -208,7 +211,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update remaining tasks
|
// Update remaining tasks
|
||||||
TextView remainingTasksView = (TextView) view.findViewById(R.id.remaining_task_count);
|
TextView remainingTasksView = view.findViewById(R.id.remaining_task_count);
|
||||||
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager();
|
NoScrollingLayoutManager layoutManager = (NoScrollingLayoutManager) recyclerView.getLayoutManager();
|
||||||
int remainingTaskCount = totalTasks - layoutManager.findLastVisibleItemPosition() - 1;
|
int remainingTaskCount = totalTasks - layoutManager.findLastVisibleItemPosition() - 1;
|
||||||
if (remainingTaskCount == 0) remainingTasksView.setText("");
|
if (remainingTaskCount == 0) remainingTasksView.setText("");
|
||||||
@@ -236,7 +239,7 @@ public class TasksFragment extends Fragment implements
|
|||||||
int direction = args.getInt("Direction");
|
int direction = args.getInt("Direction");
|
||||||
|
|
||||||
// Handle never ask again checkbox
|
// Handle never ask again checkbox
|
||||||
CheckBox neverAskAgainCheckBox = (CheckBox) dialog.getDialog().findViewById(R.id.task_confirmation_never);
|
CheckBox neverAskAgainCheckBox = dialog.getDialog().findViewById(R.id.task_confirmation_never);
|
||||||
if (neverAskAgainCheckBox.isChecked()) {
|
if (neverAskAgainCheckBox.isChecked()) {
|
||||||
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
@@ -273,14 +276,14 @@ public class TasksFragment extends Fragment implements
|
|||||||
if (task != null) id = task.getId();
|
if (task != null) id = task.getId();
|
||||||
|
|
||||||
// Get the controls
|
// Get the controls
|
||||||
Spinner listSpinner = (Spinner) dialogView.findViewById(R.id.new_task_list);
|
Spinner listSpinner = dialogView.findViewById(R.id.new_task_list);
|
||||||
EditText nameText = (EditText) dialogView.findViewById(R.id.new_task_name);
|
EditText nameText = dialogView.findViewById(R.id.new_task_name);
|
||||||
EditText descText = (EditText) dialogView.findViewById(R.id.new_task_description);
|
EditText descText = dialogView.findViewById(R.id.new_task_description);
|
||||||
SeekBar seekBar = (SeekBar) dialogView.findViewById(R.id.new_task_priority);
|
SeekBar seekBar = dialogView.findViewById(R.id.new_task_priority);
|
||||||
CheckBox setDueDate = (CheckBox) dialogView.findViewById(R.id.new_task_due_date_set);
|
CheckBox setDueDate = dialogView.findViewById(R.id.new_task_due_date_set);
|
||||||
DatePicker dueDatePicker = (DatePicker) dialogView.findViewById(R.id.new_task_due_date);
|
DatePicker dueDatePicker = dialogView.findViewById(R.id.new_task_due_date);
|
||||||
TaskList taskList = (TaskList) listSpinner.getSelectedItem();
|
TaskList taskList = (TaskList) listSpinner.getSelectedItem();
|
||||||
CheckBox todayList = (CheckBox) dialogView.findViewById(R.id.new_task_today);
|
CheckBox todayList = dialogView.findViewById(R.id.new_task_today);
|
||||||
boolean isToday = todayList.isChecked();
|
boolean isToday = todayList.isChecked();
|
||||||
// Add the task to the database
|
// Add the task to the database
|
||||||
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext(), TaskDataAccess.MODE.WRITE)) {
|
try (TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext(), TaskDataAccess.MODE.WRITE)) {
|
||||||
|
@@ -8,48 +8,12 @@
|
|||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context=".activities.MainActivity">
|
tools:context=".activities.MainActivity">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<fragment
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/fragment_main"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="@dimen/appbar_padding_top"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
|
||||||
<include layout="@layout/toolbar" android:id="@+id/toolbar" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/left_arrow"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:contentDescription="@string/tab_left_arrow"
|
|
||||||
android:src="@drawable/ic_keyboard_arrow_left_white_24dp" />
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/right_arrow"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:contentDescription="@string/tab_right_arrow"
|
|
||||||
android:src="@drawable/ic_keyboard_arrow_right_white_24dp" />
|
|
||||||
<android.support.design.widget.TabLayout
|
|
||||||
android:id="@+id/tabs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toEndOf="@+id/left_arrow"
|
|
||||||
android:layout_toStartOf="@+id/right_arrow"
|
|
||||||
app:tabMode="scrollable" />
|
|
||||||
</RelativeLayout>
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<com.wismna.geoffroy.donext.widgets.NonSwipeableViewPager
|
|
||||||
android:id="@+id/container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
android:name="com.wismna.geoffroy.donext.fragments.MainFragment"
|
||||||
|
/>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
|
51
DoNExt/app/src/main/res/layout/fragment_main.xml
Normal file
51
DoNExt/app/src/main/res/layout/fragment_main.xml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<android.support.design.widget.CoordinatorLayout 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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.wismna.geoffroy.donext.fragments.MainFragment">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/appbar_padding_top"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
<include layout="@layout/toolbar" android:id="@+id/toolbar" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/left_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:contentDescription="@string/tab_left_arrow"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_left_white_24dp" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/right_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:contentDescription="@string/tab_right_arrow"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_right_white_24dp" />
|
||||||
|
<android.support.design.widget.TabLayout
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toEndOf="@+id/left_arrow"
|
||||||
|
android:layout_toStartOf="@+id/right_arrow"
|
||||||
|
app:tabMode="scrollable" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<com.wismna.geoffroy.donext.widgets.NonSwipeableViewPager
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
@@ -30,6 +30,13 @@
|
|||||||
android:onClick="openTaskLists"
|
android:onClick="openTaskLists"
|
||||||
android:icon="@drawable/ic_list_white_24dp"
|
android:icon="@drawable/ic_list_white_24dp"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_history"
|
||||||
|
android:orderInCategory="25"
|
||||||
|
android:title="@string/action_history"
|
||||||
|
android:onClick="openHistory"
|
||||||
|
android:icon="@drawable/ic_list_white_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_settings"
|
||||||
android:orderInCategory="30"
|
android:orderInCategory="30"
|
||||||
|
@@ -58,4 +58,5 @@
|
|||||||
<string name="action_today_select">Choisissez des tâches</string>
|
<string name="action_today_select">Choisissez des tâches</string>
|
||||||
<string name="task_list_edit_list_hint">Nom de la liste</string>
|
<string name="task_list_edit_list_hint">Nom de la liste</string>
|
||||||
<string name="incompatible_sdk_version">Sorry, your Android version is not supported.</string>
|
<string name="incompatible_sdk_version">Sorry, your Android version is not supported.</string>
|
||||||
|
<string name="action_history">Historique</string>
|
||||||
</resources>
|
</resources>
|
@@ -77,4 +77,9 @@
|
|||||||
<string name="action_today_select">Select tasks</string>
|
<string name="action_today_select">Select tasks</string>
|
||||||
<string name="task_list_edit_list_hint">List name</string>
|
<string name="task_list_edit_list_hint">List name</string>
|
||||||
<string name="incompatible_sdk_version">Sorry, your Android version is not supported.</string>
|
<string name="incompatible_sdk_version">Sorry, your Android version is not supported.</string>
|
||||||
|
<string name="action_history">History</string>
|
||||||
|
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
<string name="title_activity_main2">Main2Activity</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -3,9 +3,13 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url 'https://maven.google.com/'
|
||||||
|
name 'Google'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@@ -15,6 +19,7 @@ buildscript {
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
google()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#Wed Mar 15 12:45:45 EDT 2017
|
#Sat Dec 02 18:11:16 CET 2017
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||||
|
Reference in New Issue
Block a user