mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-07 16:06:18 +00:00
Change a little bit account menu to show actions to do on an account & do some code cleanups
This commit is contained in:
parent
c27a57eda4
commit
6203b8b989
@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="37"
|
||||
android:versionName="0.21.2"> <!-- From Android 4.0 to 6.0 -->
|
||||
<uses-sdk android:maxSdkVersion="23" />
|
||||
<uses-sdk android:maxSdkVersion="23"/>
|
||||
|
||||
<uses-permission android:name="android.permission.READ_SMS"/>
|
||||
<!-- For SMS Broadcaster -->
|
||||
@ -105,6 +105,14 @@
|
||||
android:name=".activities.remote_account.ContactListActivity"
|
||||
android:label="@string/title_activity_select_contact">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.remote_account.AccountActionsActivity"
|
||||
android:label="@string/account_actions">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.remote_account.RestoreMessagesActivity"
|
||||
android:label="@string/restore_all_messages">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
@ -0,0 +1,49 @@
|
||||
package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import fr.unix_experience.android_lib.AppCompatListActivity;
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
|
||||
public class AccountActionsActivity extends AppCompatListActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_account_actions);
|
||||
|
||||
ArrayList<String> itemList = new ArrayList<>();
|
||||
ArrayAdapter<String> adp = new ArrayAdapter<>(getBaseContext(),
|
||||
android.R.layout.simple_dropdown_item_1line, itemList);
|
||||
setListAdapter(adp);
|
||||
|
||||
// Create item list
|
||||
itemList.add(getBaseContext().getString(R.string.restore_all_messages));
|
||||
|
||||
adp.notifyDataSetChanged();
|
||||
|
||||
// Fetch account name from intent
|
||||
_accountName = getIntent().getStringExtra("account");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Intent intent = new Intent(this, RestoreMessagesActivity.class);
|
||||
intent.putExtra("account", _accountName);
|
||||
startActivity(intent);
|
||||
break;
|
||||
default: break; // Unhandled
|
||||
}
|
||||
}
|
||||
|
||||
private String _accountName = "";
|
||||
private static final String TAG = AccountActionsActivity.class.getSimpleName();
|
||||
}
|
@ -12,8 +12,7 @@ import fr.unix_experience.android_lib.AppCompatListActivity;
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
|
||||
public class AccountListActivity extends AppCompatListActivity {
|
||||
ArrayList<Account> listItems = new ArrayList<>();
|
||||
AndroidAccountAdapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@ -22,16 +21,18 @@ public class AccountListActivity extends AppCompatListActivity {
|
||||
|
||||
setContentView(R.layout.restore_activity_accountlist);
|
||||
|
||||
adapter = new AndroidAccountAdapter(this,
|
||||
ArrayList<Account> itemList = new ArrayList<>();
|
||||
|
||||
AndroidAccountAdapter adapter = new AndroidAccountAdapter(this,
|
||||
android.R.layout.simple_list_item_1,
|
||||
listItems,
|
||||
itemList,
|
||||
R.layout.account_list_item,
|
||||
R.id.accountname, ContactListActivity.class);
|
||||
R.id.accountname, AccountActionsActivity.class);
|
||||
setListAdapter(adapter);
|
||||
|
||||
Account[] accountList =
|
||||
_accountMgr.getAccountsByType(getString(R.string.account_type));
|
||||
Collections.addAll(listItems, accountList);
|
||||
Collections.addAll(itemList, accountList);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
|
@ -69,13 +69,15 @@ public class ContactListActivity extends AppCompatActivity implements ASyncConta
|
||||
final Spinner sp = (Spinner) findViewById(R.id.contact_spinner);
|
||||
mContactInfos = (LinearLayout) findViewById(R.id.contactinfos_layout);
|
||||
final ProgressBar contactProgressBar = (ProgressBar) findViewById(R.id.contactlist_pgbar);
|
||||
final ListView contactPhoneListView = (ListView) findViewById(R.id.contact_phonelistView);
|
||||
ListView contactPhoneListView = (ListView) findViewById(R.id.contact_phonelistView);
|
||||
mContactPhoneListAdapter = new RecoveryPhoneNumberListViewAdapter(getBaseContext());
|
||||
assert contactPhoneListView != null;
|
||||
contactPhoneListView.setAdapter(mContactPhoneListAdapter);
|
||||
|
||||
mContactInfos.setVisibility(View.INVISIBLE);
|
||||
|
||||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
assert sp != null;
|
||||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
mContactInfos.setVisibility(View.INVISIBLE);
|
||||
@ -97,7 +99,8 @@ public class ContactListActivity extends AppCompatActivity implements ASyncConta
|
||||
for (final Account element : myAccountList) {
|
||||
if (element.name.equals(accountName)) {
|
||||
// Load "contacts"
|
||||
contactProgressBar.setVisibility(View.VISIBLE);
|
||||
assert contactProgressBar != null;
|
||||
contactProgressBar.setVisibility(View.VISIBLE);
|
||||
new ContactLoadTask(element, getBaseContext(), mAdapter, mObjects, mLayout, contactProgressBar, mContactInfos).execute();
|
||||
|
||||
// Add refresh handler
|
||||
|
@ -0,0 +1,15 @@
|
||||
package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
|
||||
public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_restore_messages);
|
||||
}
|
||||
}
|
@ -34,19 +34,19 @@ public class OCSMSNotificationUI {
|
||||
*
|
||||
* @see #cancel(Context)
|
||||
*/
|
||||
public static void notify(final Context context, final String titleString,
|
||||
final String contentString, final int number) {
|
||||
final Resources res = context.getResources();
|
||||
public static void notify(Context context, String titleString,
|
||||
String contentString, int number) {
|
||||
Resources res = context.getResources();
|
||||
|
||||
// This image is used as the notification's large icon (thumbnail).
|
||||
// TODO: Remove this if your notification has no relevant thumbnail.
|
||||
final Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_launcher);
|
||||
Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_launcher);
|
||||
|
||||
|
||||
final String ticker = (titleString.length() > 20) ? titleString.substring(0, 20) : titleString;
|
||||
final String title = res.getString(R.string.ui_notification_title_template, titleString);
|
||||
String ticker = (titleString.length() > 20) ? titleString.substring(0, 20) : titleString;
|
||||
String title = res.getString(R.string.ui_notification_title_template, titleString);
|
||||
|
||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
|
||||
// Set appropriate defaults for the notification light, sound,
|
||||
// and vibration.
|
||||
@ -76,17 +76,17 @@ public class OCSMSNotificationUI {
|
||||
.setSummaryText(titleString))
|
||||
.setAutoCancel(true);
|
||||
|
||||
notify(context, builder.build());
|
||||
OCSMSNotificationUI.notify(context, builder.build());
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
private static void notify(final Context context, final Notification notification) {
|
||||
final NotificationManager nm = (NotificationManager) context
|
||||
private static void notify(Context context, Notification notification) {
|
||||
NotificationManager nm = (NotificationManager) context
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
nm.notify(NOTIFICATION_TAG, 0, notification);
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG, 0, notification);
|
||||
} else {
|
||||
nm.notify(NOTIFICATION_TAG.hashCode(), notification);
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode(), notification);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,13 +95,13 @@ public class OCSMSNotificationUI {
|
||||
* {@link #notify(Context, String, int)}.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
public static void cancel(final Context context) {
|
||||
final NotificationManager nm = (NotificationManager) context
|
||||
public static void cancel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
nm.cancel(NOTIFICATION_TAG, 0);
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG, 0);
|
||||
} else {
|
||||
nm.cancel(NOTIFICATION_TAG.hashCode());
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
42
src/main/res/layout/activity_account_actions.xml
Normal file
42
src/main/res/layout/activity_account_actions.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
tools:context="fr.unix_experience.owncloud_sms.activities.remote_account.AccountActionsActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ListView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/list"
|
||||
android:choiceMode="singleChoice"
|
||||
android:drawSelectorOnTop="true"/>
|
||||
</LinearLayout>
|
39
src/main/res/layout/activity_restore_messages.xml
Normal file
39
src/main/res/layout/activity_restore_messages.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
-->
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="fr.unix_experience.owncloud_sms.activities.remote_account.RestoreMessagesActivity">
|
||||
|
||||
</RelativeLayout>
|
@ -168,5 +168,7 @@
|
||||
<string name="err_cannot_read_contacts">We cannot read your contacts.</string>
|
||||
<string name="err_cannot_read_sms">We cannot read your SMS.</string>
|
||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
|
||||
</resources>
|
||||
|
@ -153,4 +153,6 @@
|
||||
<string name="err_cannot_read_contacts">Nous ne pouvons lire vos contacts.</string>
|
||||
<string name="err_cannot_read_sms">Nous ne pouvons pas lire vos SMS.</string>
|
||||
<string name="action_appinfo_perms">Infos et permissions</string>
|
||||
<string name="restore_all_messages">Restaurer tous les messages</string>
|
||||
<string name="account_actions">Actions du compte</string>
|
||||
</resources>
|
||||
|
@ -27,7 +27,7 @@
|
||||
-->
|
||||
<resources>
|
||||
<!-- Translation version, reference for translators -->
|
||||
<string name="gp_translation_version">3</string>
|
||||
<string name="gp_translation_version" translatable="false">3</string>
|
||||
|
||||
<!-- Translations must begin here -->
|
||||
<string name="gp_short_description">ownCloud SMS synchronize your local SMS on your ownCloud instance</string>
|
||||
|
@ -41,7 +41,7 @@
|
||||
<string name="login_logo">Login logo</string>
|
||||
|
||||
<!-- System strings: preferences -->
|
||||
<string name="shared_preference_file">ownCloudSMSPrefs</string>
|
||||
<string name="shared_preference_file" translatable="false">ownCloudSMSPrefs</string>
|
||||
<string name="pref_lastmsgdate">last_message_date</string>
|
||||
|
||||
<!-- Translations must begin there -->
|
||||
@ -203,4 +203,6 @@
|
||||
<string name="err_cannot_read_contacts">We cannot read your contacts.</string>
|
||||
<string name="err_cannot_read_sms">We cannot read your SMS.</string>
|
||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user