11e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio/* 21e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * Copyright (C) 2011 The Android Open Source Project 31e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * 41e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * Licensed under the Apache License, Version 2.0 (the "License"); 51e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * you may not use this file except in compliance with the License. 61e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * You may obtain a copy of the License at 71e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * 81e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * http://www.apache.org/licenses/LICENSE-2.0 91e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * 101e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * Unless required by applicable law or agreed to in writing, software 111e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * distributed under the License is distributed on an "AS IS" BASIS, 121e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * See the License for the specific language governing permissions and 141e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio * limitations under the License. 151e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio */ 161e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 171e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Megliopackage com.android.bidi; 181e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 197af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglioimport android.app.Fragment; 201e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglioimport android.os.Bundle; 217af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglioimport android.view.LayoutInflater; 227af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglioimport android.view.View; 237af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglioimport android.view.ViewGroup; 241e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglioimport android.widget.SeekBar; 251e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 261e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglioimport static com.android.bidi.BiDiTestConstants.FONT_MAX_SIZE; 271e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglioimport static com.android.bidi.BiDiTestConstants.FONT_MIN_SIZE; 281e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 297af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Megliopublic class BiDiTestCanvas extends Fragment { 301e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 311e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio static final int INIT_TEXT_SIZE = (FONT_MAX_SIZE - FONT_MIN_SIZE) / 2; 321e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 331e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio private BiDiTestView testView; 341e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio private SeekBar textSizeSeekBar; 357af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio private View currentView; 361e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 371e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio @Override 387af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio public View onCreateView(LayoutInflater inflater, ViewGroup container, 397af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio Bundle savedInstanceState) { 407af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio currentView = inflater.inflate(R.layout.canvas, container, false); 417af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio return currentView; 427af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio } 431e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 447af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio @Override 457af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio public void onViewCreated(View view, Bundle savedInstanceState) { 467af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio super.onViewCreated(view, savedInstanceState); 471e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 487af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio testView = (BiDiTestView) currentView.findViewById(R.id.testview); 491e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio testView.setCurrentTextSize(INIT_TEXT_SIZE); 501e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 517af05226b901f2b623ca5b3ca23d8586941ef54bFabrice Di Meglio textSizeSeekBar = (SeekBar) currentView.findViewById(R.id.seekbar); 521e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio textSizeSeekBar.setProgress(INIT_TEXT_SIZE); 531e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio textSizeSeekBar.setMax(FONT_MAX_SIZE - FONT_MIN_SIZE); 541e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 551e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio textSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 561e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 571e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio testView.setCurrentTextSize(FONT_MIN_SIZE + progress); 581e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio } 591e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 601e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio public void onStartTrackingTouch(SeekBar seekBar) { 611e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio } 621e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio 631e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio public void onStopTrackingTouch(SeekBar seekBar) { 641e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio } 651e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio }); 661e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio } 671e4cfbeba54898373c852097d1519a1d966c0854Fabrice Di Meglio} 68