1
0
mirror of https://github.com/etesync/android synced 2024-12-26 08:28:17 +00:00

Fix Settings rendering issues

* fix Settings rendering issues (fixes #459)
* version bump to 0.7.1
This commit is contained in:
Ricki Hirner 2015-03-11 14:01:43 +01:00
parent b29756aff2
commit 23dba581e1
15 changed files with 139 additions and 107 deletions

View File

@ -4,7 +4,7 @@ N:Gump;Forrest;Mr.
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=PNG:http://10.0.0.11:3000/assets/davdroid-logo-192.png
PHOTO;VALUE=URL;TYPE=PNG:http://192.168.0.11:3000/assets/davdroid-logo-192.png
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America

View File

@ -14,7 +14,7 @@ import java.net.URISyntaxException;
import android.util.Log;
public class TestConstants {
public static final String ROBOHYDRA_BASE = "http://10.0.0.11:3000/";
public static final String ROBOHYDRA_BASE = "http://192.168.0.11:3000/";
public static URI roboHydra;
static {

View File

@ -9,7 +9,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.davdroid"
android:versionCode="55" android:versionName="0.7"
android:versionCode="56" android:versionName="0.7.1"
android:installLocation="internalOnly">
<uses-sdk
@ -83,12 +83,16 @@
android:excludeFromRecents="true" >
</activity>
<activity
android:name=".syncadapter.SettingsActivity"
android:name=".ui.settings.SettingsActivity"
android:label="@string/settings_title" >
<intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
</intent-filter>
</activity>
<activity
android:name=".ui.settings.AccountActivity"
android:label="@string/settings_title" >
</activity>
</application>
</manifest>

View File

@ -9,7 +9,7 @@ package at.bitfire.davdroid;
public class Constants {
public static final String
APP_VERSION = "0.7",
APP_VERSION = "0.7.1",
ACCOUNT_TYPE = "bitfire.at.davdroid",
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app",
WEB_URL_VIEW_LOGS = "https://github.com/bitfireAT/davdroid/wiki/How-to-view-the-logs";

View File

@ -21,7 +21,7 @@ import android.view.View;
import android.widget.TextView;
import at.bitfire.davdroid.syncadapter.AddAccountActivity;
import at.bitfire.davdroid.syncadapter.SettingsActivity;
import at.bitfire.davdroid.ui.settings.SettingsActivity;
public class MainActivity extends Activity {

View File

@ -89,15 +89,15 @@ public class AccountSettings {
public String getUserName() {
return accountManager.getUserData(account, KEY_USERNAME);
}
void setUserName(String userName) { accountManager.setUserData(account, KEY_USERNAME, userName); }
public void setUserName(String userName) { accountManager.setUserData(account, KEY_USERNAME, userName); }
public String getPassword() {
return accountManager.getPassword(account);
}
void setPassword(String password) { accountManager.setPassword(account, password); }
public void setPassword(String password) { accountManager.setPassword(account, password); }
public boolean getPreemptiveAuth() { return Boolean.parseBoolean(accountManager.getUserData(account, KEY_AUTH_PREEMPTIVE)); }
void setPreemptiveAuth(boolean preemptive) { accountManager.setUserData(account, KEY_AUTH_PREEMPTIVE, Boolean.toString(preemptive)); }
public void setPreemptiveAuth(boolean preemptive) { accountManager.setUserData(account, KEY_AUTH_PREEMPTIVE, Boolean.toString(preemptive)); }
// sync. settings

View File

@ -1,73 +0,0 @@
/*
* Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.syncadapter;
import android.accounts.Account;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import at.bitfire.davdroid.R;
public class SettingsActivity extends Activity {
private final static String KEY_SELECTED_ACCOUNT = "selected_account";
protected Account selectedAccount;
boolean tabletLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
tabletLayout = findViewById(R.id.right_pane) != null;
if (!tabletLayout)
getFragmentManager().beginTransaction()
.add(R.id.content_pane, new SettingsScopeFragment())
.commit();
if (savedInstanceState != null) {
selectedAccount = savedInstanceState.getParcelable(KEY_SELECTED_ACCOUNT);
if (selectedAccount != null)
showAccountSettings(selectedAccount);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putParcelable(KEY_SELECTED_ACCOUNT, selectedAccount);
super.onSaveInstanceState(outState);
}
void showAccountSettings(Account account) {
selectedAccount = account;
FragmentManager fm = getFragmentManager();
Fragment settingsFragment = new SettingsAccountFragment();
Bundle args = new Bundle();
args.putParcelable(SettingsAccountFragment.KEY_ACCOUNT, account);
settingsFragment.setArguments(args);
FragmentTransaction ft = fm
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
if (tabletLayout)
ft .replace(R.id.right_pane, settingsFragment);
else // phone layout
ft .replace(R.id.content_pane, settingsFragment)
.addToBackStack(null);
ft.commit();
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.ui.settings;
import android.accounts.Account;
import android.app.Activity;
import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import at.bitfire.davdroid.R;
public class AccountActivity extends Activity {
static final String EXTRA_ACCOUNT = "account";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_account_activity);
final FragmentManager fm = getFragmentManager();
AccountFragment fragment = (AccountFragment)fm.findFragmentById(R.id.account_fragment);
if (fragment == null) {
fragment = new AccountFragment();
final Bundle args = new Bundle(1);
Account account = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);
args.putParcelable(AccountFragment.ARG_ACCOUNT, account);
fragment.setArguments(args);
getFragmentManager().beginTransaction()
.add(R.id.account_fragment, fragment)
.commit();
}
}
}

View File

@ -6,11 +6,9 @@
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.syncadapter;
package at.bitfire.davdroid.ui.settings;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
@ -19,19 +17,21 @@ import android.preference.Preference;
import android.preference.PreferenceFragment;
import at.bitfire.davdroid.R;
import at.bitfire.davdroid.syncadapter.AccountSettings;
import lombok.Setter;
public class SettingsAccountFragment extends PreferenceFragment {
final static String KEY_ACCOUNT = "account";
public class AccountFragment extends PreferenceFragment {
final static String ARG_ACCOUNT = "account";
protected Account account;
Account account;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.account_prefs);
addPreferencesFromResource(R.xml.settings_account_prefs);
account = getArguments().getParcelable(KEY_ACCOUNT);
account = getArguments().getParcelable(ARG_ACCOUNT);
readFromAccount();
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.ui.settings;
import android.accounts.Account;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import at.bitfire.davdroid.R;
public class SettingsActivity extends Activity {
private final static String KEY_SELECTED_ACCOUNT = "selected_account";
boolean tabletLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
tabletLayout = findViewById(R.id.right_pane) != null;
if (tabletLayout) {
SettingsScopeFragment scope = (SettingsScopeFragment)getFragmentManager().findFragmentById(R.id.settings_scope);
scope.setLayout(true);
}
}
void showAccountSettings(Account account) {
if (tabletLayout) {
AccountFragment fragment = new AccountFragment();
Bundle args = new Bundle(1);
args.putParcelable(AccountFragment.ARG_ACCOUNT, account);
fragment.setArguments(args);
getFragmentManager().beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.right_pane, fragment)
.commit();
} else { // phone layout
Intent intent = new Intent(getApplicationContext(), AccountActivity.class);
intent.putExtra(AccountActivity.EXTRA_ACCOUNT, account);
startActivity(intent);
}
}
}

View File

@ -6,7 +6,7 @@
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.syncadapter;
package at.bitfire.davdroid.ui.settings;
import android.accounts.Account;
import android.accounts.AccountManager;
@ -26,17 +26,22 @@ public class SettingsScopeFragment extends ListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final AccountManager manager = AccountManager.get(this.getActivity());
final AccountManager manager = AccountManager.get(getActivity());
accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
final String[] accountNames = new String[accounts.length];
for (int i = 0; i < accounts.length; i++)
accountNames[i] = accounts[i].name;
setListAdapter(new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_list_item_activated_1, accountNames));
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1, accountNames));
return super.onCreateView(inflater, container, savedInstanceState);
}
public void setLayout(boolean tabletLayout) {
if (tabletLayout)
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

View File

@ -16,8 +16,8 @@
<fragment
android:layout_width="@dimen/titles_width"
android:layout_height="match_parent"
android:tag="scope"
android:name="at.bitfire.davdroid.syncadapter.SettingsScopeFragment" />
android:id="@+id/settings_scope"
android:name="at.bitfire.davdroid.ui.settings.SettingsScopeFragment" />
<FrameLayout
android:id="@+id/right_pane"

View File

@ -8,10 +8,6 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_pane"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:orientation="horizontal"
android:layout_height="match_parent">
</FrameLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/account_fragment" />

View File

@ -7,8 +7,8 @@
~ http://www.gnu.org/licenses/gpl.html
-->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settings_accounts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="scope"
android:name="at.bitfire.davdroid.ui.settings.SettingsScopeFragment" />