Skip to content

Commit 732dbb7

Browse files
committed
Added dialogs and description about the app
1 parent 2ed782d commit 732dbb7

File tree

14 files changed

+203
-5
lines changed

14 files changed

+203
-5
lines changed

app/src/main/java/net/codebuff/intentio/parser/Parser.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
package net.codebuff.intentio.parser;
22

3+
import android.app.FragmentManager;
34
import android.content.Context;
45
import android.net.Uri;
6+
import android.support.v4.app.DialogFragment;
7+
import android.support.v4.app.Fragment;
8+
import android.support.v4.app.FragmentActivity;
9+
import android.support.v4.app.FragmentTransaction;
510
import android.util.Log;
611
import android.widget.Toast;
712

813
import net.codebuff.intentio.helpers.Constants;
914
import net.codebuff.intentio.helpers.Utilities;
1015
import net.codebuff.intentio.preferences.PrefsManager;
16+
import net.codebuff.intentio.ui.about;
17+
import net.codebuff.intentio.ui.incorrect_file_dialog;
1118

1219
import org.apache.poi.hssf.usermodel.HSSFCell;
1320
import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -94,7 +101,7 @@ public String parse_excel() throws IOException {
94101
open_file();
95102

96103
if ((excel == null) || (!excel.isFile())) {
97-
Toast.makeText(context, "File not found or incorrect file provided", Toast.LENGTH_LONG).show();
104+
// Toast.makeText(context, "File not found or incorrect file provided", Toast.LENGTH_LONG).show();
98105
return "file not found";
99106
} else {
100107
prefs = new PrefsManager(context);
@@ -244,6 +251,9 @@ public String parse_excel() throws IOException {
244251
//Log.i("content", content);
245252
return content;
246253
}
254+
255+
256+
247257
}
248258

249259

app/src/main/java/net/codebuff/intentio/preferences/SettingsActivity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
import android.preference.PreferenceFragment;
1717
import android.preference.PreferenceManager;
1818
import android.preference.RingtonePreference;
19+
import android.support.v4.app.DialogFragment;
20+
import android.support.v4.app.FragmentActivity;
21+
import android.support.v4.app.FragmentTransaction;
1922
import android.text.TextUtils;
2023
import android.util.Log;
2124
import android.widget.Toast;
2225

2326
import net.codebuff.intentio.R;
2427
import net.codebuff.intentio.helpers.Constants;
25-
import net.codebuff.intentio.helpers.Utilities;
2628
import net.codebuff.intentio.parser.Parser;
29+
import net.codebuff.intentio.ui.incorrect_file_dialog;
2730

2831
import java.io.IOException;
2932
import java.util.List;
@@ -141,7 +144,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
141144

142145
Constants.schedule_updated = true;
143146
Toast.makeText(getApplicationContext(), "File successfully parsed and data saved", Toast.LENGTH_LONG).show();
144-
}} catch (IOException e) {
147+
}else{
148+
Toast.makeText(getApplicationContext(), "Incorrect file choosen", Toast.LENGTH_LONG).show();
149+
}
150+
} catch (IOException e) {
145151
e.printStackTrace();
146152
}
147153
Log.i("path",path);

app/src/main/java/net/codebuff/intentio/ui/MainActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Intent;
44
import android.preference.PreferenceManager;
5+
import android.support.v4.app.DialogFragment;
56
import android.support.v7.app.ActionBarActivity;
67
import android.support.v7.app.ActionBar;
78
import android.support.v4.app.Fragment;
@@ -157,6 +158,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
157158
startActivity(new Intent(this,week.class));
158159
return true;
159160
}
161+
if (id == R.id.action_about) {
162+
DialogFragment about = new about();
163+
about.show(getSupportFragmentManager(),"about");
164+
return true;
165+
}
160166

161167
return super.onOptionsItemSelected(item);
162168
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package net.codebuff.intentio.ui;
2+
3+
import android.app.AlertDialog;
4+
import android.app.Dialog;
5+
import android.content.DialogInterface;
6+
import android.os.Bundle;
7+
import android.support.v4.app.DialogFragment;
8+
import android.view.LayoutInflater;
9+
10+
import net.codebuff.intentio.R;
11+
12+
/**
13+
* Created by deepankar on 11/1/15.
14+
*/
15+
public class about extends DialogFragment {
16+
@Override
17+
public Dialog onCreateDialog(Bundle savedInstanceState) {
18+
// Use the Builder class for convenient dialog construction
19+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
20+
21+
// Get the layout inflater
22+
LayoutInflater inflater = getActivity().getLayoutInflater();
23+
24+
// Inflate and set the layout for the dialog
25+
// Pass null as the parent view because its going in the dialog layout
26+
builder.setView(inflater.inflate(R.layout.about, null))
27+
.setTitle("About")
28+
// Add action buttons
29+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
30+
@Override
31+
public void onClick(DialogInterface dialog, int id) {
32+
33+
}
34+
});
35+
/* .setNegativeButton("cancel'", new DialogInterface.OnClickListener() {
36+
public void onClick(DialogInterface dialog, int id) {
37+
38+
}
39+
});*/
40+
return builder.create();
41+
}
42+
}

app/src/main/java/net/codebuff/intentio/ui/first_run.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.content.Intent;
44
import android.net.Uri;
5+
import android.support.v4.app.DialogFragment;
6+
import android.support.v4.app.FragmentTransaction;
57
import android.support.v7.app.ActionBarActivity;
68
import android.os.Bundle;
79
import android.util.Log;
@@ -103,10 +105,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
103105
String xls_content = parser.parse_excel();
104106
if(!xls_content.equals("file not found")) {
105107
txt_main.setText("Intentio Setup Complete");
108+
txt_main.setTextColor(getResources().getColor(R.color.grab_attention));
106109
txt.setText("File parsed successfully and data saved, Click Done to finish setup\n (if you want you can also see the raw data of your excel file)");
107110
parser_dump.setText(xls_content);
108111
choose_file.setVisibility(View.GONE);
109112
app.update_pref_settings("reset",false);
113+
}else{
114+
DialogFragment incorrect_file = new incorrect_file_dialog();
115+
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
116+
ft.add(incorrect_file,null);
117+
ft.commitAllowingStateLoss();
110118
}
111119
} catch (IOException e) {
112120
e.printStackTrace();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package net.codebuff.intentio.ui;
2+
import android.app.AlertDialog;
3+
import android.app.Dialog;
4+
import android.content.DialogInterface;
5+
import android.os.Bundle;
6+
import android.support.v4.app.DialogFragment;
7+
import android.view.LayoutInflater;
8+
9+
import net.codebuff.intentio.R;
10+
11+
12+
/**
13+
* Created by deepankar on 11/1/15.
14+
*/
15+
public class help extends DialogFragment{
16+
17+
@Override
18+
public Dialog onCreateDialog(Bundle savedInstanceState) {
19+
// Use the Builder class for convenient dialog construction
20+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
21+
22+
// Get the layout inflater
23+
LayoutInflater inflater = getActivity().getLayoutInflater();
24+
25+
// Inflate and set the layout for the dialog
26+
// Pass null as the parent view because its going in the dialog layout
27+
builder.setView(inflater.inflate(R.layout.help, null))
28+
.setTitle("Help")
29+
// Add action buttons
30+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
31+
@Override
32+
public void onClick(DialogInterface dialog, int id) {
33+
34+
}
35+
});
36+
/* .setNegativeButton("cancel'", new DialogInterface.OnClickListener() {
37+
public void onClick(DialogInterface dialog, int id) {
38+
39+
}
40+
});*/
41+
return builder.create();
42+
}
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package net.codebuff.intentio.ui;
2+
3+
import android.app.AlertDialog;
4+
import android.app.Dialog;
5+
import android.content.DialogInterface;
6+
import android.os.Bundle;
7+
import android.support.v4.app.DialogFragment;
8+
import android.view.LayoutInflater;
9+
10+
import net.codebuff.intentio.R;
11+
12+
/**
13+
* Created by deepankar on 11/1/15.
14+
*/
15+
public class incorrect_file_dialog extends DialogFragment {
16+
@Override
17+
public Dialog onCreateDialog(Bundle savedInstanceState) {
18+
// Use the Builder class for convenient dialog construction
19+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
20+
21+
// Get the layout inflater
22+
LayoutInflater inflater = getActivity().getLayoutInflater();
23+
24+
// Inflate and set the layout for the dialog
25+
// Pass null as the parent view because its going in the dialog layout
26+
builder.setView(inflater.inflate(R.layout.incorrect_file_dialog, null))
27+
.setTitle("Incorrect File")
28+
// Add action buttons
29+
.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
30+
@Override
31+
public void onClick(DialogInterface dialog, int id) {
32+
33+
}
34+
});
35+
/* .setNegativeButton("cancel'", new DialogInterface.OnClickListener() {
36+
public void onClick(DialogInterface dialog, int id) {
37+
38+
}
39+
});*/
40+
return builder.create();
41+
}
42+
}

app/src/main/res/layout/about.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent" android:layout_height="match_parent"
4+
android:id="@+id/about">
5+
6+
<ScrollView
7+
android:layout_width="fill_parent"
8+
android:layout_height="fill_parent">
9+
<LinearLayout
10+
android:layout_width="fill_parent"
11+
android:layout_height="wrap_content">
12+
13+
14+
</LinearLayout>
15+
16+
</ScrollView>
17+
18+
19+
</android.support.v7.widget.CardView>

app/src/main/res/layout/activity_first_run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
android:layout_width="wrap_content"
103103
android:layout_height="wrap_content"
104104
android:layout_margin="@dimen/margin_medium"
105-
android:text="@string/fr_help" />
105+
android:text="@string/string_description" />
106106
</android.support.v7.widget.CardView>
107107

108108

app/src/main/res/layout/help.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="match_parent"
4+
android:layout_height="match_parent">
5+
6+
</LinearLayout>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent" android:layout_height="match_parent">
4+
5+
</LinearLayout>

app/src/main/res/menu/menu_main.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
android:title="@string/title_activity_week"
1111
android:orderInCategory="100"
1212
app:showAsAction="never"/>
13+
<item android:id="@+id/action_about"
14+
android:title="@string/action_about"
15+
android:orderInCategory="100"
16+
app:showAsAction="never"/>
1317
</menu>

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
<color name="primary_dark">#1565C0</color>
55
<color name="accent">#0091EA</color>
66
<color name="cardview_initial_background">#71C3DE</color>
7+
<color name="grab_attention">#D32F2F</color>
78
</resources>

app/src/main/res/values/strings.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
<string name="title_day6">Friday\'s Schedule</string>
1515
<string name="title_day7">Saturday\'s Schedule</string>
1616
<string name="fr_cardview_main">Please Choose the excel file from which you want to import the timetable</string>
17-
<string name="fr_help">help content</string>
17+
1818
<string name="hello_world">Hello world!</string>
19+
1920
<string name="action_settings">Settings</string>
21+
<string name="action_about">About</string>
22+
23+
2024
<string name="first_run">Intentio Set Up</string>
2125
<string name="title_activity_week">week (ascii dump)</string>
2226

27+
<string name="string_description">Intentio automatically parses your schedule from the excel(.xls) file and then displays the daily schedule in more intuitive manner.\n
28+
The app also shows you the current class and the next class and notifies about the same 10 minutes before the class</string>
2329
</resources>

0 commit comments

Comments
 (0)