use of android.app.ActionBar in project Talon-for-Twitter by klinker24.
the class NewScheduledTweet method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = AppSettings.getInstance(this);
Utils.setUpTheme(this, settings);
countHandler = new Handler();
setContentView(R.layout.scheduled_new_tweet_activity);
Intent intent = getIntent();
sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
context = this;
mEditText = (EditText) findViewById(R.id.tweet_content);
counter = (TextView) findViewById(R.id.char_remaining);
emojiButton = (ImageButton) findViewById(R.id.emojiButton);
emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard);
// if they are coming from the compose window with text, then display it
if (getIntent().getBooleanExtra("has_text", false)) {
mEditText.setText(getIntent().getStringExtra("text"));
mEditText.setSelection(mEditText.getText().length());
}
final ListPopupWindow autocomplete = new ListPopupWindow(context);
autocomplete.setAnchorView(mEditText);
autocomplete.setHeight(Utils.toDP(100, context));
autocomplete.setWidth(Utils.toDP(275, context));
try {
autocomplete.setAdapter(new AutoCompletePeopleAdapter(context, FollowersDataSource.getInstance(context).getCursor(settings.currentAccount, mEditText.getText().toString()), mEditText));
} catch (Exception e) {
// not really sure why
}
autocomplete.setPromptPosition(ListPopupWindow.POSITION_PROMPT_ABOVE);
autocomplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
autocomplete.dismiss();
}
});
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
String searchText = mEditText.getText().toString();
try {
if (searchText.substring(searchText.length() - 1, searchText.length()).equals("@")) {
autocomplete.show();
} else if (searchText.substring(searchText.length() - 1, searchText.length()).equals(" ")) {
autocomplete.dismiss();
} else if (autocomplete.isShowing()) {
String[] split = mEditText.getText().toString().split(" ");
String adapterText;
if (split.length > 1) {
adapterText = split[split.length - 1];
} else {
adapterText = split[0];
}
adapterText = adapterText.replace("@", "");
autocomplete.setAdapter(new AutoCompletePeopleAdapter(context, FollowersDataSource.getInstance(context).getCursor(settings.currentAccount, adapterText), mEditText));
}
} catch (Exception e) {
// there is no text
try {
autocomplete.dismiss();
} catch (Exception x) {
// something went really wrong i guess haha
}
}
countHandler.removeCallbacks(getCount);
countHandler.postDelayed(getCount, 300);
}
});
if (!sharedPrefs.getBoolean("keyboard_type", true)) {
mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mEditText.setImeOptions(EditorInfo.IME_ACTION_NONE);
}
startDate = intent.getStringExtra(ViewScheduledTweets.EXTRA_TIME);
startMessage = intent.getStringExtra(ViewScheduledTweets.EXTRA_TEXT);
if (TextUtils.isEmpty(startDate)) {
startDate = "";
}
if (TextUtils.isEmpty(startMessage)) {
startMessage = "";
}
final Calendar c = Calendar.getInstance();
currentYear = c.get(Calendar.YEAR);
currentMonth = c.get(Calendar.MONTH);
currentDay = c.get(Calendar.DAY_OF_MONTH);
currentHour = c.get(Calendar.HOUR_OF_DAY);
currentMinute = c.get(Calendar.MINUTE);
currentDate = new Date(currentYear, currentMonth, currentDay, currentHour, currentMinute);
timeDisplay = (TextView) findViewById(R.id.currentTime);
dateDisplay = (TextView) findViewById(R.id.currentDate);
btDate = (Button) findViewById(R.id.setDate);
btTime = (Button) findViewById(R.id.setTime);
if (!startDate.equals("") && !startDate.equals("null")) {
setDate = new Date(Long.parseLong(startDate));
timeDone = true;
btTime.setEnabled(true);
} else {
btTime.setEnabled(false);
}
if (mEditText.getText().toString().isEmpty()) {
mEditText.setText(startMessage);
}
if (!startDate.equals("")) {
Date startDateObj = new Date(Long.parseLong(startDate));
if (sharedPrefs.getBoolean("hour_format", false)) {
timeDisplay.setText(DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(startDateObj));
} else {
timeDisplay.setText(DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(startDateObj));
}
if (sharedPrefs.getBoolean("hour_format", false)) {
dateDisplay.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDateObj));
} else {
dateDisplay.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDateObj));
}
}
if (!settings.useEmoji) {
emojiButton.setVisibility(View.GONE);
} else {
emojiKeyboard.setAttached((HoloEditText) mEditText);
mEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (emojiKeyboard.isShowing()) {
emojiKeyboard.setVisibility(false);
}
}
});
emojiButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
emojiKeyboard.toggleVisibility();
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) emojiKeyboard.getLayoutParams();
params.topMargin = mEditText.getHeight();
emojiKeyboard.setLayoutParams(params);
}
});
}
// sets the date button listener to call the dialog
btDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
com.android.datetimepicker.date.DatePickerDialog.newInstance(reservationDate, currentYear, currentMonth, currentDay, settings.theme != AppSettings.THEME_LIGHT).show(getFragmentManager(), "date_picker");
btTime.setEnabled(true);
}
});
// sets the time button listener to call the dialog
btTime.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
com.android.datetimepicker.time.TimePickerDialog dialog = com.android.datetimepicker.time.TimePickerDialog.newInstance(timeDate, currentHour, currentMinute, settings.militaryTime);
if (settings.theme != AppSettings.THEME_LIGHT) {
dialog.setThemeDark(true);
}
dialog.show(getFragmentManager(), "time_picker");
}
});
// Inflate a "Done/Discard" custom action bar view.
LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(R.layout.actionbar_done_discard, null);
FrameLayout done = (FrameLayout) customActionBarView.findViewById(R.id.actionbar_done);
((TextView) done.findViewById(R.id.done)).setText(R.string.done_label);
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doneClick();
}
});
FrameLayout discard = (FrameLayout) customActionBarView.findViewById(R.id.actionbar_discard);
if (!TextUtils.isEmpty(getIntent().getStringExtra(ViewScheduledTweets.EXTRA_TIME))) {
((TextView) discard.findViewById(R.id.discard)).setText(R.string.delete);
}
discard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
discardClick();
}
});
// Show the custom action bar view and hide the normal Home icon and title.
final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
use of android.app.ActionBar in project K6nele by Kaljurand.
the class RewritesActivity method setRewrites.
private void setRewrites(String name, String[] errors) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Resources res = getResources();
mRewrites = new Rewrites(prefs, res, name);
int ruleCount = mRewrites.getRules().length;
String subtitle = res.getQuantityString(R.plurals.statusLoadRewrites, ruleCount, ruleCount);
if (errors != null) {
int errorCount = errors.length;
if (errorCount > 0) {
String errorMessage = res.getQuantityString(R.plurals.statusLoadRewritesErrors, errorCount, errorCount);
showErrors(errorMessage, errors);
subtitle += " ยท " + errorMessage;
}
}
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle(name);
actionBar.setSubtitle(subtitle);
}
}
use of android.app.ActionBar in project Reachability by sakebook.
the class NavigationDrawerFragment method showGlobalContextActionBar.
/**
* Per the navigation drawer design guidelines, updates the action bar to show the global app
* 'context', rather than just what's in the current screen.
*/
private void showGlobalContextActionBar() {
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setTitle(R.string.app_name);
}
use of android.app.ActionBar in project Reachability by sakebook.
the class NavigationDrawerFragment method setUp.
/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close) {
/* "close drawer" description for accessibility */
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
if (!mUserLearnedDrawer) {
// The user manually opened the drawer; store this flag to prevent auto-showing
// the navigation drawer automatically in the future.
mUserLearnedDrawer = true;
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
}
// calls onPrepareOptionsMenu()
getActivity().invalidateOptionsMenu();
}
};
// per the navigation drawer design guidelines.
if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
mDrawerLayout.openDrawer(mFragmentContainerView);
}
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
use of android.app.ActionBar in project LDrawer by keklikhasan.
the class SampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
ActionBar ab = getActionBar();
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.navdrawer);
drawerArrow = new DrawerArrowDrawable(this) {
@Override
public boolean isLayoutRtl() {
return false;
}
};
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, drawerArrow, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
String[] values = new String[] { "Stop Animation (Back icon)", "Stop Animation (Home icon)", "Start Animation", "Change Color", "GitHub Page", "Share", "Rate" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
mDrawerToggle.setAnimateEnabled(false);
drawerArrow.setProgress(1f);
break;
case 1:
mDrawerToggle.setAnimateEnabled(false);
drawerArrow.setProgress(0f);
break;
case 2:
mDrawerToggle.setAnimateEnabled(true);
mDrawerToggle.syncState();
break;
case 3:
if (drawerArrowColor) {
drawerArrowColor = false;
drawerArrow.setColor(R.color.ldrawer_color);
} else {
drawerArrowColor = true;
drawerArrow.setColor(R.color.drawer_arrow_second_color);
}
mDrawerToggle.syncState();
break;
case 4:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/IkiMuhendis/LDrawer"));
startActivity(browserIntent);
break;
case 5:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
share.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
share.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_description) + "\n" + "GitHub Page : https://github.com/IkiMuhendis/LDrawer\n" + "Sample App : https://play.google.com/store/apps/details?id=" + getPackageName());
startActivity(Intent.createChooser(share, getString(R.string.app_name)));
break;
case 6:
String appUrl = "https://play.google.com/store/apps/details?id=" + getPackageName();
Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(appUrl));
startActivity(rateIntent);
break;
}
}
});
}
Aggregations