1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

Merge branch 'improve_import'

This commit is contained in:
cketti 2013-03-06 07:49:53 +01:00
commit 4202ffe57d
4 changed files with 62 additions and 9 deletions

View File

@ -30,6 +30,35 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<include layout="@layout/wizard_next" /> <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="-45dip"
android:background="@android:drawable/bottom_bar"
android:gravity="bottom|right"
android:padding="0dip" >
<Button
android:id="@+id/import_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="false"
android:layout_marginBottom="-4dip"
android:minWidth="@dimen/button_minWidth"
android:text="@string/settings_import" />
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="false"
android:layout_marginBottom="-4dip"
android:drawableRight="@drawable/button_indicator_next"
android:minWidth="@dimen/button_minWidth"
android:text="@string/next_action" />
</RelativeLayout>
</LinearLayout> </LinearLayout>

View File

@ -327,6 +327,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
public static final String EXTRA_STARTUP = "startup"; public static final String EXTRA_STARTUP = "startup";
public static final String ACTION_IMPORT_SETTINGS = "importSettings";
public static void listAccounts(Context context) { public static void listAccounts(Context context) {
Intent intent = new Intent(context, Accounts.class); Intent intent = new Intent(context, Accounts.class);
@ -336,6 +338,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
context.startActivity(intent); context.startActivity(intent);
} }
public static void importSettings(Context context) {
Intent intent = new Intent(context, Accounts.class);
intent.setAction(ACTION_IMPORT_SETTINGS);
context.startActivity(intent);
}
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
Uri uri = intent.getData(); Uri uri = intent.getData();
@ -365,7 +373,9 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
//onNewIntent(intent); //onNewIntent(intent);
// see if we should show the welcome message // see if we should show the welcome message
if (accounts.length < 1) { if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
onImport();
} else if (accounts.length < 1) {
WelcomeMessage.showWelcomeMessage(this); WelcomeMessage.showWelcomeMessage(this);
finish(); finish();
return; return;
@ -525,10 +535,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
accounts = Preferences.getPreferences(this).getAccounts(); accounts = Preferences.getPreferences(this).getAccounts();
// see if we should show the welcome message // see if we should show the welcome message
if (accounts.length < 1) { // if (accounts.length < 1) {
WelcomeMessage.showWelcomeMessage(this); // WelcomeMessage.showWelcomeMessage(this);
finish(); // finish();
} // }
List<BaseAccount> newAccounts; List<BaseAccount> newAccounts;
if (!K9.isHideSpecialAccounts() && accounts.length > 0) { if (!K9.isHideSpecialAccounts() && accounts.length > 0) {

View File

@ -10,6 +10,7 @@ import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import com.fsck.k9.R; import com.fsck.k9.R;
import com.fsck.k9.activity.Accounts;
import com.fsck.k9.activity.K9Activity; import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.helper.HtmlConverter; import com.fsck.k9.helper.HtmlConverter;
@ -33,13 +34,22 @@ public class WelcomeMessage extends K9Activity implements OnClickListener{
welcome.setMovementMethod(LinkMovementMethod.getInstance()); welcome.setMovementMethod(LinkMovementMethod.getInstance());
((Button) findViewById(R.id.next)).setOnClickListener(this); ((Button) findViewById(R.id.next)).setOnClickListener(this);
((Button) findViewById(R.id.import_settings)).setOnClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (view.getId() == R.id.next) { switch (view.getId()) {
case R.id.next: {
AccountSetupBasics.actionNewAccount(this); AccountSetupBasics.actionNewAccount(this);
finish(); finish();
break;
}
case R.id.import_settings: {
Accounts.importSettings(this);
finish();
break;
}
} }
} }
} }

View File

@ -596,6 +596,10 @@ public class SettingsImporter {
private static boolean isAccountNameUsed(String name, Account[] accounts) { private static boolean isAccountNameUsed(String name, Account[] accounts) {
for (Account account : accounts) { for (Account account : accounts) {
if (account == null) {
continue;
}
if (account.getDescription().equals(name)) { if (account.getDescription().equals(name)) {
return true; return true;
} }