Switch DownloadActivity to sliding drawer

Re-remove the bin/ and gen/ files
This commit is contained in:
DjBushido 2014-04-16 13:17:12 -04:00
parent 7e2021d681
commit 00ebfb1e48
18 changed files with 316 additions and 128 deletions

View File

@ -26,6 +26,10 @@
android:name="org.bspeice.minimalbible.activities.downloader.DownloaderActivity"
android:label="@string/title_activity_downloader" >
</activity>
<activity
android:name="org.bspeice.minimalbible.activities.downloader.DownloadActivity"
android:label="@string/title_activity_download" >
</activity>
</application>
</manifest>

View File

@ -26,6 +26,10 @@
android:name="org.bspeice.minimalbible.activities.downloader.DownloaderActivity"
android:label="@string/title_activity_downloader" >
</activity>
<activity
android:name="org.bspeice.minimalbible.activities.downloader.DownloadActivity"
android:label="@string/title_activity_download" >
</activity>
</application>
</manifest>

Binary file not shown.

View File

@ -241,11 +241,11 @@ int id action_bar_subtitle 0x7f050023
int id action_bar_title 0x7f050022
int id action_context_bar 0x7f05001d
int id action_downloads 0x7f050043
int id action_example 0x7f050042
int id action_example 0x7f050041
int id action_menu_divider 0x7f050016
int id action_menu_presenter 0x7f050017
int id action_mode_close_button 0x7f050024
int id action_settings 0x7f050041
int id action_settings 0x7f050042
int id activity_chooser_view_content 0x7f050025
int id always 0x7f05000b
int id beginning 0x7f050011
@ -325,13 +325,15 @@ int layout abc_popup_menu_item_layout 0x7f030014
int layout abc_search_dropdown_item_icons_2line 0x7f030015
int layout abc_search_view 0x7f030016
int layout activity_bible_viewer 0x7f030017
int layout activity_downloader 0x7f030018
int layout fragment_main 0x7f030019
int layout fragment_navigation_drawer 0x7f03001a
int layout support_simple_spinner_dropdown_item 0x7f03001b
int menu downloader 0x7f0c0000
int menu global 0x7f0c0001
int menu main 0x7f0c0002
int layout activity_download 0x7f030018
int layout fragment_download 0x7f030019
int layout fragment_main 0x7f03001a
int layout fragment_navigation_drawer 0x7f03001b
int layout support_simple_spinner_dropdown_item 0x7f03001c
int menu download 0x7f0c0000
int menu downloader 0x7f0c0001
int menu global 0x7f0c0002
int menu main 0x7f0c0003
int string abc_action_bar_home_description 0x7f0a0001
int string abc_action_bar_up_description 0x7f0a0002
int string abc_action_menu_overflow_description 0x7f0a0003
@ -351,6 +353,7 @@ int string app_name 0x7f0a000d
int string hello_world 0x7f0a0016
int string navigation_drawer_close 0x7f0a0012
int string navigation_drawer_open 0x7f0a0011
int string title_activity_download 0x7f0a0017
int string title_activity_downloader 0x7f0a0015
int string title_section1 0x7f0a000e
int string title_section2 0x7f0a000f

Binary file not shown.

View File

@ -1,5 +1,5 @@
# cache for current jar dependency. DO NOT EDIT.
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
1397601216283 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf C:\Users\bspeice\git\MinimalBible\MinimalBible\libs\android-support-v4.jar
1397601220438 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf C:\Users\bspeice\git\MinimalBible\appcompat_v7\libs\android-support-v4.jar
1397660355169 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf C:\Users\bspeice\git\MinimalBible\MinimalBible\libs\android-support-v4.jar
1397660356920 627582 cb6883d96005bc85b3e868f204507ea5b4fa9bbf C:\Users\bspeice\git\MinimalBible\appcompat_v7\libs\android-support-v4.jar

Binary file not shown.

View File

@ -0,0 +1,38 @@
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.bspeice.minimalbible.activities.downloader.DownloadActivity" >
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--
android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead.
-->
<!--
The drawer is given a fixed width in dp and extends the full height of
the container.
-->
<fragment
android:id="@+id/navigation_drawer"
android:name="org.bspeice.minimalbible.activities.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start" />
</android.support.v4.widget.DrawerLayout>

View File

@ -6,6 +6,11 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DownloaderActivity" >
tools:context="org.bspeice.minimalbible.DownloadActivity$PlaceholderFragment" >
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View File

@ -7,4 +7,5 @@
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
tools:context="org.bspeice.minimalbible.activities.NavigationDrawerFragment" />
tools:context="org.bspeice.minimalbible.NavigationDrawerFragment" />

View File

@ -0,0 +1,16 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.bspeice.minimalbible.DownloadActivity" >
<item
android:id="@+id/action_example"
android:title="@string/action_example"
app:showAsAction="withText|ifRoom"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
</menu>

View File

@ -11,5 +11,6 @@
<string name="action_settings">Settings</string>
<string name="title_activity_downloader">Downloads</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_download">DownloadActivity</string>
</resources>

View File

@ -1,13 +1,10 @@
package org.bspeice.minimalbible;
import org.bspeice.minimalbible.activities.NavigationDrawerFragment;
import org.bspeice.minimalbible.activities.downloader.DownloaderActivity;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import org.bspeice.minimalbible.activities.downloader.DownloadActivity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -22,6 +19,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.readystatesoftware.systembartint.SystemBarTintManager;
public class BibleViewer extends ActionBarActivity implements
NavigationDrawerFragment.NavigationDrawerCallbacks {
@ -111,7 +110,7 @@ public class BibleViewer extends ActionBarActivity implements
if (id == R.id.action_settings) {
return true;
} else if (id == R.id.action_downloads) {
startActivity(new Intent(this, DownloaderActivity.class));
startActivity(new Intent(this, DownloadActivity.class));
}
return super.onOptionsItemSelected(item);
}

View File

@ -4,4 +4,7 @@ public class MinimalBibleConstants {
public static final String DOWNLOAD_PREFS_FILE = "DOWNLOADER_PREFERENCES";
public static final String KEY_DOWNLOAD_ENABLED = "HAS_ENABLED_DOWNLOAD";
public static final String KEY_PERM_DISABLE_DOWNLOAD = "PERMANENTLY_DISABLE_DOWNLOAD";
}

View File

@ -1,28 +1,19 @@
package org.bspeice.minimalbible.activities;
import org.bspeice.minimalbible.R;
import org.bspeice.minimalbible.R.drawable;
import org.bspeice.minimalbible.R.id;
import org.bspeice.minimalbible.R.layout;
import org.bspeice.minimalbible.R.menu;
import org.bspeice.minimalbible.R.string;
import org.bspeice.minimalbible.activities.downloader.DownloaderActivity;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -34,6 +25,8 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.readystatesoftware.systembartint.SystemBarTintManager;
/**
* Fragment used for managing interactions for and presentation of a navigation
* drawer. See the <a href=

View File

@ -0,0 +1,197 @@
package org.bspeice.minimalbible.activities.downloader;
import org.bspeice.minimalbible.MinimalBibleConstants;
import org.bspeice.minimalbible.R;
import org.bspeice.minimalbible.activities.NavigationDrawerFragment;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
public class DownloadActivity extends ActionBarActivity implements
NavigationDrawerFragment.NavigationDrawerCallbacks {
/**
* Fragment managing the behaviors, interactions and presentation of the
* navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
/**
* Used to store the last screen title. For use in
* {@link #restoreActionBar()}.
*/
private CharSequence mTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_download);
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
.findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout));
}
@Override
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager
.beginTransaction()
.replace(R.id.container,
PlaceholderFragment.newInstance(position + 1)).commit();
}
public void onSectionAttached(int number) {
switch (number) {
case 1:
mTitle = getString(R.string.title_section1);
break;
case 2:
mTitle = getString(R.string.title_section2);
break;
case 3:
mTitle = getString(R.string.title_section3);
break;
}
}
public void restoreActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) {
// Only show items in the action bar relevant to this screen
// if the drawer is not showing. Otherwise, let the drawer
// decide what to show in the action bar.
getMenuInflater().inflate(R.menu.download, menu);
restoreActionBar();
return true;
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_download,
container, false);
TextView textView = (TextView) rootView
.findViewById(R.id.section_label);
textView.setText(Integer.toString(getArguments().getInt(
ARG_SECTION_NUMBER)));
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
((DownloadActivity) activity).onSectionAttached(getArguments()
.getInt(ARG_SECTION_NUMBER));
}
}
private void displayInternetWarning() {
SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE);
// If downloading has not been enabled, or user has permanently disabled downloading, WARN THEM!
if (!prefs.getBoolean(MinimalBibleConstants.KEY_DOWNLOAD_ENABLED, false) || prefs.getBoolean(MinimalBibleConstants.KEY_PERM_DISABLE_DOWNLOAD, false)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
DownloadDialogListener dialogListener = new DownloadDialogListener();
builder.setMessage("About to contact servers to download content. Continue?")
.setPositiveButton("Yes", dialogListener).setNegativeButton("No", dialogListener)
.setCancelable(false).show();
} else {
downloadModules();
}
}
private void downloadModules() {
}
private class DownloadDialogListener implements DialogInterface.OnClickListener {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
// Clicked ready to continue - allow downloading in the future
SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE);
prefs.edit().putBoolean(MinimalBibleConstants.KEY_DOWNLOAD_ENABLED, true).commit();
// And warn them that it has been enabled in the future.
Toast.makeText(DownloadActivity.this,
"Downloading now enabled. Disable in settings.", Toast.LENGTH_SHORT).show();
downloadModules();
break;
case DialogInterface.BUTTON_NEGATIVE:
// Not going to continue, still show what has
// already been downloaded.
break;
}
}
}
}

View File

@ -1,76 +0,0 @@
package org.bspeice.minimalbible.activities.downloader;
import org.bspeice.minimalbible.MinimalBibleConstants;
import org.bspeice.minimalbible.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;
public class DownloaderActivity extends Activity {
private static final String KEY_DOWNLOAD_ENABLED = "HAS_ENABLED_DOWNLOAD";
public static final String KEY_PERM_DISABLE_DOWNLOAD = "PERMANENTLY_DISABLE_DOWNLOAD";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_downloader);
// Display a warning about internet connectivity
displayInternetWarning();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.downloader, menu);
return true;
}
private void displayInternetWarning() {
SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE);
// If downloading has not been enabled, or user has permanently disabled downloading, WARN THEM!
if (!prefs.getBoolean(KEY_DOWNLOAD_ENABLED, false) || prefs.getBoolean(KEY_PERM_DISABLE_DOWNLOAD, false)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
DownloadDialogListener dialogListener = new DownloadDialogListener();
builder.setMessage("About to contact servers to download content. Continue?")
.setPositiveButton("Yes", dialogListener).setNegativeButton("No", dialogListener)
.setCancelable(false).show();
}
}
private void downloadModules() {
}
private class DownloadDialogListener implements DialogInterface.OnClickListener {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
// Clicked ready to continue - allow downloading in the future
SharedPreferences prefs = getSharedPreferences(MinimalBibleConstants.DOWNLOAD_PREFS_FILE, MODE_PRIVATE);
prefs.edit().putBoolean(KEY_DOWNLOAD_ENABLED, true).commit();
// And warn them that it has been enabled in the future.
Toast.makeText(DownloaderActivity.this,
"Downloading now enabled. Disable in settings.", Toast.LENGTH_SHORT).show();
downloadModules();
break;
case DialogInterface.BUTTON_NEGATIVE:
// Not going to continue, still show what has
// already been downloaded.
break;
}
}
}
}