use view instead of dialog about no setup account

This commit is contained in:
Bartek Przybylski 2012-05-25 21:32:20 +02:00
parent b735fc9458
commit 63f68f1020
4 changed files with 55 additions and 18 deletions

View file

@ -20,7 +20,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@color/owncloud_white" android:background="@color/owncloud_white"
android:orientation="vertical" > android:orientation="vertical"
android:id="@+id/file_list_view">
<fragment <fragment
android:id="@+id/fileList" android:id="@+id/fileList"

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" android:gravity="center_vertical|center_horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical" android:gravity="center_vertical|center_horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:gravity="center"
android:text="@string/main_wrn_accsetup"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/setup_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/main_tit_accsetup" />
</LinearLayout>
</LinearLayout>

View file

@ -12,7 +12,7 @@
<string name="main_calendar">Calendar</string> <string name="main_calendar">Calendar</string>
<string name="main_bookmarks">Bookmarks</string> <string name="main_bookmarks">Bookmarks</string>
<string name="main_settings">Settings</string> <string name="main_settings">Settings</string>
<string name="main_tit_accsetup">Account Setup</string> <string name="main_tit_accsetup">Setup Account</string>
<string name="main_wrn_accsetup">There are no ownCloud accounts on your device. In order to use this App, you need to create one.</string> <string name="main_wrn_accsetup">There are no ownCloud accounts on your device. In order to use this App, you need to create one.</string>
<string name="actionbar_sync">Sync account</string> <string name="actionbar_sync">Sync account</string>

View file

@ -42,6 +42,7 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
@ -73,7 +74,7 @@ import eu.alefzero.webdav.WebdavClient;
*/ */
public class FileDisplayActivity extends SherlockFragmentActivity implements public class FileDisplayActivity extends SherlockFragmentActivity implements
OnNavigationListener, OnClickListener { OnNavigationListener, OnClickListener, android.view.View.OnClickListener {
private ArrayAdapter<String> mDirectories; private ArrayAdapter<String> mDirectories;
private DataStorageManager mStorageManager; private DataStorageManager mStorageManager;
private FileListFragment mFileList; private FileListFragment mFileList;
@ -93,19 +94,12 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (!accountsAreSetup()) {
showDialog(DIALOG_SETUP_ACCOUNT);
return;
}
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(false); setProgressBarIndeterminateVisibility(false);
if(savedInstanceState != null){ if(savedInstanceState != null){
mCurrentDir = (OCFile) savedInstanceState.getParcelable(KEY_CURRENT_DIR); mCurrentDir = (OCFile) savedInstanceState.getParcelable(KEY_CURRENT_DIR);
} }
setContentView(R.layout.files);
} }
@Override @Override
@ -209,7 +203,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (mDirectories.getCount() == 1) { if (mDirectories == null || mDirectories.getCount() == 1) {
finish(); finish();
return; return;
} }
@ -226,10 +220,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
@Override @Override
protected void onRestoreInstanceState(Bundle savedInstanceState) { protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState); super.onRestoreInstanceState(savedInstanceState);
// Check, if there are ownCloud accounts
if (!accountsAreSetup()) {
showDialog(DIALOG_SETUP_ACCOUNT);
}
mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY); mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY);
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item); mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
mDirectories.add("/"); mDirectories.add("/");
@ -241,7 +231,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if(mDirectories != null){ if(mDirectories != null && mDirectories.getCount() != 0){
mDirs = new String[mDirectories.getCount()-1]; mDirs = new String[mDirectories.getCount()-1];
for (int j = mDirectories.getCount() - 2, i = 0; j >= 0; --j, ++i) { for (int j = mDirectories.getCount() - 2, i = 0; j >= 0; --j, ++i) {
mDirs[i] = mDirectories.getItem(j); mDirs[i] = mDirectories.getItem(j);
@ -257,8 +247,13 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
//TODO: Dialog useless -> get rid of this //TODO: Dialog useless -> get rid of this
if (!accountsAreSetup()) { if (!accountsAreSetup()) {
showDialog(DIALOG_SETUP_ACCOUNT); setContentView(R.layout.no_account_available);
setProgressBarIndeterminateVisibility(false);
getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);
findViewById(R.id.setup_account).setOnClickListener(this);
return; return;
} else if (findViewById(R.id.file_list_view) == null) {
setContentView(R.layout.files);
} }
// Listen for sync messages // Listen for sync messages
@ -324,7 +319,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
action_bar.setDisplayHomeAsUpEnabled(false); action_bar.setDisplayHomeAsUpEnabled(false);
} }
// List dir here // List dir here
mFileList.listDirectory(mCurrentDir); mFileList.listDirectory(mCurrentDir);
} }
@ -558,4 +552,13 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
} }
@Override
public void onClick(View v) {
if (v.getId() == R.id.setup_account) {
Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
intent.putExtra("authorities", new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
startActivity(intent);
}
}
} }