mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2026-08-20 12:52:59 +00:00
Drawer, Toolbar and minor UI optimizations (#145)
* initial add of toolbar and hamburger menu to main activity * toolbar added to preferences and accounts screens * fixed original string (name) * Layout fix for content * initial add of toolbar and hamburger menu to main activity * remove unnecessary padding bottom * fix styling and paint login activity in blue * toolbar added to preferences and accounts screens * Layout fix for content * remove unnecessary padding bottom * fix styling and paint login activity in blue * fixes after rebase * consolidate style since minVersion=16, make drawer to be behind the systembar * optimize drawer header * add back navigation to login activity, fix spinner background * add back navigation * more launcher icon to mipmap folders * fix identation * fix license header * revert code style deletion, change identation * proper notification icon * proper resolution for login logo * fix large notification icon * removed unused Eclair switch since support is v16+ * only use small notification icon * spaces->tabs * fix toolbar style for Android 4.x
This commit is contained in:
committed by
Loïc Blot
parent
0bc671901e
commit
f83eebe4dd
@@ -29,10 +29,12 @@ import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -65,7 +67,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private EditText _loginView;
|
||||
private EditText _passwordView;
|
||||
private EditText _serverView;
|
||||
private ActionProcessButton _signInButton;
|
||||
private ActionProcessButton _signInButton;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@@ -74,6 +76,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Set up the login form.
|
||||
_protocolView = (Spinner) findViewById(R.id.oc_protocol);
|
||||
_serverView = (EditText) findViewById(R.id.oc_server);
|
||||
@@ -84,7 +89,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int id,
|
||||
KeyEvent keyEvent) {
|
||||
KeyEvent keyEvent) {
|
||||
if ((id == R.id.oc_login) || (id == EditorInfo.IME_NULL)) {
|
||||
attemptLogin();
|
||||
return true;
|
||||
@@ -93,7 +98,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
_signInButton = (ActionProcessButton) findViewById(R.id.oc_signin_button);
|
||||
_signInButton = (ActionProcessButton) findViewById(R.id.oc_signin_button);
|
||||
_signInButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -105,6 +110,19 @@ public class LoginActivity extends AppCompatActivity {
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to sign in or register the account specified by the login form.
|
||||
* If there are form errors (invalid email, missing fields, etc.), the
|
||||
@@ -127,12 +145,12 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
|
||||
// Check for a valid server address.
|
||||
if (TextUtils.isEmpty(protocol)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
// Check for a valid server address.
|
||||
if (TextUtils.isEmpty(serverAddr)) {
|
||||
_serverView.setError(getString(R.string.error_field_required));
|
||||
@@ -146,14 +164,14 @@ public class LoginActivity extends AppCompatActivity {
|
||||
focusView = _loginView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
// Check for a valid password
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
_passwordView.setError(getString(R.string.error_field_required));
|
||||
focusView = _passwordView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
if (!isPasswordValid(password)) {
|
||||
_passwordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = _passwordView;
|
||||
@@ -163,15 +181,15 @@ public class LoginActivity extends AppCompatActivity {
|
||||
if (cancel) {
|
||||
// There was an error; don't attempt login and focus the first
|
||||
// form field with an error.
|
||||
// reset the button progress
|
||||
_signInButton.setProgress(0);
|
||||
if (focusView != null) {
|
||||
focusView.requestFocus();
|
||||
}
|
||||
} else {
|
||||
// reset the button progress
|
||||
_signInButton.setProgress(0);
|
||||
if (focusView != null) {
|
||||
focusView.requestFocus();
|
||||
}
|
||||
} else {
|
||||
// Show a progress spinner, and kick off a background task to
|
||||
// perform the user login attempt.
|
||||
_signInButton.setProgress(25);
|
||||
_signInButton.setProgress(25);
|
||||
showProgress(true);
|
||||
String serverURL = protocol + serverAddr;
|
||||
mAuthTask = new UserLoginTask(serverURL, login, password);
|
||||
@@ -229,10 +247,10 @@ public class LoginActivity extends AppCompatActivity {
|
||||
* Represents an asynchronous login/registration task used to authenticate
|
||||
* the user.
|
||||
*/
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
UserLoginTask(String serverURI, String login, String password) {
|
||||
Log.i(TAG, "_serverURI = " + serverURI);
|
||||
Log.i(TAG, "_serverURI = " + serverURI);
|
||||
_serverURI = Uri.parse(serverURI);
|
||||
_login = login;
|
||||
_password = password;
|
||||
@@ -259,47 +277,47 @@ public class LoginActivity extends AppCompatActivity {
|
||||
protected void onPostExecute(Boolean success) {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
_signInButton.setProgress(90);
|
||||
_signInButton.setProgress(90);
|
||||
|
||||
if (success) {
|
||||
_signInButton.setProgress(100);
|
||||
_signInButton.setProgress(100);
|
||||
String accountType = getIntent().getStringExtra(UserLoginTask.PARAM_AUTHTOKEN_TYPE);
|
||||
if (accountType == null) {
|
||||
accountType = getString(R.string.account_type);
|
||||
}
|
||||
|
||||
if (accountType == null) {
|
||||
accountType = getString(R.string.account_type);
|
||||
}
|
||||
|
||||
// Generate a label
|
||||
String accountLabel = _login + "@" + _serverURI.getHost();
|
||||
|
||||
|
||||
// We create the account
|
||||
Account account = new Account(accountLabel, accountType);
|
||||
Bundle accountBundle = new Bundle();
|
||||
accountBundle.putString("ocLogin", _login);
|
||||
accountBundle.putString("ocURI", _serverURI.toString());
|
||||
|
||||
|
||||
// And we push it to Android
|
||||
AccountManager accMgr = AccountManager.get(getApplicationContext());
|
||||
accMgr.addAccountExplicitly(account, _password, accountBundle);
|
||||
|
||||
accMgr.addAccountExplicitly(account, _password, accountBundle);
|
||||
|
||||
// Set sync options
|
||||
ContentResolver.setSyncAutomatically(account, getString(R.string.account_authority), true);
|
||||
|
||||
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("synctype", 1);
|
||||
|
||||
|
||||
ContentResolver.addPeriodicSync(account, getString(R.string.account_authority), b, DefaultPrefs.syncInterval * 60);
|
||||
// Then it's finished
|
||||
finish();
|
||||
|
||||
|
||||
// Start sync settings, we have finished to configure account
|
||||
Intent settingsIntent = new Intent(Settings.ACTION_SYNC_SETTINGS);
|
||||
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(settingsIntent);
|
||||
} else {
|
||||
boolean serverViewRequestFocus = true;
|
||||
boolean serverViewRequestFocus = true;
|
||||
switch (_returnCode) {
|
||||
case 0:
|
||||
_serverView.setError("UNK");
|
||||
_serverView.setError("UNK");
|
||||
break;
|
||||
case 404:
|
||||
_serverView.setError(getString(R.string.error_connection_failed_not_found));
|
||||
@@ -312,24 +330,24 @@ public class LoginActivity extends AppCompatActivity {
|
||||
_serverView.setError(getString(R.string.error_http_connection_failed));
|
||||
break;
|
||||
case 401:
|
||||
case 403:
|
||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||
_passwordView.requestFocus();
|
||||
// Warning, there is no break here to disable serverViewRequestFocus too
|
||||
case 200:
|
||||
default:
|
||||
serverViewRequestFocus = false;
|
||||
break;
|
||||
case 403:
|
||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||
_passwordView.requestFocus();
|
||||
// Warning, there is no break here to disable serverViewRequestFocus too
|
||||
case 200:
|
||||
default:
|
||||
serverViewRequestFocus = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (serverViewRequestFocus) {
|
||||
_serverView.requestFocus();
|
||||
}
|
||||
if (serverViewRequestFocus) {
|
||||
_serverView.requestFocus();
|
||||
}
|
||||
|
||||
// If not ok, reset the progress
|
||||
if (_returnCode != 200) {
|
||||
_signInButton.setProgress(0);
|
||||
}
|
||||
// If not ok, reset the progress
|
||||
if (_returnCode != 200) {
|
||||
_signInButton.setProgress(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,8 +361,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private final String _login;
|
||||
private final String _password;
|
||||
private int _returnCode;
|
||||
|
||||
|
||||
static final String PARAM_AUTHTOKEN_TYPE = "auth.token";
|
||||
private final String TAG = UserLoginTask.class.getCanonicalName();
|
||||
}
|
||||
private final String TAG = UserLoginTask.class.getCanonicalName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
@@ -59,107 +60,174 @@ import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_MAX;
|
||||
import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_SMS;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener{
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private ConnectivityMonitor _ConnectivityMonitor = null;
|
||||
|
||||
private DrawerLayout drawer;
|
||||
|
||||
private ConnectivityMonitor _ConnectivityMonitor = null;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (_ConnectivityMonitor == null) {
|
||||
_ConnectivityMonitor = new ConnectivityMonitor(getApplicationContext());
|
||||
}
|
||||
if (_ConnectivityMonitor == null) {
|
||||
_ConnectivityMonitor = new ConnectivityMonitor(getApplicationContext());
|
||||
}
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
assert drawer != null;
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
assert navigationView != null;
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
setupToolbar();
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
setupDrawer();
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
assert drawer != null;
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
protected void setupToolbar() {
|
||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
boolean res = true;
|
||||
private void setupDrawer() {
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
assert drawer != null;
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
toggle.setDrawerIndicatorEnabled(true);
|
||||
|
||||
switch (id) {
|
||||
case R.id.nav_sync: syncAllMessages(); break;
|
||||
case R.id.nav_manage: res = openAppSettings(); break;
|
||||
case R.id.nav_rateus: res = openGooglePlayStore(); break;
|
||||
case R.id.nav_add_account: res = openAddAccount(); break;
|
||||
case R.id.nav_my_accounts: res = openMyAccounts(); break;
|
||||
case R.id.nav_appinfo_perms: res = openAppInfos(); break;
|
||||
}
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
assert drawer != null;
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return res;
|
||||
}
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
assert navigationView != null;
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
}
|
||||
|
||||
private boolean openAppSettings () {
|
||||
/**
|
||||
* checks if the drawer exists and is opened.
|
||||
*
|
||||
* @return <code>true</code> if the drawer is open, else <code>false</code>
|
||||
*/
|
||||
public boolean isDrawerOpen() {
|
||||
return drawer != null && drawer.isDrawerOpen(GravityCompat.START);
|
||||
}
|
||||
|
||||
/**
|
||||
* closes the drawer.
|
||||
*/
|
||||
public void closeDrawer() {
|
||||
if (drawer != null) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* opens the drawer.
|
||||
*/
|
||||
public void openDrawer() {
|
||||
if (drawer != null) {
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: {
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
boolean res = true;
|
||||
|
||||
switch (id) {
|
||||
case R.id.nav_sync:
|
||||
syncAllMessages();
|
||||
break;
|
||||
case R.id.nav_manage:
|
||||
res = openAppSettings();
|
||||
break;
|
||||
case R.id.nav_rateus:
|
||||
res = openGooglePlayStore();
|
||||
break;
|
||||
case R.id.nav_add_account:
|
||||
res = openAddAccount();
|
||||
break;
|
||||
case R.id.nav_my_accounts:
|
||||
res = openMyAccounts();
|
||||
break;
|
||||
case R.id.nav_appinfo_perms:
|
||||
res = openAppInfos();
|
||||
break;
|
||||
}
|
||||
closeDrawer();
|
||||
return res;
|
||||
}
|
||||
|
||||
private boolean openAppSettings() {
|
||||
startActivity(new Intent(this, OCSMSSettingsActivity.class));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openAddAccount () {
|
||||
private boolean openAddAccount() {
|
||||
startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void syncAllMessages () {
|
||||
Log.v(MainActivity.TAG, "Launch syncAllMessages()");
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.READ_SMS,
|
||||
REQUEST_SMS)) {
|
||||
return;
|
||||
}
|
||||
public void syncAllMessages() {
|
||||
Log.v(MainActivity.TAG, "Launch syncAllMessages()");
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.READ_SMS,
|
||||
REQUEST_SMS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
if (_ConnectivityMonitor.isValid()) {
|
||||
// Now fetch messages since last stored date
|
||||
JSONArray smsList = new JSONArray();
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
|
||||
if (smsList.length() > 0) {
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
new SyncTask(getApplicationContext(), smsList).execute();
|
||||
} else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.err_sync_no_connection_available), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages()");
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages()");
|
||||
}
|
||||
|
||||
private boolean openMyAccounts () {
|
||||
private boolean openMyAccounts() {
|
||||
startActivity(new Intent(this, AccountListActivity.class));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openGooglePlayStore () {
|
||||
private boolean openGooglePlayStore() {
|
||||
Intent intent;
|
||||
try {
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
|
||||
@@ -168,45 +236,45 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openAppInfos () {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
private boolean openAppInfos() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Permissions
|
||||
*/
|
||||
/*
|
||||
* Permissions
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
PermissionID requestCodeID = REQUEST_MAX;
|
||||
if ((requestCode > 0) || (requestCode < REQUEST_MAX.ordinal())) {
|
||||
requestCodeID = PermissionID.values()[requestCode];
|
||||
}
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
PermissionID requestCodeID = REQUEST_MAX;
|
||||
if ((requestCode > 0) || (requestCode < REQUEST_MAX.ordinal())) {
|
||||
requestCodeID = PermissionID.values()[requestCode];
|
||||
}
|
||||
|
||||
switch (requestCodeID) {
|
||||
case REQUEST_SMS:
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
syncAllMessages();
|
||||
} else {
|
||||
// Permission Denied
|
||||
Toast.makeText(this, getString(R.string.err_cannot_read_sms) + " " +
|
||||
getString(R.string.please_fix_it), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
switch (requestCodeID) {
|
||||
case REQUEST_SMS:
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
syncAllMessages();
|
||||
} else {
|
||||
// Permission Denied
|
||||
Toast.makeText(this, getString(R.string.err_cannot_read_sms) + " " +
|
||||
getString(R.string.please_fix_it), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
}
|
||||
|
||||
+103
-65
@@ -24,7 +24,10 @@ import android.content.ContentResolver;
|
||||
import android.content.PeriodicSync;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,82 +40,104 @@ import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
||||
import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_ACCOUNTS;
|
||||
|
||||
public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
private static final String TAG = OCSMSSettingsActivity.class.getSimpleName();
|
||||
private static final String TAG = OCSMSSettingsActivity.class.getSimpleName();
|
||||
|
||||
private static AccountManager _accountMgr;
|
||||
private static String _accountAuthority;
|
||||
private static String _accountType;
|
||||
private static AccountManager _accountMgr;
|
||||
private static String _accountAuthority;
|
||||
private static String _accountType;
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
OCSMSSettingsActivity._accountMgr = AccountManager.get(getBaseContext());
|
||||
OCSMSSettingsActivity._accountAuthority = getString(R.string.account_authority);
|
||||
OCSMSSettingsActivity._accountType = getString(R.string.account_type);
|
||||
VirtualSettingsActivity._prefsRessourceFile = R.xml.pref_data_sync;
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
||||
// Bind our boolean preferences
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("push_on_receive", DefaultPrefs.pushOnReceive));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_wifi", DefaultPrefs.syncWifi));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_4g", DefaultPrefs.sync4G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_3g", DefaultPrefs.sync3G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_gprs", DefaultPrefs.syncGPRS));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_2g", DefaultPrefs.sync2G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_others", DefaultPrefs.syncOthers));
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Bind our string preferences
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_frequency", "15"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_bulk_messages", "-1"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("minimum_sync_chars", "1"));
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Must be at the end, after preference bind
|
||||
super.onPostCreate(savedInstanceState);
|
||||
}
|
||||
private AppCompatDelegate getDelegate() {
|
||||
if (mDelegate == null) {
|
||||
mDelegate = AppCompatDelegate.create(this, null);
|
||||
}
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
protected void handleCheckboxPreference(String key, Boolean value) {
|
||||
// Network types allowed for sync
|
||||
if ("push_on_receive".equals(key) ||
|
||||
"sync_wifi".equals(key) || "sync_2g".equals(key) ||
|
||||
"sync_3g".equals(key) || "sync_gprs".equals(key) ||
|
||||
"sync_4g".equals(key) || "sync_others".equals(key)) {
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
Log.i(OCSMSSettingsActivity.TAG, "OCSMSSettingsActivity.handleCheckboxPreference: set " + key + " to "
|
||||
+ value.toString());
|
||||
prefs.putBoolean(key, value);
|
||||
}
|
||||
}
|
||||
public ActionBar getSupportActionBar() {
|
||||
return getDelegate().getSupportActionBar();
|
||||
}
|
||||
|
||||
protected void handleListPreference(String key, String value,
|
||||
ListPreference preference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
int index = preference.findIndexOfValue(value);
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
OCSMSSettingsActivity._accountMgr = AccountManager.get(getBaseContext());
|
||||
OCSMSSettingsActivity._accountAuthority = getString(R.string.account_authority);
|
||||
OCSMSSettingsActivity._accountType = getString(R.string.account_type);
|
||||
VirtualSettingsActivity._prefsRessourceFile = R.xml.pref_data_sync;
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference
|
||||
.setSummary((index >= 0) ? preference.getEntries()[index]
|
||||
: null);
|
||||
// Bind our boolean preferences
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("push_on_receive", DefaultPrefs.pushOnReceive));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_wifi", DefaultPrefs.syncWifi));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_4g", DefaultPrefs.sync4G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_3g", DefaultPrefs.sync3G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_gprs", DefaultPrefs.syncGPRS));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_2g", DefaultPrefs.sync2G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_others", DefaultPrefs.syncOthers));
|
||||
|
||||
Log.i(OCSMSSettingsActivity.TAG, "Modifying listPreference " + key);
|
||||
// Bind our string preferences
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_frequency", "15"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_bulk_messages", "-1"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("minimum_sync_chars", "1"));
|
||||
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
// Must be at the end, after preference bind
|
||||
super.onPostCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
// Handle sync frequency change
|
||||
if ("sync_frequency".equals(key)) {
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.GET_ACCOUNTS,
|
||||
REQUEST_ACCOUNTS)) {
|
||||
return;
|
||||
}
|
||||
protected void handleCheckboxPreference(String key, Boolean value) {
|
||||
// Network types allowed for sync
|
||||
if ("push_on_receive".equals(key) ||
|
||||
"sync_wifi".equals(key) || "sync_2g".equals(key) ||
|
||||
"sync_3g".equals(key) || "sync_gprs".equals(key) ||
|
||||
"sync_4g".equals(key) || "sync_others".equals(key)) {
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
Log.i(OCSMSSettingsActivity.TAG, "OCSMSSettingsActivity.handleCheckboxPreference: set " + key + " to "
|
||||
+ value.toString());
|
||||
prefs.putBoolean(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Account[] myAccountList = OCSMSSettingsActivity._accountMgr.getAccountsByType(OCSMSSettingsActivity._accountType);
|
||||
long syncFreq = Long.parseLong(value);
|
||||
protected void handleListPreference(String key, String value,
|
||||
ListPreference preference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
int index = preference.findIndexOfValue(value);
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference
|
||||
.setSummary((index >= 0) ? preference.getEntries()[index]
|
||||
: null);
|
||||
|
||||
Log.i(OCSMSSettingsActivity.TAG, "Modifying listPreference " + key);
|
||||
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
|
||||
// Handle sync frequency change
|
||||
if ("sync_frequency".equals(key)) {
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.GET_ACCOUNTS,
|
||||
REQUEST_ACCOUNTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Account[] myAccountList = OCSMSSettingsActivity._accountMgr.getAccountsByType(OCSMSSettingsActivity._accountType);
|
||||
long syncFreq = Long.parseLong(value);
|
||||
|
||||
// Get ownCloud SMS account list
|
||||
for (Account acct: myAccountList) {
|
||||
for (Account acct : myAccountList) {
|
||||
// And get all authorities for this account
|
||||
List<PeriodicSync> syncList = ContentResolver.getPeriodicSyncs(acct, OCSMSSettingsActivity._accountAuthority);
|
||||
|
||||
boolean foundSameSyncCycle = false;
|
||||
for (PeriodicSync ps: syncList) {
|
||||
for (PeriodicSync ps : syncList) {
|
||||
if ((ps.period == syncFreq) && (ps.extras.getInt("synctype") == 1)) {
|
||||
foundSameSyncCycle = true;
|
||||
}
|
||||
@@ -123,16 +148,29 @@ public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
b.putInt("synctype", 1);
|
||||
|
||||
ContentResolver.removePeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b);
|
||||
if (syncFreq > 0) {
|
||||
ContentResolver.addPeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b, syncFreq * 60);
|
||||
}
|
||||
if (syncFreq > 0) {
|
||||
ContentResolver.addPeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b, syncFreq * 60);
|
||||
}
|
||||
}
|
||||
|
||||
prefs.putLong(key, syncFreq);
|
||||
prefs.putLong(key, syncFreq);
|
||||
}
|
||||
} else if ("sync_bulk_messages".equals(key) || "minimum_sync_chars".equals(key)) {
|
||||
prefs.putInteger(key, Integer.parseInt(value));
|
||||
}
|
||||
else if ("sync_bulk_messages".equals(key) || "minimum_sync_chars".equals(key)) {
|
||||
prefs.putInteger(key, Integer.parseInt(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
super.onMenuItemSelected(featureId, item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-7
@@ -2,7 +2,9 @@ package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
@@ -19,6 +21,9 @@ public class AccountActionsActivity extends AppCompatListActivity {
|
||||
|
||||
setContentView(R.layout.activity_account_actions);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
ArrayList<String> itemList = new ArrayList<>();
|
||||
ArrayAdapter<String> adp = new ArrayAdapter<>(getBaseContext(),
|
||||
android.R.layout.simple_dropdown_item_1line, itemList);
|
||||
@@ -33,20 +38,33 @@ public class AccountActionsActivity extends AppCompatListActivity {
|
||||
_accountName = getIntent().getStringExtra("account");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@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);
|
||||
try {
|
||||
startActivity(intent);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
Log.e(AccountActionsActivity.TAG, e.getMessage());
|
||||
}
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e(AccountActionsActivity.TAG, e.getMessage());
|
||||
}
|
||||
break;
|
||||
default: break; // Unhandled
|
||||
default:
|
||||
break; // Unhandled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+20
-5
@@ -3,13 +3,14 @@ package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import fr.unix_experience.owncloud_sms.adapters.AndroidAccountAdapter;
|
||||
import fr.unix_experience.android_lib.AppCompatListActivity;
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
import fr.unix_experience.owncloud_sms.adapters.AndroidAccountAdapter;
|
||||
|
||||
public class AccountListActivity extends AppCompatListActivity {
|
||||
|
||||
@@ -21,21 +22,35 @@ public class AccountListActivity extends AppCompatListActivity {
|
||||
|
||||
setContentView(R.layout.restore_activity_accountlist);
|
||||
|
||||
ArrayList<Account> itemList = new ArrayList<>();
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AndroidAccountAdapter adapter = new AndroidAccountAdapter(this,
|
||||
ArrayList<Account> itemList = new ArrayList<>();
|
||||
|
||||
AndroidAccountAdapter adapter = new AndroidAccountAdapter(this,
|
||||
android.R.layout.simple_list_item_1,
|
||||
itemList,
|
||||
itemList,
|
||||
R.layout.account_list_item,
|
||||
R.id.accountname, AccountActionsActivity.class);
|
||||
setListAdapter(adapter);
|
||||
|
||||
Account[] accountList =
|
||||
_accountMgr.getAccountsByType(getString(R.string.account_type));
|
||||
Collections.addAll(itemList, accountList);
|
||||
Collections.addAll(itemList, accountList);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-2
@@ -26,8 +26,10 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Telephony;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
@@ -49,6 +51,9 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_restore_messages);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
assert getIntent().getExtras() != null;
|
||||
|
||||
String accountName = getIntent().getExtras().getString("account");
|
||||
@@ -111,6 +116,19 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void initInterface() {
|
||||
TextView tv_error = (TextView) findViewById(R.id.tv_error_default_smsapp);
|
||||
tv_error.setText(R.string.error_make_default_sms_app);
|
||||
@@ -132,8 +150,7 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
tv_error.setVisibility(View.VISIBLE);
|
||||
fix_button.setVisibility(View.VISIBLE);
|
||||
launch_restore.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tv_error.setVisibility(View.INVISIBLE);
|
||||
fix_button.setVisibility(View.INVISIBLE);
|
||||
launch_restore.setVisibility(View.VISIBLE);
|
||||
|
||||
+13
-27
@@ -3,13 +3,10 @@ package fr.unix_experience.owncloud_sms.notifications;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
@@ -40,7 +37,7 @@ public class OCSMSNotificationUI {
|
||||
|
||||
// This image is used as the notification's large icon (thumbnail).
|
||||
// TODO: Remove this if your notification has no relevant thumbnail.
|
||||
Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_launcher);
|
||||
Bitmap picture = BitmapFactory.decodeResource(res, R.mipmap.ic_launcher);
|
||||
|
||||
|
||||
String ticker = (titleString.length() > 20) ? titleString.substring(0, 20) : titleString;
|
||||
@@ -50,31 +47,28 @@ public class OCSMSNotificationUI {
|
||||
|
||||
// Set appropriate defaults for the notification light, sound,
|
||||
// and vibration.
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentTitle(title)
|
||||
.setContentText(contentString)
|
||||
|
||||
// All fields below this line are optional.
|
||||
// All fields below this line are optional.
|
||||
|
||||
// Use a default priority (recognized on devices running Android
|
||||
// 4.1 or later)
|
||||
// Use a default priority (recognized on devices running Android
|
||||
// 4.1 or later)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
|
||||
// Provide a large icon, shown with the notification in the
|
||||
// notification drawer on devices running Android 3.0 or later.
|
||||
.setLargeIcon(picture)
|
||||
|
||||
// Set ticker text (preview) information for this notification.
|
||||
// Set ticker text (preview) information for this notification.
|
||||
//.setTicker(ticker)
|
||||
|
||||
// Show a number. This is useful when stacking notifications of
|
||||
// a single type.
|
||||
// Show a number. This is useful when stacking notifications of
|
||||
// a single type.
|
||||
.setNumber(number)
|
||||
.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(contentString)
|
||||
.setBigContentTitle(title)
|
||||
.setSummaryText(titleString))
|
||||
.setAutoCancel(true);
|
||||
.setAutoCancel(true)
|
||||
.setColor(context.getResources().getColor(R.color.oc_primary));
|
||||
|
||||
OCSMSNotificationUI.notify(context, builder.build());
|
||||
}
|
||||
@@ -83,25 +77,17 @@ public class OCSMSNotificationUI {
|
||||
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(OCSMSNotificationUI.NOTIFICATION_TAG, 0, notification);
|
||||
} else {
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode(), notification);
|
||||
}
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG, 0, notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels any notifications of this type previously shown using
|
||||
* {@link #notify(Context, String, int)}.
|
||||
* {@link #notify(Context, String, String, int)}.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
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(OCSMSNotificationUI.NOTIFICATION_TAG, 0);
|
||||
} else {
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode());
|
||||
}
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user