forked from upstream-mirrors/OpenTracks
Set dialog title divider for dialogfragment
This commit is contained in:
@@ -184,4 +184,9 @@ public class Api11Adapter extends Api10Adapter {
|
||||
tabWidget.getChildAt(i).setBackgroundResource(R.drawable.tab_indicator_mytracks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDialogTitleDivider() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* API level 8 specific implementation of the {@link ApiAdapter}.
|
||||
*
|
||||
*
|
||||
* @author Bartlomiej Niechwiej
|
||||
*/
|
||||
public class Api8Adapter implements ApiAdapter {
|
||||
|
||||
private static final String TAG = Api8Adapter.class.getSimpleName();
|
||||
|
||||
|
||||
@Override
|
||||
public void applyPreferenceChanges(Editor editor) {
|
||||
editor.commit();
|
||||
@@ -101,7 +101,8 @@ public class Api8Adapter implements ApiAdapter {
|
||||
} catch (InvocationTargetException e) {
|
||||
Log.d(TAG, "Unable to create insecure connection", e);
|
||||
}
|
||||
return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID);
|
||||
return bluetoothDevice.createRfcommSocketToServiceRecord(
|
||||
BluetoothConnectionManager.MY_TRACKS_UUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,23 +144,28 @@ public class Api8Adapter implements ApiAdapter {
|
||||
public void invalidMenu(Activity activity) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean showEditTextClearButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTabBackground(TabWidget tabWidget) {
|
||||
// Do nothing
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasDialogTitleDivider() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSearchKey(MenuItem menuItem) {
|
||||
// Return false and allow the framework to handle the search key.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isGoogleFeedbackAvailable() {
|
||||
return false;
|
||||
@@ -172,13 +178,13 @@ public class Api8Adapter implements ApiAdapter {
|
||||
|
||||
@Override
|
||||
public void setAppWidgetSize(AppWidgetManager appWidgetManager, int appWidgetId, int size) {
|
||||
// Do nothing
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void removeGlobalLayoutListener(
|
||||
ViewTreeObserver observer, OnGlobalLayoutListener listener) {
|
||||
observer.removeGlobalOnLayoutListener(listener);
|
||||
observer.removeGlobalOnLayoutListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,14 @@ public interface ApiAdapter {
|
||||
* @param tabWidget the tab widget
|
||||
*/
|
||||
public void setTabBackground(TabWidget tabWidget);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if has dialog title divider.
|
||||
* <p>
|
||||
* Due to changes in API level 11.
|
||||
*/
|
||||
public boolean hasDialogTitleDivider();
|
||||
|
||||
/**
|
||||
* Handles the search key press. Returns true if handled.
|
||||
* <p>
|
||||
|
||||
@@ -23,6 +23,10 @@ import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* Utilities for creating dialogs.
|
||||
@@ -101,4 +105,20 @@ public class DialogUtils {
|
||||
progressDialog.setTitle(R.string.generic_progress_title);
|
||||
return progressDialog;
|
||||
}
|
||||
|
||||
public static void setTitleDivier(Context context, Dialog dialog) {
|
||||
if (ApiAdapterFactory.getApiAdapter().hasDialogTitleDivider()) {
|
||||
try {
|
||||
ViewGroup decorView = (ViewGroup) dialog.getWindow().getDecorView();
|
||||
FrameLayout windowContentView = (FrameLayout) decorView.getChildAt(0);
|
||||
FrameLayout contentView = (FrameLayout) windowContentView.getChildAt(0);
|
||||
LinearLayout parentPanel = (LinearLayout) contentView.getChildAt(0);
|
||||
LinearLayout topPanel = (LinearLayout) parentPanel.getChildAt(0);
|
||||
View titleDivider = topPanel.getChildAt(2);
|
||||
titleDivider.setBackgroundColor(context.getResources().getColor(R.color.holo_orange_dark));
|
||||
} catch (Exception e) {
|
||||
// Can safely ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user