mirror of
https://github.com/etesync/android
synced 2025-01-23 06:01:01 +00:00
Add stats to the collection edit page.
This commit is contained in:
parent
7bb57c15a9
commit
32df64000f
@ -11,17 +11,26 @@ package com.etesync.syncadapter.ui;
|
||||
import android.accounts.Account;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.etesync.syncadapter.R;
|
||||
import com.etesync.syncadapter.model.CollectionInfo;
|
||||
import com.etesync.syncadapter.resource.LocalAddressBook;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import at.bitfire.vcard4android.ContactsStorageException;
|
||||
|
||||
public class CreateAddressBookActivity extends AppCompatActivity {
|
||||
public static final String EXTRA_ACCOUNT = "account",
|
||||
@ -48,6 +57,17 @@ public class CreateAddressBookActivity extends AppCompatActivity {
|
||||
|
||||
final EditText desc = (EditText) findViewById(R.id.description);
|
||||
desc.setText(info.description);
|
||||
|
||||
final TextView stats = (TextView) findViewById(R.id.stats);
|
||||
final View statsGroup = findViewById(R.id.stats_group);
|
||||
try {
|
||||
LocalAddressBook resource = new LocalAddressBook(account, this.getContentResolver().acquireContentProviderClient(ContactsContract.Contacts.CONTENT_URI));
|
||||
long count = resource.count();
|
||||
stats.setText(String.format(Locale.getDefault(), "Contacts: %d", count));
|
||||
statsGroup.setVisibility(View.VISIBLE);
|
||||
} catch (ContactsStorageException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import android.accounts.Account;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.CalendarContract;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@ -20,6 +21,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -28,6 +30,9 @@ import com.etesync.syncadapter.R;
|
||||
import com.etesync.syncadapter.model.CollectionInfo;
|
||||
import com.etesync.syncadapter.resource.LocalCalendar;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import at.bitfire.ical4android.CalendarStorageException;
|
||||
import yuku.ambilwarna.AmbilWarnaDialog;
|
||||
|
||||
public class CreateCalendarActivity extends AppCompatActivity {
|
||||
@ -81,6 +86,18 @@ public class CreateCalendarActivity extends AppCompatActivity {
|
||||
} else {
|
||||
colorSquare.setBackgroundColor(LocalCalendar.defaultColor);
|
||||
}
|
||||
|
||||
final TextView stats = (TextView) findViewById(R.id.stats);
|
||||
final View statsGroup = findViewById(R.id.stats_group);
|
||||
try {
|
||||
LocalCalendar resource = (LocalCalendar) LocalCalendar.find(account, this.getContentResolver().acquireContentProviderClient(CalendarContract.CONTENT_URI),
|
||||
LocalCalendar.Factory.INSTANCE, CalendarContract.Calendars.NAME + "=?", new String[]{info.url})[0];
|
||||
long count = resource.count();
|
||||
stats.setText(String.format(Locale.getDefault(), "Events: %d", count));
|
||||
statsGroup.setVisibility(View.VISIBLE);
|
||||
} catch (CalendarStorageException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,5 +39,26 @@
|
||||
android:inputType="textAutoCorrect"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/stats_group"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/collection_stats_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/stats"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@ -59,6 +59,27 @@
|
||||
android:text="@string/create_collection_color"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/stats_group"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/collection_stats_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/stats"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -188,6 +188,7 @@
|
||||
<string name="delete_collection_confirm_title">Are you sure?</string>
|
||||
<string name="delete_collection_confirm_warning">This collection (%s) and all its data will be removed from the server.</string>
|
||||
<string name="delete_collection_deleting_collection">Deleting collection</string>
|
||||
<string name="collection_stats_title">Stats</string>
|
||||
|
||||
<!-- ExceptionInfoFragment -->
|
||||
<string name="exception">An error has occurred.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user