OC-1833: Add CustomButton class to can change the background of buttons

This commit is contained in:
masensio 2013-10-28 12:58:56 +01:00
parent 6e21c84026
commit dd59f5871c
24 changed files with 99 additions and 91 deletions

View file

@ -185,7 +185,7 @@
</LinearLayout>
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@id/buttonOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -49,14 +49,14 @@
android:orientation="horizontal" >
<!-- 'OK' / 'CANCEL' BUTTONS CHANGE THEIR ORDER FROM ANDROID 4.0 ; THANKS, GOOGLE -->
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_cancel" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -166,7 +166,7 @@
android:gravity="center_vertical"
android:text="@string/auth_unauthorized" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/buttonOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -34,14 +34,14 @@
android:layout_margin="5dp"
android:weightSum="1.0" >
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/buttonNo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/common_no"
android:layout_weight="0.5"/>
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/buttonYes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View file

@ -63,7 +63,7 @@
android:text="@string/failed_upload_all_cb"
android:textSize="8sp" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/failed_upload_retry_all_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -72,7 +72,7 @@
android:text="@string/failed_upload_headline_retryall_btn"
android:textSize="8sp" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/failed_upload_delete_all_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -10,7 +10,7 @@
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/failed_uploadactivity_close_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View file

@ -48,14 +48,14 @@
android:gravity="center"
android:orientation="horizontal" >
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_ok" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -24,7 +24,8 @@
android:layout_height="wrap_content"
android:gravity="bottom">
<Button android:id="@+id/deleteLogHistoryButton"
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/deleteLogHistoryButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/prefs_log_delete_history_button"/>

View file

@ -39,7 +39,7 @@
android:text="@string/main_wrn_accsetup"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/setup_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -68,7 +68,7 @@
style="@style/PassCodeStyle" />
</LinearLayout>
<Button android:layout_width="wrap_content"
<de.mobilcom.debitel.cloud.android.ui.CustomButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/common_cancel"
android:textColor="@android:color/black"

View file

@ -408,21 +408,21 @@
android:layout_height="wrap_content"
android:gravity="center" >
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_cancel" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/details_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/ssl_validator_btn_details_see" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"

View file

@ -35,13 +35,13 @@
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/upload_files_btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/common_cancel" />
<Button
<de.mobilcom.debitel.cloud.android.ui.CustomButton
android:id="@+id/upload_files_btn_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -33,8 +33,8 @@
</FrameLayout>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_alignParentBottom="true" android:layout_height="wrap_content" android:orientation="vertical">
<Button android:layout_gravity="bottom" android:layout_height="wrap_content"
<de.mobilcom.debitel.cloud.android.ui.CustomButton android:layout_gravity="bottom" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/uploader_choose_folder"
android:text="@string/uploader_btn_upload_text"></Button>
android:text="@string/uploader_btn_upload_text"/>
</LinearLayout>
</RelativeLayout>

View file

@ -49,7 +49,6 @@ import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter;
import android.widget.Toast;
@ -61,6 +60,7 @@ import de.mobilcom.debitel.cloud.android.datamodel.DataStorageManager;
import de.mobilcom.debitel.cloud.android.datamodel.FileDataStorageManager;
import de.mobilcom.debitel.cloud.android.datamodel.OCFile;
import de.mobilcom.debitel.cloud.android.files.services.FileUploader;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
/**
* This can be used to upload things to an ownCloud instance.
@ -310,7 +310,7 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
new String[] {"dirname"},
new int[] {R.id.textView1});
setListAdapter(sa);
Button btn = (Button) findViewById(R.id.uploader_choose_folder);
CustomButton btn = (CustomButton) findViewById(R.id.uploader_choose_folder);
btn.setOnClickListener(this);
getListView().setOnItemClickListener(this);
}

View file

@ -64,6 +64,7 @@ import de.mobilcom.debitel.cloud.android.operations.OwnCloudServerCheckOperation
import de.mobilcom.debitel.cloud.android.operations.RemoteOperation;
import de.mobilcom.debitel.cloud.android.operations.RemoteOperationResult;
import de.mobilcom.debitel.cloud.android.operations.RemoteOperationResult.ResultCode;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import de.mobilcom.debitel.cloud.android.ui.dialog.SamlWebViewDialog;
import de.mobilcom.debitel.cloud.android.ui.dialog.SslValidatorDialog;
import de.mobilcom.debitel.cloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;
@ -187,7 +188,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);
mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);
mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
mOkButton = findViewById(R.id.buttonOK);
mOkButton = (CustomButton) findViewById(R.id.buttonOK);
mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text);
/// set Host Url Input Enabled
@ -200,10 +201,10 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name)));
}
/// complete background of 'OK' button
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
mOkButton.setBackgroundResource(R.drawable.btn_default);
// /// complete background of 'OK' button
// boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
// if (customButtons)
// mOkButton.setBackgroundResource(R.drawable.btn_default);
/// initialization
mAccountMgr = AccountManager.get(this);

View file

@ -20,6 +20,7 @@ package de.mobilcom.debitel.cloud.android.extensions;
import de.mobilcom.debitel.cloud.android.Log_OC;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
@ -27,7 +28,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExtensionsAvailableDialog extends DialogFragment implements
OnClickListener {
@ -40,15 +40,8 @@ public class ExtensionsAvailableDialog extends DialogFragment implements
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.extensions_available_dialog,
container);
Button btnYes = (Button) view.findViewById(R.id.buttonYes);
Button btnNo = (Button) view.findViewById(R.id.buttonNo);
// Set background of buttons
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons) {
btnYes.setBackgroundResource(R.drawable.btn_default);
btnNo.setBackgroundResource(R.drawable.btn_default);
}
CustomButton btnYes = (CustomButton) view.findViewById(R.id.buttonYes);
CustomButton btnNo = (CustomButton) view.findViewById(R.id.buttonNo);
btnYes.setOnClickListener(this);
btnNo.setOnClickListener(this);

View file

@ -0,0 +1,45 @@
package de.mobilcom.debitel.cloud.android.ui;
import de.mobilcom.debitel.cloud.android.R;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
/**
* @author masensio
*
* Button for customizing the button background
*/
public class CustomButton extends Button {
public CustomButton(Context context) {
super(context);
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
{
this.setBackgroundResource(R.drawable.btn_default);
}
}
public CustomButton(Context context, AttributeSet attrs) {
super(context, attrs);
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
{
this.setBackgroundResource(R.drawable.btn_default);
}
}
public CustomButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
{
this.setBackgroundResource(R.drawable.btn_default);
}
}
}

View file

@ -33,7 +33,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@ -44,6 +43,7 @@ import de.mobilcom.debitel.cloud.android.Log_OC;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.datamodel.FileDataStorageManager;
import de.mobilcom.debitel.cloud.android.datamodel.OCFile;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import de.mobilcom.debitel.cloud.android.ui.dialog.IndeterminateProgressDialog;
import de.mobilcom.debitel.cloud.android.utils.FileStorageUtils;
@ -117,14 +117,8 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity
}
/// customize buttons
Button cancelBtn = (Button) findViewById(R.id.cancel);
Button okBtn = (Button) findViewById(R.id.ok);
// Set background of buttons
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons) {
cancelBtn.setBackgroundResource(R.drawable.btn_default);
okBtn.setBackgroundResource(R.drawable.btn_default);
}
CustomButton cancelBtn = (CustomButton) findViewById(R.id.cancel);
CustomButton okBtn = (CustomButton) findViewById(R.id.ok);
okBtn.setText(R.string.foreign_files_move);
cancelBtn.setOnClickListener(this);

View file

@ -21,10 +21,10 @@ import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
/**
* This Activity is used to display a detail message for failed uploads
@ -44,11 +44,7 @@ public class FailedUploadActivity extends Activity {
String message = getIntent().getStringExtra(MESSAGE);
TextView textView = (TextView) findViewById(R.id.faild_upload_message);
textView.setText(message);
Button closeBtn = (Button) findViewById(R.id.failed_uploadactivity_close_button);
// Set background of 'close' button
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
closeBtn.setBackgroundResource(R.drawable.btn_default);
CustomButton closeBtn = (CustomButton) findViewById(R.id.failed_uploadactivity_close_button);
closeBtn.setOnClickListener(new OnClickListener() {
@Override

View file

@ -47,6 +47,7 @@ import de.mobilcom.debitel.cloud.android.authentication.AccountUtils;
import de.mobilcom.debitel.cloud.android.db.DbHandler;
import de.mobilcom.debitel.cloud.android.files.InstantUploadBroadcastReceiver;
import de.mobilcom.debitel.cloud.android.files.services.FileUploader;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import de.mobilcom.debitel.cloud.android.utils.FileStorageUtils;
/**
@ -76,21 +77,14 @@ public class InstantUploadActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.failed_upload_files);
Button deleteAllBtn = (Button) findViewById(R.id.failed_upload_delete_all_btn);
CustomButton deleteAllBtn = (CustomButton) findViewById(R.id.failed_upload_delete_all_btn);
deleteAllBtn.setOnClickListener(getDeleteListner());
Button retryAllBtn = (Button) findViewById(R.id.failed_upload_retry_all_btn);
CustomButton retryAllBtn = (CustomButton) findViewById(R.id.failed_upload_retry_all_btn);
retryAllBtn.setOnClickListener(getRetryListner());
this.failed_upload_all_cb = (CheckBox) findViewById(R.id.failed_upload_headline_cb);
failed_upload_all_cb.setOnCheckedChangeListener(getCheckAllListener());
listView = (LinearLayout) findViewById(R.id.failed_upload_scrollviewlayout);
// Set background of buttons
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons) {
deleteAllBtn.setBackgroundResource(R.drawable.btn_default);
retryAllBtn.setBackgroundResource(R.drawable.btn_default);
}
loadListView(true);
}

View file

@ -26,7 +26,6 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import com.actionbarsherlock.app.ActionBar;
@ -34,6 +33,7 @@ import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.view.MenuItem;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import de.mobilcom.debitel.cloud.android.ui.adapter.LogListAdapter;
import de.mobilcom.debitel.cloud.android.utils.FileStorageUtils;
@ -52,12 +52,7 @@ public class LogHistoryActivity extends SherlockPreferenceActivity implements On
ActionBar actionBar = getSherlock().getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
ListView listView = (ListView) findViewById(android.R.id.list);
Button deleteHistoryButton = (Button) findViewById(R.id.deleteLogHistoryButton);
// Set background of 'deleteHistory' button
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
deleteHistoryButton.setBackgroundResource(R.drawable.btn_default);
CustomButton deleteHistoryButton = (CustomButton) findViewById(R.id.deleteLogHistoryButton);
deleteHistoryButton.setOnClickListener(new OnClickListener() {

View file

@ -21,6 +21,7 @@ import java.util.Arrays;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import android.app.AlertDialog;
import android.content.DialogInterface;
@ -35,7 +36,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
@ -45,7 +45,7 @@ public class PinCodeActivity extends SherlockFragmentActivity {
public final static String EXTRA_ACTIVITY = "de.mobilcom.debitel.cloud.android.ui.activity.PinCodeActivity.ACTIVITY";
public final static String EXTRA_NEW_STATE = "de.mobilcom.debitel.cloud.android.ui.activity.PinCodeActivity.NEW_STATE";
Button bCancel;
CustomButton bCancel;
TextView mPinHdr;
TextView mPinHdrExplanation;
EditText mText1;
@ -71,7 +71,7 @@ public class PinCodeActivity extends SherlockFragmentActivity {
Intent intent = getIntent();
activity = intent.getStringExtra(EXTRA_ACTIVITY);
bCancel = (Button) findViewById(R.id.cancel);
bCancel = (CustomButton) findViewById(R.id.cancel);
mPinHdr = (TextView) findViewById(R.id.pinHdr);
mPinHdrExplanation = (TextView) findViewById(R.id.pinHdrExpl);
mText1 = (EditText) findViewById(R.id.txt1);
@ -81,11 +81,6 @@ public class PinCodeActivity extends SherlockFragmentActivity {
mText3 = (EditText) findViewById(R.id.txt3);
mText4 = (EditText) findViewById(R.id.txt4);
// Set background of 'Cancel' button
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons)
bCancel.setBackgroundResource(R.drawable.btn_default);
SharedPreferences appPrefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());

View file

@ -29,7 +29,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
@ -38,6 +37,7 @@ import com.actionbarsherlock.view.MenuItem;
import de.mobilcom.debitel.cloud.android.Log_OC;
import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
import de.mobilcom.debitel.cloud.android.ui.dialog.IndeterminateProgressDialog;
import de.mobilcom.debitel.cloud.android.ui.fragment.ConfirmationDialogFragment;
import de.mobilcom.debitel.cloud.android.ui.fragment.LocalFileListFragment;
@ -58,8 +58,8 @@ public class UploadFilesActivity extends FileActivity implements
private ArrayAdapter<String> mDirectories;
private File mCurrentDir = null;
private LocalFileListFragment mFileListFragment;
private Button mCancelBtn;
private Button mUploadBtn;
private CustomButton mCancelBtn;
private CustomButton mUploadBtn;
private Account mAccountOnCreation;
private DialogFragment mCurrentDialog;
@ -103,17 +103,11 @@ public class UploadFilesActivity extends FileActivity implements
// Set input controllers
mCancelBtn = (Button) findViewById(R.id.upload_files_btn_cancel);
mCancelBtn = (CustomButton) findViewById(R.id.upload_files_btn_cancel);
mCancelBtn.setOnClickListener(this);
mUploadBtn = (Button) findViewById(R.id.upload_files_btn_upload);
mUploadBtn = (CustomButton) findViewById(R.id.upload_files_btn_upload);
mUploadBtn.setOnClickListener(this);
// Set background of buttons
boolean customButtons = getResources().getBoolean(R.bool.custom_buttons);
if (customButtons) {
mCancelBtn.setBackgroundResource(R.drawable.btn_default);
mUploadBtn.setBackgroundResource(R.drawable.btn_default);
}
// Action bar setup
ActionBar actionBar = getSupportActionBar();

View file

@ -34,7 +34,6 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import de.mobilcom.debitel.cloud.android.Log_OC;
@ -42,6 +41,7 @@ import de.mobilcom.debitel.cloud.android.R;
import de.mobilcom.debitel.cloud.android.network.CertificateCombinedException;
import de.mobilcom.debitel.cloud.android.network.OwnCloudClientUtils;
import de.mobilcom.debitel.cloud.android.operations.RemoteOperationResult;
import de.mobilcom.debitel.cloud.android.ui.CustomButton;
/**
* Dialog to request the user about a certificate that could not be validated with the certificates store in the system.
@ -142,11 +142,11 @@ public class SslValidatorDialog extends Dialog {
View detailsScroll = findViewById(R.id.details_scroll);
if (detailsScroll.getVisibility() == View.VISIBLE) {
detailsScroll.setVisibility(View.GONE);
((Button)v).setText(R.string.ssl_validator_btn_details_see);
((CustomButton)v).setText(R.string.ssl_validator_btn_details_see);
} else {
detailsScroll.setVisibility(View.VISIBLE);
((Button)v).setText(R.string.ssl_validator_btn_details_hide);
((CustomButton)v).setText(R.string.ssl_validator_btn_details_hide);
}
}
});