A bounded continuous function $f : \mathbb{R} \to \mathbb{C}$ is almost periodic if for every $\epsilon>0$, there exists some $L>0$, such that every interval of $\mathbb{R}$ with length $\ge L$ contains some real number $T$ such that $\Vert f(\cdot+T)-f \Vert_\infty \le \epsilon$.
An equivalent definition is the relative compactness of the set of all functions $f(\cdot+T)$ with $T$ varying in $\mathbb{R}$ in the space of all continuous bounded functions endowed with $\Vert \cdot \Vert_\infty$.
It is necessary to have $$\liminf_{T \to \infty} \Vert f(\cdot+T)-f \Vert_\infty = 0.$$ Is it also sufficient?
My thought: the triangle inequality and the invariance of the norm $\Vert \cdot \Vert_\infty$ under translations show that the function $T \mapsto \Vert f(\cdot+T)-f \Vert_\infty$ is sub-additive on $\mathbb{R}_+$.
The answer is "No". Just take a hump at $0$ and place copies of it on the line along a finite arithmetic progression with some big difference slowly scaling it down to $0$. Then take the whole resulting picture and place copies of it on the line along a (longer) finite arithmetic progression with much bigger difference even more slowly scaling it down to $0$. And so on. You'll get a function with your properties that is identically $0$ on arbitrarily long intervals, which is, clearly, not almost-periodic.
By eulersgroupie's request here is a formula. Let $\psi$ be your favorite bump on $[-1,1]$. Choose a sequence of numbers $T_j$ going up really fast. Now put $$ f(x)=\sum_{k=(k_1,\dots)}\prod_{j\ge 1}\left(1-\tfrac{|k_j|}{j}\right)_+\psi(x+\sum_j k_jT_j) $$ where the first summation is taken over sequences $k$ having only finitely many integer non-zero entries and $x_+=\max(x,0)$.